/* MetricVision project page. Theme: a stereo rig. Cyan = left camera, red = right camera (an anaglyph pair),
   faint horizontal "epipolar lines" in the header. Light and dark follow the system unless the toggle sets one. */

:root {
  --left: #0891b2;          /* cyan: left camera */
  --right: #e11d48;         /* red: right camera */
  --kept: #16a34a;          /* tracks kept */
  --gate: #d97706;          /* new modules / gate */
  --bg: #f7f8fb;
  --bg-alt: #eef1f7;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #475569;
  --line: #d9dee8;
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.06), 0 8px 24px rgba(15, 23, 42, 0.06);
  --hero-bg: #0b1020;
  --hero-text: #e6ebf5;
  --hero-muted: #9aa8c4;
  --hero-cyan: #22d3ee;
  --hero-red: #f43f5e;
  --radius: 14px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Space Grotesk", var(--font);
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --left: #22d3ee;
    --right: #fb7185;
    --kept: #4ade80;
    --gate: #fbbf24;
    --bg: #0d1324;
    --bg-alt: #111a30;
    --surface: #151f38;
    --text: #e6ebf5;
    --muted: #9aa8c4;
    --line: #26324f;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --left: #22d3ee;
  --right: #fb7185;
  --kept: #4ade80;
  --gate: #fbbf24;
  --bg: #0d1324;
  --bg-alt: #111a30;
  --surface: #151f38;
  --text: #e6ebf5;
  --muted: #9aa8c4;
  --line: #26324f;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--left); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--right); }
code { font-family: var(--mono); font-size: 0.9em; }
p code { background: var(--bg-alt); padding: 0.1em 0.35em; border-radius: 5px; }
.small { font-size: 0.9rem; color: var(--muted); }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 24px; }

/* ------------------------------------------------------------------ hero */
.hero {
  position: relative;
  color: var(--hero-text);
  background:
    repeating-linear-gradient(to bottom, rgba(148, 163, 184, 0.07) 0 1px, transparent 1px 28px),
    radial-gradient(900px 420px at 12% 0%, rgba(34, 211, 238, 0.16), transparent 70%),
    radial-gradient(900px 420px at 92% 100%, rgba(244, 63, 94, 0.14), transparent 70%),
    var(--hero-bg);
  overflow: hidden;
}

.nav {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1120px;
  margin: 0 auto;
  padding: 16px 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--hero-text); text-decoration: none; font-family: var(--display); font-weight: 600; font-size: 1.1rem; }
.brand:hover { color: var(--hero-text); }
.brand svg { width: 28px; height: 28px; fill: none; stroke-width: 3; }
.brand svg circle:first-child { stroke: var(--hero-cyan); }
.brand svg circle:last-child { stroke: var(--hero-red); mix-blend-mode: screen; }
.nav-links { display: flex; gap: 20px; margin-left: auto; }
.nav-links a { color: var(--hero-muted); text-decoration: none; font-size: 0.95rem; }
.nav-links a:hover { color: var(--hero-text); }

.theme-toggle {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid rgba(154, 168, 196, 0.35);
  background: rgba(255, 255, 255, 0.04);
  color: var(--hero-text);
  cursor: pointer;
}
.theme-toggle:hover { background: rgba(255, 255, 255, 0.1); }
.theme-toggle svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.i-moon { display: none; }
:root[data-theme="dark"] .i-sun { display: none; }
:root[data-theme="dark"] .i-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: block; }
}

