/*
 * Objective — page
 *
 * The copy is a fixed overlay whose opacity is driven by scroll progress; the
 * scroll itself is a plain tall document. Wide viewports put the instrument
 * right of centre with copy on the left (beat 1), centre it with callouts
 * (beat 2), then left of centre with copy on the right (beat 3). Portrait
 * centres the instrument and stacks copy above or below it. Reduced motion and
 * WebGL failure collapse everything to ordinary static flow.
 */

@font-face {
  font-family: "Inter";
  src: url("../shared/fonts/Inter-Latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: block;   /* preloaded and local: no fallback flash */
}

:root {
  --paper: #f3efe8;
  --ink: #15130f;
  --muted: #5b5446;
  --accent: #ff5c00;
  --line: rgba(21, 19, 15, 0.16);
  --progress: 0;
  --cool: 0;
  --gutter: clamp(20px, 4.4vw, 76px);
  color-scheme: light;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

html[data-motion="reduced"] { scroll-behavior: auto; }

body {
  margin: 0;
  min-height: 100%;
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.anchor-point {
  position: absolute;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

/* ------------------------------------------------------------------ canvas */

.scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  opacity: 0;
  transition: opacity 600ms ease;
}

html[data-objective="set"] .scene,
html[data-objective="ready"] .scene { opacity: 1; }

/* the eyepiece field: a circle that closes around the slide */
.field {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.field[hidden] { display: none; }
html[data-webgl="failed"] .scene { display: none; }

.loading {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: clamp(60px, 8vh, 90px);
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

.loading[hidden] { display: none; }

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: fixed;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: clamp(16px, 2.4vw, 26px) var(--gutter);
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  text-decoration: none;
  color: var(--ink);
  font-size: 0.9rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.wordmark b { font-weight: 700; letter-spacing: 0.16em; }
.wordmark-mark { width: 20px; height: 20px; fill: var(--ink); }
.wordmark-mark .accent { fill: var(--accent); }

.topnav {
  display: inline-flex;
  align-items: center;
  gap: 18px;
  font-size: 0.82rem;
}

.topnav a {
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.01em;
}

.topnav a:hover { text-decoration: underline; text-underline-offset: 4px; }

.topnav-cta {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(243, 239, 232, 0.8);
  backdrop-filter: blur(6px);
  font-weight: 700;
}

.topnav-cta:hover { text-decoration: none !important; background: var(--ink); color: var(--paper); }

/* while the eyepiece field is up, the fixed interface goes light on dark */
html[data-field="on"] .wordmark,
html[data-field="on"] .topnav a,
html[data-field="on"] .index a { color: var(--paper); }
html[data-field="on"] .wordmark-mark { fill: var(--paper); }
html[data-field="on"] .index a:not([aria-current]) { color: rgba(243, 239, 232, 0.55); }
html[data-field="on"] .topnav-cta { background: rgba(21, 19, 15, 0.6); border-color: rgba(243, 239, 232, 0.3); }
.wordmark, .topnav a, .index a, .wordmark-mark { transition: color 300ms ease, fill 300ms ease; }

/* ------------------------------------------------------------------- index */

.index {
  position: fixed;
  z-index: 6;
  left: var(--gutter);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.index a {
  display: grid;
  grid-template-columns: 2.2rem auto;
  align-items: baseline;
  gap: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: color 240ms ease;
}

.index-num { font-variant-numeric: tabular-nums; }
.index-name { position: relative; padding-bottom: 3px; }

.index-name::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 1px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 320ms ease;
}

.index a[aria-current] { color: var(--ink); }
.index a[aria-current] .index-name::after { transform: scaleX(1); }
.index a:hover { color: var(--ink); }

.progress {
  position: fixed;
  z-index: 6;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: transparent;
}

.progress span {
  display: block;
  height: 100%;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
}

/* ------------------------------------------------------------------- stage */

.stage {
  position: fixed;
  z-index: 2;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(300px, 42vw) 1fr minmax(300px, 40vw);
  grid-template-rows: 1fr;
  align-items: center;
  padding: clamp(84px, 11vh, 132px) var(--gutter) clamp(76px, 9vh, 112px) calc(var(--gutter) + 9rem);
  pointer-events: none;
}

.panel {
  position: relative;
  max-width: 34rem;
}

.panel-hero { grid-column: 1; grid-row: 1; align-self: center; }
.panel-detail { grid-column: 3; grid-row: 1; align-self: end; justify-self: end; max-width: 26rem; }
.panel-outro { grid-column: 3; grid-row: 1; align-self: center; justify-self: end; }
.panel-lens { grid-column: 1; grid-row: 1; align-self: end; max-width: 24rem; margin-bottom: 28px; color: var(--paper); }
html[data-play="on"] .index, html[data-play="on"] .credit, html[data-play="on"] .stage { visibility: hidden; }
.panel-lens::before { display: none; }
.panel-lens .kicker, .panel-lens .lede { color: rgba(243, 239, 232, 0.7); }
.panel-lens h2 { font-size: clamp(2rem, 3.6vw, 3.2rem); }
.panel-lens .lede { margin-bottom: 18px; }

.captions {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
  min-height: 3.6rem;
  border-top: 1px solid rgba(243, 239, 232, 0.25);
}

.caption {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  padding-top: 12px;
  font-size: 0.86rem;
  line-height: 1.4;
  color: rgba(243, 239, 232, 0.7);
}

.caption b { display: block; color: var(--paper); font-weight: 700; margin-bottom: 2px; }
.caption[data-off] { visibility: hidden; }

.play-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 18px 10px 14px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: #15130f;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 700;
  cursor: pointer;
  pointer-events: auto;
}

.play-button svg { width: 14px; height: 14px; fill: currentColor; }
.play-button:hover { background: var(--paper); }

/* ------------------------------------------------------------- play overlay */

.play {
  position: fixed;
  inset: 0;
  z-index: 8;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  padding: clamp(72px, 9vh, 96px) var(--gutter) clamp(56px, 7vh, 80px);
  background: rgba(8, 7, 6, 0.86);
}

.play[hidden] { display: none; }

.play-frame {
  width: min(100%, calc((100vh - 220px) * 16 / 9), 1280px);
  aspect-ratio: 16 / 9;
  border-radius: 18px;
  overflow: hidden;
  background: #000;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(243, 239, 232, 0.12);
}

.play-frame iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
}

.play-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px 22px;
  margin-top: 16px;
  color: rgba(243, 239, 232, 0.7);
  font-size: 0.82rem;
}

.play-hint { margin: 0; }

.play-link {
  color: var(--paper);
  text-decoration: none;
  font-weight: 700;
}

.play-link:hover { text-decoration: underline; text-underline-offset: 4px; }

.play-close {
  padding: 9px 18px;
  border: 1px solid rgba(243, 239, 232, 0.35);
  border-radius: 999px;
  background: transparent;
  color: var(--paper);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}

.play-close:hover { background: var(--paper); color: var(--ink); }

@media (max-aspect-ratio: 21/20) {
  .play { padding: 64px 12px 24px; }
  .play-frame { width: 100%; aspect-ratio: 4 / 5; border-radius: 12px; }   /* the game lays itself out for touch */
  .play-hint { display: none; }
}

/* a soft paper backdrop behind each block of copy, so brass never fights type */
.panel::before {
  content: "";
  position: absolute;
  inset: -12% -16%;
  z-index: -1;
  background: radial-gradient(closest-side, rgba(243, 239, 232, 0.94), rgba(243, 239, 232, 0.72) 60%, rgba(243, 239, 232, 0));
  filter: blur(6px);
}

.panel a,
.panel button { pointer-events: auto; }

.panel[data-off] { visibility: hidden; }

.kicker {
  margin: 0 0 16px;
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
}

h1, h2 {
  margin: 0 0 20px;
  font-weight: 700;
  letter-spacing: -0.045em;
  line-height: 0.92;
}

h1 { font-size: clamp(3.4rem, 8.6vw, 8.4rem); }
h2 { font-size: clamp(2.4rem, 4.8vw, 4.4rem); }
.panel-detail h2 { font-size: clamp(2rem, 3.6vw, 3.2rem); }

.lede {
  margin: 0 0 26px;
  max-width: 28rem;
  font-size: clamp(1rem, 1.15vw, 1.12rem);
  line-height: 1.5;
  color: var(--muted);
}

.part-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
  max-width: 22rem;
}

.part-list li {
  display: flex;
  gap: 14px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.86rem;
  color: var(--muted);
}

.part-list span {
  flex: 0 0 7.2rem;
  color: var(--ink);
  font-weight: 700;
}

/* on wide screens the callouts carry these; the list stays for portrait/reduced */
@media (min-aspect-ratio: 21/20) {
  html[data-motion="full"] .part-list { display: none; }
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 22px;
}

.cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 24px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.cta:hover { background: var(--accent); }

.cta svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.cta-quiet {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 12px 22px;
}

.cta-quiet:hover { background: transparent; border-color: var(--ink); }

.back {
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
}

.back:hover { color: var(--ink); }

/* ---------------------------------------------------------------- callouts */

.callouts {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.callouts[data-off] { visibility: hidden; }

.callout {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  align-items: baseline;
  padding-left: 18px;
  white-space: nowrap;
  font-size: 0.78rem;
  line-height: 1.2;
  will-change: transform;
}

.callout[data-hidden] { visibility: hidden; }

.callout i {
  grid-row: 1 / span 2;
  position: relative;
  display: block;
  width: 8px;
  height: 8px;
  margin-top: 2px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(243, 239, 232, 0.9);
}

.callout i::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 3.5px;
  width: 64px;
  height: 1px;
  background: var(--ink);
}

.callout b {
  grid-column: 2;
  grid-row: 1;
  margin-left: 70px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.callout em {
  grid-column: 2;
  grid-row: 2;
  margin-left: 70px;
  font-style: normal;
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.callout-left { direction: rtl; }
.callout-left i::before { left: auto; right: 8px; }
.callout-left b, .callout-left em { margin-left: 0; margin-right: 70px; direction: ltr; }
.callout-left { transform-origin: right top; }

/* --------------------------------------------------------------------- hint */

.scroll-hint {
  position: fixed;
  left: 50%;
  bottom: clamp(60px, 8vh, 90px);
  transform: translateX(-50%);
  margin: 0;
  font-size: 0.7rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--muted);
}

.scroll-hint::after {
  content: "";
  display: block;
  margin: 8px auto 0;
  width: 1px;
  height: 26px;
  background: var(--ink);
  opacity: 0.6;
}

.scroll-hint[data-off] { visibility: hidden; }

/* --------------------------------------------------------------- no script */

html[data-objective="loading"] .scroll-hint { visibility: hidden; }

/* ---------------------------------------------------------------- fallback */

.fallback {
  display: none;
  position: relative;
  z-index: 3;
  margin: 0 var(--gutter) 32px;
  padding: 22px 24px;
  max-width: 34rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fffdf8;
}

.fallback h2 { font-size: 1.15rem; margin-bottom: 8px; letter-spacing: -0.01em; }
.fallback p { margin: 0; color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.fallback-reason { margin-top: 10px !important; font-size: 0.8rem !important; }
.fallback-reason[hidden] { display: none; }

html[data-webgl="failed"] #fallback { display: block; }
.fallback-forced { display: block; margin-top: 120px; }

/* ------------------------------------------------------------------ credit */

.credit {
  position: fixed;
  z-index: 4;
  left: var(--gutter);
  right: var(--gutter);
  bottom: clamp(12px, 1.6vh, 20px);
  margin: 0;
  pointer-events: none;
}

.credit p {
  display: inline-block;
  margin: 0;
  max-width: 52rem;
  padding: 5px 10px;
  border-radius: 8px;
  background: rgba(243, 239, 232, 0.82);
  backdrop-filter: blur(6px);
  font-size: 0.68rem;
  line-height: 1.45;
  color: var(--muted);
}

.credit b { color: var(--ink); font-weight: 700; }

/* ------------------------------------------------------------- scroll space */

#scrollspace {
  position: relative;
  height: 760vh;
}

/* progress = scrollY / (760vh − 100vh). 0.44 → 290vh, 0.79 → 521vh, 0.96 → 634vh. */
.anchor-parts { top: 290vh; }
.anchor-lens { top: 521vh; }
.anchor-closer { top: 634vh; }

/* -------------------------------------------------------------- focus ring */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- portrait */

@media (max-aspect-ratio: 21/20) {
  .stage {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    align-items: start;
    padding: clamp(72px, 10vh, 104px) clamp(20px, 6vw, 40px) clamp(96px, 12vh, 130px);
  }

  .panel { max-width: none; }
  .panel::before { inset: -8% -10%; }
  .panel-hero { grid-column: 1; grid-row: 1; align-self: start; }
  .panel-detail { grid-column: 1; grid-row: 3; align-self: end; justify-self: stretch; max-width: none; }
  .panel-outro { grid-column: 1; grid-row: 3; align-self: end; justify-self: stretch; }
  .panel-lens { grid-column: 1; grid-row: 3; align-self: end; max-width: none; }
  .panel-lens h2 { font-size: clamp(1.8rem, 9vw, 2.8rem); }
  html[data-motion="full"] .panel-lens .lede { display: none; }

  .callouts { display: none; }
  .index { display: none; }
  .topnav a:not(.topnav-cta) { display: none; }

  h1 { font-size: clamp(3rem, 17vw, 5.2rem); margin-bottom: 14px; }
  h2 { font-size: clamp(2rem, 10vw, 3.2rem); margin-bottom: 12px; }
  .panel-detail h2 { font-size: clamp(1.8rem, 9vw, 2.8rem); }
  .lede { font-size: 15px; line-height: 1.45; max-width: 34ch; margin-bottom: 18px; }
  .part-list { max-width: none; }
  html[data-motion="full"] .panel-detail .lede { display: none; }
  .part-list li { padding: 7px 0; font-size: 0.82rem; }
  .part-list span { flex-basis: 6.4rem; }
  .cta { padding: 12px 20px; }
  .scroll-hint { left: auto; right: clamp(20px, 6vw, 40px); transform: none; }
  .credit p { font-size: 0.62rem; }
}

/* ------------------------------------------------- static: reduced / failed */

html[data-motion="reduced"] .scroll-hint,
html[data-motion="reduced"] .progress,
html[data-motion="reduced"] .index,
html[data-webgl="failed"] .scroll-hint,
html[data-webgl="failed"] .progress,
html[data-webgl="failed"] .index { display: none; }

html[data-motion="reduced"] #scrollspace,
html[data-webgl="failed"] #scrollspace { height: 0; }

html[data-motion="reduced"] #scrollspace .anchor-point,
html[data-webgl="failed"] #scrollspace .anchor-point { top: 0; }

html[data-motion="reduced"] .stage,
html[data-webgl="failed"] .stage {
  position: relative;
  display: block;
  padding: clamp(96px, 14vh, 150px) var(--gutter) 40px;
  max-width: 44rem;
}

html[data-motion="reduced"] .panel,
html[data-webgl="failed"] .panel {
  opacity: 1 !important;
  visibility: visible !important;
  max-width: none;
  margin-bottom: 52px;
}

html[data-motion="reduced"] .panel::before,
html[data-webgl="failed"] .panel::before { inset: -6% -8%; }

html[data-motion="reduced"] .callouts,
html[data-webgl="failed"] .callouts { display: none; }

html[data-motion="reduced"] .panel-lens,
html[data-webgl="failed"] .panel-lens { color: var(--ink); }
html[data-motion="reduced"] .panel-lens .kicker, html[data-motion="reduced"] .panel-lens .lede, html[data-motion="reduced"] .caption,
html[data-webgl="failed"] .panel-lens .kicker, html[data-webgl="failed"] .panel-lens .lede, html[data-webgl="failed"] .caption { color: var(--muted); }
html[data-motion="reduced"] .caption b, html[data-webgl="failed"] .caption b { color: var(--ink); }
html[data-motion="reduced"] .caption, html[data-webgl="failed"] .caption { position: static; padding: 10px 0; border-bottom: 1px solid var(--line); }
html[data-motion="reduced"] .captions, html[data-webgl="failed"] .captions { border-top: 1px solid var(--line); }

html[data-motion="reduced"] .part-list,
html[data-webgl="failed"] .part-list { display: block !important; }

html[data-motion="reduced"] .scene {
  position: fixed;
  z-index: 0;
}

html[data-motion="reduced"] .credit,
html[data-webgl="failed"] .credit {
  position: static;
  padding: 0 var(--gutter) 48px;
}
