/* =========================================================================
   /rig — the rig in 3D (hidden test page)
   Loaded after css/styles.css; uses its tokens (--bg, --accent, fonts…).
   Daylight: the 3D sits on the warm light tour stage (--stage), like the
   home page's tour; the canvas is transparent (core.js clears to alpha 0),
   so the stage colour shows through it.

   Modes (set on <html> by js/rig/boot.js before the first paint):
     .rig-full    live 3D: pinned stage, scroll-scrubbed storyboard
     .rig-static  poster + stacked copy (reduced motion, no WebGL 2,
                  save-data, low-end device, or the 3D failed to load)
     (no class)   no JavaScript at all: same as static
     .rig-mobile  phone / tablet LOD (layout itself uses media queries)
     .rig-poster  tools/rig/render-poster.mjs only: just the hero canvas
   ========================================================================= */

/* Fonts: the self-hosted @font-face rules are in css/styles.css (every
   page uses them now); rig.html preloads the three files. */

:root {
  --rig-stage-bg:
    radial-gradient(58% 40% at 50% 66%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 72%),
    radial-gradient(85% 70% at 50% 45%, #EDE9E1 0%, var(--stage) 70%);
  --rig-display: "Anton", "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
}

/* ---- Skip link --------------------------------------------------------
   First thing in the tab order, invisible until focused: jumps past the
   pinned storyboard (several screens long) to the part list. */
.rig-skip {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.7rem 1rem;
  border-radius: var(--pill);
  background: var(--accent);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-160%);
}
.rig-skip:focus,
.rig-skip:focus-visible { transform: none; outline: 2px solid var(--text); outline-offset: 2px; }
/* The skip target gets focus (tabindex="-1") so the next Tab continues
   from the part list; it is not itself a control, so no ring. */
#rig-specs { scroll-margin-top: var(--header-h); }
#rig-specs:focus { outline: none; }

/* Primary buttons: ink on Savannah Yellow (10.9:1) is now the site-wide
   .btn--primary in css/styles.css, so /rig needs no override. */

/* ---- Hero / storyboard layout ---------------------------------------- */
.rig-hero {
  position: relative;
  border-bottom: 1px solid var(--border);
}
.rig-hero__grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}
.rig-hero__stage-col { position: relative; min-width: 0; }
.rig-hero__copy { min-width: 0; padding: 1.75rem 1rem 3rem; }

/* The stage: poster and canvas stacked in the same box. */
.rig-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: var(--rig-stage-bg);
  overflow: hidden;
}
.rig-stage__poster,
.rig-stage__poster img,
.rig-stage__canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.rig-stage__poster img { object-fit: contain; }
.rig-stage__poster { transition: opacity 0.7s ease; }
.rig-stage__canvas {
  display: block;
  opacity: 0;
  transition: opacity 0.7s ease;
  touch-action: pan-y; /* never trap vertical scrolling on phones */
}
.rig-stage__canvas.is-ready { opacity: 1; }
/* Only while the page is in full mode: if the 3D drops to static mid-visit
   (a context lost, a chunk failing to load), every poster comes back, even
   on a stage whose own viewer was still live. */
.rig-full .rig-stage.is-live .rig-stage__poster { opacity: 0; }
html:not(.rig-full) .rig-stage__canvas { display: none; }

/* "Tap to load 3D" (phones, slow connections: boot.js puts html.rig-tap
   on the page). Sits over the bottom of the poster until tapped. */
.rig-load3d { display: none; }
.rig-tap .rig-load3d {
  display: inline-flex;
  position: absolute;
  left: 50%;
  bottom: 0.9rem;
  transform: translateX(-50%);
  z-index: 2;
  background: var(--bg);
}

/* Beat progress dots (story.js marks the current one .is-active). */
.rig-stage__progress {
  position: absolute;
  right: 0.9rem;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  list-style: none;
  pointer-events: none;
}
.rig-stage__progress li {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #B5AE9F;
  transition: background 0.3s ease, transform 0.3s ease;
}
.rig-stage__progress li.is-active { background: var(--accent); box-shadow: 0 0 0 1px var(--text); transform: scale(1.5); }
html:not(.rig-full) .rig-stage__progress { display: none; }

/* ---- Copy ------------------------------------------------------------ */
.rig-intro .eyebrow { margin-bottom: 0.9rem; }
.rig-display {
  font-family: var(--rig-display);
  font-weight: 400;
  text-transform: uppercase;
  font-size: clamp(2.3rem, 9vw, 4.4rem);
  line-height: 1.02;
  letter-spacing: 0.005em;
}
.rig-accent { color: var(--accent-bright); }
.rig-intro__sub {
  color: var(--muted);
  font-size: 1.08rem;
  margin-top: 1rem;
  max-width: 34rem;
}
.rig-cta { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 1.6rem; }
.rig-cta--center { justify-content: center; }
.rig-intro__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
  margin-top: 1.4rem;
  font-family: var(--font-head);
  font-size: 0.92rem;
  color: var(--silver);
}
.rig-intro__meta > span::before { content: "›"; color: var(--accent-ink); margin-right: 0.45rem; font-weight: 700; }
.rig-scroll-hint {
  margin-top: 2.2rem;
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted); /* --muted-2 is 4.48:1 on --bg: just under AA */
}
.rig-scroll-hint::after {
  content: "";
  display: block;
  width: 1px;
  height: 2.2rem;
  margin-top: 0.7rem;
  background: linear-gradient(var(--accent), transparent);
}
html:not(.rig-full) .rig-scroll-hint { display: none; }

