/* Act 1 film (js/film.js): a pinned, scroll-scrubbed Blender render, the page's one deliberate dark moment. The copy
   sits in the calm band the render leaves for it (the dark wall above the café for beats 1-3, the darkened left of
   the close-up for beat 4), one line at a time, crossfaded with a little blur. The section dissolves into the next
   section's base colour over its last 20dvh. */
.film {
  --film-bg: oklch(0 0 0);                         /* the render's studio black, matched exactly */
  --film-next: var(--paper);                       /* the colour of the section after the film */
  --film-ink: oklch(0.975 0.006 255);
  --film-ink-2: oklch(0.82 0.01 255);
  --film-ink-3: oklch(0.68 0.012 255);
  position: relative;
  height: var(--film-length, 1400dvh);   /* founder 2026-11-27: every caption stays longer: ~1 screen of scroll per line, the rethink lines ~2.5 */
  background: var(--film-bg);
  color: var(--film-ink);
}
.film__stage {
  position: sticky; top: 0;
  height: 100dvh;
  overflow: clip;
  contain: layout paint;
}
.film__poster, .film__canvas {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 50% var(--film-py, 30%);   /* wide screens crop top/bottom: keep more of the top so the chrome head isn't cut (founder 2026-11-27) */
  display: block;
}
.film__canvas { opacity: 0; }
.film.is-live .film__canvas { opacity: 1; }
.film.is-live .film__poster { visibility: hidden; }

/* ---- copy */
.film__copy {
  position: absolute; z-index: 1;
  inset: 0;
  display: grid;
  pointer-events: none;
}
.film__line {
  grid-area: 1 / 1;
  justify-self: center; align-self: start;
  margin-top: clamp(4.5rem, 11dvh, 8rem);
  width: min(40rem, calc(100% - 2rem));
  text-align: center;
  opacity: 0; filter: blur(6px); translate: 0 0.4rem; visibility: hidden;
  transition: opacity 0.5s var(--ease-out), filter 0.5s var(--ease-out), translate 0.5s var(--ease-out), visibility 0s 0.5s;
}
.film__line[data-for="turn"] {
  justify-self: start; align-self: center; margin: 0 0 0 clamp(1rem, 6vw, 6.5rem);
  width: min(26rem, 40vw); text-align: start;
}
.film__stage[data-beat="cafe"] .film__line[data-for="cafe"],
.film__stage[data-beat="overlook"][data-step="0"] .film__line[data-for="overlook"][data-step="0"],
.film__stage[data-beat="overlook"][data-step="1"] .film__line[data-for="overlook"][data-step="1"],
.film__stage[data-beat="overlook"][data-step="2"] .film__line[data-for="overlook"][data-step="2"],
.film__stage[data-beat="overlook"][data-step="3"] .film__line[data-for="overlook"][data-step="3"],
.film__stage[data-beat="rethink"][data-step="0"] .film__line[data-for="rethink"][data-step="0"],
.film__stage[data-beat="rethink"][data-step="1"] .film__line[data-for="rethink"][data-step="1"],
.film__stage[data-beat="turn"] .film__line[data-for="turn"],
.film__stage:not([data-beat]) .film__line[data-for="cafe"] {
  opacity: 1; filter: none; translate: 0 0; visibility: visible;
  transition: opacity 0.5s var(--ease-out), filter 0.5s var(--ease-out), translate 0.5s var(--ease-out), visibility 0s;
}
.film__title {
  font-family: var(--font-display);
  font-weight: var(--display-wght);
  font-size: clamp(2.3rem, 1.3rem + 3.4 * var(--fl), 4.6rem);
  letter-spacing: var(--display-track);
  line-height: var(--display-lh);
}
.film__say {
  font-family: var(--font-lead);
  font-weight: var(--lead-wght);
  font-size: clamp(1.3rem, 1rem + 1 * var(--fl), 2rem);
  letter-spacing: var(--lead-track);
  line-height: var(--lead-lh);
  color: var(--film-ink);
}
.film__line[data-for="turn"] .film__say { font-size: clamp(1.15rem, 1.6vw, 1.45rem); line-height: 1.4; color: var(--film-ink-2); }

/* ---- tracking boxes (beat "overlook"): corner brackets and a small label, placed by film.js every frame */
.film__boxes { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.film__box {
  position: absolute; left: 0; top: 0;
  --c: oklch(0.975 0.006 255 / 0.92); --t: 1.5px; --l: 28%;
  background:
    linear-gradient(var(--c), var(--c)) top left / var(--l) var(--t), linear-gradient(var(--c), var(--c)) top left / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) top right / var(--l) var(--t), linear-gradient(var(--c), var(--c)) top right / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) bottom left / var(--l) var(--t), linear-gradient(var(--c), var(--c)) bottom left / var(--t) var(--l),
    linear-gradient(var(--c), var(--c)) bottom right / var(--l) var(--t), linear-gradient(var(--c), var(--c)) bottom right / var(--t) var(--l);
  background-repeat: no-repeat;
  opacity: 0;
}
.film__box span {
  position: absolute; left: 0; top: calc(100% + 6px);
  white-space: nowrap;
  font-size: 0.75rem; font-weight: 500; letter-spacing: 0.01em;
  color: var(--film-ink);
  text-shadow: 0 0 6px oklch(0 0 0 / 0.8);
}

