/* ============================ OPENING CUTSCENE (eavesdrop) ============================ */
/* A 4-beat cinematic sequence: enter the museum -> stop at the door + overheard dialogue ->
   a suspect senses you (real-risk choice) -> leave. Full-bleed, one viewport, noir.
   All motion gates on html[data-reduce="1"] (the Settings reduced-motion signal, NOT the bare
   media query) so a player on a reduce-by-default OS can force it back on. See ddr-eavesdrop-cutscene. */

#eavesdrop-view { max-width: none; margin: 0; padding: 0; }
#cs-stage { position: relative; overflow: hidden; background: #0a0805; }

/* --- Stills: three layered noir backgrounds; one shown at a time, push-in while active. --- */
.cs-layers { position: absolute; inset: 0; pointer-events: none; }
.cs-still {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0; transform: scale(1.04);
  will-change: transform; /* opacity is instant — the .cs-dip black fade handles the scene cut */
}
#cs-door     { background-image: url("/cutscene/door.webp"); }
.cs-still.show { opacity: 1; }
/* Slow push-in (the "walking in" camera). Duration is generous so it reads as drift, not zoom. */
.cs-still.push { animation: cs-push 6.5s linear forwards; }
@keyframes cs-push { from { transform: scale(1.04); } to { transform: scale(1.18); } }

/* --- Warm glow at the door. The door art now bakes the light spilling correctly through the gap, so
   this is only a soft halo around the opening (NOT the old diagonal blade, which fought the baked
   light and read wrong). Kept subtle so it enhances the art instead of doubling it. --- */
.cs-beam { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .8s ease;
  background: radial-gradient(46% 40% at 52% 42%, rgba(230,184,78,0.14), transparent 72%); }
.cs-beam.show { opacity: 1; }

/* --- Beat 3: an advancing shadow + tightening dark when a suspect turns toward the door. --- */
.cs-shadow { position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(22% 28% at 50% 32%, rgba(0,0,0,0.7), rgba(0,0,0,0) 70%); }
#cs-stage.danger .cs-shadow { opacity: 1; animation: cs-loom var(--danger-ms,5000ms) ease-in forwards; }
@keyframes cs-loom {
  from { transform: scale(0.5); }
  to   { transform: scale(3.2); }
}

/* Discovery alarm: a red breath that pulses while a suspect turns toward the door (beat 3). Stays in
   palette (dark noir red), gated off under reduced motion (steady tint instead). */
