/* ============================================================================
 * NexaHSE — scroll-snap-to-scene pitch site
 * Palette: navy stage, blue (#1d4ed8) + teal (#0d9488) accents, light modal.
 * The page never scrolls; the hero is a fixed curtain over the fixed stage.
 * ==========================================================================*/

* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --blue: #1d4ed8;
  --teal: #0d9488;
  --teal-bright: #2dd4bf;
  --navy: #0b1220;
  --ink: #0f172a;
  --ink-soft: #475569;
  --paper: #f8fafc;
  --line: #e2e8f0;
}

html, body {
  height: 100%;
  overflow: hidden;               /* gestures drive scenes, not the page */
  overscroll-behavior: none;
}

body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  background: var(--navy);
  color: var(--ink);
}

/* Swipes are chapter gestures, not scrolls — scoped to the story layers rather
   than blanketed on <body>. Scrolling was never the casualty (engines reset the
   inherited touch-action at a scroll container, so #modal-body panned either
   way); pinch-zoom was. `none` on <body> disabled it page-wide, including over
   the modal's dense tables and slide images, which is exactly where a phone
   needs to zoom. These four are direct children of <body>, so the modal's
   ancestor chain stays untouched. */
#hero, #stage, #scene-nav, #section-nav { touch-action: none; }

/* --------------------------------------------------------------------------
 * Client access gate (outranks even the opening film — nothing runs before it)
 * ------------------------------------------------------------------------*/

/* Everything but the gate is hidden outright while it is up. `visibility`
   rather than opacity or a z-index race, because it also pulls the hero, the
   Skip button and the section menu out of the tab order — otherwise Tab walks
   focus straight into a proposal the visitor has not been let into yet. */
html.gated body > *:not(#gate) { visibility: hidden; }

#gate {
  position: fixed;
  inset: 0;
  z-index: 300;                   /* over the film's 200, which is over the modal */
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  /* The site's own palette, lit from the same two accents as the progress bar,
     so the first screen already belongs to the film it precedes. */
  background:
    radial-gradient(1100px 620px at 50% -10%, rgba(29, 78, 216, 0.30), transparent 70%),
    radial-gradient(760px 520px at 50% 112%, rgba(13, 148, 136, 0.22), transparent 70%),
    var(--navy);
  /* The one screen on this site that may scroll: a landscape phone with the
     keyboard up has barely 150px of height left for a two-field form. */
  overflow-y: auto;
  touch-action: manipulation;
  transition: opacity 0.6s ease, transform 0.7s cubic-bezier(0.65, 0, 0.35, 1);
}

/* Lifted on success, mirroring the film's own exit; JS display:none's it once
   the fade ends, since a transparent curtain still eats every click. */
#gate.gate-done {
  opacity: 0;
  transform: translateY(-4%);
  pointer-events: none;
}

#gate[hidden] { display: none; }

#gate-panel {
  width: 100%;
  max-width: 390px;
  padding: clamp(26px, 5vw, 38px);
  border-radius: 20px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  background: rgba(11, 18, 32, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(2, 6, 23, 0.55);
  color: #e2e8f0;
  animation: gateIn 0.55s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}

@keyframes gateIn {
  from { opacity: 0; transform: translateY(14px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}

/* Same mark as the hero, dialled down to label size. */
#gate-eyebrow {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--teal-bright);
}

/* Carries the panel on its own now that the heading is gone, so it sits a
   little larger and brighter than the supporting-copy size it started at. */
#gate-note {
  margin-top: 16px;
  font-size: 1rem;
  line-height: 1.55;
  color: rgba(226, 232, 240, 0.9);
}

/* Placeholder text while Firebase restores a saved session. */
#gate-status {
  margin-top: 26px;
  font-size: 0.88rem;
  color: rgba(203, 213, 225, 0.7);
  animation: introCueBreathe 1.8s ease-in-out infinite;
}

#gate-form { margin-top: 24px; }

.gate-field { display: block; }
.gate-field + .gate-field { margin-top: 14px; }

.gate-field span {
  display: block;
  margin-bottom: 7px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.95);
}

.gate-field input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 11px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(2, 8, 23, 0.55);
  color: #f1f5f9;
  font-family: inherit;
  /* 16px exactly: anything smaller and iOS Safari zooms the page on focus,
     which on a fixed full-screen layout it then cannot zoom back out of. */
  font-size: 16px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.gate-field input:focus {
  outline: none;
  border-color: var(--teal-bright);
  background: rgba(2, 8, 23, 0.75);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.16);
}

/* Chrome paints autofilled fields a hard opaque yellow-white, which on this
   panel reads as a rendering bug. There is no property that clears it — the
   standing trick is an inset shadow big enough to repaint the whole box. */
.gate-field input:-webkit-autofill,
.gate-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: #f1f5f9;
  -webkit-box-shadow: 0 0 0 1000px #0d1526 inset;
  caret-color: #f1f5f9;
}

#gate-submit {
  width: 100%;
  margin-top: 22px;
  padding: 13px 18px;
  border: none;
  border-radius: 11px;
  background: linear-gradient(90deg, var(--blue), var(--teal));
  color: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: filter 0.2s ease, transform 0.12s ease, box-shadow 0.2s ease;
}

#gate-submit:hover:not(:disabled),
#gate-submit:focus-visible:not(:disabled) {
  filter: brightness(1.12);
  box-shadow: 0 10px 30px rgba(29, 78, 216, 0.35);
  outline: none;
}

#gate-submit:active:not(:disabled) { transform: translateY(1px); }
#gate-submit:disabled { cursor: default; opacity: 0.6; }

#gate.gate-busy #gate-panel { cursor: progress; }

#gate-error {
  margin-top: 16px;
  padding: 11px 13px;
  border-radius: 10px;
  border: 1px solid rgba(248, 113, 113, 0.34);
  background: rgba(127, 29, 29, 0.24);
  color: #fecaca;
  font-size: 0.86rem;
  line-height: 1.5;
}

#gate-error[hidden] { display: none; }

/* A refused password is worth one physical beat — it is the difference
   between "the site did nothing" and "the site said no". */
#gate.gate-shake #gate-panel { animation: gateShake 0.45s ease; }

@keyframes gateShake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}

/* The media query, not the .reduce-motion class main.js sets: the gate paints
   before main.js has run, so a class-based rule would arrive after the entrance
   animation it was meant to suppress had already started. */
