/* Substrate
 * ---------
 * Light / dark via [data-theme] on <html>. Toggle in script.js.
 */

:root {
  /* Light theme — warm off-white, "soil" undertone */
  --bg: #faf8f3;
  --bg-elev: #ffffff;
  --bg-sunken: #f1ede2;
  --fg: #1a1a1a;
  --fg-muted: #5b5b5b;
  --fg-faint: #8a8a8a;
  --border: #e3ddcc;
  --border-strong: #c9c1ab;
  --accent: #7209b7;
  --accent-fg: #ffffff;
  --accent-soft: rgba(114, 9, 183, 0.12);
  --link: #5a14a3;
  --code-bg: #f1ede2;
  --code-fg: #2a2a2a;
  --shadow-card: 0 1px 2px rgba(20, 14, 4, 0.04), 0 8px 24px rgba(20, 14, 4, 0.04);
  --shadow-hover: 0 1px 2px rgba(20, 14, 4, 0.06), 0 12px 32px rgba(20, 14, 4, 0.08);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --max-w: 1080px;
  --pad-x: clamp(20px, 5vw, 48px);
}

[data-theme="dark"] {
  /* Matches the viz template's GitHub-ish palette for visual continuity */
  --bg: #0d1117;
  --bg-elev: #161b22;
  --bg-sunken: #0a0d12;
  --fg: #e6edf3;
  --fg-muted: #b1bac4;
  --fg-faint: #7d8590;
  --border: #21262d;
  --border-strong: #30363d;
  --accent: #b886ff;
  --accent-fg: #1a1a1a;
  --accent-soft: rgba(184, 134, 255, 0.16);
  --link: #b886ff;
  --code-bg: #161b22;
  --code-fg: #e6edf3;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.32);
  --shadow-hover: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ---------- typography ---------- */

h1, h2, h3 {
  color: var(--fg);
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0 0 0.4em;
}
h1 { font-size: clamp(2rem, 5vw, 3.4rem); font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.2rem); font-weight: 650; }
h3 { font-size: 1.15rem; font-weight: 600; }

p { margin: 0 0 1em; }

a { color: var(--link); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent); text-decoration: underline; }

code {
  font-family: var(--font-mono);
  font-size: 0.92em;
  background: var(--code-bg);
  padding: 0.12em 0.36em;
  border-radius: 4px;
  color: var(--code-fg);
}

pre {
  font-family: var(--font-mono);
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 16px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.55;
  margin: 1em 0;
}
pre code { background: transparent; padding: 0; }

blockquote { margin: 0; }

q { quotes: "\201C" "\201D" "\2018" "\2019"; font-style: italic; color: var(--fg-muted); }

.kicker {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 0.8em;
}
.eyebrow {
  font-size: clamp(1rem, 1.5vw, 1.15rem);
  font-weight: 600;
  color: var(--accent);
  margin: 0 0 1em;
  letter-spacing: -0.005em;
}

.lede, .section-lede {
  font-size: 1.08rem;
  color: var(--fg-muted);
  max-width: 60ch;
}
.lede em { color: var(--fg); font-style: italic; }

.footnote {
  font-size: 0.85rem;
  color: var(--fg-faint);
  margin-top: 1.2em;
}
.footnote a { color: var(--fg-muted); }

/* ---------- top bar ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px var(--pad-x);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--fg);
  font-weight: 600;
  letter-spacing: -0.005em;
}
.brand:hover { text-decoration: none; color: var(--fg); }
.brand img { display: block; }
.brand-name { font-size: 1.05rem; }

.topnav {
  display: flex;
  gap: 22px;
  margin-left: auto;
  font-size: 0.93rem;
}
.topnav a { color: var(--fg-muted); }
.topnav a:hover { color: var(--accent); text-decoration: none; }

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--fg-muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- sections ---------- */

.section { padding: clamp(56px, 9vw, 96px) 0; }
.section-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}

/* ---------- hero ---------- */

.hero {
  padding: clamp(64px, 11vw, 120px) 0 clamp(56px, 9vw, 96px);
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, var(--accent-soft), transparent 70%),
    var(--bg);
  border-bottom: 1px solid var(--border);
}
.hero-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--pad-x);
}
.hero h1 { max-width: 18ch; }
.hero .lede { font-size: clamp(1.05rem, 1.6vw, 1.25rem); max-width: 60ch; margin-top: 0.6em; }
.cta { display: flex; gap: 12px; margin-top: 2rem; flex-wrap: wrap; }

.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.7em 1.2em;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: transform 0.05s, background 0.15s, border-color 0.15s, color 0.15s;
  cursor: pointer;
  user-select: none;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, black); color: var(--accent-fg); }
