/* ===========================================================
   home.css — homepage "TECHNICAL DOCUMENT" experience
   Static-first: with no JS every section renders as a normal
   document. home-boot.js adds html.js3d (full scene) or
   html.m-simple (mobile simplified) or html.static3d (fallback);
   only then do the scroll-stage rules below kick in.
   =========================================================== */

:root {
  --paper: #fcfcfa;
  --ink: #16161c;
  --ink-soft: #5a5a60;
  --red: #e8362d;
  --hairline: rgba(22, 22, 28, 0.12);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

/* The homepage is light by design — the 3D scene is a bright studio. */
body.home {
  background: var(--paper);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Engineering vellum: 1px grid at 4% opacity */
body.home::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    linear-gradient(rgba(22,22,28,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22,22,28,0.04) 1px, transparent 1px);
  background-size: 56px 56px;
}

body.home .nav {
  background: rgba(252, 252, 250, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--hairline);
}
body.home .nav a { color: var(--ink); }

main { position: relative; z-index: 1; }

/* ---------- WebGL canvas ---------- */
#gl {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  transition: opacity 0.5s ease;
}
.js3d #gl, .m-simple #gl { display: block; }

/* ---------- Progress rule ---------- */
.progress-rule {
  display: none;
  position: fixed;
  top: 0; right: 0;
  width: 3px; height: 100vh;
  z-index: 50;
  background: rgba(22,22,28,0.07);
}
.js3d .progress-rule, .m-simple .progress-rule { display: block; }
.progress-rule .pr-fill {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 0%;
  background: var(--red);
}
.progress-rule .pr-tick {
  position: absolute;
  right: 0;
  width: 9px; height: 1px;
  background: var(--ink);
  opacity: 0.55;
}

/* ---------- Shared typography ---------- */
.sht-ref {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--red);
  margin: 0 0 18px;
}
.anno {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.chapter h1 {
  font-size: clamp(54px, 8vw, 118px);
  font-weight: 750;
  letter-spacing: -0.04em;
  line-height: 0.98;
  margin: 0 0 26px;
  color: var(--ink);
}
.chapter h1 em, .promise em { font-style: normal; color: var(--red); }
.chapter h2 {
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.02;
  margin: 0 0 18px;
  color: var(--ink);
}
.lede {
  font-size: clamp(16px, 1.6vw, 20px);
  line-height: 1.55;
  color: var(--ink-soft);
  max-width: 560px;
  margin: 0 0 32px;
}

/* ---------- Buttons ---------- */
.cta-row { display: flex; gap: 14px; flex-wrap: wrap; }
.btn-tech {
  display: inline-block;
  padding: 14px 28px;
  border: 1.5px solid var(--ink);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  background: var(--paper);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-tech:hover { transform: translateY(-2px); box-shadow: 0 4px 0 0 var(--ink); }
.btn-tech-primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}
.btn-tech-primary:hover { box-shadow: 0 4px 0 0 #a82018; }

/* ---------- Chapters: STATIC layout (default, no JS) ---------- */
.chapter { position: relative; padding: 110px 0 70px; }
.ch-frame { position: relative; }
.hero-static { display: block; max-width: min(680px, 92%); height: auto; margin: 48px 0 0; }
.scroll-cue { display: none; }

/* ---------- Chapters: 3D scroll-stage layout ---------- */
.js3d #stage { height: 560vh; position: relative; }
.js3d .chapter {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  padding: 0;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 2;
}
.js3d .chapter.active { visibility: visible; pointer-events: auto; }
.js3d .chapter .ch-frame { width: 100%; }
.js3d .hero-static { display: none; }
.js3d .ch1 .scroll-cue {
  display: block;
  position: absolute;
  bottom: -22vh;
  left: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: var(--ink-soft);
  animation: cue-bob 2.2s ease-in-out infinite;
}
@keyframes cue-bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(7px); } }

/* CH1: copy sits left, document renders right of center */
.js3d .ch1 .ch-frame { max-width: 1200px; }
.js3d .ch1 h1, .js3d .ch1 .lede, .js3d .ch1 .cta-row, .js3d .ch1 .hero-anno { max-width: 620px; }
.hero-anno { margin-top: 26px; }

/* CH2 annotations */
.anno-list { list-style: none; margin: 26px 0 0; padding: 0; max-width: 520px; }
.anno-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--ink);
  padding: 11px 0;
  border-bottom: 1px solid var(--hairline);
  display: flex;
  align-items: center;
  gap: 12px;
}
.anno-label .dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--red);
  flex: none;
  position: relative;
}
.anno-label .dot::after {
  content: "";
  position: absolute;
  left: 7px; top: 3px;
  width: 26px; height: 1px;
  background: var(--ink);
  opacity: 0.5;
}
.anno-label a { color: var(--red); text-decoration: none; text-transform: none; letter-spacing: 0.02em; }
.anno-label a:hover { text-decoration: underline; }
.js3d .ch2 .ch-frame { max-width: 1240px; }
.js3d .ch2 h2, .js3d .ch2 .lede, .js3d .ch2 .anno-list { max-width: 460px; }