.cs-alarm { position: absolute; inset: 0; z-index: 1; pointer-events: none; opacity: 0;
  background: radial-gradient(125% 108% at 50% 48%, #00000000 12%, #aa1c0e 90%); }
#cs-stage.danger .cs-alarm { animation: cs-alarm-pulse 1.1s ease-in-out infinite; }
@keyframes cs-alarm-pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

.cs-vignette { position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 100% at 50% 42%, #00000000 38%, #000000d8 100%);
  transition: background .6s ease; }
#cs-stage.danger .cs-vignette { background: radial-gradient(95% 78% at 50% 42%, #00000000 20%, #000000f2 100%); }

/* Fade-through-black between scene cuts (driven by cutscene.js dipTo). z-1 covers the stills; the
   content text + skip (z higher) stay above so dialogue is never hidden during a cut. */
.cs-dip { position: absolute; inset: 0; z-index: 1; background: #060503; opacity: 0; pointer-events: none;
  transition: opacity .3s ease; }
.cs-dip.on { opacity: 1; }

/* --- Content: scene narration (top) + overheard subtitles + actions (bottom). --- */
.cs-content { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; justify-content: flex-end;
  padding: clamp(96px,16vh,150px) clamp(18px,5.5vw,26px) clamp(24px,4vh,38px); gap: 12px;
  /* lower-third scrim so the rising subtitles + actions stay legible over the busy noir art */
  background: linear-gradient(to top, #000000d4 0%, #0000008c 26%, #00000000 56%); }

.cs-scene { position: absolute; top: clamp(40px,7vh,64px); left: clamp(18px,5.5vw,26px); right: clamp(18px,5.5vw,26px);
  font-family: var(--font-read); font-style: normal; font-size: clamp(17px,4.8vw,22px); line-height: 1.5; color: var(--ink-soft);
  margin: 0; opacity: 0; transition: opacity .9s ease; text-shadow: 0 2px 18px #000, 0 0 8px #000, 0 1px 2px #000; }
.cs-scene.show { opacity: 1; }

/* Overheard dialogue: fills the space, anchored to the bottom; new lines push older ones UP and they
   fade out at the top (no scrollbar — Yiftach's call). Reduced motion can scroll (scrollbar hidden). */
.cs-dialogue { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 13px;
  overflow-y: auto; scrollbar-width: none; }
/* Top fade applies ONLY once lines have scrolled above the top (cutscene.js toggles .masked on scroll).
   The first line is never faded: nothing is above it yet, so fading it just made the opening line hard
   to read (Yiftach 2026-07-09). The fade still softens older lines as the conversation continues. */
.cs-dialogue.masked {
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 100%);
          mask-image: linear-gradient(to bottom, transparent 0, #000 18%, #000 100%); }
.cs-dialogue::-webkit-scrollbar { display: none; }
/* Top-aligned: lines type from the top down and the box scrolls to follow the newest one, so already-
   typed lines never reflow (no jumps). Older lines scroll up under the top fade mask. */
/* End-of-scene review: drop the fade and show a thin subtle scrollbar so the player can read back
   through everything they overheard before stepping away. */
.cs-dialogue.review { -webkit-mask-image: none; mask-image: none; scrollbar-width: thin; scrollbar-color: #6b5d3f transparent; }
.cs-dialogue.review::-webkit-scrollbar { display: block; width: 6px; }
.cs-dialogue.review::-webkit-scrollbar-thumb { background: #6b5d3f; border-radius: 3px; }
.cs-dialogue.review::-webkit-scrollbar-track { background: transparent; }
/* Overheard line = a self-contained subtitle. Each carries its own dark bed (+ blur) so it stays
   legible as it rises over the bright door-light and busy art, not just over the bottom scrim. */
.cs-line { font-family: var(--font-read); font-style: normal; font-weight: 420; font-size: clamp(17px,4.6vw,21px); line-height: 1.45;
  color: #f2e9d6; margin: 0; align-self: flex-start; max-width: 100%;
  background: rgba(8,6,3,0.72); -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  padding: 7px 12px 8px; border-radius: 3px; border-left: 2px solid var(--brass-dim);
  text-shadow: 0 1px 3px #000; }
.cs-line .cs-who { display: block; font-family: var(--font-oswald); font-weight: 700; font-style: normal;
  text-transform: uppercase; letter-spacing: 0.06em; font-size: clamp(11px,3vw,13px); color: var(--brass); margin-bottom: 3px; }
/* Typewriter reveal: the full line is laid out up-front with every character hidden (.cs-ch--pending)
   so wrapping is final and no word ever jumps to a new line mid-type. Characters are revealed in
   place one at a time; the blinking caret rides the current character (the reveal frontier). */
.cs-ch--pending { opacity: 0; }
.cs-ch--cursor::after { content: "▌"; margin-left: 1px; color: var(--brass); animation: cs-blink 1.05s steps(1,end) infinite; }
@keyframes cs-blink { 50% { opacity: 0; } }

/* Reserve a constant height so the dialogue box never resizes when buttons appear/clear — otherwise
   the newest (closing) line, scrolled to the bottom, gets pushed out of view when "Step away" renders.
   A top hairline + spacing set the action band apart from the dialogue so buttons never read as sitting
   ON a spoken line (item 6). */
.cs-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; min-height: 50px;
  margin-top: 4px; padding-top: 12px; border-top: 1px solid transparent; } /* height reserved constant (no reflow) */
.cs-actions:not(:empty) { border-top-color: rgba(205,163,73,0.12); } /* hairline only when buttons are present */
.cs-actions .begin-btn { margin-top: 0; }

/* --- Danger countdown bar (motion mode only). Duration must match DANGER_MS in cutscene.js. --- */
.cs-timer { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; background: #2a1d12; opacity: 0; }
#cs-stage.danger .cs-timer { opacity: 1; }
.cs-timer-fill { height: 100%; width: 100%; background: linear-gradient(90deg,#e6b84e,#f0897c); transform-origin: left; transform: scaleX(1); }
#cs-stage.danger .cs-timer-fill { animation: cs-drain var(--danger-ms,5000ms) linear forwards; }
@keyframes cs-drain { from { transform: scaleX(1); } to { transform: scaleX(0); } }

/* --- Skip: always available; respects the seen-once flag at the flow level. --- */
.cs-skip { position: absolute; top: clamp(12px,2.4vh,18px); right: clamp(12px,4vw,18px); z-index: 2;
  font-family: var(--font-jbmono); font-size: var(--ts-meta); letter-spacing: .12em; color: #9a8f78;
  background: #00000066; border: 1px solid #3a3326; border-radius: 6px; padding: 5px 11px; cursor: pointer; }
.cs-skip:hover { color: var(--brass); border-color: var(--brass-dim); }
.cs-skip:focus-visible { outline: 3px solid var(--brass); outline-offset: 2px; }

/* --- Reduced motion: no camera, no loom, no timer; stills + text appear at once; choice is untimed. --- */
html[data-reduce="1"] .cs-still { transition: none; animation: none; transform: none; }
html[data-reduce="1"] .cs-beam,
html[data-reduce="1"] .cs-scene,
html[data-reduce="1"] .cs-line,
html[data-reduce="1"] .cs-vignette { transition: none; animation: none; }
html[data-reduce="1"] .cs-line { opacity: 1; }
html[data-reduce="1"] #cs-stage.danger .cs-shadow { animation: none; transform: scale(1.6); }
html[data-reduce="1"] .cs-timer { display: none; }
html[data-reduce="1"] #cs-stage.danger .cs-timer-fill { animation: none; }
html[data-reduce="1"] .cs-dip { transition: none; }
html[data-reduce="1"] #cs-stage.danger .cs-alarm { animation: none; opacity: 0.55; }
/* Reduced motion shows every line at once — let it scroll top-down (scrollbar stays hidden) instead
   of clipping the rising stack, so nothing is lost. */
html[data-reduce="1"] .cs-dialogue { -webkit-mask-image: none; mask-image: none; }