.hero-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 40px 24px 72px;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 48px;
  align-items: center;
}
.eyebrow { margin: 0 0 12px; font-family: var(--mono); font-size: 0.8rem; letter-spacing: 0.04em; color: var(--hero-cyan); text-transform: uppercase; }
.anaglyph {
  margin: 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(2.8rem, 7vw, 4.6rem);
  line-height: 1.02;
  letter-spacing: -0.02em;
  color: #f8fafc;
  text-shadow: -3px 0 0 rgba(34, 211, 238, 0.75), 3px 0 0 rgba(244, 63, 94, 0.75);
}
.tagline { margin: 18px 0 14px; font-size: 1.2rem; line-height: 1.5; color: var(--hero-text); max-width: 34ch; }
.tagline em { font-style: normal; color: #fde68a; }
.authors { margin: 0 0 26px; color: var(--hero-muted); }

.buttons { display: flex; flex-wrap: wrap; gap: 12px; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  border: 1px solid rgba(154, 168, 196, 0.4);
  color: var(--hero-text);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.95rem;
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.btn:hover { color: #fff; background: rgba(255, 255, 255, 0.1); border-color: rgba(154, 168, 196, 0.7); transform: translateY(-1px); }
.btn svg { width: 18px; height: 18px; fill: currentColor; }
.btn-primary { background: linear-gradient(90deg, #0e7490, #be123c); border-color: transparent; color: #fff; }
.btn-primary:hover { background: linear-gradient(90deg, #0891b2, #e11d48); }

.hero-figure { margin: 0; }
.stereo-pair { display: grid; grid-template-columns: 0.42fr 1fr; gap: 12px; align-items: stretch; }
.stereo-pair img { width: 100%; height: 100%; object-fit: cover; border-radius: 12px; border: 1px solid rgba(154, 168, 196, 0.25); }
.stereo-pair img:first-child { box-shadow: -6px 0 24px -10px rgba(34, 211, 238, 0.7); }
.stereo-pair img:last-child { box-shadow: 6px 0 24px -10px rgba(244, 63, 94, 0.7); }
.hero-figure figcaption { margin-top: 10px; font-size: 0.85rem; color: var(--hero-muted); }

/* ------------------------------------------------------------------ sections */
.section { padding: 80px 0; }
.section.alt { background: var(--bg-alt); }
h2 {
  margin: 0 0 24px;
  font-family: var(--display);
  font-size: clamp(1.7rem, 3.5vw, 2.3rem);
  letter-spacing: -0.01em;
  line-height: 1.15;
}
h2 .num { font-family: var(--mono); font-size: 0.55em; color: var(--left); vertical-align: middle; margin-right: 10px; letter-spacing: 0; }
h3 { font-family: var(--display); font-size: 1.2rem; margin: 0 0 10px; line-height: 1.3; }
h3.sub { margin: 48px 0 16px; font-size: 1.3rem; }
h3.sub:first-of-type { margin-top: 8px; }
.lead { font-size: 1.15rem; max-width: 70ch; }
.section p { max-width: 75ch; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-top: 36px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-top: 3px solid var(--left);
}
.stat:nth-child(even) { border-top-color: var(--right); }
.stat-value { display: block; font-family: var(--display); font-weight: 700; font-size: 1.75rem; line-height: 1.2; }
.stat-value small { font-size: 0.6em; font-weight: 600; color: var(--muted); }
.stat-label { display: block; margin-top: 6px; font-size: 0.88rem; color: var(--muted); line-height: 1.45; }

figure { margin: 0; }
figure img { border-radius: 10px; border: 1px solid var(--line); background: #fff; }
figcaption { margin-top: 10px; font-size: 0.88rem; color: var(--muted); line-height: 1.5; }
figure.wide { margin: 8px 0 40px; }
figure.wide img { width: 100%; }
figure.wide.narrow { max-width: 920px; margin-left: auto; margin-right: auto; }
.ladder + .note { margin-bottom: 28px; }
.zoomable { cursor: zoom-in; }

.cards { display: grid; gap: 20px; }
.cards.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}
.card p { margin: 0 0 12px; }
.card p:last-child { margin-bottom: 0; }
.math { overflow-x: auto; overflow-y: hidden; margin: 4px 0 12px; font-size: 0.95em; }

.novelty { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 28px; }
.card.novel { border-top: 3px solid var(--gate); }
.card.novel figure { margin: 16px 0; }
.badge {
  position: absolute; top: -12px; right: 20px;
  background: var(--gate); color: #111827;
  font-family: var(--mono); font-size: 0.72rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 3px 10px; border-radius: 999px;
}
.gates { margin: 0 0 8px; padding-left: 1.3em; }
.gates li { margin: 4px 0; }
.gates li::marker { color: var(--gate); font-family: var(--mono); font-weight: 600; }
.finding { margin-top: 12px !important; padding: 12px 14px; border-left: 3px solid var(--gate); background: var(--bg-alt); border-radius: 0 8px 8px 0; font-size: 0.95rem; }

/* ------------------------------------------------------------------ ablation ladder */
.ladder {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px 12px;
  box-shadow: var(--shadow);
}
.ladder-group { margin: 6px 0 4px; font-family: var(--mono); font-size: 0.78rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted); max-width: none !important; }
.ladder-group:not(:first-child) { margin-top: 18px; }
.rung { display: grid; grid-template-columns: minmax(150px, 230px) 1fr auto; gap: 14px; align-items: center; padding: 5px 0; }
.rung .lbl { font-size: 0.93rem; text-align: right; }
.rung .bar { position: relative; height: 18px; }
.rung .bar i {
  position: absolute; inset: 0 auto 0 0;
  width: calc(var(--v) / 29.73 * 100%);
  border-radius: 4px;
  background: color-mix(in srgb, var(--muted) 45%, transparent);
  transform-origin: left;
  transition: transform 0.9s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.rung.key .bar i { background: var(--left); }
.rung.best .bar i { background: linear-gradient(90deg, var(--left), var(--right)); }
.rung.key .lbl, .rung.best .lbl { font-weight: 600; }
.rung .val { font-family: var(--mono); font-size: 0.85rem; white-space: nowrap; }
.js .ladder:not(.in) .bar i { transform: scaleX(0); }
@media (prefers-reduced-motion: reduce) { .rung .bar i { transition: none; } .js .ladder:not(.in) .bar i { transform: none; } }
.note { font-size: 0.88rem; color: var(--muted); margin-top: 10px; }

.grid.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin: 28px 0 8px; align-items: start; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
th, td { padding: 10px 14px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--line); }
th:first-child, td:first-child { text-align: left; }
thead th { font-weight: 600; color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; background: var(--bg-alt); }
tbody tr:last-child td { border-bottom: none; }
td { font-family: var(--mono); font-size: 0.88rem; }
td:first-child { font-family: var(--font); font-size: 0.93rem; }
tr.ours td { font-weight: 600; background: color-mix(in srgb, var(--left) 10%, transparent); }

.takeaways { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.takeaways li { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.takeaways li strong { display: block; font-family: var(--display); font-size: 1.05rem; margin-bottom: 4px; }

.code { position: relative; margin-top: 16px; }
.code pre {
  margin: 0;
  padding: 20px 22px;
  overflow-x: auto;
  border-radius: var(--radius);
  background: #0b1020;
  color: #dbe4f3;
  font-size: 0.86rem;
  line-height: 1.6;
  border: 1px solid #1e2a45;
}
.copy {
  position: absolute; top: 10px; right: 10px;
  padding: 5px 12px;
  border-radius: 8px;
  border: 1px solid #334166;
  background: #151f38;
  color: #dbe4f3;
  font-family: var(--font);
  font-size: 0.8rem;
  cursor: pointer;
}
.copy:hover { background: #1f2b4a; }

.footer { padding: 40px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.9rem; }
.footer p { margin: 4px 0; }

/* ------------------------------------------------------------------ lightbox */
.lightbox { border: none; padding: 0; background: transparent; max-width: 96vw; max-height: 94vh; }
.lightbox::backdrop { background: rgba(5, 8, 18, 0.86); }
.lightbox img { max-width: 96vw; max-height: 90vh; width: auto; border-radius: 10px; background: #fff; }
.lightbox-close {
  position: fixed; top: 16px; right: 20px;
  width: 40px; height: 40px; border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.3); background: rgba(0, 0, 0, 0.4);
  color: #fff; font-size: 1.5rem; line-height: 1; cursor: pointer;
}

/* ------------------------------------------------------------------ narrow screens */
@media (max-width: 960px) {
  .hero-inner { grid-template-columns: 1fr; gap: 32px; padding-top: 24px; }
  .cards.three, .novelty, .grid.two, .takeaways { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-links { display: none; }
  .theme-toggle { margin-left: auto; }
}
@media (max-width: 600px) {
  body { font-size: 16px; }
  .wrap, .nav, .hero-inner { padding-left: 16px; padding-right: 16px; }
  .section { padding: 56px 0; }
  .stats { grid-template-columns: 1fr; }
  .rung { grid-template-columns: 1fr auto; gap: 4px 10px; }
  .rung .lbl { grid-column: 1 / -1; text-align: left; }
  .stereo-pair { grid-template-columns: 0.42fr 1fr; }
}
