/* ═══════════════════════════════════════════════════════════════
   SCROLL-FILM — styles for the cinematic film sections
   (linked only on index / for-professionals / for-organizations)

   Two rendering modes, switched by the engine adding `film-active`
   to <html> once it has booted cleanly:

   1. STATIC (default — no JS, reduced motion, old browsers, or a
      failed manifest fetch): the film section is an ordinary page
      section. Poster visible, copy blocks stacked in flow, no
      canvas, no overlays. This must always read as a complete page.

   2. FILM (html.film-active): the driver becomes a tall scroll
      runway, the stage pins to the viewport, the canvas scrubs
      footage, and the copy blocks float over the film with their
      opacity driven per-frame by js/scroll-film.js.
   ═══════════════════════════════════════════════════════════════ */

/* ─── STATIC MODE (the safe default) ─── */
.film {
  /* Mirrors the .hero dark-gradient surface so the fallback page keeps
     the site's existing opening feel. */
  background: linear-gradient(135deg, var(--salud-blue), #2c3a4a 60%, #1f2937);
  color: #fff;
}

.film-stage {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: 8rem 1.5rem 4rem;
}

.film-canvas,
.film-vignette,
.film-grain,
.film-exit,
.film-loader,
.film-anchor {
  display: none;
}

.film-poster {
  display: block;
  width: 100%;
  max-width: 900px;
  height: auto;
  margin: 0 auto 3rem;
  border-radius: 16px;
}

.film-beat {
  max-width: 720px;
  margin: 0 auto 3.5rem;
}

/* ─── FILM MODE ─── */
/* Lenis owns scroll smoothing once the film boots; the base stylesheet's
   scroll-behavior:smooth must not double-animate (and it breaks the
   ?jump dev contract's instant landing). */
html.film-active {
  scroll-behavior: auto;
}

html.film-active .film {
  background: #000;
}

html.film-active .film-driver {
  position: relative;
  /* height is set by the engine: chapters × 170svh */
}

html.film-active .film-stage {
  position: sticky;
  top: 0;
  height: 100vh;   /* fallback */
  height: 100svh;  /* stable against the iOS URL bar */
  max-width: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

html.film-active .film-poster {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  margin: 0;
  border-radius: 0;
  object-fit: cover;
  /* The poster is the LCP image and the pre-canvas placeholder; once the
     first real frame paints, the canvas fully covers it. */
}

html.film-active .film-canvas {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Vignette + grain sell the "one continuous shot" feel; both are faded
   out by the engine across the film→content handoff. */
html.film-active .film-vignette {
  display: block;
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
              transparent 58%, rgba(10, 14, 22, 0.42) 100%);
}

html.film-active .film-grain {
  display: block;
  position: absolute;
  inset: -100px;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='140'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='140' height='140' filter='url(%23n)' opacity='0.5'/></svg>");
  animation: film-grain-shift 0.9s steps(4) infinite;
}

@keyframes film-grain-shift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-34px, 22px); }
  50%  { transform: translate(18px, -40px); }
  75%  { transform: translate(-28px, -14px); }
  100% { transform: translate(0, 0); }
}

/* Film → content seam: gradient to the sampled final-frame color,
   ramped in by the engine over the last 8% of film progress. */
html.film-active .film-exit {
  display: block;
  position: absolute;
  inset: auto 0 0 0;
  height: 38vh;
  pointer-events: none;
  opacity: 0;
}

/* ─── BEATS (copy over the film) ─── */
html.film-active .film-beat {
  position: absolute;
  z-index: 3;
  max-width: min(560px, 82vw);
  margin: 0;
  opacity: 0;
  pointer-events: none;
  will-change: opacity, transform;
  /* A soft scrim keeps copy legible over any footage without boxing it. */
  text-shadow: 0 1px 24px rgba(10, 14, 22, 0.55), 0 1px 3px rgba(10, 14, 22, 0.5);
}

html.film-active .film-beat-hero {
  left: max(6vw, calc((100vw - 1200px) / 2 + 1.5rem));
  top: 50%;
  transform: translateY(-50%);
  max-width: min(640px, 88vw);
}

/* Default chapter beat: lower-left third, clear of the header zone —
   footage is composed with its top 15% tonally quiet for the chrome. */
html.film-active .film-beat-chapter {
  left: max(6vw, calc((100vw - 1200px) / 2 + 1.5rem));
  bottom: 14vh;
}

/* A feathered pool of shade behind chapter copy — busy/bright footage
   (produce walls, lit fridge interiors) eats a bare text-shadow. The radial
   fades to nothing well inside its box, so it reads as local vignette,
   never as a card. (.film-beat-scrim pages use their pill instead.) */