/* CH3 bench cards */
.bench-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; margin-top: 8px; }
.bench-card {
  display: block;
  border: 1px solid var(--hairline);
  background: rgba(255,255,255,0.82);
  padding: 22px 20px 18px;
  text-decoration: none;
  color: var(--ink);
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.bench-card:hover { transform: translateY(-3px); border-color: var(--ink); }
.bench-card .bc-num { font-family: var(--mono); font-size: 11px; color: var(--red); letter-spacing: 0.14em; }
.bench-card h3 { margin: 8px 0 8px; font-size: 22px; font-weight: 750; letter-spacing: -0.02em; }
.bench-card p { margin: 0 0 16px; font-size: 13.5px; line-height: 1.5; color: var(--ink-soft); }
.bench-card .bc-go { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.14em; color: var(--ink); }
.bench-card:hover .bc-go { color: var(--red); }
/* In 3D mode cards appear one at a time, pinned right of the vignette */
.js3d .ch3 .bench-cards { display: block; max-width: 380px; margin-left: auto; margin-right: 6vw; position: relative; height: 280px; }
.js3d .ch3 .bench-card { position: absolute; inset: 0; opacity: 0; transform: translateY(24px); }

/* CH4 promise */
.strike-list { list-style: none; margin: 0 0 34px; padding: 0; display: flex; flex-wrap: wrap; gap: 10px 26px; }
.strike-list s {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-soft);
  text-decoration-color: var(--red);
  text-decoration-thickness: 1.5px;
}
.promise { font-size: clamp(40px, 6vw, 84px); }
.js3d .ch4 .ch-frame { text-align: center; }
.js3d .ch4 .strike-list { justify-content: center; }
.js3d .strike-list li { opacity: 0; transform: translateY(14px); }

/* ---------- CH5 index zone (always plain DOM) ---------- */
.index-zone { position: relative; z-index: 3; background: var(--paper); }
section.index-zone { padding: 90px 0 40px; }
.index-zone .section-title { color: var(--ink); }
.index-zone .section-sub { color: var(--ink-soft); }

.tool-index { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 36px 28px; margin-top: 44px; }
.ti-cat {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--red);
  border-bottom: 1px solid var(--ink);
  padding-bottom: 8px;
  margin: 0 0 6px;
}
.ti-group a {
  display: block;
  padding: 11px 2px;
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
  color: var(--ink);
  transition: padding-left 0.15s ease;
}
.ti-group a:hover { padding-left: 8px; }
.ti-group a:hover strong { color: var(--red); }
.ti-group a strong { display: block; font-size: 15.5px; font-weight: 650; letter-spacing: -0.01em; }
.ti-group a span { display: block; font-size: 12.5px; color: var(--ink-soft); margin-top: 2px; }

body.home .faq-item { background: rgba(255,255,255,0.8); border: 1px solid var(--hairline); }
body.home .faq-item summary { color: var(--ink); }
body.home .faq-item p { color: var(--ink-soft); }

body.home .footer { background: var(--paper); border-top: 1px solid var(--ink); position: relative; z-index: 3; }
body.home .footer a, body.home .footer h4, body.home .footer .brand-text { color: var(--ink); }
body.home .footer-tag, body.home .footer-bottom { color: var(--ink-soft); }

/* ---------- Mobile-simplified (.m-simple): CH1+CH2 scrub, CH3/CH4 normal flow ---------- */
.m-simple #stage { height: 260vh; position: relative; }
.m-simple .ch1, .m-simple .ch2 {
  position: fixed; inset: 0;
  display: flex; align-items: center;
  padding: 0;
  opacity: 0; visibility: hidden; pointer-events: none;
  z-index: 2;
}
.m-simple .chapter.active { visibility: visible; pointer-events: auto; }
.m-simple .hero-static { display: none; }
.m-simple .ch3, .m-simple .ch4 {
  position: relative; z-index: 3;
  background: var(--paper);
}

/* ---------- Static fallback (.static3d): everything flows, SVG hero ---------- */
.static3d #gl, .static3d .progress-rule { display: none !important; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .scroll-cue { animation: none; }
  .btn-tech, .bench-card, .ti-group a { transition: none; }
}

/* ---------- Small screens ---------- */
@media (max-width: 767px) {
  .chapter { padding: 84px 0 48px; }
  .js3d .ch3 .bench-cards { margin-right: 4vw; max-width: 320px; }
}