@media (prefers-reduced-motion: reduce) {
  #gate-panel,
  #gate.gate-shake #gate-panel,
  #gate-status { animation: none; }
}

/* --------------------------------------------------------------------------
 * Opening film (full-screen curtain above everything, including the modal)
 * ------------------------------------------------------------------------*/

#intro {
  position: fixed;
  inset: 0;
  z-index: 200;                   /* over the modal's 100 — nothing outranks it */
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  /* The lift mirrors the hero's own exit, so the two reveals read as one move. */
  transition: opacity 0.9s ease, transform 1s cubic-bezier(0.65, 0, 0.35, 1);
}

/* Dismissed: faded and lifted, then display:none'd by JS once the fade ends
   (a merely transparent overlay would still swallow every click). */
#intro.intro-done {
  opacity: 0;
  transform: translateY(-6%);
  pointer-events: none;
}

#intro[hidden] { display: none; }

/* contain by default: a 16:9 film on a 9:19.5 phone loses two thirds of its
   width to a cover crop, and an opening title is exactly the thing that would
   be cut. Letterboxing into black is the honest choice for a title sequence. */
#intro-video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #000;
}

/* …but that reasoning is about NARROW screens, and the bars people actually
   see are on a wide one. Pillarboxing happens only where the viewport is wider
   than the film — every laptop, desktop window and phone held sideways. Fill
   there instead, because past 16:9 the crop comes off the top and bottom
   rather than the sides, and this film keeps nothing at top or bottom while
   the EDGE mark and the year live hard against the left and right edges.
   Portrait keeps the letterbox the note above is protecting.

   The crop is biased hard DOWN, not centred, because the film's dead space is
   not centred and its subject is not either. Measuring mean row brightness:
   the console screen — the only part that carries information — occupies
   roughly 5%–67% of the height. Below it sit the keyboard deck and then dark
   floor (≈11 against ≈45 for the console); above it there is only 5% of dim
   ceiling. So there is a great deal to give away below the subject and almost
   nothing above it, and object-position: 12% spends the crop in that ratio.

   Deliberately NO upper bound on the aspect ratio. A phone in landscape is
   ~2.86:1 once Safari's toolbar is accounted for — and on this page that
   toolbar never retracts, because retracting is a response to scrolling and
   this page never scrolls (see index.html). That shape is therefore permanent
   on a landscape phone, not transient, and letterboxing it into thirds is
   exactly what we are trying to stop.

   The bias makes the extreme case degrade gracefully rather than break: at
   2.86 the crop is 38% of height, taken as 4.5% off the top and 33% off the
   bottom, which leaves 4.5%–67% on screen. That is the console screen almost
   exactly — the keyboard deck goes, the information does not. */
@media (min-aspect-ratio: 16/9) {
  #intro-video {
    object-fit: cover;
    object-position: 50% 12%;
  }
}

/* --- top-right chrome: sound + skip ------------------------------------- */

#intro-controls {
  position: absolute;
  top: max(clamp(14px, 2.5vw, 24px), env(safe-area-inset-top));
  right: max(clamp(14px, 2.5vw, 24px), env(safe-area-inset-right));
  display: flex;
  align-items: center;
  gap: 10px;
}

#intro-controls button {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(11, 18, 32, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

#intro-controls button:hover,
#intro-controls button:focus-visible {
  background: rgba(11, 18, 32, 0.85);
  border-color: rgba(45, 212, 191, 0.6);
  color: #ffffff;
  outline: none;
}

/* Muted is now a state the visitor chose, not one the browser imposed, so the
   button only reports it — no pulsing, no nagging to turn sound back on.
   Written as #intro-controls #intro-sound purely to out-specify the shared
   `#intro-controls button` block above. */
#intro-controls #intro-sound {
  border-color: rgba(148, 163, 184, 0.42);
  color: #cbd5e1;
}

/* Speaker + a wave arc that only exists once sound is on.
   The box is sized to the full drawing (24px), not just the speaker: the
   pseudo-elements are absolutely positioned and contribute nothing to layout,
   so a box measured to the cone alone lets the wave arc slide under the
   label. flex: none keeps the pill's flexbox from shrinking it either. */
.intro-sound-icon {
  position: relative;
  width: 24px;
  height: 12px;
  flex: none;
}

/* Body and cone as one silhouette — two pseudo-elements is all there is, and
   the second is spoken for by the slash/wave. */
.intro-sound-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  background: currentColor;
  clip-path: polygon(0 33%, 28% 33%, 62% 2%, 62% 98%, 28% 67%, 0 67%);
}

/* Muted: a small ✕ standing where the wave would be. A slash laid ACROSS the
   speaker was the first attempt and it merged with the cone at this size —
   the pair read as a tick, not a muted speaker. Two crossed bars built from
   background gradients (one element, and ::after is the only one left). */
.intro-sound-icon::after {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 9px;
  height: 9px;
  background:
    linear-gradient(currentColor, currentColor) center / 9px 1.6px no-repeat,
    linear-gradient(currentColor, currentColor) center / 1.6px 9px no-repeat;
  transform: translateY(-50%) rotate(45deg);
}

#intro.sound-on .intro-sound-icon::after {   /* sound on: the wave arc */
  left: 13px;
  width: 7px;
  height: 7px;
  background: none;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 0 5px 0 0;
  transform: translateY(-50%) rotate(45deg);
}

/* ✕ drawn from two rotated bars — no glyph, so it can't shift with the font. */
.intro-skip-x {
  position: relative;
  width: 11px;
  height: 11px;
}

.intro-skip-x::before,
.intro-skip-x::after {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  height: 2px;
  background: currentColor;
  border-radius: 2px;
}

.intro-skip-x::before { transform: translateY(-50%) rotate(45deg); }
.intro-skip-x::after  { transform: translateY(-50%) rotate(-45deg); }

#intro-skip:hover .intro-skip-x,
#intro-skip:focus-visible .intro-skip-x { color: var(--teal-bright); }

/* --- "click anywhere" cue (film held until it can start WITH sound) ------
   Shown only while #intro carries .awaiting-sound. Deliberately NOT a button:
   the entire overlay releases the film, so a pressable target would be a
   smaller version of the truth and would invite aiming at it. This is a
   label — no border, no fill, no cursor:pointer — that says where to click,
   which is everywhere. */