html.film-active .film-beat-chapter:not(.film-beat-scrim) {
  padding: 2.4rem 3.4rem 2.4rem 2.6rem;
  margin: -2.4rem -3.4rem -2.4rem -2.6rem;
  /* closest-side hits alpha 0 exactly at the nearest box edge — everything
     past it stays transparent, so the pool can never show a clipped seam. */
  background: radial-gradient(
    closest-side at 42% 50%,
    rgba(8, 12, 20, 0.52) 0%,
    rgba(8, 12, 20, 0.34) 52%,
    rgba(8, 12, 20, 0) 100%
  );
}

/* Right-anchored variant for chapters whose subject sits left of frame. */
html.film-active .film-beat-right {
  left: auto;
  right: max(6vw, calc((100vw - 1200px) / 2 + 1.5rem));
}

/* Scrim-pill variant for captions that ride over light product UI, where
   the text-shadow alone washes out (pros portal chapters). */
html.film-active .film-beat-scrim {
  background: rgba(10, 14, 22, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  border-radius: 14px;
  padding: 0.85rem 1.15rem;
  max-width: min(430px, 82vw);
}

html.film-active .film-beat-scrim h3 { margin-bottom: 0.2rem; }
html.film-active .film-beat-scrim h4 { margin-bottom: 0; }

/* Finale beat (data-out="2"): anchored left so a centered closing subject
   stays hero; never fades. */
html.film-active .film-beat-finale {
  left: max(6vw, calc((100vw - 1200px) / 2 + 1.5rem));
  top: 50%;
  transform: translateY(-50%);
}

/* In-film anchor targets: real elements inside the driver so fragment
   navigation lands mid-film. Positioned by the engine. */
html.film-active .film-anchor {
  display: block;
  position: absolute;
  width: 1px;
  height: 1px;
  visibility: hidden;
}

/* ─── LOADER ─── */
html.film-active .film-loader {
  display: block;
  position: absolute;
  left: 50%;
  bottom: 7vh;
  transform: translateX(-50%);
  width: min(280px, 60vw);
  height: 2px;
  border-radius: 999px;
  background: rgba(239, 241, 245, 0.22);
  overflow: hidden;
  transition: opacity 0.6s ease;
}

html.film-active .film-loader.done {
  opacity: 0;
}

html.film-active .film-loader-bar {
  width: 0;
  height: 100%;
  border-radius: 999px;
  background: var(--salud-green);
  transition: width 0.25s ease;
}

/* ─── ADAPTIVE HEADER ('clear' mode only — pre-built, currently unused
       because no dark full-wordmark asset exists; pages ship 'solid') ─── */
html.film-active .site-header.header-clear {
  background: transparent;
  box-shadow: none;
}

html.film-active .site-header.header-clear .nav-menu a,
html.film-active .site-header.header-clear .nav-anchor a {
  color: currentColor;
}

html.film-active .site-header.header-clear.on-light {
  color: var(--salud-blue);
}

/* ─── BEAT TYPOGRAPHY ─── */
/* Beats carry the page's real copy (canonical home) over the footage, so
   they mirror the hero/step type scales from styles.css but always in
   film-legible white with the scrim from .film-beat. */
.film-beat h1 {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  color: #fff;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.film-beat h1 span {
  color: var(--salud-green);
}

.film-beat > p,
.film-beat .step-copy p {
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(1rem, 2vw, 1.15rem);
  line-height: 1.65;
  margin-bottom: 1.5rem;
  max-width: 46ch;
}

.film-beat .step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--salud-green);
  color: var(--salud-blue);
  font-weight: 700;
  margin-bottom: 0.9rem;
}

.film-beat h3 {
  font-size: clamp(1.4rem, 2.6vw, 1.9rem);
  color: #fff;
  margin-bottom: 0.35rem;
  letter-spacing: -0.01em;
}

.film-beat h4 {
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  color: var(--salud-green);
  font-weight: 600;
  margin-bottom: 0.9rem;
}

/* ─── MOBILE ─── */
@media (max-width: 768px) {
  html.film-active .film-beat {
    max-width: 88vw;
    text-shadow: 0 1px 18px rgba(10, 14, 22, 0.65), 0 1px 3px rgba(10, 14, 22, 0.55);
  }
  html.film-active .film-beat-hero,
  html.film-active .film-beat-finale {
    left: 6vw;
    right: 6vw;
    max-width: none;
  }
  html.film-active .film-beat-chapter,
  html.film-active .film-beat-right {
    left: 6vw;
    right: 6vw;
    bottom: 12vh;
  }
}

