/* ══════════════════════════════════════════════════════════════════════════
   RESPONSIVE ART DIRECTION + ACCESSIBILITY FALLBACKS
   Desktop: monumental environments. Tablet: simplified geometry, narrative
   kept. Mobile: deliberately recomposed, unpinned, short transitions.
   Layer 3 of 3.
   ══════════════════════════════════════════════════════════════════════════ */

/* ── Wide desktop: the monumental case ─────────────────────────────────── */
@media (min-width: 1500px) {
  .gate-copy { max-width: 1280px; }
  .interface-stage { width: min(1040px, 52vw); }
}

/* ── Laptop / small desktop ────────────────────────────────────────────── */
@media (max-width: 1340px) {
  .main-nav a { font-size: 9.5px; letter-spacing: 0.2em; }
  .identity-sub { display: none; }
  .interface-stage { width: min(860px, 62vw); }
}

@media (max-width: 1180px) {
  :root { --header-h: 66px; --rail-space: 0px; }
  .chapter-rail { display: none; }
  .depth-marks { right: var(--gutter); }
  .main-nav { gap: clamp(9px, 1.4vw, 18px); }
  .core-grid { grid-template-columns: minmax(0, 1fr); }
  .terminal { grid-template-columns: minmax(0, 1fr); }
  .terminal-main { position: static; }
  .footer-shell { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .interface-stage { position: relative; inset: auto; width: min(760px, 92%); margin: 0 auto; align-self: end; }
  #infinite .pin-stage { align-content: center; gap: 3vh; }
  .infinite-copy { position: relative; inset: auto; justify-self: center; text-align: center; }
  .infinite-copy .lead { margin-inline: auto; }
}

/* ── Tablet: unpinned chapters, simplified camera travel ───────────────── */
@media (max-width: 1020px) {
  :root { --gutter: clamp(20px, 5vw, 54px); }

  .pin-track { height: auto; }
  .pin-stage {
    position: relative;
    height: auto;
    min-height: 84svh;
    padding: clamp(90px, 12vh, 140px) var(--gutter) clamp(56px, 8vh, 96px);
    gap: clamp(24px, 4vh, 46px);
    align-content: center;
    justify-items: stretch;
  }
  .scene-canvas { opacity: 0.62; }

  /* The crew camera becomes a vertical dossier stack, still art-directed. */
  .crew-track {
    position: relative;
    inset: auto;
    grid-auto-flow: row;
    grid-auto-columns: auto;
    align-items: stretch;
    gap: clamp(20px, 4vh, 34px);
    transform: none !important;
    padding: 0;
  }
  .operative {
    min-height: 0;
    grid-template-columns: minmax(96px, 22%) minmax(0, 1fr);
    opacity: 1;
    transform: none;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--c-line);
  }
  .operative-figure { height: auto; width: 100%; max-width: 150px; }
  .operative-name { font-size: clamp(24px, 4.4vw, 38px); }
  .operative-line { font-size: clamp(16px, 2.4vw, 21px); }
  .crew-legend { position: relative; inset: auto; justify-self: start; }
  .crew-aside { position: relative; inset: auto; max-width: none; justify-self: stretch; }

  .descent-type { position: relative; inset: auto; justify-self: start; }
  .descent-type h2 { font-size: clamp(28px, 6vw, 62px); }
  .hud { position: relative; inset: auto; justify-self: start; }
  .depth-marks { position: relative; inset: auto; transform: none; text-align: left; opacity: 1; }
  .depth-marks li { opacity: 1; transform: none; }

  .exit-copy { max-width: none; }
  .mac-split { grid-template-columns: 150px minmax(0, 1fr); }
  .mac-detail { display: none; }
  .gate-readouts { gap: 0 26px; }
}

/* ── Narrow stage: mirrors the canvas `width < 900` art direction ─────── */
@media (max-width: 899px) {
  /* Both scenes drop their vanishing point to the centre and let the door rise
     up behind the copy at this width, so the text needs plates of its own —
     the canvas scrim alone leaves brass shining straight under the readings. */
  .corridor-canvas { opacity: 0.5; }
  .gate-readouts {
    gap: 14px 20px;
    padding: 15px 16px;
    border: 1px solid var(--c-line);
    border-top: 2px solid var(--c-gold-deep);
    border-radius: var(--r-hair);
    background: linear-gradient(180deg, rgba(10, 11, 14, 0.95), rgba(6, 6, 8, 0.96));
  }
  .gate-readouts > div { padding: 0; }
  /* The door's brass ring passes straight behind the sub-copy once the scene
     centres itself at this width. A gradient scrim under that one paragraph
     keeps the sentence readable without dimming the whole gate canvas, which is
     the only thing holding the lower half of the frame together on a phone. */
  .gate-sub {
    padding: 11px 14px;
    margin-left: -14px;
    border-radius: var(--r-hair);
    background: linear-gradient(90deg, rgba(6, 6, 8, 0.9), rgba(6, 6, 8, 0.55) 72%, rgba(6, 6, 8, 0));
    color: var(--c-fog);
  }
  .gate-fiction {
    padding: 12px 15px;
    border-left: 2px solid var(--c-alert-soft);
    border-radius: 0 var(--r-hair) var(--r-hair) 0;
    background: rgba(6, 6, 8, 0.92);
    color: var(--c-fog);
    opacity: 1;
  }
}