#intro-cue {
  position: absolute;
  display: none;
  align-items: center;
  gap: 13px;
  color: rgba(241, 245, 249, 0.94);
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 500;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 20px rgba(2, 8, 23, 0.9);
  pointer-events: none;            /* the overlay behind it takes the click */
  animation: introCueIn 0.7s ease-out both, introCueBreathe 3s ease-in-out 0.7s infinite;
}

#intro.awaiting-sound #intro-cue { display: inline-flex; }

/* A speaker, so the cue reads as "this has sound" and not merely "press me". */
.intro-cue-icon {
  position: relative;
  width: 26px;
  height: 15px;
  flex: none;
  color: var(--teal-bright);
}

.intro-cue-icon::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  width: 15px;
  height: 15px;
  background: currentColor;
  clip-path: polygon(0 33%, 28% 33%, 62% 2%, 62% 98%, 28% 67%, 0 67%);
}

.intro-cue-icon::after {
  content: "";
  position: absolute;
  left: 16px;
  top: 50%;
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 0 6px 0 0;
  transform: translateY(-50%) rotate(45deg);
}

@keyframes introCueIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes introCueBreathe {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

/* Nothing to mute before the film has been released. */
#intro.awaiting-sound #intro-sound { display: none; }

/* --- elapsed bar --------------------------------------------------------- */

#intro-progress {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(226, 232, 240, 0.14);
}

#intro-progress-bar {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--blue), var(--teal-bright));
  transition: width 0.25s linear;
}

/* Phones: the two pills eat a lot of a 390px-wide screen, so slim them down. */
@media (max-width: 560px) {
  #intro-controls { gap: 8px; }
  #intro-controls button { padding: 8px 13px; font-size: 12px; gap: 7px; }
}

/* --------------------------------------------------------------------------
 * Hero landing (fixed curtain; slides up on the first scroll-down gesture)
 * ------------------------------------------------------------------------*/

/* Transparent over the stage: the video's first frame is the hero backdrop.
   A soft vertical dim keeps the white text legible against the sunrise. */
#hero {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 48px 24px 120px;
  background: linear-gradient(180deg,
    rgba(2, 8, 23, 0.52) 0%,
    rgba(2, 8, 23, 0.22) 42%,
    rgba(2, 8, 23, 0.55) 100%);
  transition: transform 1s cubic-bezier(0.65, 0, 0.35, 1);
}

#hero.hero-hidden {
  transform: translateY(-100%);
  pointer-events: none;
}

#hero-eyebrow {
  font-size: clamp(1.5rem, 4vw, 2.6rem);
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal-bright);
  margin-bottom: clamp(20px, 3vh, 32px);
  text-shadow: 0 2px 20px rgba(2, 8, 23, 0.65);
}

#hero-headline {
  max-width: 17ch;
  font-size: clamp(2.5rem, 6vw, 4.4rem);
  font-weight: 750;
  letter-spacing: -0.025em;
  line-height: 1.06;
  color: #ffffff;
  text-wrap: balance;
  text-shadow: 0 2px 28px rgba(2, 8, 23, 0.65);
}

#hero-subheadline {
  margin-top: 26px;
  max-width: 44ch;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  font-weight: 400;
  line-height: 1.55;
  color: rgba(241, 245, 249, 0.92);
  text-shadow: 0 1px 18px rgba(2, 8, 23, 0.6);
}

#hero-cue {
  position: absolute;
  left: 50%;
  bottom: 40px;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.05em;
  color: rgba(226, 232, 240, 0.9);
  text-shadow: 0 1px 12px rgba(2, 8, 23, 0.6);
}

.chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid var(--teal-bright);
  border-bottom: 2px solid var(--teal-bright);
  transform: rotate(45deg);
  animation: bob 1.4s ease-in-out infinite;
}

.chevron-dark {
  border-right-color: var(--teal-bright);
  border-bottom-color: var(--teal-bright);
}

/* A phone in landscape is wide but very short — ~956×333 with Safari's tab bar
   showing. Every size above is driven by viewport WIDTH (6vw ⇒ a 57px
   headline), so the hero lays ~325px of text into ~165px of space: the eyebrow
   clips off the top and the subheadline lands on the scroll cue. Drive the
   type off HEIGHT here, and let the headline run wider since width is the one
   thing this shape has plenty of. */
@media (orientation: landscape) and (max-height: 500px) {
  #hero { padding: 14px 20px 56px; }

  #hero-eyebrow {
    font-size: clamp(0.9rem, 4vh, 1.4rem);
    margin-bottom: clamp(6px, 1.5vh, 14px);
  }

  #hero-headline {
    max-width: 26ch;
    font-size: clamp(1.4rem, 8vh, 2.6rem);
  }

  #hero-subheadline {
    margin-top: 8px;
    max-width: 54ch;
    font-size: clamp(0.8rem, 3.2vh, 1rem);
  }

  #hero-cue {
    bottom: max(12px, env(safe-area-inset-bottom));
    gap: 6px;
    font-size: 12px;
  }
}

/* While the hero is up, keep the stage's loading pill from ghosting through
   the transparent hero next to the scroll cue. */
#hero:not(.hero-hidden) + #stage .hint { opacity: 0; }

/* …except once the viewer has actually tried to scroll and the video isn't
   ready yet. On a phone the film can still be buffering, and without this the
   swipe is silently queued behind a screen that says "Scroll to see how" —
   indistinguishable from the page being broken. */
body.awaiting-video #hero:not(.hero-hidden) + #stage .hint.visible { opacity: 1; }

@keyframes bob {
  0%, 100% { transform: rotate(45deg) translate(0, 0); }
  50%      { transform: rotate(45deg) translate(3px, 3px); }
}

/* --------------------------------------------------------------------------
 * Stage (fixed, full viewport)
 * ------------------------------------------------------------------------*/

#stage {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--navy);
  user-select: none;
  -webkit-user-select: none;
}