/* ---- the hand-over: the last 20dvh of the section dissolves into the next section's colour */
.film::after {
  content: "";
  position: absolute; inset: auto 0 0 0; z-index: 2;
  height: 20dvh;
  background: linear-gradient(to bottom in oklch, color-mix(in oklch, var(--film-bg) 0%, transparent), var(--film-next));
  pointer-events: none;
}

/* ---- portrait: the 9:16 crop fills the screen; the copy keeps the dark band at the top */
@media (max-aspect-ratio: 1/1) {
  .film__line { margin-top: max(4.5rem, 8dvh); }
  .film__line[data-for="turn"] {
    justify-self: center; align-self: start; margin: max(4.5rem, 8dvh) 0 0; width: calc(100% - 2rem); text-align: center;
  }
  .film__title { font-size: clamp(2rem, 9vw, 2.6rem); }
  .film__say { font-size: 1.25rem; }
  .film__stage::before {
    content: ""; position: absolute; inset: 0 0 auto 0; height: 40dvh; z-index: 1; pointer-events: none;
    background: linear-gradient(to bottom in oklch, color-mix(in oklch, var(--film-bg) 85%, transparent) 40%, color-mix(in oklch, var(--film-bg) 0%, transparent));
  }
}

@media (prefers-reduced-motion: reduce) {
  .film__line { transition: none; filter: none; translate: none; }
}
:root[data-motion="off"] .film__line { transition: none; filter: none; translate: none; }

/* ---- founder 2026-11-27: one typeface for every film line, big, each line on its own caption card so it reads over
   any frame (the film is busy and bright behind the copy). The card is the design system's dark note look: basalt
   glass, blurred backdrop, alpha border, nested radius. Lines size to their text (fit-content) and wrap balanced. */
.film__line {
  width: fit-content; max-inline-size: min(62rem, calc(100% - 3rem));
  padding: clamp(0.7rem, 1.4vw, 1.1rem) clamp(1.1rem, 2.2vw, 1.75rem);
  border-radius: clamp(18px, 2vw, 26px);
  background: oklch(0.16 0.006 55 / 0.62);
  border: 1px solid oklch(1 0 0 / 0.09);
  box-shadow: 0 12px 40px oklch(0 0 0 / 0.35);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  text-wrap: balance;
}
.film__title, .film__say, .film__line[data-for="turn"] .film__say {
  font-family: var(--font-display); font-weight: var(--display-wght);
  letter-spacing: var(--display-track-head, -0.015em); color: var(--film-ink); margin: 0;
}
.film__title { font-size: clamp(2.4rem, 1.4rem + 3.2 * var(--fl), 4.4rem); line-height: 1.02; }
.film__say, .film__line[data-for="turn"] .film__say { font-size: clamp(1.6rem, 1.1rem + 1.6 * var(--fl), 2.75rem); line-height: 1.12; }
/* the closing line keeps its place on the left, as a card of the same family */
.film__line[data-for="turn"] { width: fit-content; max-inline-size: min(34rem, 46vw); text-wrap: balance; }
@media (max-aspect-ratio: 1/1) {
  .film__line[data-for="turn"] { max-inline-size: calc(100% - 2rem); }
  .film__title { font-size: clamp(2rem, 8.5vw, 2.6rem); }
  .film__say, .film__line[data-for="turn"] .film__say { font-size: clamp(1.35rem, 6vw, 1.7rem); }
}
@supports not (backdrop-filter: blur(1px)) { .film__line { background: oklch(0.16 0.006 55 / 0.86); } }
/* the cards start below the top bar (its backdrop blur would smear a card's first line) */
.film__line:not([data-for="turn"]) { margin-top: calc(var(--bar-h, 4.5rem) + clamp(0.75rem, 3dvh, 2rem)); }

/* founder 2026-11-27: the tracking boxes and their labels sit on their own layer above the film and read on any frame:
   brighter brackets with a dark hairline behind them, and each label on a small dark pill (glacier dot + bone text) */
.film__boxes { z-index: 3; }
.film__box { --c: oklch(0.86 0.09 230); --t: 2px; filter: drop-shadow(0 0 1px oklch(0 0 0 / 0.9)) drop-shadow(0 0 6px oklch(0 0 0 / 0.5)); }
.film__box span {
  top: calc(100% + 8px);
  display: inline-flex; align-items: center; gap: 0.4em;
  padding: 0.3em 0.65em 0.32em; border-radius: 999px;
  font: 600 0.8rem/1 var(--font); letter-spacing: 0.01em; color: oklch(0.97 0.005 85);
  background: oklch(0.14 0.006 55 / 0.82); border: 1px solid oklch(0.86 0.09 230 / 0.45);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  text-shadow: none;
}
.film__box span::before { content: ""; inline-size: 0.45em; block-size: 0.45em; border-radius: 50%; background: oklch(0.8 0.11 230); }