/* ── Compact access panel ─────────────────────────────────────────────────
   The chapter row, the sound control and the download button cannot share a
   bar below ~1080px: measured, the row ran 171px past the frame at 821px,
   which put the primary call to action outside the viewport. From here down
   the chapters fold into the toggle and the actions hold the right edge. */
@media (max-width: 1080px) {
  .main-nav {
    position: fixed;
    inset: var(--header-h) 0 auto;
    display: grid;
    gap: 2px;
    padding: 16px var(--gutter) 22px;
    background: rgba(5, 5, 7, 0.97);
    border-bottom: 1px solid var(--c-line);
    backdrop-filter: blur(16px);
    transform: translateY(-102%);
    visibility: hidden;
    transition: transform var(--t-base) var(--e-out), visibility 0s linear var(--t-base);
  }
  /* Opening drops the visibility delay so the panel is focusable the instant it
     is asked for; closing keeps it, so nothing disappears mid-transition. */
  body.nav-open .main-nav {
    transform: translateY(0);
    visibility: visible;
    transition: transform var(--t-base) var(--e-out), visibility 0s;
  }
  /* The chapter row was the flex spacer that pushed the actions right; once it
     leaves the flow the header needs an explicit one. */
  .chrome-actions { margin-left: auto; }
}

/* ── Mobile: deliberately recomposed ──────────────────────────────────── */
@media (max-width: 820px) {
  :root {
    --header-h: 60px;
    --tr-label: 0.18em;
    --t-reveal: 700ms;
    --t-epic: 1100ms;
    --t-mega: 1800ms;
  }

  .main-nav a { padding: 12px 2px; border-bottom: 1px solid var(--c-line-cold); font-size: 11px; }
  .main-nav a::after { display: none; }

  .site-header { gap: 10px; }
  .identity-word { font-size: 17px; }
  .btn--sm { padding: 9px 13px; }
  .sound-toggle { padding: 8px 9px; }
  .sound-toggle span:last-child { display: none; }

  .chapter--gate { padding-top: calc(var(--header-h) + 8vh); align-items: start; }
  .gate-copy h1 { font-size: clamp(38px, 11.4vw, 74px); }
  .gate-actions .btn { flex: 1 1 auto; }
  .scroll-indicator { display: none; }

  .capability { grid-template-columns: 46px minmax(0, 1fr); gap: 14px; }
  .cap-index { font-size: 18px; }
  .dossier > div { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .terminal-cta .btn { flex: 1 1 100%; }
  .footer-shell { grid-template-columns: minmax(0, 1fr); gap: 26px; }

  .mac-cols, .mac-list li { grid-template-columns: minmax(0, 1.6fr) 0.8fr 0.9fr; }
  .mac-cols span:nth-child(3), .mac-cols span:nth-child(4),
  .mac-list li span:nth-child(3), .mac-list li span:nth-child(4) { display: none; }
  .mac-split { grid-template-columns: minmax(0, 1fr); }
  .mac-side { display: none; }
  .mac-detail { display: block; border-left: 0; border-top: 1px solid rgba(0, 0, 0, 0.7); }

  .pin-stage { min-height: 74svh; }
  .operative { grid-template-columns: minmax(74px, 26%) minmax(0, 1fr); }
  .operative-concept { font-size: 11.5px; }
}

@media (max-width: 480px) {
  /* The four tumblers cannot sit in one line inside the plate at this width, and
     a row of three with one left over reads as a mistake rather than a wrap. */
  .dial-row { display: grid; grid-template-columns: repeat(2, auto); gap: 18px; }
  .gate-readouts > div { min-width: 44%; }
  .operative-figure { max-width: 96px; }
  .operative-dossier { padding: 16px; }
  .btn--lg { padding: 15px 20px; }
}

/* ── Mobile access-panel toggle ─────────────────────────────────────────── */
.nav-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 13px;
  border: 1px solid var(--c-line-cold);
  border-radius: var(--r-plate);
  background: transparent;
  color: var(--c-fog);
  font: 500 var(--ts-eyebrow)/1 var(--f-mono);
  letter-spacing: var(--tr-label);
  text-transform: uppercase;
  cursor: pointer;
}
/* Declared after the base rule so it wins the cascade: the full chapter row is
   in the header above this width, so the toggle has nothing to do. */