/* The frame always carries the film's own 16:9 shape, so hotspot percentages
   keep mapping 1:1 onto video pixels and the picture is never squashed. What
   varies is how much of it is on screen — the frame is allowed to overflow
   #stage (which clips it) so a phone isn't left staring at navy bands:

     near 16:9        exact fit, no crop, no bars (desktop is untouched)
     wider viewport   fills the width; crop comes off the top/bottom
     taller viewport  grows until a panel would leave the screen, then
                      letterboxes for whatever is left over

   The --panel-safe caps are what stop the crop before a Command Centre panel
   goes off screen. They come from the hotspot bounds in content.js — x
   196–1088, y 63–570 of the 1280×720 reference — leaving 15% dead margin on
   each side and 8.8% top / 20.8% bottom, plus ~2% breathing room. Re-derive
   them if those hotspots ever move. */
#video-frame {
  --vh: 100vh;             /* → 100dvh below, where supported */

  /* Covering a phone screen with a 16:9 film costs a lot of crop. Allowing the
     frame to drift slightly off 16:9 buys some of it back: the frame no longer
     has to grow as large to reach the screen edges, so less falls outside it.
     --stretch is the ceiling on that drift — 1 = none, 1.12 = up to 12%, which
     is about what a 16:10 laptop has always shown and reads as square. The
     trade is roughly one-for-one: 12% of stretch returns 12% more picture. */
  --stretch: 1.12;

  --w: max(100vw,     calc(var(--vh) * 16 / 9 / var(--stretch)));
  --h: max(var(--vh), calc(100vw * 9 / 16 / var(--stretch)));

  position: relative;
  width: var(--w);
  height: var(--h);
  /* #stage is a flex row: without this the frame is shrunk back to the stage
     width the moment --w exceeds it, silently undoing every crop. */
  flex-shrink: 0;
  /* The pull-back onto the panel wall reads as a deliberate reveal. */
  transition: width 0.7s cubic-bezier(0.65, 0, 0.35, 1),
              height 0.7s cubic-bezier(0.65, 0, 0.35, 1),
              transform 0.7s cubic-bezier(0.65, 0, 0.35, 1);
  /* The film has 20.8% dead space below the panels but only 8.8% above, so
     split the vertical crop 30/70 instead of evenly. That nearly doubles what
     can be hidden (17.5% → 29.6%) and is what lets a phone in landscape fill
     the screen edge to edge without clipping the top row of panels. */
  transform: translateY(calc(max(0px, var(--h) - var(--vh)) * 0.2042));
}

/* Portrait is where the 16:9 film loses the most to the crop — a phone screen
   is ~0.59:1 — so it gets a little more headroom than the 1.12 baseline. */
@media (orientation: portrait) {
  #video-frame { --stretch: 1.35; }
}

/* The final stop is the only interactive frame, so it is the only one that has
   to hold still for its hotspots. Cap the crop here so all six panels stay on
   screen: at most 26% of the film's width and 28% of its height may be hidden.
   Everywhere else the film is free to fill the screen. */
#stage.at-end #video-frame {
  --w: min(
         max(100vw, calc(var(--vh) * 16 / 9)),
         calc(100vw / 0.74),
         calc(var(--vh) * 16 / 9 / 0.72)
       );
  --h: calc(var(--w) * 9 / 16);   /* exact 16:9 — no stretch on the one frame
                                     whose pixels have to line up with hotspots */
}

/* dvh tracks the viewport actually left over between Safari's toolbars; the
   vh fallback above keeps the frame from collapsing on browsers without it. */
@supports (height: 100dvh) {
  #video-frame { --vh: 100dvh; }
}

#scrub-video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;     /* frame is already 16:9, so fill == contain, no squash */
  pointer-events: none; /* pure scene player — never clickable/playable */
}

/* --------------------------------------------------------------------------
 * Hotspots (inert until the final scene holds on the panel wall)
 * ------------------------------------------------------------------------*/

#hotspots { position: absolute; inset: 0; }

.hotspot {
  position: absolute;           /* left/top/width/height set inline from data */
  appearance: none;
  border: none;
  background: transparent;
  border-radius: 10px;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;         /* inert until .at-end */
  transition: opacity 0.35s ease, box-shadow 0.2s ease, background 0.2s ease;
}

#stage.at-end .hotspot {
  opacity: 1;                   /* still visually invisible — see below */
  pointer-events: auto;
}

/* Subtle hover: faint teal wash + hairline ring, nothing that fights the
   labels already baked into the video. */
#stage.at-end .hotspot:hover,
#stage.at-end .hotspot:focus-visible {
  background: rgba(45, 212, 191, 0.10);
  box-shadow: inset 0 0 0 2px rgba(45, 212, 191, 0.65),
              0 0 24px rgba(45, 212, 191, 0.25);
  outline: none;
}

/* While a panel is being explored with the pointer, dim the top plate so it
   recedes behind the wall. */
#stage.at-end:has(.hotspot:hover) .scene-text.visible { opacity: 0.35; }

/* --------------------------------------------------------------------------
 * Hints
 * ------------------------------------------------------------------------*/

