/* How a machine sees depth · Balluff register
   Grammar: RED = light the sensor emits. BLUE = data measured back.
   Achromatic base, hairline borders, square corners, flat surfaces. */

@font-face {
  font-family: "Roboto Flex";
  src: url("../assets/fonts/RobotoFlex-VariableFont.ttf") format("truetype-variations");
  font-weight: 100 1000;
  font-stretch: 25% 151%;
  font-style: normal;
  font-display: swap;
}

:root {
  --black: #1d1d1b;
  --white: #ffffff;
  --red: #e73446;
  --gray-50: #f5f5f5;
  --gray-200: #e6e6e6;
  --gray-400: #9e9e9e;
  --gray-600: #6b6b6a;
  --gray-800: #414140;
  /* data-accent palette (measurement, never decoration) */
  --data-blue: #6a9dc6;
  --data-cyan: #70bfd7;
  --data-gray: #94a7b4;
  --data-silver: #bcbcbc;
  --data-teal: #a3c7c7;
  --data-green: #779389;
  /* instrument stage (dark panels the optics live on) */
  --stage-bg: #0e0e0d;
  --stage-bg-2: #141413;
  --stage-line: #2b2b29;
  --stage-line-2: #3a3a38;
  --stage-text: #b9b9b6;
  --stage-text-dim: #7c7c79;
  --font: "Roboto Flex", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-optical-sizing: auto;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font);
  font-optical-sizing: auto;
  color: var(--black);
  background: var(--white);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--red); color: #fff; }

a { color: inherit; text-decoration-color: var(--gray-400); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--red); }

strong { font-weight: 660; }
em { font-style: italic; }