@media (min-width: 1081px) { .nav-toggle { display: none; } }
.nav-toggle:hover { color: var(--c-gold-hot); border-color: var(--c-gold-deep); }
.nav-toggle-bars { display: grid; gap: 3px; }
.nav-toggle-bars i { display: block; width: 13px; height: 1px; background: currentColor; transition: transform var(--t-quick) var(--e-mech), opacity var(--t-quick) linear; }
body.nav-open .nav-toggle-bars i:nth-child(1) { transform: translateY(4px) rotate(45deg); }
body.nav-open .nav-toggle-bars i:nth-child(2) { opacity: 0; }
body.nav-open .nav-toggle-bars i:nth-child(3) { transform: translateY(-4px) rotate(-45deg); }
/* Below 480 the header carries the wordmark, this toggle, the sound control and
   the download button, so the toggle drops to its glyph. The name stays on the
   button through aria-label, which also keeps it the accessible name when the
   text is gone. */
@media (max-width: 480px) { .nav-toggle { padding: 9px 11px; } .nav-toggle span:last-child { display: none; } }
/* 320px is the narrowest phone still in use, and it is where the bar runs out:
   measured, the four controls ended 7px past the frame. Tightening the tracking
   and the hit padding buys the margin back without dropping the wordmark or the
   download button, both of which a first-time visitor needs more than the label
   on the chapters toggle. */
@media (max-width: 360px) {
  .site-header { gap: 8px; }
  .chrome-actions { gap: 8px; }
  .identity-word { font-size: 16px; letter-spacing: 0.06em; }
  .btn--sm { padding: 9px 10px; letter-spacing: 0.12em; }
}
@media (min-width: 1081px) { body.nav-open .main-nav { position: static; transform: none; visibility: visible; } }

/* ── Reduced motion / non-3D alternative ──────────────────────────────── */
@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;
  }
}

/* main.js adds .motion-off when the visitor asks for less motion, and the inline
   script in <head> leaves .no-js on the document when the scripts never run.
   Both routes release the sticky stage, so every scene layer that was pinned to
   a corner of it has to rejoin the document flow instead of piling up on the
   next one. One rule set serves both, at desktop and phone widths alike. */
:is(.motion-off, .no-js) .pin-stage {
  position: relative;
  height: auto;
  min-height: 0;
  padding: clamp(70px, 10vh, 120px);
  /* A stacked stage runs its content the full width of the frame, so the right
     hand column has to stop short of the fixed depth rail. --rail-space is 0
     once the rail is hidden, which makes this a no-op on smaller screens. */
  padding-inline: var(--gutter) calc(var(--gutter) + var(--rail-space) + 26px);
  display: grid;
  gap: clamp(24px, 4vh, 46px);
  align-content: start;
  justify-items: stretch;
}
:is(.motion-off, .no-js) .pin-track { height: auto; }
:is(.motion-off, .no-js) :is(.hud, .descent-type, .depth-marks, .crew-track,
                              .crew-legend, .crew-aside, .interface-stage,
                              .infinite-copy) {
  position: relative;
  inset: auto;
  justify-self: start;
}
:is(.motion-off, .no-js) .crew-track {
  grid-auto-flow: row;
  grid-auto-columns: auto;
  align-items: stretch;
  gap: clamp(20px, 4vh, 34px);
  padding: 0;
  transform: none !important;
}
:is(.motion-off, .no-js) .crew-aside { max-width: none; justify-self: stretch; }
:is(.motion-off, .no-js) .operative { min-height: 0; opacity: 1; transform: none; }
:is(.motion-off, .no-js) .depth-marks { transform: none; text-align: left; opacity: 1; }
:is(.motion-off, .no-js) .depth-marks li { opacity: 1; transform: none; }
:is(.motion-off, .no-js) .interface-stage { transform: none; opacity: 1; width: min(940px, 100%); }
:is(.motion-off, .no-js) .gate-light { opacity: 1; }
:is(.motion-off, .no-js) [data-reveal] { opacity: 1; transform: none; }
:is(.motion-off, .no-js) .cursor-lamp,
:is(.motion-off, .no-js) .scroll-indicator,
:is(.motion-off, .no-js) .grain,
:is(.motion-off, .no-js) .preloader { display: none; }
/* Without the script the toggle cannot open anything, so the chapter row stays
   in the bar. It is a single-column grid while it is a drop-down panel; back in
   the flow it has to wrap, or six stacked links make the header taller than the
   page it is navigating. */