.hint {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: max(4%, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 22px;
  border-radius: 999px;
  background: rgba(11, 18, 32, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #e2e8f0;
  font-size: 14px;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.hint.visible { opacity: 1; }

/* --------------------------------------------------------------------------
 * Scene narration overlays (shown only while holding on a scene's end frame)
 * ------------------------------------------------------------------------*/

#scene-scrim {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(100deg,
    rgba(2, 8, 23, 0.62) 0%,
    rgba(2, 8, 23, 0.34) 34%,
    rgba(2, 8, 23, 0.00) 60%);
  transition: opacity 0.5s ease;
}

#scene-scrim.visible { opacity: 0.95; transition: opacity 0.9s ease 0.25s; }

#scene-texts { position: absolute; inset: 0; pointer-events: none; }

.scene-text {
  position: absolute;
  left: max(clamp(24px, 6vw, 96px), env(safe-area-inset-left));
  bottom: clamp(72px, 16vh, 200px);
  max-width: min(29rem, 76vw);
  /* Frosted glass plate — same language as the modal slides, for legibility. */
  padding: clamp(15px, 1.7vw, 22px) clamp(18px, 2vw, 28px);
  background: linear-gradient(160deg,
    rgba(17, 26, 44, 0.66), rgba(9, 14, 26, 0.58));
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 14px;
  box-shadow:
    inset 3px 0 0 var(--kicker, #2dd4bf),
    0 20px 48px rgba(2, 6, 23, 0.48),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  opacity: 0;
  visibility: hidden;
  transform: translateY(18px);
  transition: opacity 0.35s ease, transform 0.35s ease,
              visibility 0s linear 0.35s;
}

.scene-text.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  transition: opacity 0.85s ease 0.3s, transform 0.85s ease 0.3s,
              visibility 0s;
}

.scene-kicker {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--kicker, #e2e8f0);
}

.scene-kicker::before {
  content: "";
  width: 24px;
  height: 1px;
  background: var(--kicker, #e2e8f0);
}

.scene-line {
  margin-top: 10px;
  font-size: clamp(1.25rem, 2.4vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.018em;
  line-height: 1.14;
  color: #ffffff;
  text-wrap: balance;
}

.scene-support {
  margin-top: 9px;
  max-width: 44ch;
  font-size: clamp(0.85rem, 1.2vw, 1rem);
  font-weight: 400;
  line-height: 1.5;
  color: rgba(226, 232, 240, 0.92);
}

/* --------------------------------------------------------------------------
 * Final stop: the message docks as a slim horizontal plate along the top,
 * clear of every clickable panel below.
 * ------------------------------------------------------------------------*/

.scene-text--final {
  left: 50%;
  right: auto;
  top: auto;
  bottom: clamp(16px, 4vh, 40px);
  max-width: min(940px, 94vw);
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  justify-content: center;
  column-gap: 18px;
  row-gap: 4px;
  padding: clamp(12px, 1.4vw, 18px) clamp(20px, 2.4vw, 34px);
  text-align: center;
  transform: translate(-50%, 12px);
}

.scene-text--final.visible { transform: translate(-50%, 0); }

.scene-text--final .scene-kicker { flex: 0 0 auto; }
.scene-text--final .scene-line {
  margin-top: 0;
  font-size: clamp(1.05rem, 1.9vw, 1.5rem);
}
.scene-text--final .scene-support {
  margin-top: 0;
  max-width: none;
  font-size: clamp(0.82rem, 1.1vw, 0.95rem);
}

@media (max-width: 700px) {
  .scene-text--final { column-gap: 12px; }
  .scene-text--final .scene-support { flex-basis: 100%; }
}

/* On the final wall the message plate lives at the bottom, so the panel hint
   moves up to the ceiling band the plate vacated. */
#end-hint {
  top: clamp(14px, 2.4vh, 26px);
  bottom: auto;
}

/* --------------------------------------------------------------------------
 * Chapter dots
 * ------------------------------------------------------------------------*/

/* Right-rail: an orientation label ("02 · Capture") beside the chapter dots. */
#scene-nav {
  position: fixed;
  right: max(clamp(16px, 3vw, 44px), env(safe-area-inset-right));
  top: 50%;
  transform: translateY(-50%);
  z-index: 15;
  display: flex;
  align-items: center;
  gap: 14px;
  pointer-events: none;   /* only the dots inside are clickable */
}

#scene-dots-label {
  max-width: 24vw;
  text-align: right;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(226, 232, 240, 0.85);
  text-shadow: 0 1px 10px rgba(2, 8, 23, 0.6);
  opacity: 0;
  transition: opacity 0.6s ease;
}

#scene-dots-label.visible { opacity: 1; }

/* Short viewports too, not just narrow ones: a phone in landscape is ~844px
   wide but only ~390 tall, so the rail label cleared the width test and sat
   on top of the panel wall now that the film fills the screen. */
@media (max-width: 640px), (max-height: 480px) {
  #scene-dots-label { display: none; }
}

#scene-dots {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease;
}

#scene-dots.visible { opacity: 1; }

/* Buttons: 12px visual dot inside a 24px hit target (transparent border). */
.dot {
  appearance: none;
  padding: 0;
  width: 24px;
  height: 24px;
  border: 6px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
  background-color: rgba(226, 232, 240, 0.32);
  cursor: pointer;
  pointer-events: auto;
  transition: height 0.35s ease, background-color 0.35s ease,
              transform 0.2s ease;
}

/* Inert while the rail is hidden (hero screen) — they'd be invisible
   click-traps otherwise. */
#scene-dots:not(.visible) .dot { pointer-events: none; }

.dot:hover:not(.active) {
  background-color: rgba(226, 232, 240, 0.8);
  transform: scale(1.2);
}

.dot:focus-visible {
  outline: 2px solid var(--teal-bright);
  outline-offset: -3px;
}

/* Extra breathing room before the first clip of each scene, so the rail
   reads as chapter groups. */
.dot.scene-break { margin-top: 12px; }

.dot.done { background-color: rgba(226, 232, 240, 0.65); }

.dot.active {
  height: 40px;
  background-color: var(--teal-bright);
  box-shadow: 0 0 14px rgba(45, 212, 191, 0.4);
}

@media (max-width: 640px), (max-height: 480px) {
  #end-hint { display: none; }      /* too crowded on small or short screens */
}

/* --------------------------------------------------------------------------
 * Modal slideshow — dark cinematic glass (per-section --accent tints chrome)
 * ------------------------------------------------------------------------*/

#modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right))
           max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity 0.3s ease;
}

#modal-backdrop.open { opacity: 1; }

/* The ID selector above out-specifies the UA's [hidden] rule — restore it,
   otherwise an invisible full-screen layer eats every click on the page. */
#modal-backdrop[hidden] { display: none; }

#modal {
  --accent: #2dd4bf;   /* overridden per section from JS */
  position: relative;
  width: min(1320px, 96vw);
  aspect-ratio: 16 / 9;   /* reads as a presentation slide */
  /* 1vh on iOS Safari is 1% of the viewport with the toolbars HIDDEN, so a
     plain 94vh sheet runs under the address/tab bar and buries the footer's
     Next button. dvh tracks the real visible height; the 100% clamp keeps the
     sheet inside the backdrop's padding. vh line = fallback for no-dvh UAs. */
  max-height: 94vh;
  max-height: min(94dvh, 100%);
  display: flex;
  flex-direction: column;
  color: #e2e8f0;
  background:
    radial-gradient(120% 80% at 50% -10%,
      color-mix(in srgb, var(--accent) 16%, transparent) 0%,
      transparent 60%),
    linear-gradient(180deg, rgba(17, 26, 44, 0.96), rgba(9, 14, 26, 0.97));
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 18px;
  box-shadow:
    0 32px 80px rgba(2, 6, 23, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
  transform: translateY(16px) scale(0.985);
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#modal-backdrop.open #modal { transform: translateY(0) scale(1); }

/* Progress bar hugging the top edge. */
#modal-progress {
  height: 3px;
  width: 100%;
  background: rgba(148, 163, 184, 0.14);
  flex: 0 0 auto;
}