/* ─── PANEL MODE (phones) ─── */
/* Pages that tag their film section .film-panel-mobile trade the full-bleed
   cover-crop for an honest product view on portrait phones: the WHOLE 16:9
   frame at viewport width under the header (no cropping, no pans — a
   desktop-layout product UI through a keyhole never reads), cinematic
   grain/vignette off, and every beat living in one copy zone BELOW the
   video, crossfading in place as the visitor scrolls. The film still scrubs;
   only the presentation changes. */
@media (max-width: 768px) and (orientation: portrait) {
  html.film-active .film-panel-mobile .film-poster,
  html.film-active .film-panel-mobile .film-canvas {
    inset: auto 0 auto 0;
    /* --film-header-h is measured from the real header by the engine, so
       the video sits flush beneath it — no guessed offset, no black bar. */
    top: var(--film-header-h, 3.5rem);
    height: calc(100vw * 9 / 16);
  }

  /* The fixed header collapses slightly in its scrolled state, so no single
     measurement is exact in both states — extend the header's navy down to
     the video's top edge and any residual sliver reads as header, never as
     a black bar. */
  html.film-active .film-panel-mobile .film-stage::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--film-header-h, 3.5rem) + 2px);
    background: #3A4B5D;
  }

  html.film-active .film-panel-mobile .film-vignette,
  html.film-active .film-panel-mobile .film-grain {
    display: none;
  }

  html.film-active .film-panel-mobile .film-beat,
  html.film-active .film-panel-mobile .film-beat-hero,
  html.film-active .film-panel-mobile .film-beat-chapter,
  html.film-active .film-panel-mobile .film-beat-right,
  html.film-active .film-panel-mobile .film-beat-finale {
    top: calc(var(--film-header-h, 3.5rem) + 56.25vw + 1.8rem);
    bottom: auto;
    left: 6vw;
    right: 6vw;
    max-width: none;
  }
}

/* Belt-and-suspenders: the engine never boots under reduced motion, but if
   film-active were ever present, kill the grain loop anyway. */
@media (prefers-reduced-motion: reduce) {
  html.film-active .film-grain {
    animation: none;
  }
}

/* ═══════════════════════════════════════════════════════════════
   ORGS SCENE — "The Bigger Picture" (for-organizations.html)
   A pure-code preview of the future Org Portal, styled in the real
   Pro Portal design language (navy sidebar #3A4B5D, lime #B1D354
   with ink text, slate #F8FAFC canvas, white cards, #E2E8F0
   hairlines). Markup renders the FINISHED dashboard statically;
   html.orgs-active (set by js/films/organizations.js) enables the
   pinned scrub choreography.
   ═══════════════════════════════════════════════════════════════ */
.orgs-scene {
  background: linear-gradient(135deg, var(--salud-blue), #2c3a4a 60%, #1f2937);
  color: #fff;
}

/* Head (eyebrow + h1) and body (paragraph, captions, CTAs) are separate grid
   items so mobile can put the portal mock directly under the headline —
   Chuck's rule: the animated screen must be visible without hunting for it. */
.orgs-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  grid-template-areas:
    "head orgp"
    "body orgp";
  align-content: center;
  align-items: center;
  column-gap: 3rem;
  max-width: 1200px;
  margin: 0 auto;
  padding: 7rem 1.5rem 4rem;
  min-height: 100svh;
  box-sizing: border-box;
}

.orgs-copy-head { grid-area: head; align-self: end; }
.orgs-copy-body { grid-area: body; align-self: start; }
.orgs-grid .orgp { grid-area: orgp; }

html.orgs-active .orgs-scene {
  /* pinned by ScrollTrigger; height/pin-spacing handled by GSAP */
}

.orgs-copy h1 {
  font-size: clamp(2.25rem, 5vw, 3.5rem);
  color: #fff;
  margin-bottom: 1.5rem;
  letter-spacing: -0.02em;
}

.orgs-copy h1 span { color: var(--salud-green); }

.orgs-copy > p {
  color: rgba(255, 255, 255, 0.75);
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.65;
  margin-bottom: 2rem;
}

.orgs-captions { min-height: 2.2rem; position: relative; margin-bottom: 2rem; }