/* ── rail ─────────────────────────────────────────────────── */
.rail {
  position: fixed; inset: 0 0 auto 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  height: 52px; padding: 0 20px;
  background: rgba(19, 19, 18, 0.92);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  color: #d9d9d6;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.8125rem;
}
.rail .wordmark { height: 15px; display: block; }
.rail .div { width: 1px; height: 18px; background: rgba(255,255,255,0.22); }
.rail .ctx { color: #b7b7b4; letter-spacing: 0.01em; white-space: nowrap; }
.rail .spacer { flex: 1; }
.rail .legend { display: flex; gap: 14px; align-items: center; color: #9c9c99; font-size: 0.75rem; white-space: nowrap; }
.rail .legend .key { display: inline-flex; align-items: center; gap: 6px; }
.rail .legend .sw { width: 14px; height: 3px; display: inline-block; }
.rail .legend .sw.red { background: var(--red); box-shadow: 0 0 6px rgba(231,52,70,0.8); }
.rail .legend .sw.blue { background: var(--data-cyan); }
.rail nav.toc { display: flex; gap: 5px; align-items: center; }
.rail nav.toc a {
  width: 9px; height: 9px; border: 1px solid #6f6f6c; display: block;
  text-decoration: none; transition: background 0.2s, border-color 0.2s;
}
.rail nav.toc a:hover { border-color: #d9d9d6; }
.rail nav.toc a.active { background: var(--red); border-color: var(--red); }
.rail nav.toc a.seen:not(.active) { background: #555552; }

@media (max-width: 760px) {
  .rail { gap: 10px; padding: 0 14px; }
  .rail .ctx, .rail .legend .lab { display: none; }
}

/* ── hero ─────────────────────────────────────────────────── */
.hero {
  background: var(--stage-bg);
  color: #e8e8e5;
  padding: 52px 0 0;
  position: relative;
  min-height: 100vh;
  display: flex; flex-direction: column; justify-content: flex-start;
  overflow: hidden;
}
.hero-inner {
  max-width: 1240px; margin: 0 auto; padding: 84px 24px 0; width: 100%;
  position: relative; z-index: 2; pointer-events: none;
}
.hero-inner a { pointer-events: auto; }
.eyebrow {
  font-size: 0.8125rem; font-weight: 560; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--gray-400); margin: 0 0 14px;
}
.hero .eyebrow { color: #8f8f8c; }
.hero .eyebrow .rd { color: var(--red); }
h1 {
  margin: 0 0 20px;
  font-size: clamp(2.7rem, 6.4vw, 4.5rem);
  line-height: 1.02;
  font-weight: 640;
  font-stretch: 88%;
  letter-spacing: -0.015em;
  max-width: 15ch;
}
.hero .lede {
  font-size: clamp(1.05rem, 1.6vw, 1.25rem);
  line-height: 1.55; color: #c9c9c6; max-width: 52ch; margin: 0 0 10px;
}
.hero .lede strong { color: #fff; font-weight: 620; }
.hero-grammar {
  display: flex; gap: 22px; margin: 22px 0 0; font-size: 0.875rem; color: #a8a8a5;
  flex-wrap: wrap;
}
.hero-grammar .key { display: inline-flex; align-items: center; gap: 8px; }
.hero-grammar .sw { width: 22px; height: 4px; }
.hero-grammar .sw.red { background: var(--red); box-shadow: 0 0 10px rgba(231,52,70,0.75); }
.hero-grammar .sw.blue { background: var(--data-cyan); }

.hero-stage { position: absolute; inset: 52px 0 0 0; z-index: 1; }
.hero-stage canvas {
  display: block; width: 100%; height: 100%;
  cursor: crosshair; touch-action: pan-y;
}
@media (max-width: 900px) {
  .hero { min-height: 108vh; }
  .hero-stage { inset: 52px 0 0 0; }
}
.hero-hud {
  position: absolute; left: 24px; bottom: 18px; z-index: 3;
  font-size: 0.8125rem; color: #9c9c99; display: flex; gap: 18px; align-items: baseline;
  pointer-events: none;
}
.hero-hud .n { color: var(--data-cyan); font-weight: 600; font-variant-numeric: tabular-nums; }
.hero-scroll {
  position: absolute; right: 24px; bottom: 18px; z-index: 3;
  font-size: 0.8125rem; color: #7c7c79; pointer-events: none;
}

/* ── beats (chapters) ─────────────────────────────────────── */
main { display: block; }
.beat { padding: 96px 0 40px; border-top: 1px solid var(--gray-200); }
.beat.dark { background: var(--stage-bg); color: #e2e2df; border-top-color: #242422; }
.beat-inner { max-width: 1240px; margin: 0 auto; padding: 0 24px; }
.beat .eyebrow .fam { color: var(--gray-600); font-weight: 460; text-transform: none; letter-spacing: 0.02em; }
.beat h2 {
  margin: 0 0 18px;
  font-size: clamp(1.9rem, 3.6vw, 2.7rem);
  line-height: 1.08; font-weight: 620; font-stretch: 92%;
  letter-spacing: -0.012em; max-width: 24ch;
}
.beat-lede { font-size: 1.0925rem; line-height: 1.62; color: var(--gray-800); max-width: 68ch; margin: 0 0 8px; }
.beat.dark .beat-lede { color: #bcbcb9; }
.beat-lede strong { color: var(--black); }
.beat.dark .beat-lede strong { color: #fff; }

/* family chip */
.famchip {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--gray-200); color: var(--gray-600);
  padding: 4px 10px; margin-left: 12px; vertical-align: 2px;
}
.famchip .dot { width: 7px; height: 7px; }
.famchip.angle .dot { background: var(--red); }
.famchip.time .dot { background: var(--data-blue); }
.famchip.focus .dot { background: var(--data-teal); }

/* ── the three ideas ──────────────────────────────────────── */
.ideas-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0; margin-top: 40px; border: 1px solid var(--gray-200); }
.idea { display: block; text-decoration: none; border-right: 1px solid var(--gray-200); background: var(--white); }
.idea:last-child { border-right: none; }
.idea canvas { display: block; width: 100%; height: 170px; background: var(--stage-bg); }
.idea-body { padding: 18px 20px 20px; }
.idea h3 { margin: 0 0 8px; font-size: 1.05rem; font-weight: 640; display: flex; align-items: center; gap: 9px; }
.idea h3 .dot { width: 9px; height: 9px; flex: none; }
.idea h3 .dot.angle { background: var(--red); }
.idea h3 .dot.time { background: var(--data-blue); }
.idea h3 .dot.focus { background: var(--data-teal); }
.idea p { margin: 0; font-size: 0.875rem; color: var(--gray-600); line-height: 1.55; }
.idea:hover h3 { color: var(--red); }
@media (max-width: 900px) {
  .ideas-grid { grid-template-columns: 1fr; }
  .idea { border-right: none; border-bottom: 1px solid var(--gray-200); }
  .idea:last-child { border-bottom: none; }
}

/* ── sim panel layout ─────────────────────────────────────── */
.sim { margin: 40px 0 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0; border: 1px solid var(--gray-200); }
.sim .stage { position: relative; background: var(--stage-bg); min-height: 380px; }
.sim .stage canvas { display: block; width: 100%; height: 100%; position: absolute; inset: 0; touch-action: none; }
.sim .panel {
  border-left: 1px solid var(--gray-200); background: var(--white);
  padding: 22px 22px 18px; display: flex; flex-direction: column; gap: 18px;
  font-size: 0.9rem;
}
.beat.dark .sim { border-color: var(--stage-line); }
.beat.dark .sim .panel { background: var(--stage-bg-2); border-left-color: var(--stage-line); color: #cfcfcc; }

.sim figcaption, .sim .caption {
  grid-column: 1 / -1; border-top: 1px solid var(--gray-200);
  padding: 12px 18px; font-size: 0.845rem; color: var(--gray-600); line-height: 1.55;
}
.beat.dark .sim figcaption, .beat.dark .sim .caption { border-top-color: var(--stage-line); color: #8f8f8c; }

#line .stage, #scan .stage, #fringe .stage, #stereo .stage { min-height: 470px; }
@media (max-width: 900px) {
  .sim { grid-template-columns: 1fr; }
  .sim .stage { min-height: 340px; }
  #line .stage, #scan .stage, #fringe .stage, #stereo .stage { min-height: 560px; }
  .sim .panel { border-left: none; border-top: 1px solid var(--gray-200); }
  .beat.dark .sim .panel { border-top-color: var(--stage-line); }
}

/* controls */
.ctl-label {
  display: block; font-size: 0.75rem; font-weight: 600; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--gray-600); margin: 0 0 8px;
}
.beat.dark .ctl-label { color: #8f8f8c; }
.slider-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.readout { font-variant-numeric: tabular-nums; font-weight: 640; font-size: 1rem; color: var(--black); white-space: nowrap; }
.beat.dark .readout { color: #fff; }
.readout .u { font-weight: 440; color: var(--gray-600); font-size: 0.85em; }
.beat.dark .readout .u { color: #8f8f8c; }
.ctl-hint { font-size: 0.8rem; color: var(--gray-600); margin: 6px 0 0; line-height: 1.5; }
.beat.dark .ctl-hint { color: #8f8f8c; }

input[type="range"] {
  width: 100%; margin: 10px 0 0; appearance: none; -webkit-appearance: none;
  height: 26px; background: transparent; cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: var(--gray-200); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -7px;
  background: var(--white); border: 2px solid var(--black); border-radius: 0;
}
input[type="range"]:active::-webkit-slider-thumb, input[type="range"]:focus-visible::-webkit-slider-thumb { border-color: var(--red); }
input[type="range"]::-moz-range-track { height: 2px; background: var(--gray-200); }
input[type="range"]::-moz-range-thumb { width: 12px; height: 12px; background: var(--white); border: 2px solid var(--black); border-radius: 0; }
.beat.dark input[type="range"]::-webkit-slider-runnable-track { background: var(--stage-line-2); }
.beat.dark input[type="range"]::-webkit-slider-thumb { background: var(--stage-bg-2); border-color: #d9d9d6; }
.beat.dark input[type="range"]:active::-webkit-slider-thumb { border-color: var(--red); }

/* segmented buttons */
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg button {
  font: inherit; font-size: 0.8125rem; font-weight: 560;
  padding: 7px 12px; background: var(--white); color: var(--gray-800);
  border: 1px solid var(--gray-200); cursor: pointer; border-radius: 0;
}
.seg button:hover { border-color: var(--gray-400); }
.seg button[aria-pressed="true"] { background: var(--black); color: #fff; border-color: var(--black); }
.beat.dark .seg button { background: var(--stage-bg-2); color: #cfcfcc; border-color: var(--stage-line-2); }
.beat.dark .seg button:hover { border-color: #6f6f6c; }
.beat.dark .seg button[aria-pressed="true"] { background: #e8e8e5; color: var(--black); border-color: #e8e8e5; }

button.action {
  font: inherit; font-size: 0.875rem; font-weight: 620; letter-spacing: 0.01em;
  padding: 11px 16px; background: var(--red); color: #fff; border: none; cursor: pointer;
  border-radius: 0; width: 100%;
}
button.action:hover { background: #d02638; }
button.action:disabled { background: var(--gray-200); color: var(--gray-400); cursor: default; }
button.ghost {
  font: inherit; font-size: 0.8125rem; font-weight: 560;
  padding: 8px 12px; background: transparent; color: var(--gray-800);
  border: 1px solid var(--gray-400); cursor: pointer; border-radius: 0;
}
.beat.dark button.ghost { color: #cfcfcc; border-color: var(--stage-line-2); }
.beat.dark button.ghost:hover { border-color: #8f8f8c; }
button.ghost:disabled { opacity: 0.35; cursor: default; }
button.ghost:disabled:hover { border-color: var(--gray-400); }

/* metric block */
.metric { border: 1px solid var(--gray-200); padding: 12px 14px; }
.beat.dark .metric { border-color: var(--stage-line); }
.metric .k { font-size: 0.72rem; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--gray-600); }
.beat.dark .metric .k { color: #8f8f8c; }
.metric .v { font-size: 1.35rem; font-weight: 660; font-variant-numeric: tabular-nums; line-height: 1.25; margin-top: 2px; }
.metric .v .u { font-size: 0.8em; font-weight: 460; color: var(--gray-600); }
.beat.dark .metric .v .u { color: #8f8f8c; }
.metric .n { font-size: 0.8rem; color: var(--gray-600); line-height: 1.45; margin-top: 4px; }
.beat.dark .metric .n { color: #8f8f8c; }
.metric.hot .v { color: var(--red); }

/* trade-off twin bars */
.twinbar { display: grid; gap: 8px; }
.twinbar .row { display: grid; grid-template-columns: 88px 1fr 68px; align-items: center; gap: 10px; font-size: 0.78rem; }
.twinbar .lab { color: var(--gray-600); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; font-size: 0.7rem; }
.beat.dark .twinbar .lab { color: #8f8f8c; }
.twinbar .bar { height: 6px; background: var(--gray-200); position: relative; }
.beat.dark .twinbar .bar { background: var(--stage-line); }
.twinbar .bar .fill { position: absolute; inset: 0 auto 0 0; background: var(--data-blue); transition: width 0.12s linear; }
.twinbar .bar .fill.warn { background: var(--red); }
.twinbar .val { font-variant-numeric: tabular-nums; font-weight: 620; text-align: right; font-size: 0.8rem; }

/* prose annotations under sims */
.afterword { max-width: 68ch; margin: 26px 0 0; font-size: 0.975rem; color: var(--gray-800); line-height: 1.65; }
.beat.dark .afterword { color: #b3b3b0; }
.afterword strong { color: var(--black); }
.beat.dark .afterword strong { color: #fff; }

/* footnote / honesty line */
.caveat { font-size: 0.8rem; color: var(--gray-600); margin: 14px 0 0; max-width: 70ch; line-height: 1.5; }
.beat.dark .caveat { color: #7c7c79; }

/* ── gauntlet ─────────────────────────────────────────────── */
.gzones { margin-top: 36px; }
.gnote { font-size: 0.875rem; color: #8f8f8c; margin: 14px 0 22px; max-width: 70ch; }
.ggrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.gtile { border: 1px solid var(--stage-line); background: var(--stage-bg-2); padding: 12px 14px 14px; }
.gtile .gname { display: flex; justify-content: space-between; align-items: baseline; font-size: 0.9rem; font-weight: 640; margin-bottom: 10px; }
.gtile .gname a { font-size: 0.72rem; font-weight: 500; color: #8f8f8c; text-decoration-color: #4a4a48; }
.gtile canvas { display: block; width: 100%; height: 84px; margin-bottom: 10px; }
.gtile .gverdict { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.09em; text-transform: uppercase; margin-bottom: 5px; }
.gtile[data-verdict="g"] .gverdict { color: var(--data-cyan); }
.gtile[data-verdict="m"] .gverdict { color: #d9a441; }
.gtile[data-verdict="p"] .gverdict { color: var(--red); }
.gtile .gwhy { font-size: 0.8rem; color: #9c9c99; line-height: 1.5; }

/* ── reference table ──────────────────────────────────────── */
.tablewrap { overflow-x: auto; margin-top: 36px; border: 1px solid var(--gray-200); }
.maptable { border-collapse: collapse; width: 100%; min-width: 860px; font-size: 0.875rem; }
.maptable th {
  text-align: left; font-size: 0.72rem; font-weight: 640; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--gray-600);
  padding: 12px 16px; border-bottom: 1px solid var(--black); background: var(--gray-50);
}
.maptable td { padding: 12px 16px; border-bottom: 1px solid var(--gray-200); vertical-align: top; line-height: 1.5; color: var(--gray-800); }
.maptable tr:last-child td { border-bottom: none; }
.maptable td:first-child { font-weight: 640; color: var(--black); white-space: nowrap; }
.maptable td:first-child a { text-decoration: none; }
.maptable td:first-child a:hover { color: var(--red); }

/* ── chooser ──────────────────────────────────────────────── */
.chq { margin: 26px 0 0; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 4px; }
.chips button {
  font: inherit; font-size: 0.875rem; font-weight: 540;
  padding: 9px 14px; background: var(--white); color: var(--gray-800);
  border: 1px solid var(--gray-200); cursor: pointer; border-radius: 0;
}
.chips button:hover { border-color: var(--gray-400); }
.chips button[aria-pressed="true"] { background: var(--black); color: #fff; border-color: var(--black); }
.chprogress { margin: 30px 0 0; font-size: 0.9rem; color: var(--gray-600); }
.chresults { margin-top: 8px; }
.fitcard { border: 1px solid var(--gray-200); padding: 18px 20px; margin-top: 18px; }
.fitcard.top { border-color: var(--black); border-width: 2px; }
.fitcard .fitrank { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--gray-600); }
.fitcard.top .fitrank { color: var(--red); }
.fitcard h3 { margin: 4px 0 10px; font-size: 1.25rem; font-weight: 660; }
.fitcard h3 a { font-size: 0.78rem; font-weight: 500; color: var(--gray-600); margin-left: 8px; }
.fitbar { display: block; height: 5px; background: var(--gray-50); margin: 0 0 12px; }
.fitbar span { display: block; height: 100%; background: var(--data-blue); }
.fitcard.top .fitbar span { background: var(--red); }
.fitcard ul { margin: 0; padding: 0 0 0 18px; font-size: 0.9rem; line-height: 1.55; color: var(--gray-800); }
.fitcard li.plus::marker { content: "+ "; color: var(--data-blue); font-weight: 700; }
.fitcard li.minus::marker { content: "− "; color: var(--gray-400); font-weight: 700; }
.chothers { font-size: 0.875rem; color: var(--gray-600); margin: 18px 0 0; }
.chout { margin-top: 26px; border-top: 1px solid var(--gray-200); padding-top: 16px; }
.chout p { font-size: 0.875rem; color: var(--gray-600); margin: 8px 0 0; max-width: 75ch; }
.chout a { font-size: 0.8rem; }

/* ── footer ───────────────────────────────────────────────── */
footer {
  background: var(--stage-bg); color: #9c9c99; margin-top: 80px;
  padding: 44px 0 52px; font-size: 0.845rem; line-height: 1.6;
}
footer .beat-inner { display: grid; gap: 18px; }
footer .wordmark { height: 16px; }
footer a { color: #c9c9c6; }