#modal-progress-bar {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 70%, transparent);
  transition: width 0.35s ease;
}

#modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.1);
  color: #cbd5e1;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

#modal-close:hover,
#modal-close:focus-visible {
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  color: #ffffff;
  outline: none;
}

/* Footer hidden entirely when there's a single slide (nothing to page). */
#modal.single #modal-footer { display: none; }
#modal.single #modal-body { padding-bottom: clamp(40px, 6vw, 72px); }

#modal-body {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  /* The one scrollable region on the page: vertical panning plus pinch-zoom
     (for the dense tables), never horizontal. `contain` is the load-bearing
     one — it stops a swipe carried past the top/bottom edge from chaining out
     to the document, which on iOS Safari rubber-bands the page and drags the
     toolbars around behind the sheet. */
  touch-action: pan-y pinch-zoom;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  /* Centre via auto margins (see #modal-kicker / #slide-content) rather than
     justify-content: center — the latter spawns a phantom scrollbar in a flex
     scroll container. Auto margins collapse to 0 when content overflows, so it
     top-aligns and scrolls only when genuinely needed. */
  /* Vertical padding tracks viewport HEIGHT (not width) so tall slides don't
     overflow on short screens. */
  padding: clamp(22px, 3.2vh, 56px) clamp(40px, 5.2vw, 92px);
}

#modal-kicker {
  flex: 0 0 auto;
  margin-top: auto;   /* with #slide-content's margin-bottom:auto → centres group */
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

#slide-title {
  flex: 0 0 auto;
  margin-top: 12px;
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.06;
  color: #ffffff;
  text-wrap: balance;
}

#slide-title:empty { display: none; }

#slide-content {
  flex: 0 0 auto;
  margin-top: 30px;
  margin-bottom: auto;   /* pairs with #modal-kicker margin-top:auto to centre */
  font-size: 18px;
  line-height: 1.68;
  color: #cbd5e1;
}

#slide-content p + p { margin-top: 14px; }
#slide-content img { max-width: 100%; border-radius: 10px; }
#slide-content a { color: var(--accent); }
#slide-content strong { color: #f1f5f9; }

/* Generic lists get an accent marker. */
#slide-content ul:not(.checks),
#slide-content ol { padding-left: 22px; margin-top: 14px; }
#slide-content ul:not(.checks) li,
#slide-content ol li { margin-top: 6px; }
#slide-content li::marker { color: var(--accent); }

/* Objective-style checklists: a two-column grid of accent check chips. */
#slide-content ul.checks {
  list-style: none;
  padding: 0;
  margin-top: 26px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 38px;
}

#slide-content ul.checks li {
  position: relative;
  padding-left: 40px;
  font-size: 18px;
  line-height: 1.45;
  color: #e2e8f0;
}

#slide-content ul.checks li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  top: 1px;
  width: 25px;
  height: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 50%;
}

@media (max-width: 560px) {
  #slide-content ul.checks { grid-template-columns: 1fr; }
}

/* Numbered "the pilot validates N things" list: accent number badge, bold
   term, then the question it answers. */
#slide-content ol.validates {
  list-style: none;
  counter-reset: v;
  padding: 0;
  margin-top: 26px;
  display: grid;
  gap: 18px;
}

#slide-content ol.validates li {
  counter-increment: v;
  position: relative;
  padding-left: 50px;
  font-size: 18px;
  line-height: 1.5;
  color: #cbd5e1;
}

#slide-content ol.validates li::before {
  content: counter(v);
  position: absolute;
  left: 0;
  top: -1px;
  width: 33px;
  height: 33px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 50%;
}

#slide-content ol.validates strong { color: #f1f5f9; font-weight: 650; }

/* Phased-engagement columns: an accent-topped card per phase. */
/* --- opening statement ----------------------------------------------------
   The sentence a reader should leave with if they read nothing else on the
   slide, so it sits a size above the list beneath it and is ruled off from it
   the same way a headline figure is. */
#slide-content p.lede {
  margin-bottom: 22px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  color: #e2e8f0;
  font-size: clamp(1.05rem, 2.2vw, 1.22rem);
  line-height: 1.55;
}

/* --- headline figure (a price, a duration) -------------------------------
   The one number a reader is looking for, given its own line above the detail
   rather than buried mid-sentence in the first bullet. Uses the section's
   --accent, so Commercials reads teal and Pilot Scope green, exactly as their
   hotspots and chapter dots already do. */
#slide-content p.figure {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

#slide-content p.figure strong {
  color: var(--accent);
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1;
}

/* White, not --ink-soft: that variable is the light-palette body tone (#475569)
   and this figure sits inside the dark modal, where it rendered as slate on
   navy. White matches #slide-title and keeps the caption legible next to the
   accent-coloured number. */
#slide-content p.figure span {
  color: #ffffff;
  font-size: clamp(0.85rem, 1.6vw, 0.98rem);
  line-height: 1.4;
}

/* --- closing statement ----------------------------------------------------
   The conclusion a section is arguing towards, not another item in its list —
   so it sits after the list, ruled off and tinted, rather than becoming a
   final bullet that would read as merely one more of the same. */
#slide-content p.outcome {
  margin-top: 24px;
  padding: 16px 18px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: rgba(148, 163, 184, 0.09);
  line-height: 1.6;
}

#slide-content p.outcome strong {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

#slide-content .phases {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 26px 34px;
  margin-top: 30px;
}

#slide-content .phase {
  padding-top: 14px;
  border-top: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
}

#slide-content .phase-week {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

#slide-content .phase h4 {
  margin-top: 5px;
  font-size: 18px;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: #f1f5f9;
}

#slide-content .phase ul {
  list-style: none;
  padding: 0;
  margin-top: 13px;
  display: grid;
  gap: 8px;
}

#slide-content .phase li {
  position: relative;
  padding-left: 18px;
  font-size: 15px;
  line-height: 1.45;
  color: #cbd5e1;
}

#slide-content .phase li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Role table (the Team subsection, rebuilt as HTML — no image). */
#slide-content table.team {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
  font-size: 15.5px;
}