.no-js .main-nav {
  position: static;
  display: flex;
  flex-wrap: wrap;
  gap: 0 clamp(10px, 2vw, 22px);
  padding: 0;
  background: none;
  border-bottom: 0;
  backdrop-filter: none;
  transform: none;
  visibility: visible;
}
.no-js .nav-toggle { display: none; }
/* The sound control switches a synthesiser on. With no script there is no
   synthesiser, and a dead control in the bar is worse than no control. */
.no-js .sound-toggle { display: none; }
/* A header that opens nothing cannot be a fixed overlay: without the toggle the
   chapter row is taller than one line, and a pinned bar that tall would sit on
   top of the headline. Let it take its own space at the head of the document. */
.no-js .site-header {
  position: static;
  flex-wrap: wrap;
  row-gap: 12px;
  padding-block: 14px;
  background: rgba(5, 5, 7, 0.97);
  border-bottom: 1px solid var(--c-line);
}
@media (max-width: 1080px) {
  /* Below the compact-panel width the chapter row gets its own line under the
     wordmark and the download button rather than squeezing beside them. */
  .no-js .main-nav { order: 3; flex: 1 1 100%; }
}

@media (max-width: 1180px) {
  /* The rail is gone below this width, so the stage returns to even gutters. */
  :is(.motion-off, .no-js) .pin-stage { padding-inline: var(--gutter); }
}

/* ── Coarse pointers: touch-friendly hit areas ────────────────────────── */
@media (pointer: coarse) {
  .btn { padding-block: 17px; }
  .chapter-rail a, .main-nav a { padding-block: 13px; }
  .dial { width: 78px; }
  .terminal { -webkit-overflow-scrolling: touch; }
}

/* ── Higher contrast: strip atmosphere, keep structure ─────────────────── */
@media (prefers-contrast: more) {
  body { background: #000; }
  .grain, .vignette, .beacon-wash, .cursor-lamp { display: none; }
  .plate, .operative-dossier, .hud { background: #0a0a0c; }
  .note, .muted, .capability p, .operative-concept { color: #d7d3ca; }
  .main-nav a, .chapter-rail a { color: #cdc9c0; }
}

/* ── Print: the product, without the theatre ──────────────────────────── */
@media print {
  .atmosphere, .cursor-lamp, .scroll-progress, .chapter-rail, .scene-canvas,
  .gate-canvas, .corridor-canvas, .core-canvas, .preloader, .scroll-indicator,
  .gate-light, .skip-link, .nav-toggle, .btn, .sound-toggle, .dial-row { display: none !important; }

  body { background: #fff; }
  /* A chapter is sized to a viewport. On paper that leaves most of a sheet
     empty between sections, so the monumental heights come off. */
  .chapter, .pin-stage, .pin-track { min-height: 0 !important; }
  .pin-track { height: auto; }
  .chapter, .site-footer { padding: 12pt 0 !important; }
  .site-header { position: static; }

  /* Releasing the sticky stage is not enough: the layers inside it were pinned
     to its corners, and a printed page has no stage to be pinned to. They have
     to rejoin the flow, which is the same release the still-frame route
     performs — but print cannot borrow those selectors, so it repeats them. */
  .pin-stage,
  .pin-stage :is(.hud, .descent-type, .depth-marks, .crew-track, .crew-legend,
                 .crew-aside, .interface-stage, .infinite-copy, .operative) {
    position: static;
    inset: auto;
    display: block;
    height: auto;
    width: auto;
    max-width: 100%;
    margin: 0 0 10pt;
    padding: 0;
    transform: none;
    opacity: 1;
    text-align: left;
  }
  .crew-track { display: grid; grid-auto-flow: row; gap: 10pt; }
  .operative { display: grid; }
  .depth-marks li { opacity: 1; transform: none; }

  /* A visitor can print from the first screen without scrolling, so nothing may
     still be waiting on an intersection that will never happen on paper. */
  [data-reveal], .line-mask, .line-mask > span {
    opacity: 1 !important;
    transform: none !important;
    clip-path: none !important;
  }

  /* Every colour in this design is chosen against a dark chamber. Re-picking
     each token for paper is a second design nobody asked for; print collapses
     the palette instead and lets the structure speak. */
  * {
    color: #111 !important;
    background-color: transparent !important;
    border-color: #b9b5ac !important;
    box-shadow: none !important;
    text-shadow: none !important;
    backdrop-filter: none !important;
  }
  svg text { fill: #111 !important; }
  /* The collapse is universal, so the paper itself has to be put back. */
  html, body { background: #fff !important; }
  a { text-decoration: none; }
  a[href^="downloads"]::after { content: " — " attr(href); }
  .main-nav { position: static; display: flex; flex-wrap: wrap; gap: 0 16px; padding: 0; visibility: visible; transform: none; }
  h1, h2, h3, .operative-dossier, .capability, .dossier > div { break-inside: avoid; }
}