.rig-beat {
  padding: 2.4rem 0 0;
  max-width: 34rem;
}
.rig-beat__num {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent-bright);
}
.rig-beat h2 {
  font-size: clamp(1.6rem, 5.5vw, 2.5rem);
  margin-top: 0.6rem;
}
.rig-beat p { color: var(--muted); margin-top: 0.9rem; font-size: 1.04rem; }
.rig-link { color: var(--text); text-decoration: underline; text-decoration-color: var(--accent-deep); text-decoration-thickness: 2px; text-underline-offset: 3px; }

.rig-callouts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.2rem;
}
.rig-callouts li {
  font-family: var(--font-head);
  font-size: 0.86rem;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--silver);
  background: var(--surface);
}
.rig-callouts li::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: middle;
  box-shadow: 0 0 0 1px rgba(21, 23, 26, 0.35);
}


/* ---- Phones / tablets: one column ------------------------------------ */
@media (max-width: 899px) {
  /* Full mode: the stage sticks under the header while the copy scrolls
     up beneath it. Static: it is just an image at the top. */
  .rig-full .rig-hero__stage-col {
    position: sticky;
    top: var(--header-h);
    z-index: 2;
    background: var(--bg);
  }
  .rig-full .rig-stage { aspect-ratio: auto; height: min(46svh, 75vw); }
  .rig-full .rig-beat {
    min-height: 62svh;
    padding-top: 3rem;
  }
  .rig-full .rig-beat:last-child { min-height: 0; padding-bottom: 2rem; }
  /* Tabbing to a link in the copy scrolls it into view: keep it clear of
     the sticky header + stage instead of underneath them. */
  .rig-full .rig-hero__copy a { scroll-margin-top: calc(var(--header-h) + min(46svh, 75vw) + 1rem); }
}

/* ---- Desktop: stage left (pinned), copy right ------------------------ */
@media (min-width: 900px) {
  .rig-hero__grid {
    grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr);
    max-width: 1600px;
    margin-inline: auto;
  }
  .rig-hero__stage-col {
    position: sticky;
    top: var(--header-h);
    align-self: start;
    height: calc(100vh - var(--header-h));
    height: calc(100svh - var(--header-h));
  }
  .rig-hero .rig-stage { aspect-ratio: auto; height: 100%; }
  .rig-hero__copy { padding: 0 clamp(1.5rem, 4vw, 4rem) 4rem clamp(1rem, 2vw, 2rem); }
  .rig-intro {
    min-height: calc(100svh - var(--header-h) - 2rem);
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding-block: 3rem;
  }
  .rig-display { font-size: clamp(2.6rem, 4.4vw, 4.6rem); }
  .rig-beat { padding-block: 3rem; }
  .rig-full .rig-beat {
    min-height: 78svh;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .rig-full .rig-beat:last-child { min-height: calc(100svh - var(--header-h)); }
}

/* ---- Part explorer: see css/rig-specs.css ---------------------------- */

/* The site's mobile menu is position: fixed inside the header, whose
   backdrop-filter makes the header its containing block, so the closed
   menu peeks out above the header while the announcement bar is on
   screen (all pages; see the core stage report). Hidden here for this
   page only until the shared stylesheet is fixed. */
@media (max-width: 760px) {
  .rig-page .nav-links:not(.is-open) { visibility: hidden; }
}

/* ---- Reduced motion -------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .rig-stage__poster,
  .rig-stage__canvas,
  .rig-panel,
  .rig-chip,
  .rig-stage__progress li { transition: none; }
}

/* ---- Poster render mode (tools/rig/render-poster.mjs) ---------------- */
.rig-poster body { background: transparent; }
.rig-poster .announce,
.rig-poster .site-header,
.rig-poster .rig-hero__copy,
.rig-poster .rig-stage__progress,
.rig-poster .rig-stage__poster,
.rig-poster #rig-specs,
.rig-poster main > section:not(#rig-hero),
.rig-poster .site-footer { display: none !important; }
.rig-poster .rig-hero__stage-col,
.rig-poster .rig-hero .rig-stage {
  position: fixed;
  left: 0;
  top: 0;
  width: 800px;
  height: 600px;
  aspect-ratio: auto;
  background: transparent;
}