#slide-content table.team th {
  text-align: left;
  padding: 0 20px 10px 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

#slide-content table.team td {
  padding: 10px 20px 10px 0;
  vertical-align: top;
  line-height: 1.4;
  color: #cbd5e1;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

#slide-content table.team tr:last-child td { border-bottom: none; padding-bottom: 0; }
#slide-content table.team td:first-child { color: #f1f5f9; font-weight: 650; }
#slide-content table.team td:first-child em { color: #94a3b8; font-weight: 400; font-style: italic; }

/* Slide enter animation (re-triggered on each slide change). */
@keyframes slideEnter {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.slide-enter #slide-title,
.slide-enter #slide-content { animation: slideEnter 0.45s ease both; }
.slide-enter #slide-content { animation-delay: 0.06s; }

/* Image-only slides: hide the text chrome and size the modal to the image so
   the graphic fills it edge-to-edge — no letterbox, no stretch/distortion.
   The image height is capped; the modal width shrinks to fit the image. */
#modal.image-mode #modal-kicker,
#modal.image-mode #slide-title { display: none; }

#modal.image-mode {
  width: auto;
  aspect-ratio: auto;
  max-width: 96vw;
  max-height: 94vh;
  max-height: min(94dvh, 100%);
}

#modal.image-mode #modal-body {
  padding: 0;
  display: block;
  overflow: hidden;
}

#modal.image-mode #slide-content { margin: 0; position: relative; }

/* Zoom is PORTRAIT-ONLY. Fitted to a phone held upright, these ~1536px
   infographics render around 420px — a 0.27x downscale putting 16px source
   text at 4.4px, well under the ~11px legibility floor — so a tap turns the
   graphic on its side to use the screen's long axis instead (sized in JS: a
   rotated element keeps its unrotated layout box, so the container has to be
   given the swapped dimensions). Landscape is deliberately left alone — the
   slide is already upright there, and zooming only ever produced a fragment
   you had to pan around. */
@media (orientation: portrait) {
  #modal.image-mode #slide-content img.slide-image { cursor: zoom-in; }
  #modal.image-mode.zoomed #slide-content img.slide-image { cursor: zoom-out; }

  #modal.image-mode.zoomed #modal-body {
    overflow: auto;
    touch-action: pan-x pan-y pinch-zoom;
    overscroll-behavior: contain;
  }
}

/* Landscape shows the WHOLE slide, never a scrollable crop of it — so height
   is the binding constraint and every pixel of chrome comes straight off the
   graphic. A 3:2 slide in a 2.87:1 viewport also leaves ~456px of dead space
   either side, so the pager moves OUT of the vertical stack and into that gap:
   Back and Next ride the margins, the dots tuck into the bottom-left corner,
   and the graphic gets the modal's full height instead of sharing it with a
   40px bar. */
@media (orientation: landscape) and (max-height: 500px) {
  #modal.image-mode { width: 100%; max-width: 100%; }

  #modal.image-mode #modal-body {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  #modal.image-mode #modal-footer {
    position: absolute;   /* out of flow — fitImageSlide() stops counting it */
    inset: 0;
    padding: 0 12px;
    border-top: none;
    pointer-events: none; /* only the controls themselves take taps */
  }

  #modal.image-mode #modal-footer > * { pointer-events: auto; }

  #modal.image-mode #slide-nav {
    position: absolute;
    left: 12px;
    bottom: 8px;
  }
}

/* Touch devices get no cursor to hint with, so say it outright — and only
   where tapping actually does something. */
@media (orientation: portrait) and (hover: none) {
  #modal.image-mode:not(.zoomed) #slide-content::after {
    content: "Tap to zoom";
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    background: rgba(11, 18, 32, 0.78);
    border: 1px solid rgba(148, 163, 184, 0.28);
    color: #e2e8f0;
    font-size: 12px;
    letter-spacing: 0.02em;
    pointer-events: none;
  }
}

#slide-content img.slide-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 96vw;
  /* --img-max-h is measured in JS from the real chrome (backdrop padding +
     progress bar + footer). The calc below is only a fallback: it guesses the
     chrome at 80px and ignores the backdrop's padding, so on a short landscape
     viewport it sized the image ~31px taller than the box holding it and the
     bottom of the slide got clipped. */
  max-height: calc(94vh - 80px);
  max-height: var(--img-max-h, calc(94dvh - 80px));
  border-radius: 0;
}

/* --------------------------------- footer ------------------------------- */

#modal-footer {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px 20px;
  border-top: 1px solid rgba(148, 163, 184, 0.12);
  /* Nothing scrolls here — tell the compositor up front, so a stray drag on
     the pager can't start moving Safari's toolbars before JS cancels it. */
  touch-action: none;
}

#slide-prev,
#slide-next {
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: transparent;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease,
              color 0.15s ease, box-shadow 0.15s ease;
}

#slide-next {
  background: var(--accent);
  border-color: var(--accent);
  color: #06121a;
}

#slide-prev:hover:not(:disabled),
#slide-prev:focus-visible {
  border-color: var(--accent);
  color: #ffffff;
  outline: none;
}

#slide-next:hover:not(:disabled),
#slide-next:focus-visible {
  box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 55%, transparent);
  outline: none;
}

#slide-prev:disabled,
#slide-next:disabled { opacity: 0.35; cursor: default; }

#slide-nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#slide-dots { display: flex; gap: 8px; }
#slide-dots[hidden] { display: none; }

.slide-dot {
  width: 8px;
  height: 8px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.35);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.slide-dot:hover { background: rgba(226, 232, 240, 0.7); }
.slide-dot.active { background: var(--accent); transform: scale(1.3); }
.slide-dot:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#slide-counter {
  font-size: 12px;
  color: #94a3b8;
  letter-spacing: 0.05em;
}

/* Mobile / short viewports: drop the slide aspect and dock as a bottom sheet. */
@media (max-width: 720px), (max-height: 620px) {
  #modal {
    width: 100%;
    aspect-ratio: auto;
    max-height: 92vh;
    max-height: min(92dvh, 100%);
  }
  #modal-body { justify-content: flex-start; }
}

/* On a phone in landscape the viewport is only ~333px tall, and the pager plus
   the backdrop's padding were spending a quarter of it on chrome — which is
   why the slide sat so small with dead space either side. Slim both down and
   hand the height to the slide. (The side gaps themselves are geometry: a 3:2
   graphic in a 2.87:1 viewport is height-bound no matter what.) */