/* founder 2026-11-27, the café loop (js/film.js): the loop video is never shown itself (the canvas draws it); it stays
   a 1 px element in the stage so browsers keep decoding it. Boxes lock on with two quick blinks and let go with a fade. */
.film__video { position: absolute; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.film__box { opacity: 1; animation: film-lock 0.32s linear both; transition: opacity 0.22s var(--ease-out); }
.film__box.is-out { opacity: 0; }
@keyframes film-lock { 0%, 24% { opacity: 0; } 25%, 49% { opacity: 1; } 50%, 66% { opacity: 0; } 67%, 100% { opacity: 1; } }

/* founder 2026-11-27: the hand-over must have no step. It runs over the section's last 55dvh and reaches the page colour
   a bar's height (+1rem) before the section ends, so the top bar's backdrop never samples a half-dissolved film (that
   showed as a grey band with ghost imagery and a hard line under the bar). Eased stops keep each 4 px under ~1.5 % L. */
.film::after {
  height: 55dvh;
  bottom: -1px;   /* at fractional device pixels (DPR 1.33) the section's black edge row showed as a 1 px dark hairline */
  background: linear-gradient(to bottom in oklch,
    color-mix(in oklch, var(--film-next) 0%, transparent),
    color-mix(in oklch, var(--film-next) 18%, transparent) 25%,
    color-mix(in oklch, var(--film-next) 48%, transparent) 50%,
    color-mix(in oklch, var(--film-next) 80%, transparent) calc(100% - var(--bar-h, 4.5rem) - 5rem),
    var(--film-next) calc(100% - var(--bar-h, 4.5rem) - 1rem));
}

/* Caption redesign: displacement belongs to the glass, never the typography.
   Adaptation of the existing basalt caption surface; no pixel canvas or edge tears. */
.film__line {
  isolation: isolate;
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  filter: none;
  translate: none;
  transition: opacity 0.5s var(--ease-out), visibility 0s 0.5s;
}
.film__line::before, .film__line::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  pointer-events: none;
}
.film__line::before {
  background: linear-gradient(115deg in oklch, oklch(0.25 0.008 55 / 0.78), oklch(0.16 0.006 55 / 0.86) 54%, oklch(0.21 0.012 230 / 0.72));
  border: 1px solid oklch(0.95 0.01 85 / 0.12);
  backdrop-filter: blur(18px) saturate(0.7);
  -webkit-backdrop-filter: blur(18px) saturate(0.7);
  animation: film-glass-displace 7.2s steps(1, end) infinite;
}
.film__line::after {
  background: linear-gradient(105deg in oklch, transparent 10%, oklch(0.75 0.04 230 / 0.16) 34%, transparent 64%);
  opacity: 0;
  filter: blur(5px);
  animation: film-glass-memory 7.2s steps(1, end) infinite;
}
.film__line:nth-child(even)::before, .film__line:nth-child(even)::after { animation-delay: -2.4s; }
@keyframes film-glass-displace {
  0%, 82%, 88%, 100% { transform: none; }
  83% { transform: translateX(-3px) skewX(-1.2deg); }
  85% { transform: translateX(2px) skewX(0.6deg); }
}
@keyframes film-glass-memory {
  0%, 82%, 88%, 100% { opacity: 0; transform: none; }
  83% { opacity: 0.7; transform: translateX(12px) scaleX(1.025); }
  85% { opacity: 0.35; transform: translateX(-7px); }
}
:root[data-motion="off"] .film__line::before,
:root[data-motion="off"] .film__line::after { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .film__line::before, .film__line::after { animation: none; }
}

/* One photographic film; soft straight edge fades, never a circular vignette. */
.film { --film-bg: var(--paper); }
.film__canvas, .film__poster {
  object-position: 50% 50%;
  mask-image: linear-gradient(to right, transparent, black 9%, black 91%, transparent), linear-gradient(to bottom, transparent, black 15%, black 84%, transparent);
  mask-composite: intersect;
}
@media (max-aspect-ratio: 1/1) {
  .film__line[data-for="turn"] { margin-top: calc(var(--bar-h, 4.5rem) + clamp(0.75rem, 3dvh, 2rem)); }
}

/* The last shot stays pinned beneath the real calling controls; its original travel is unchanged. */
.film:has(> .ways) { height: auto; }
.film:has(> .ways)::after { display: none; }
.film:has(> .ways) .film__copy { opacity: var(--film-copy-opacity, 1); }