.orgs-caption {
  position: absolute;
  inset: 0 auto auto 0;
  font-size: 0.95rem;
  color: var(--salud-green);
  font-weight: 600;
  letter-spacing: 0.02em;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.orgs-caption.is-on { opacity: 1; }
/* Static fallback: show the first caption */
html:not(.orgs-active) .orgs-caption:first-child { opacity: 1; }

/* ─── The mock portal ─── */
.orgp {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  border-radius: 16px;
  overflow: hidden;
  background: #F8FAFC;
  box-shadow: 0 30px 80px rgba(10, 14, 22, 0.45);
  aspect-ratio: 16 / 10.4;
  font-size: 12px;
  color: #1E293B;
}

.orgp-sidebar {
  background: var(--salud-blue);
  color: #EFF1F5;
  padding: 14px 10px;
  display: flex;
  flex-direction: column;
}

.orgp-brand {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 12px;
}

.orgp-brand img {
  width: 104px;
  max-width: calc(100% - 44px);
  height: auto;
  display: block;
}

.orgp-brand em {
  font-style: normal;
  font-weight: 800;
  background: var(--salud-green);
  color: var(--salud-blue);
  border-radius: 999px;
  font-size: 9px;
  padding: 2px 7px;
  letter-spacing: 0.08em;
}

.orgp-nav { list-style: none; margin: 0; padding: 0; }

.orgp-nav li {
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 2px;
  color: rgba(239, 241, 245, 0.82);
  font-weight: 500;
}

.orgp-nav li.is-on {
  background: rgba(177, 211, 84, 0.14);
  color: var(--salud-green);
  font-weight: 700;
}

.orgp-admin {
  margin-top: auto;
  font-size: 10px;
  color: rgba(239, 241, 245, 0.65);
  padding: 8px 10px;
  border-top: 1px solid rgba(239, 241, 245, 0.14);
}

.orgp-main { padding: 14px 16px; min-width: 0; }

.orgp-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.orgp-head h5 { margin: 0; font-size: 13px; letter-spacing: -0.01em; }

.orgp-tiles {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.orgp-tile {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 9px 10px;
}

.orgp-tile strong { display: block; font-size: 16px; letter-spacing: -0.02em; }
.orgp-tile span { color: #64748B; font-size: 9.5px; font-weight: 500; }
.orgp-tile[data-tone="navy"] strong { color: var(--salud-blue); }
.orgp-tile[data-tone="lime"] strong { color: #7BAE20; }
.orgp-tile[data-tone="blue"] strong { color: #2563EB; }
.orgp-tile[data-tone="amber"] strong { color: #D97706; }

/* Panels: stacked, one visible. Static fallback shows the first. */
.orgp-panels { position: relative; min-height: 118px; }

.orgp-panel {
  position: absolute;
  inset: 0;
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  padding: 10px 12px;
  opacity: 0;
  transition: opacity 0.45s ease;
}

.orgp-panel.is-on { opacity: 1; }
html:not(.orgs-active) .orgp-panel:first-child { opacity: 1; }

.orgp-panel h6 {
  margin: 0 0 8px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #94A3B8;
}

.orgp-bars { display: flex; align-items: flex-end; gap: 8px; height: 74px; }

.orgp-bars span {
  flex: 1;
  border-radius: 6px 6px 3px 3px;
  background: #F1F5F9;
  position: relative;
  overflow: hidden;
  display: block;
  height: 100%;
}

.orgp-bars span::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: var(--v);
  background: var(--salud-green);
  border-radius: 6px 6px 3px 3px;
}

.orgp-cohort { display: grid; gap: 8px; }

.orgp-cohort > div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  font-size: 10.5px;
  font-weight: 600;
}

.orgp-cohort b { font-weight: 700; text-align: right; color: #7BAE20; }

.orgp-cohort u {
  text-decoration: none;
  background: #F1F5F9;
  border-radius: 999px;
  height: 7px;
  overflow: hidden;
  display: block;
}

.orgp-cohort i {
  display: block;
  height: 100%;
  width: var(--v);
  border-radius: 999px;
  background: var(--salud-green);
}

.orgp-outcomes svg { display: block; width: 100%; height: 84px; }

/* ─── Mobile ─── */
/* One column, portal directly under the headline so the animated screen is
   on-screen from the first paint; captions sit right beneath it (they
   caption the portal), then the paragraph and CTAs. No pinning at this
   breakpoint — js/films/organizations.js auto-cycles the phases instead. */
@media (max-width: 1024px) {
  .orgs-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "orgp"
      "body";
    row-gap: 1.4rem;
    text-align: left;
    padding-top: 6.5rem;
    min-height: 0;
  }
  .orgs-copy-head h1 { margin-bottom: 0; }
  .orgp { font-size: 11px; }
  .orgs-copy-body { display: flex; flex-direction: column; }
  .orgs-copy-body .orgs-captions { order: 1; margin-bottom: 1.1rem; }
  .orgs-copy-body p { order: 2; }
  .orgs-copy-body .hero-cta { order: 3; }
}

@media (max-width: 640px) {
  .orgp { grid-template-columns: 108px minmax(0, 1fr); aspect-ratio: auto; }
  .orgp-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