@media (max-height: 500px) {
  /* Zero vertical padding: at ~333px tall every pixel here is a pixel the
     graphic doesn't get, and the slide has to fit whole without scrolling. */
  #modal-backdrop {
    padding: 0 max(10px, env(safe-area-inset-right))
             0 max(10px, env(safe-area-inset-left));
  }
  #modal-footer { padding: 4px 14px 5px; gap: 10px; }
  #slide-prev, #slide-next { padding: 4px 12px; font-size: 12px; }
  #slide-nav { gap: 2px; }
  #slide-dots { gap: 6px; }
  #slide-dots .slide-dot { width: 6px; height: 6px; }
  #slide-counter { font-size: 10px; }
  #modal { border-radius: 12px; }
  #modal-close { top: 8px; right: 10px; width: 30px; height: 30px; font-size: 19px; }
}

@media (max-width: 560px) {
  #modal-backdrop {
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    align-items: flex-end;
  }
  #modal { border-radius: 20px 20px 0 0; }
  #modal-body { padding: 34px 22px 26px; }
  #modal-footer { padding: 14px 20px 18px; }
}

/* --------------------------------------------------------------------------
 * Loading spinner + video-load failure notice
 * ------------------------------------------------------------------------*/

.hint-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(226, 232, 240, 0.3);
  border-top-color: #e2e8f0;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Multi-line, centered — overrides the single-line pill defaults of .hint. */
#video-error {
  max-width: min(90vw, 460px);
  bottom: auto;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: normal;
  text-align: center;
  line-height: 1.5;
}

#video-error[hidden] { display: none; }

/* --------------------------------------------------------------------------
 * Persistent section menu (top-right; above hero, below modal)
 * ------------------------------------------------------------------------*/

#section-nav {
  position: fixed;
  top: max(clamp(14px, 2.5vw, 24px), env(safe-area-inset-top));
  right: max(clamp(14px, 2.5vw, 24px), env(safe-area-inset-right));
  z-index: 40;
}

body.modal-open #section-nav { display: none; }

/* The download button is styled with the section toggle, not near it: the two
   are a matched pair in opposite corners, and any drift between them would
   show immediately at the top of the screen. */
#section-nav-toggle,
#pdf-download {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(11, 18, 32, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #e2e8f0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

#section-nav-toggle:hover,
#section-nav-toggle:focus-visible,
#pdf-download:hover,
#pdf-download:focus-visible {
  background: rgba(11, 18, 32, 0.85);
  border-color: rgba(45, 212, 191, 0.6);
  outline: none;
}

/* Top-left, mirroring #section-nav's insets exactly so the pair sits level. */
#pdf-download {
  position: fixed;
  top: max(clamp(14px, 2.5vw, 24px), env(safe-area-inset-top));
  left: max(clamp(14px, 2.5vw, 24px), env(safe-area-inset-left));
  z-index: 40;
  gap: 9px;
}

/* Beats the inline-flex above — without it `hidden` does nothing and the
   button sits over the sign-in curtain. */
#pdf-download[hidden] { display: none; }

#pdf-download svg { flex: 0 0 auto; }

body.modal-open #pdf-download { display: none; }

/* Same breakpoint as the Sections label: on a narrow phone both collapse to
   their icons rather than one shedding its text and the other keeping it. */
@media (max-width: 480px) { .pdf-download-text { display: none; } }

/* Hamburger drawn as one bar + two box-shadow bars. */
.section-nav-bars {
  position: relative;
  width: 16px;
  height: 2px;
  background: currentColor;
  box-shadow: 0 -5px 0 currentColor, 0 5px 0 currentColor;
}

@media (max-width: 480px) { .section-nav-text { display: none; } }

#section-nav-list {
  position: absolute;
  right: 0;
  margin-top: 10px;
  padding: 8px;
  min-width: 232px;
  list-style: none;
  border-radius: 12px;
  background: rgba(11, 18, 32, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.22);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 18px 44px rgba(2, 6, 23, 0.5);
}

#section-nav-list[hidden] { display: none; }

/* The anchor is styled alongside the buttons rather than separately: the PDF
   item is a link because it downloads a file, but in this menu it is just
   another row and must not announce itself as a different kind of thing. */
#section-nav-list button,
#section-nav-list a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 14px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

#section-nav-list button:hover,
#section-nav-list button:focus-visible,
#section-nav-list a:hover,
#section-nav-list a:focus-visible {
  background: rgba(45, 212, 191, 0.14);
  color: #ffffff;
  outline: none;
}

/* Download (appended by main.js once the gate is open). Ruled off from the
   sections above it — it is an action, not a seventh chapter — and tinted
   with the teal the rest of the chrome already uses, so it reads as something
   offered rather than as housekeeping like Sign out below it. */
.nav-download {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

#section-nav-list .nav-download a {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--teal-bright);
}

#section-nav-list .nav-download a svg { flex: 0 0 auto; }

/* Sign out (appended by main.js when a gate is in play). Ruled off and
   quieted: it is account housekeeping sitting in a list of proposal
   sections, and it should not compete with them for the eye. */
.nav-signout {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

#section-nav-list .nav-signout button {
  color: rgba(148, 163, 184, 0.9);
  font-size: 13px;
}

/* --------------------------------------------------------------------------
 * One-time "keep scrolling" nudge on the first content scene
 * ------------------------------------------------------------------------*/

.step-hint { gap: 10px; }
.step-hint .chevron { width: 8px; height: 8px; }

/* --------------------------------------------------------------------------
 * First-land hotspot pulse (draws the eye to the clickable panels)
 * ------------------------------------------------------------------------*/

#hotspots.pulse-once .hotspot { animation: hotspotPulse 0.9s ease-out 3; }

@keyframes hotspotPulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(45, 212, 191, 0); }
  50% {
    box-shadow: inset 0 0 0 2px rgba(45, 212, 191, 0.7),
                0 0 26px rgba(45, 212, 191, 0.35);
  }
}

/* --------------------------------------------------------------------------
 * Reduced motion: scenes cut instantly (JS uses seekDirect), and every
 * transition/animation is neutralized so nothing scrubs or slides.
 * ------------------------------------------------------------------------*/

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