.btn-ghost { background: transparent; color: var(--fg); border-color: var(--border-strong); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

.hero-meta {
  margin-top: 2rem;
  font-size: 0.85rem;
  color: var(--fg-faint);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.hero-meta .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

/* ---------- problem grid ---------- */

.problem-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  margin-top: 2.5rem;
}
.problem-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.problem-card h3 {
  margin-bottom: 0.6em;
  color: var(--accent);
  font-size: 1rem;
  letter-spacing: 0.01em;
}
.problem-card p { color: var(--fg-muted); font-size: 0.97rem; }
.problem-card strong { color: var(--fg); }

.figure {
  margin: 1.2em 0 0.8em;
  padding: 12px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.figure img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 4px;
}
.figure figcaption {
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--fg-muted);
  line-height: 1.5;
}
.figure-source { display: block; margin-top: 4px; color: var(--fg-faint); }

/* ---------- manifesto ---------- */

.manifesto {
  padding: clamp(56px, 9vw, 96px) 0;
  background: var(--bg-sunken);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.manifesto-inner { max-width: 760px; }
.manifesto blockquote {
  font-size: clamp(1.3rem, 2.6vw, 1.7rem);
  line-height: 1.4;
  font-weight: 500;
  color: var(--fg);
  border-left: 3px solid var(--accent);
  padding-left: 24px;
}
.manifesto blockquote strong { color: var(--accent); font-weight: 600; }
.manifesto-tag {
  margin-top: 1.4em;
  padding-left: 27px;
  color: var(--fg-muted);
  font-size: 1rem;
}

/* ---------- demo ---------- */

.demo-frame {
  margin-top: 2.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  background: #0d1117; /* matches the viz template; same in both modes */
}
.demo-frame iframe {
  display: block;
  width: 100%;
  height: 640px;
  border: 0;
  background: #0d1117;
}

/* ---------- benchmarks ---------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 2.5rem;
}
.metric {
  display: flex;
  flex-direction: column;
  padding: 24px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  color: var(--fg);
  text-decoration: none;
  transition: transform 0.1s, box-shadow 0.15s, border-color 0.15s;
}
.metric:hover {
  text-decoration: none;
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: var(--shadow-hover);
  color: var(--fg);
}
.metric-value {
  font-size: clamp(1.8rem, 3.2vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--accent);
  line-height: 1.05;
  font-feature-settings: "tnum";
}
.metric-vs {
  display: block;
  font-size: 0.7em;
  font-weight: 500;
  color: var(--fg-muted);
  margin-top: 2px;
}
.metric-label {
  margin-top: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--fg);
}
.metric-context {
  margin-top: 4px;
  font-size: 0.82rem;
  color: var(--fg-faint);
}

.bench-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin: 0 0 1rem;
}

/* ---------- tools table ---------- */

.tools-table-wrap {
  margin-top: 2rem;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
}
.tools-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}
.tools-table th, .tools-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.tools-table thead th {
  background: var(--bg-sunken);
  font-weight: 600;
  color: var(--fg-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.tools-table tbody tr:last-child td { border-bottom: 0; }
.tools-table tbody tr:hover td { background: var(--accent-soft); }
.tools-table td:first-child { width: 36%; }
.tools-table code { font-size: 0.88rem; background: transparent; padding: 0; color: var(--accent); font-weight: 500; }

/* ---------- pipeline / code blocks ---------- */

.pipeline {
  margin-top: 1.6rem;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre;
}

.code {
  font-size: 0.9rem;
}

/* ---------- footer ---------- */

.footer {
  border-top: 1px solid var(--border);
  padding: 32px 0 40px;
  background: var(--bg);
  margin-top: 24px;
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
}
.footer-brand {
  display: flex; align-items: center; gap: 8px;
  color: var(--fg-muted);
  font-weight: 500;
}
.footer-links {
  display: flex; gap: 18px;
  margin-left: auto;
  font-size: 0.92rem;
}
.footer-links a { color: var(--fg-muted); }
.footer-links a:hover { color: var(--accent); }
.footer-credit {
  flex-basis: 100%;
  margin: 0;
  font-size: 0.82rem;
  color: var(--fg-faint);
}

/* ---------- responsive ---------- */

@media (max-width: 720px) {
  .topnav { display: none; }
  .topbar { gap: 12px; }
  .demo-frame iframe { height: 480px; }
  .metric-value { font-size: 1.7rem; }
}

@media (max-width: 480px) {
  .hero { padding-top: 56px; padding-bottom: 56px; }
  .demo-frame iframe { height: 400px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
