/* =====================================================================
   css/base.css — reset, room, shared layers and shared components.
   Owned by the FOUNDATION package. Scene CSS never restyles these;
   it only positions them inside its own root.
   ===================================================================== */
*,*::before,*::after{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;color-scheme:dark;background:var(--c-midnight)}
html,body{margin:0;height:100%;overflow:hidden;overscroll-behavior:none}
body{background:var(--c-midnight);color:var(--c-wick);font:400 var(--step-0)/var(--lh-body) var(--font-script);
  -webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent}
button{font:inherit;color:inherit}
img{display:block;max-width:100%}
p{margin:0}
[hidden]{display:none !important}
.sr-only{position:absolute !important;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}

/* ---------- The room: stacked light layers, crossfaded by opacity only ---------- */
.room{position:fixed;inset:0;z-index:var(--z-room);overflow:hidden;background:var(--c-midnight);pointer-events:none}
.room > *{position:absolute;inset:0;transition:opacity var(--t-light) var(--ease-inout)}
.room.is-shifting > *{will-change:opacity}
.room__base{background:radial-gradient(90% 60% at 50% 118%, #04050a, transparent 70%),
  linear-gradient(#0c0f20, var(--c-midnight) 55%, #080913)}
.room__moon{opacity:var(--l-moon,.95)}
.room__moon .pane-set{position:absolute;left:var(--moon-x,36%);top:var(--moon-y,10%);width:var(--moon-w,48%);height:var(--moon-h,32%);
  display:grid;grid-template:1fr 1fr / 1fr 1fr;gap:clamp(6px,1.2vw,12px);transform:skewY(-9deg) skewX(-14deg);filter:blur(7px)}
.room__moon .pane-set i{background:linear-gradient(160deg, rgba(var(--rgb-moon),.22), rgba(var(--rgb-moon),.10));border-radius:2px}
.room__warm{opacity:var(--l-warm,0);background:radial-gradient(90% 55% at 50% 0%, rgba(255,170,90,.24), rgba(255,150,70,.06) 60%, transparent 85%)}
.room__candle{opacity:var(--l-candle,0);background:radial-gradient(var(--candle-r,48vmax) circle at var(--candle-x,50%) var(--candle-y,62%),
  rgba(255,178,91,.30), rgba(255,150,70,.10) 40%, transparent 70%)}
.room__spill{opacity:var(--l-spill,0);mix-blend-mode:screen;background:radial-gradient(var(--spill-rx,80vw) var(--spill-ry,30vh) at var(--spill-x,50%) var(--spill-y,36%),
  rgba(255,168,84,.26), rgba(255,150,70,.10) 45%, rgba(255,140,60,.03) 72%, transparent)}
.room__spot{opacity:var(--l-spot,0);background:radial-gradient(var(--spot-r,62vmin) circle at var(--spot-x,50%) var(--spot-y,46%),
  rgba(var(--rgb-wick),.15), rgba(var(--rgb-wick),.05) 55%, transparent 72%)}

/* String lights (SVG built by room.js) */
.festoon{position:absolute;z-index:var(--z-festoon);left:0;top:env(safe-area-inset-top);width:100%;height:170px;overflow:visible}
.festoon .wire{fill:none;stroke:#2c3044;stroke-width:1.6}
.festoon .cap{fill:#262a3a}
.festoon .glass{fill:#151a2e;stroke:rgba(var(--rgb-moon),.35);stroke-width:.8}
.festoon .glint{fill:rgba(var(--rgb-moon),.55)}
.festoon .lit{opacity:var(--l-festoon,0);transition:opacity var(--t-base) var(--ease-out)}
.festoon.is-flicker .lit{animation:flick .5s steps(4,end) both;animation-delay:var(--d,0s)}
@keyframes flick{0%{opacity:0}25%{opacity:1}45%{opacity:.2}70%{opacity:1}85%{opacity:.6}100%{opacity:var(--l-festoon,1)}}

/* ---------- Stage layers ---------- */
.stage{position:fixed;inset:0;z-index:var(--z-shot)}
.shot,.scene{position:absolute;inset:0}
.scene{z-index:var(--z-scene)}
.fx{position:fixed;inset:0;width:100%;height:100%;z-index:var(--z-fx);pointer-events:none}
.ui-layer{position:fixed;inset:0;z-index:var(--z-ui);pointer-events:none}
.scene-ui{position:absolute;inset:0;pointer-events:none}
.scene-ui a,.scene-ui button,.scene-ui [data-action]{pointer-events:auto}
.dimmer{position:fixed;inset:0;z-index:var(--z-dimmer);background:var(--c-midnight);opacity:0;pointer-events:none;
  transition:opacity var(--t-dip) var(--ease-inout)}
.dimmer.is-on{opacity:.94;pointer-events:auto}
.grain{position:fixed;inset:0;z-index:var(--z-grain);pointer-events:none;opacity:.045;   /* white noise: normal blending equals screen here, without a blend group */
  
  background-image:url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1  0 0 0 0 1  0 0 0 0 1  0 0 0 1.2 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>")}
html.is-hidden *,html.is-hidden *::before,html.is-hidden *::after{animation-play-state:paused !important}

/* ---------- Table shot: shared by cake / wish / peak (slots owned by WP3 + WP4) ---------- */
.shot--table{display:flex;flex-direction:column;align-items:center;justify-content:center;
  padding:calc(var(--chrome-h) + env(safe-area-inset-top) + var(--sp-4)) 0 calc(var(--dock-h) + env(safe-area-inset-bottom));
  transform-origin:50% 64%;transition:transform calc(2400ms * var(--t-move)) var(--ease-inout)}
.shot--table.is-pushed{transform:scale(1.06)}
.shot--table.is-instant{transition:none}
.shot-table__sign{position:relative;width:100%;flex:none;display:flex;justify-content:center}   /* --sign-cap/--sign-foot set by the sign */
.shot-table__table{position:relative;width:100%;flex:none;display:flex;justify-content:center;margin-top:calc(var(--sign-foot,0px) * -1)}
.shot-table__top{position:absolute;z-index:-1;left:50%;top:calc(var(--sign-cap,0px) * -.06);bottom:8px;width:min(150vw,1500px);transform:translateX(-50%);
  opacity:min(1, calc(var(--l-moon,.95) + var(--l-warm,0) + var(--l-candle,0) + var(--l-spill,0) + var(--l-spot,0)));  /* dims with the room (cue black = gone) */
  background:radial-gradient(42% 95% at 50% 0%, rgba(255,170,90,.18), rgba(255,160,80,.05) 55%, transparent 82%),
    radial-gradient(55% 150% at 50% 0%, rgba(34,32,56,.7), rgba(22,22,40,.32) 55%, transparent 80%)}
.shot-table__top::after{content:"";position:absolute;left:50%;bottom:0;width:min(130vw,1300px);height:3px;transform:translateX(-50%);
  background:radial-gradient(closest-side, rgba(255,200,140,.3), rgba(255,200,140,.08) 70%, transparent)}
.shot-table__cake{position:relative;width:min(58vw, 34dvh, 340px)}
@media (min-width:760px){ .shot-table__cake{width:clamp(220px, min(22vw, 30dvh), 320px)} }
@media (orientation:landscape) and (max-height:500px){
  .shot--table{right:40%;padding-top:calc(var(--chrome-h) + var(--sp-2));padding-bottom:var(--sp-3)}
  .shot-table__cake{width:min(30vw, 34dvh)}
}

/* ---------- Overlay (the letter), rehearsal + error panels ---------- */
.overlay{position:fixed;inset:0;z-index:var(--z-overlay);overflow-y:auto;overscroll-behavior:contain;-webkit-overflow-scrolling:touch;
  background:var(--c-midnight);
  padding:calc(var(--chrome-h) + env(safe-area-inset-top)) calc(var(--gutter) + env(safe-area-inset-right)) calc(var(--sp-7) + env(safe-area-inset-bottom)) calc(var(--gutter) + env(safe-area-inset-left))}
.panel-note{position:fixed;inset:0;z-index:var(--z-debug);display:flex;flex-direction:column;align-items:center;justify-content:center;gap:var(--sp-4);
  padding:var(--sp-6) var(--gutter);border:0;background:rgba(var(--rgb-midnight),.92);color:var(--c-wick);text-align:center;cursor:pointer;
  font:italic 400 var(--step-0)/1.5 var(--font-script)}
.panel-note:focus-visible{outline:var(--focus-ring);outline-offset:-8px}

/* ---------- Chrome: slate (left) + music toggle (right) ---------- */
.chrome{position:fixed;z-index:var(--z-chrome);top:0;left:0;right:0;display:flex;align-items:center;justify-content:space-between;gap:var(--sp-3);
  height:calc(var(--chrome-h) + env(safe-area-inset-top));padding:env(safe-area-inset-top) calc(var(--gutter) + env(safe-area-inset-right)) 0 calc(var(--gutter) + env(safe-area-inset-left));
  pointer-events:none;transition:opacity var(--t-slow) var(--ease-out)}
.chrome > *{pointer-events:auto}
/* a faint ceiling shade keeps Smoke on a ground dark enough for 4.5:1 (3.4 rule 2) where the lit
   festoon or the sign's glow reaches the top of the room; it fades out above the bulbs */
.chrome::before{content:"";position:absolute;z-index:-1;inset:0 0 -12px;pointer-events:none;
  background:linear-gradient(rgba(var(--rgb-midnight),.5), rgba(var(--rgb-midnight),0))}
/* receded, yet every word stays >= 4.5:1 (Smoke at .8 is 4.9:1 on the dimmed room); the disc
   recedes further, and a focused or hovered toggle comes back to full strength with its ring */
.chrome.is-dim{opacity:.8}
.chrome.is-dim .music-toggle__disc{opacity:.6}
.chrome.is-dim:focus-within,.chrome.is-dim:hover{opacity:1}
.chrome.is-off{opacity:0;visibility:hidden;transition:opacity var(--t-fast) linear, visibility 0s linear var(--t-fast)}
.slate,.chrome__hint{font:400 var(--step--2)/1.2 var(--font-script);letter-spacing:var(--track-caps);text-transform:uppercase;color:var(--c-smoke);white-space:nowrap;
  min-width:0;overflow:hidden;text-overflow:ellipsis}   /* a long translation truncates, never collides */
.music-toggle{max-width:58vw;display:inline-flex;align-items:center;gap:.6em;min-height:44px;margin-right:-6px;padding:0 6px 0 10px;border:0;border-radius:var(--r-focus);background:none;cursor:pointer;
  font:400 var(--step--2)/1 var(--font-script);letter-spacing:var(--track-caps);text-transform:uppercase;color:var(--c-smoke);white-space:nowrap;transition:color var(--t-fast)}
.music-toggle__disc{flex:none;width:16px;height:16px;border-radius:50%;box-shadow:0 0 0 1px rgba(157,161,188,.5);
  background:radial-gradient(circle, var(--c-surprise) 0 16%, #111 18% 30%, #2a2a33 32% 34%, #111 36% 60%, #2a2a33 62% 64%, #111 66%);
  animation:disc-spin 1.8s linear infinite}
.music-toggle[data-state="paused"] .music-toggle__disc{animation-play-state:paused}
.music-toggle:focus-visible{outline:var(--focus-ring);outline-offset:2px}
.music-toggle > span:last-child{min-width:0;overflow:hidden;text-overflow:ellipsis}
@keyframes disc-spin{to{transform:rotate(1turn)}}

/* ---------- Dock: every scene's copy + controls, in the thumb zone ---------- */
.dock{position:absolute;left:0;right:0;bottom:0;display:flex;flex-direction:column;align-items:center;gap:var(--sp-3);
  padding:0 calc(var(--gutter) + env(safe-area-inset-right)) max(var(--sp-5), calc(env(safe-area-inset-bottom) + var(--sp-3))) calc(var(--gutter) + env(safe-area-inset-left));
  text-align:center}
.dock > *{max-width:var(--measure)}
.dock__row{display:flex;flex-wrap:wrap;align-items:center;justify-content:center;gap:var(--sp-2) var(--sp-4)}
@media (min-width:760px){ .dock{gap:var(--sp-4)} }
@media (orientation:landscape) and (max-height:500px){
  .dock{left:auto;top:var(--chrome-h);width:min(40%,340px);justify-content:center}
}

/* ---------- Script typography (the screenplay voice) ---------- */
.slugline{font:700 var(--step-0)/1.4 var(--font-script);letter-spacing:.02em;text-transform:uppercase;color:var(--c-wick)}
.slugline time{color:var(--c-tungsten)}
.line{font:400 var(--step-0)/var(--lh-body) var(--font-script);color:var(--c-wick);text-wrap:pretty}
.line--lead{font-size:var(--step-1);line-height:1.35}
.direction{font:italic 400 var(--step-0)/1.45 var(--font-script);color:var(--c-smoke);text-align:center;text-wrap:balance}
.label,.counter{font:400 var(--step--2)/1.2 var(--font-script);letter-spacing:var(--track-caps);text-transform:uppercase;color:var(--c-smoke)}
.counter b{font-weight:700;color:var(--c-wick)}
.note{font:italic 400 var(--step--1)/1.4 var(--font-script);color:var(--c-smoke)}
.big-count{font:700 var(--step-2)/1.1 var(--font-script);letter-spacing:.04em;color:var(--c-tungsten);font-variant-numeric:tabular-nums}

/* His hand */
.caption{font:700 var(--step-1)/1.22 var(--font-hand);font-variation-settings:var(--hand-axes);color:var(--c-wick);text-align:center;text-wrap:balance}

/* The display face, used exactly twice */
.display{margin:0;font:400 var(--step-display)/var(--lh-tight) var(--font-display);letter-spacing:-.005em;color:var(--c-wick);text-align:center;
  -webkit-text-stroke:.13em var(--c-midnight);paint-order:stroke fill;text-shadow:var(--glow-text);transform:rotate(-4deg)}
.display--curtain{font-size:var(--step-display-2);transform:rotate(-3deg)}

/* ---------- Controls: masking tape (primary) ---------- */
.tape{--tilt:-2deg;position:relative;isolation:isolate;display:inline-flex;align-items:center;justify-content:center;gap:.5em;
  min-height:52px;min-width:44px;padding:.7em 1em .74em;border:0;background:none;cursor:pointer;text-decoration:none;
  font:700 clamp(0.78rem, 0.72rem + 0.25vw, 1.05rem)/1.05 var(--font-hand);font-variation-settings:var(--hand-axes);color:var(--c-ink);text-align:center;
  white-space:nowrap;
  transform:rotate(var(--tilt));filter:var(--sh-tape);border-radius:var(--r-focus);
  transition:transform var(--t-fast) var(--ease-out), filter var(--t-fast) var(--ease-out);
  touch-action:manipulation;-webkit-user-select:none;user-select:none}
.tape::before{content:"";position:absolute;inset:0;z-index:-2;clip-path:var(--tear);
  background:linear-gradient(90deg, rgba(0,0,0,.07), transparent 12%, transparent 88%, rgba(0,0,0,.08)),
    linear-gradient(rgba(255,255,255,.38), rgba(255,255,255,0) 46%), var(--c-tape)}
@media (hover:hover){
  .tape:hover{transform:rotate(var(--tilt)) translateY(-2px);filter:var(--sh-tape-lift)}
}
.tape.is-hover{transform:rotate(var(--tilt)) translateY(-2px);filter:var(--sh-tape-lift)} /* .is-hover/.is-focus: style-tile demo states only */
.tape:active{transform:rotate(var(--tilt)) translateY(1px) scale(.98);filter:var(--sh-tape-press)}
.tape:focus-visible,.tape.is-focus{outline:var(--focus-ring);outline-offset:6px}
.tape:disabled,.tape[aria-disabled="true"]{cursor:not-allowed;opacity:.42;filter:none;transform:rotate(var(--tilt))}

/* Gaffer tape (secondary): dark cloth tape, light marker */
.tape--gaffer{--tilt:1.5deg;min-height:48px;padding:.62em 1.2em .66em;font-size:var(--step-0);color:var(--c-wick)}
.tape--gaffer::before{background:repeating-linear-gradient(90deg, rgba(255,255,255,.035) 0 1px, transparent 1px 3px),
  linear-gradient(rgba(255,255,255,.09), rgba(255,255,255,0) 50%), var(--c-gaffer)}

/* Hold-to-act tape: a lamp-coloured fill grows under the lettering */
.tape--hold{touch-action:none;-webkit-touch-callout:none}
.tape--hold::after{content:"";position:absolute;inset:15% 3%;z-index:-1;border-radius:2px;transform-origin:0 50%;transform:scaleX(var(--hold,0));
  background:linear-gradient(90deg, rgba(var(--rgb-tungsten),.42), rgba(var(--rgb-tungsten),.72))}   /* a marker shading the tape in */

/* Ghost (tertiary): a line of script you can tap */
.ghost{display:inline-flex;align-items:center;justify-content:center;min-height:44px;padding:.4em .7em;border:0;border-radius:var(--r-focus);background:none;cursor:pointer;
  font:italic 400 var(--step-0)/1.2 var(--font-script);color:var(--c-smoke);text-decoration:underline dotted rgba(157,161,188,.65);
  text-decoration-thickness:1px;text-underline-offset:.3em;transition:color var(--t-fast), text-decoration-color var(--t-fast)}
@media (hover:hover){ .ghost:hover{color:var(--c-wick);text-decoration-color:var(--c-tungsten)} }
.ghost.is-hover{color:var(--c-wick);text-decoration-color:var(--c-tungsten)}
.ghost:focus-visible,.ghost.is-focus{outline:var(--focus-ring);outline-offset:2px;color:var(--c-wick)}
.ghost:disabled,.ghost[aria-disabled="true"]{opacity:.45;cursor:not-allowed;text-decoration:none}

/* ---------- Paper: the cue card ---------- */
.cue-card{--tilt:-1.2deg;position:relative;display:flex;flex-direction:column;justify-content:center;gap:.6em;
  width:min(86vw, 520px);min-height:min(46vh, 400px);max-height:min(58vh, 520px);
  min-height:min(46dvh, 400px);max-height:min(58dvh, 520px);overflow-y:auto;
  padding:clamp(28px,6vw,48px) clamp(24px,5.5vw,48px);border-radius:var(--r-card);
  background:linear-gradient(rgba(255,255,255,.35), rgba(255,255,255,0) 30%),
    radial-gradient(120% 90% at 50% 0%, #FFF7E6, var(--c-wick) 58%, #F0DDBA);
  box-shadow:var(--sh-card);color:var(--c-ink);text-align:center;transform:rotate(var(--tilt));
  font:700 clamp(1.05rem, 0.95rem + 0.5vw, 1.3rem)/1.45 var(--font-hand);font-variation-settings:var(--hand-axes)}
.cue-card p{margin:0;text-wrap:pretty;overflow-wrap:break-word}
.cue-card.is-dense{font-size:clamp(0.95rem, 0.85rem + 0.4vw, 1.15rem)}
.cue-card.is-denser{font-size:clamp(0.85rem, 0.75rem + 0.3vw, 1.05rem)}
.cue-card:focus-visible{outline:var(--focus-ring-ink);outline-offset:-8px}

@media (forced-colors:active){
  .tape,.cue-card{forced-color-adjust:none}
  .display{-webkit-text-stroke:0;text-shadow:none}   /* a stroke in the forced text colour fills the counters */
  .chrome::before{display:none}
}
@media (prefers-contrast:more){ .chrome.is-dim{opacity:1} }

@media (prefers-reduced-motion:reduce){
  .music-toggle__disc,.festoon.is-flicker .lit{animation:none}
  .tape,.ghost,.chrome{transition:none}
}

/* ---- WP0 additions ---- */
/* ?fast: the token durations are quartered; scene CSS writes calc(<ms> * var(--t-scale)) */
html[data-fast]{--t-scale:.25;--t-light:400ms;--t-dip:75ms;--t-slow:150ms;--t-base:75ms;--t-fast:40ms}
@media (prefers-reduced-motion:reduce){ html[data-fast]{--t-light:50ms;--t-dip:30ms;--t-slow:50ms} }

/* Stage roots let taps through to the shared shot below them, like the UI roots do;
   a scene opts its own interactive props in with pointer-events:auto */
.scene{pointer-events:none}
.scene a,.scene button,.scene [data-action]{pointer-events:auto}
.scene:focus,.scene-ui:focus,.overlay:focus{outline:none}

/* Shared-shot states, set only through BDAY.director.shotState() */
.shot.is-receded{opacity:.22;transform:scale(.96);
  transition:opacity calc(600ms * var(--t-scale)) var(--ease-out), transform calc(600ms * var(--t-scale) * var(--t-move)) var(--ease-out)}
.shot.is-gone{opacity:0;transition:opacity calc(1200ms * var(--t-scale)) var(--ease-out)}

/* The festoon's unlit glass, caps, wire and glints are lit by the moon only:
   they glint in cue dark and vanish in cue black (the lit glow follows --l-festoon) */
.festoon .wire,.festoon .cap,.festoon .glass{opacity:max(var(--l-moon,.95), var(--l-festoon,0));transition:opacity var(--t-light) var(--ease-inout)}
.festoon .glint{opacity:var(--l-moon,.95);transition:opacity var(--t-light) var(--ease-inout)}
.festoon .lit .glow{opacity:.55}

/* Panels: rehearsal notes, the deep-link roll, the broken-config notice */
.panel-note__heading{display:block;font:400 var(--step--2)/1.2 var(--font-script);letter-spacing:var(--track-caps);text-transform:uppercase;color:var(--c-smoke)}
.panel-note__line{display:block;max-width:var(--measure);font-style:normal;color:var(--c-wick);text-wrap:pretty}
.panel-note__footer{display:block;max-width:var(--measure);margin-top:var(--sp-3);color:var(--c-smoke);text-wrap:balance}
.panel-note--broken{cursor:default}
.panel-note--broken p{max-width:var(--measure);color:var(--c-wick);font-style:normal}

/* ?debug=1 */
.debug-hud{position:fixed;z-index:var(--z-debug);left:calc(var(--sp-2) + env(safe-area-inset-left));bottom:calc(var(--sp-2) + env(safe-area-inset-bottom));
  max-width:calc(100vw - 2 * var(--sp-4));margin:0;padding:var(--sp-2) var(--sp-3);border-radius:var(--r-paper);background:rgba(var(--rgb-midnight),.8);
  color:var(--c-smoke);font:400 var(--step--2)/1.35 var(--font-script);white-space:pre-wrap;pointer-events:none}
