/* css/film.css — the onboarding: gate, film player, hand-off (film/gate.mjs, film/player.mjs). Prefix .pf-
 * Layers inside .pf (back → front): .pf-stage (film canvas, letterbox = the frame's ground) · .pf-gate (particles,
 * type, buttons, HUD) · .pf-controls · .pf-flydot / .pf-rim (the dot, the iris rim) · .pf-toast · .pf-sr.
 * Tokens come from css/tokens.css when the site loads it; every value has a literal fallback so the overlay
 * also works on its own.
 */

/* ── before the module arrives: a night curtain (first visits only; the site's head snippet sets the class).
      If the script never mounts, the curtain lifts by itself after 6 s. ─────────────────────────────── */
html.pd-onb-pending::after {
  content: ""; position: fixed; inset: 0; z-index: 2147483000; background: #0B0D14; pointer-events: none;
  animation: pf-bail .35s ease 6s forwards;
}
@keyframes pf-bail { to { opacity: 0; visibility: hidden; } }

html.pf-lock, html.pf-lock body { overflow: hidden !important; overscroll-behavior: none; }

.pf {
  --pf-night: var(--night, #0B0D14);
  --pf-paper: var(--paper, #F4F1EA);
  --pf-cobalt: var(--cobalt, #2340FF);
  --pf-cobalt-lift: #5C73FF;
  --pf-thread: var(--thread, #E5352B);
  --pf-display: var(--display, 'Roboto Flex', 'Helvetica Neue', Arial, sans-serif);
  --pf-human: var(--human, 'Fraunces', Georgia, serif);
  --pf-mono: var(--mono, 'Martian Mono', 'SF Mono', Menlo, monospace);
  --pf-swift: cubic-bezier(.2, 0, 0, 1);
  position: fixed; inset: 0; z-index: 10000;
  width: 100vw; height: 100vh; height: 100dvh;
  overflow: hidden; contain: strict;
  background: var(--pf-night); color: var(--pf-paper);
  font-family: var(--pf-display);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: contain;
  outline: none;
  isolation: isolate;
}
.pf, .pf:focus, .pf:focus-visible { border-radius: 0 !important; outline: none !important; }
.pf *, .pf *::before, .pf *::after { box-sizing: border-box; }
/* the site's h1 after the hand-off: focused for screen readers and the next Tab, but a programmatic landing shows no ring */
.pf-quiet-focus:focus-visible, .pf-quiet-focus:focus { outline: none !important; }
.pf.is-fading { transition: opacity .28s ease; opacity: 0; }
.pf.is-flooding, .pf.is-iris { background: transparent; }

.pf-vh, .pf-sr {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ── film stage ─────────────────────────────────────────────────────────────────────────────── */
.pf-stage { position: absolute; inset: 0; z-index: 1; background: var(--pf-night); visibility: hidden; }
.pf.is-film .pf-stage { visibility: visible; }
.pf.is-idle .pf-stage { cursor: none; }
.pf-bars { position: absolute; display: block; left: 0; top: 0; pointer-events: none; }
.pf-film { position: absolute; display: block; left: 0; top: 0; transform-origin: 50% 50%; will-change: transform; }
.pf-rotate {
  position: absolute; left: 50%; transform: translateX(-50%); margin: 0; padding: 0 16px; width: max-content; max-width: 100%;
  font: 500 10px/1.4 var(--pf-mono); letter-spacing: .08em; text-transform: uppercase; text-align: center; white-space: nowrap;
  color: rgba(244, 241, 234, .66); opacity: 0; transition: opacity .5s ease; pointer-events: none;
}
.pf-rotate.on { opacity: 1; }
.pf.is-light .pf-rotate { color: rgba(18, 19, 24, .62); }
.pf-rotate svg { width: 14px; height: 14px; vertical-align: -3px; margin-right: 6px; fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ── gate ───────────────────────────────────────────────────────────────────────────────────── */
.pf-gate { position: absolute; inset: 0; z-index: 2; }
.pf-ground {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(60% 50% at 50% 46%, rgba(35, 64, 255, .10), rgba(35, 64, 255, 0) 70%),
    radial-gradient(120% 90% at 50% 44%, #151929 0%, #0F121D 42%, #0B0D14 78%);
  transition: opacity 1s ease;
}
.pf-cv { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.pf-col {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 1180px); display: flex; flex-direction: column; align-items: center; text-align: center;
  pointer-events: none; transition: opacity .3s ease;
}
.pf-title { margin: 0; font-weight: inherit; }
.pf-kicker {
  display: inline-block; font-family: var(--pf-human); font-style: italic; font-weight: 300;
  font-size: clamp(20px, min(2.3vw + 8px, 5.2vh), 46px); line-height: 1.1; letter-spacing: -.01em;
  color: rgba(244, 241, 234, .9);
  opacity: 0; transform: translateY(12px); transition: opacity .8s ease, transform 1s var(--pf-swift);
}
.pf-gate.is-kicker .pf-kicker { opacity: 1; transform: none; }
.pf-word { width: 100%; height: clamp(84px, min(21vw, 31vh), 290px); margin: clamp(2px, 1vh, 12px) 0 0; }
@media (max-width: 600px) { .pf-word { height: clamp(84px, min(27vw, 26vh), 200px); } }
@media (max-width: 600px) and (orientation: portrait) { .pf-word { height: clamp(120px, min(72vw, 35vh), 320px); } }
.pf-invite {
  position: relative; margin: clamp(10px, 2.2vh, 24px) 0 0; padding-bottom: 12px;
  font-family: var(--pf-human); font-style: italic; font-weight: 400;
  font-size: clamp(16px, .7vw + 11px, 22px); line-height: 1.3; color: rgba(244, 241, 234, .82);
}
.pf-w { display: inline-block; opacity: 0; transform: translateY(.4em); filter: blur(3px);
  transition: opacity .45s ease, transform .6s var(--pf-swift), filter .45s ease; }
.pf-w.on { opacity: 1; transform: none; filter: none; }
.pf-actions {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 12px 26px;
  margin-top: clamp(20px, 4.4vh, 46px); pointer-events: auto;
  opacity: 0; transform: translateY(16px); transition: opacity .7s ease, transform .9s var(--pf-swift);
}
.pf-gate.is-actions .pf-actions { opacity: 1; transform: none; }
.pf-play {
  display: inline-flex; align-items: center; gap: 10px; min-height: 58px; padding: 0 28px 0 22px; border: 0; border-radius: 999px;
  background: var(--pf-cobalt); color: #fff; cursor: pointer;
  font: 750 17px/1 var(--pf-display); letter-spacing: -.005em;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, .06) inset, 0 14px 44px -8px rgba(35, 64, 255, .65), 0 2px 8px rgba(0, 0, 0, .3);
  transition: transform .22s var(--pf-swift), box-shadow .22s ease, filter .22s ease;
}
.pf-play svg { width: 20px; height: 20px; fill: currentColor; flex: none; }
.pf-play-m { font-weight: 500; opacity: .82; white-space: nowrap; }
.pf-play:hover { transform: translateY(-1px); filter: brightness(1.1); box-shadow: 0 0 0 1px rgba(255, 255, 255, .1) inset, 0 18px 54px -8px rgba(35, 64, 255, .8), 0 2px 8px rgba(0, 0, 0, .3); }
.pf-play:active { transform: translateY(0) scale(.98); }
.pf-skip {
  min-height: 48px; padding: 0 6px; border: 0; background: none; cursor: pointer; color: rgba(244, 241, 234, .8);
  font: 600 16px/1 var(--pf-display); text-decoration: underline; text-decoration-color: rgba(244, 241, 234, .3);
  text-underline-offset: 6px; text-decoration-thickness: 1px; transition: color .2s ease, text-decoration-color .2s ease;
}
.pf-skip:hover { color: #fff; text-decoration-color: var(--pf-thread); }
.pf-skip span { display: inline-block; transition: transform .25s var(--pf-swift); }
.pf-skip:hover span { transform: translateX(3px); }
.pf-play:focus-visible, .pf-skip:focus-visible, .pf-transcript summary:focus-visible,
.pf-cbtn:focus-visible, .pf-cskip:focus-visible, .pf-scrub:focus-visible {
  outline: 2px solid var(--pf-paper); outline-offset: 3px;
}
.pf-gate.is-draining .pf-col, .pf-gate.is-hud.is-draining .pf-bl { opacity: 0; pointer-events: none; }
.pf-gate.is-draining .pf-actions { pointer-events: none; }
.pf-gate.is-draining .pf-ground { opacity: 0; }
.pf-gate.is-draining .pf-cv { cursor: default; }

/* HUD corners (OPUS): where the film's HUD will be on landscape screens */
.pf-hud {
  position: absolute; margin: 0; white-space: nowrap; pointer-events: none;
  font: 500 var(--hud-fs, 11px)/1 var(--pf-mono); letter-spacing: .08em; text-transform: uppercase;
  color: rgba(244, 241, 234, .92); font-variant-numeric: tabular-nums;
  opacity: 0; transition: opacity .6s ease;
}
.pf-gate.is-hud .pf-hud { opacity: 1; }
.pf-tl { left: var(--hud-l, 16px); top: var(--hud-top, 18px); }
.pf-tr { right: var(--hud-r, 16px); top: var(--hud-top, 18px); }
.pf-bl { left: var(--hud-l, 16px); bottom: var(--hud-bot, 18px); transition: opacity .3s ease; }
.pf-br { right: var(--hud-r, 16px); bottom: var(--hud-bot, 18px); display: flex; align-items: flex-end; gap: 1.6em; }
.pf-beats { display: inline-flex; gap: .4em; }
.pf-beats i { width: .67em; height: .67em; border: 1.5px solid currentColor; }
.pf-beats i.on { background: currentColor; }
.pf-wait {
  position: absolute; left: 0; top: 0; white-space: nowrap; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  font: 500 10.5px/1 var(--pf-mono); letter-spacing: .12em; text-transform: uppercase; color: rgba(244, 241, 234, .6);
  opacity: 0; transition: opacity .4s ease;
}
.pf-gate.is-waiting .pf-wait { opacity: 1; }
.pf-wskip {
  min-height: 44px; padding: 0 10px; border: 0; background: none; cursor: pointer; color: rgba(244, 241, 234, .8);
  font: 600 14px/1 var(--pf-display); letter-spacing: 0; text-transform: none;
  text-decoration: underline; text-decoration-color: rgba(244, 241, 234, .3); text-underline-offset: 5px; text-decoration-thickness: 1px;
  opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .4s ease, visibility 0s linear .4s, color .2s ease;
}
.pf-gate.is-waiting.is-wait-long .pf-wskip { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .4s ease, color .2s ease; }
.pf-wskip:hover { color: #fff; text-decoration-color: var(--pf-thread); }
.pf-wskip:focus-visible { outline: 2px solid var(--pf-paper); outline-offset: 3px; border-radius: 6px; }

/* reduced motion: the film as text (a toggle under the buttons, a panel over the gate) */
.pf-tbtn {
  pointer-events: auto; margin-top: 14px; min-height: 44px; padding: 0 12px; border: 0; background: none; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  font: 500 11px/1 var(--pf-mono); letter-spacing: .12em; text-transform: uppercase; color: rgba(244, 241, 234, .78);
}
.pf-tbtn::before { content: "+"; font-size: 14px; color: var(--pf-thread); }
.pf-tbtn[aria-expanded="true"]::before { content: "–"; }
.pf-tbtn:focus-visible, .pf-tclose:focus-visible, .pf-tpanel h3:focus-visible { outline: 2px solid var(--pf-paper); outline-offset: 3px; }
.pf-tpanel {
  position: absolute; z-index: 7; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(680px, calc(100% - 32px)); max-height: min(82vh, 760px); overflow: auto; overscroll-behavior: contain;
  padding: 0 24px 22px; border-radius: 20px; background: #121521; border: 1px solid rgba(244, 241, 234, .14);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55); color: rgba(244, 241, 234, .92); font: 400 15px/1.5 var(--pf-display);
}
.pf-tpanel[hidden] { display: none; }
.pf-tbar { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 0 12px; background: #121521; border-bottom: 1px solid rgba(244, 241, 234, .1); }
.pf-tbar h3 { margin: 0; font: 500 11px/1.4 var(--pf-mono); letter-spacing: .12em; text-transform: uppercase; color: rgba(244, 241, 234, .7); }
.pf-tclose { width: 44px; height: 44px; border: 0; border-radius: 12px; background: rgba(244, 241, 234, .08); color: inherit; font: 400 24px/1 var(--pf-display); cursor: pointer; }
.pf-tpanel ol { list-style: none; margin: 16px 0 0; padding: 0; }
.pf-tpanel li + li { margin-top: 16px; }
.pf-tpanel p { margin: 0; }
.pf-t-h { font: 500 11px/1.4 var(--pf-mono) !important; letter-spacing: .1em; color: #9DB1E6; margin-bottom: 4px !important; }
.pf-t-pic { color: rgba(244, 241, 234, .62); font-style: italic; font-family: var(--pf-human) !important; }
.pf-t-lines { font-weight: 650; margin-top: 4px !important; }
.pf-gate.is-still .pf-kicker, .pf-gate.is-still .pf-w, .pf-gate.is-still .pf-actions, .pf-gate.is-still .pf-hud { transition: none; }

/* ── controls ──────────────────────────────────────────────────────────────────────────────── */
.pf-controls {
  position: absolute; z-index: 3; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  width: min(1120px, calc(100% - 28px));
  display: grid; grid-template-columns: auto auto minmax(140px, 1fr) auto auto; grid-template-areas: "play time scrub mute skip";
  align-items: center; gap: 4px 12px; padding: 8px 10px 8px 8px; border-radius: 20px;
  background: rgba(11, 13, 20, .84); color: var(--pf-paper);
  -webkit-backdrop-filter: blur(14px) saturate(1.3); backdrop-filter: blur(14px) saturate(1.3);
  border: 1px solid rgba(255, 255, 255, .09); box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  transition: opacity .3s ease, transform .3s var(--pf-swift);
}
.pf-controls[hidden] { display: none; }
.pf.is-idle .pf-controls { opacity: 0; transform: translate(-50%, 12px); pointer-events: none; }
.pf.is-leaving .pf-controls, .pf.is-leaving .pf-rotate { opacity: 0 !important; pointer-events: none; transition: opacity .18s ease; }
.pf-cbtn {
  grid-area: play; width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 14px;
  background: transparent; color: inherit; cursor: pointer; transition: background .18s ease;
}
.pf-cbtn:hover { background: rgba(255, 255, 255, .1); }
.pf-cbtn svg { width: 22px; height: 22px; fill: currentColor; }
.pf-mute { grid-area: mute; width: auto; padding: 0 12px 0 10px; display: inline-flex; align-items: center; gap: 8px; }
.pf-mute span { font: 500 11px/1 var(--pf-mono); letter-spacing: .1em; text-transform: uppercase; }
.pf-mute .pf-i-off { display: none; }
.pf-mute[aria-pressed="true"] .pf-i-on { display: none; }
.pf-mute[aria-pressed="true"] .pf-i-off { display: block; }
.pf-time { grid-area: time; display: flex; align-items: baseline; gap: 12px; white-space: nowrap;
  font: 500 12px/1 var(--pf-mono); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.pf-time i { font-style: normal; opacity: .5; }
.pf-chap { opacity: .7; text-transform: uppercase; letter-spacing: .1em; font-size: 11px; min-width: 16ch; }
.pf-scrub { grid-area: scrub; position: relative; height: 40px; cursor: pointer; touch-action: none; user-select: none; -webkit-user-select: none; border-radius: 8px; }
.pf-segs { position: absolute; left: 0; right: 0; top: 17px; height: 6px; display: flex; gap: 3px; pointer-events: none; }
.pf-seg { position: relative; min-width: 0; height: 100%; border-radius: 3px; background: rgba(244, 241, 234, .2); overflow: hidden; transition: height .15s ease, transform .15s ease; }
.pf-seg b { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--pf-cobalt-lift); }
.pf-seg.on { background: rgba(244, 241, 234, .3); }
.pf-scrub:hover .pf-seg { transform: scaleY(1.5); }
.pf-nums { position: absolute; left: 0; right: 0; top: 4px; height: 9px; pointer-events: none; }
.pf-nums span { position: absolute; font: 500 8.5px/1 var(--pf-mono); letter-spacing: .06em; color: rgba(244, 241, 234, .42); transition: color .2s ease; }
.pf-nums span.on { color: rgba(244, 241, 234, .9); }
.pf-head { position: absolute; top: 13px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--pf-paper);
  box-shadow: 0 0 0 4px rgba(92, 115, 255, .28); pointer-events: none; }
.pf-tip {
  position: absolute; bottom: 42px; transform: translateX(-50%); padding: 7px 10px; border-radius: 8px; white-space: nowrap; pointer-events: none;
  background: var(--pf-paper); color: var(--ink, #121318); font: 500 10.5px/1 var(--pf-mono); letter-spacing: .08em; text-transform: uppercase;
  opacity: 0; transition: opacity .12s ease;
}
.pf-tip.on { opacity: 1; }
.pf-cskip {
  grid-area: skip; min-height: 44px; padding: 0 16px; border-radius: 14px; border: 1px solid rgba(244, 241, 234, .22);
  background: transparent; color: inherit; cursor: pointer; white-space: nowrap;
  font: 650 14px/1 var(--pf-display); transition: background .18s ease, border-color .18s ease;
}
.pf-cskip:hover { background: rgba(255, 255, 255, .1); border-color: rgba(244, 241, 234, .4); }
@media (max-width: 1000px) { .pf-nums { display: none; } }
@media (max-width: 760px) {
  .pf-controls { grid-template-columns: auto 1fr auto auto; grid-template-areas: "scrub scrub scrub scrub" "play time mute skip"; padding: 4px 8px 8px; gap: 0 6px; border-radius: 18px; }
  .pf-chap { display: none; }
  .pf-mute span { display: none; }
  .pf-mute { padding: 0; width: 44px; justify-content: center; }
  .pf-cskip { padding: 0 12px; font-size: 13.5px; }
  .pf-time { gap: 8px; }
}
@media (max-width: 480px) {
  .pf-time i { display: none; }
  .pf-hud .pf-long { display: none; }
}
/* no room under the picture (16:9 screens, 16:10 laptops, phones on their side — player.mjs sets .is-tight): a
   full-width strip on a scrim over the picture's bottom edge, so the frame's HUD row is covered cleanly instead of
   peeking out on both sides of a floating pill. The scrim is solid behind the control row — and up over the frame's
   HUD row when that row would collide with it (player.mjs sets --pf-hud-cover: the HUD row's top in px from the
   bottom of the screen, or 0 when the HUD row sits clear above) — then fades out. */
.pf.is-tight .pf-controls {
  --pf-row: calc(max(14px, env(safe-area-inset-bottom)) + 44px);
  --pf-solid: max(var(--pf-row), var(--pf-hud-cover, 0px));
  left: 0; right: 0; bottom: 0; width: auto; transform: none;
  min-height: calc(var(--pf-solid) + var(--pf-fade, 36px)); align-content: end;
  padding: 0 max(20px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  border: 0; border-radius: 0; box-shadow: none;
  background: linear-gradient(to top, rgb(11, 13, 20) 0, rgb(11, 13, 20) var(--pf-solid),
    rgba(11, 13, 20, .62) calc(var(--pf-solid) + var(--pf-fade, 36px) * .4), rgba(11, 13, 20, 0) 100%);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.pf.is-tight.is-idle .pf-controls { transform: translateY(12px); }
@media (max-width: 760px) { .pf.is-tight .pf-controls { --pf-row: calc(max(14px, env(safe-area-inset-bottom)) + 84px); } }
/* short screens (phones on their side): a slim single row — the picture is only ~390 px tall */
@media (max-height: 500px) {
  .pf-controls {
    grid-template-columns: auto auto minmax(80px, 1fr) auto auto; grid-template-areas: "play time scrub mute skip";
    gap: 0 8px; padding: 4px 8px 4px 6px; border-radius: 16px;
  }
  .pf.is-tight .pf-controls {
    --pf-row: calc(max(4px, env(safe-area-inset-bottom)) + 38px); --pf-fade: 22px;
    padding: 0 max(14px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  }
  .pf-cbtn { width: 38px; height: 38px; border-radius: 12px; }
  .pf-cbtn svg { width: 20px; height: 20px; }
  .pf-mute { width: 38px; padding: 0; justify-content: center; }
  .pf-mute span, .pf-chap, .pf-time i, .pf-nums { display: none; }
  .pf-time { gap: 8px; font-size: 11.5px; }
  .pf-scrub { height: 32px; }
  .pf-segs { top: 13px; height: 5px; }
  .pf-head { top: 8.5px; width: 13px; height: 13px; margin-left: -6.5px; }
  .pf-tip { bottom: 32px; }
  .pf-cskip { min-height: 36px; padding: 0 12px; border-radius: 12px; font-size: 13px; }
}

/* ── the dot (replay intro) · the iris rim · toast ─────────────────────────────────────────── */
.pf-flydot { position: absolute; z-index: 4; left: 0; top: 0; border-radius: 50%; background: var(--pf-cobalt); pointer-events: none; will-change: transform; }
.pf-rim { position: absolute; z-index: 5; left: 0; top: 0; display: none; border-radius: 50%; border-style: solid; border-color: var(--pf-cobalt); pointer-events: none; box-sizing: border-box; }
.pf-toast {
  position: absolute; z-index: 6; left: 50%; top: max(16px, env(safe-area-inset-top)); transform: translate(-50%, -8px);
  max-width: calc(100% - 32px); padding: 10px 16px; border-radius: 999px; pointer-events: none;
  background: rgba(11, 13, 20, .84); border: 1px solid rgba(255, 255, 255, .12); color: var(--pf-paper);
  font: 500 11px/1.35 var(--pf-mono); letter-spacing: .08em; text-transform: uppercase; text-align: center;
  opacity: 0; transition: opacity .3s ease, transform .3s var(--pf-swift);
}
.pf-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ── small screens ─────────────────────────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .pf-actions { flex-direction: column; gap: 6px; width: 100%; }
  .pf-play { width: min(100%, 360px); justify-content: center; padding: 0 20px; font-size: 16px; }
  .pf-skip { font-size: 15px; }
}
@media (max-height: 500px) {
  .pf-bl, .pf-br { display: none; }
  .pf-actions { margin-top: 12px; }
  .pf-play { min-height: 48px; }
}
@media (prefers-reduced-motion: reduce) {
  .pf *, .pf *::before, .pf *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
