/* ── reset & base ──────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #F5F0E8;
  --text: #111;
  --accent: #D1462F;
  --code-bg: #111;
  --code-text: #F5F0E8;
  --border: #bbb;
  --muted: #555;
  --section-gap: 4.5rem;
}

html { scroll-behavior: smooth; }

body {
  font-family: "Space Mono", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

/* ── typography ────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;600;700&family=Space+Mono:wght@400;700&display=swap');

h1, h2, h3, h4 {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

h1 { font-size: 3.5rem; }
h2 { font-size: 1.75rem; margin-bottom: 1rem; }
h3 { font-size: 1.15rem; margin-bottom: 0.5rem; }

.section-label {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.4rem;
  display: block;
}

p { max-width: 680px; margin-bottom: 0.75rem; font-size: 0.9rem; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── layout ────────────────────────────────────────────── */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

section {
  padding: var(--section-gap) 0;
  border-bottom: 1px solid var(--border);
}

section:last-of-type { border-bottom: none; }

/* ── nav ───────────────────────────────────────────────── */
nav {
  position: sticky;
  top: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  z-index: 100;
  padding: 0.75rem 0;
}

nav .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

nav .logo {
  font-family: "Space Mono", monospace;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: 0.05em;
}

nav .links {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}

nav .links a {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  color: var(--muted);
  text-decoration: none;
  transition: color 0.15s;
}

nav .links a:hover,
nav .links a.active {
  color: var(--text);
}

/* ── hero ──────────────────────────────────────────────── */
.hero {
  padding: 5rem 0 4rem;
  border-bottom: 1px solid var(--border);
}

.hero-readout {
  margin-bottom: 1.5rem;
}

.readout-line {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  display: block;
}

.hero h1 {
  font-size: 4rem;
  margin-bottom: 0.5rem;
}

.hero .subline {
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 1.5rem;
  max-width: 500px;
  font-family: "Space Mono", monospace;
}

.hero-stats {
  margin: 1.5rem 0;
}

.hero-links {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  padding: 0.6rem 1.25rem;
  text-decoration: none;
  display: inline-block;
  transition: opacity 0.15s;
}

.btn:hover { text-decoration: none; opacity: 0.85; }

.btn-primary {
  background: var(--text);
  color: var(--bg);
}

.btn-secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--text);
}

/* ── stat boxes ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin: 2rem 0;
}

.stat-box {
  background: var(--bg);
  padding: 1.25rem 1rem;
  text-align: center;
}

.stat-box .number {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-bottom: 0.15rem;
}

.stat-box .label {
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── three-column blocks ───────────────────────────────── */
.three-col {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-top: 1.5rem;
}

.block {
  background: var(--bg);
  padding: 1.5rem;
}

.block h3 {
  font-family: "Space Mono", monospace;
  font-size: 0.9rem;
  font-weight: 700;
}

.block p {
  font-size: 0.85rem;
  color: var(--muted);
}

/* ── code blocks ───────────────────────────────────────── */
pre {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  padding: 1.5rem;
  overflow-x: auto;
  margin: 1rem 0;
}

code {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
}

p code, li code {
  background: var(--code-bg);
  color: var(--code-text);
  padding: 0.1em 0.35em;
  font-size: 0.8rem;
}

/* ── terminal ─────────────────────────────────────────── */
.terminal {
  border: 1px solid var(--border);
  margin: 1.5rem 0;
  overflow: hidden;
}

.terminal-bar {
  background: #2a2a2a;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
  display: inline-block;
}

.terminal-dot:nth-child(1) { background: #ff5f57; }
.terminal-dot:nth-child(2) { background: #ffbd2e; }
.terminal-dot:nth-child(3) { background: #28c840; }

.terminal-title {
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  color: #888;
  margin-left: 0.5rem;
}

.terminal-body {
  margin: 0;
  padding: 1.25rem;
  font-size: 0.75rem;
  line-height: 1.5;
  background: var(--code-bg);
  color: #ccc;
}

.t-conflict {
  color: var(--accent);
  font-weight: 700;
}

.t-num {
  color: #5af78e;
  font-weight: 700;
}

/* ── link cards ────────────────────────────────────────── */
.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin-top: 1.5rem;
}

.card {
  background: var(--bg);
  padding: 1.5rem;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
  display: block;
}

.card:hover {
  background: #ede8df;
  text-decoration: none;
}

.card h3 {
  margin-bottom: 0.35rem;
  font-family: "Space Mono", monospace;
  font-size: 0.9rem;
}

.card p {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ── images ────────────────────────────────────────────── */
.chart {
  width: 100%;
  max-width: 800px;
  margin: 1.5rem 0;
  border: 1px solid var(--border);
}

.chart-wide {
  max-width: 100%;
}

.chart-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin: 1.5rem 0;
}

.chart-pair .chart {
  width: 100%;
  max-width: 100%;
  margin: 0 0 0.35rem 0;
}

.chart-pair .chart-caption {
  margin-top: 0;
}

.chart-caption {
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  color: var(--muted);
  margin-top: -0.75rem;
  margin-bottom: 1.5rem;
}

/* ── pipeline flow (architecture) ─────────────────────── */
.pipeline-flow {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin: 2rem 0;
  border: 1px solid var(--border);
  overflow-x: auto;
}

.pipeline-step {
  flex: 1;
  padding: 1.25rem 1rem;
  border-right: 1px solid var(--border);
  min-width: 120px;
}

.pipeline-step:last-child {
  border-right: none;
}

.pipeline-step.active {
  background: var(--code-bg);
  color: var(--code-text);
}

.pipeline-step.active .pipeline-step-desc {
  color: #888;
}

.pipeline-step-num {
  font-family: "Space Mono", monospace;
  font-size: 0.65rem;
  color: var(--accent);
  display: block;
  margin-bottom: 0.35rem;
}

.pipeline-step.active .pipeline-step-num {
  color: var(--accent);
}

.pipeline-step-title {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  font-weight: 700;
  display: block;
  margin-bottom: 0.25rem;
}

.pipeline-step-desc {
  font-family: "Space Mono", monospace;
  font-size: 0.65rem;
  color: var(--muted);
  display: block;
}

.pipeline-sep {
  display: none;
}

/* ── architecture diagram (legacy, keep for compat) ───── */
.diagram-box {
  background: var(--code-bg);
  color: var(--code-text);
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  padding: 1.5rem;
  line-height: 1.7;
  overflow-x: auto;
  margin: 1.5rem 0;
}

/* ── data table ────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.85rem;
}

th, td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

th {
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

td {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
}

/* ── fields list (architecture) ────────────────────────── */
.field-list {
  list-style: none;
  margin: 1rem 0;
}

.field-list li {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.field-list li:last-child { border-bottom: none; }

.field-name {
  color: var(--accent);
  font-weight: 700;
}

.field-type {
  color: var(--muted);
}

/* ── two-stage pipeline (conflict detection) ──────────── */
.pipeline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  margin: 1.5rem 0;
}

.stage {
  background: var(--bg);
  padding: 1.5rem;
}

.stage-label {
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
  display: block;
}

/* ── conflict funnel ──────────────────────────────────── */
.funnel {
  max-width: 420px;
  margin: 1.5rem 0;
}

.funnel-step {
  border: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
}

.funnel-number {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--accent);
  display: block;
  margin-bottom: 0.15rem;
}

.funnel-label {
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  font-weight: 700;
  display: block;
  margin-bottom: 0.15rem;
}

.funnel-desc {
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  color: var(--muted);
  display: block;
}

.funnel-arrow {
  text-align: center;
  font-size: 1.25rem;
  color: var(--muted);
  padding: 0.25rem 0;
}

/* ── conflict examples ────────────────────────────────── */
.conflict-examples {
  margin: 1.5rem 0;
}

.conflict-examples h3 {
  margin-bottom: 0.75rem;
}

.conflict-card {
  border: 1px solid var(--border);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.conflict-sim {
  font-family: "Space Mono", monospace;
  font-size: 0.7rem;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin-bottom: 0.5rem;
}

.conflict-pair p {
  font-size: 0.8rem;
  margin-bottom: 0.35rem;
}

.conflict-pair p:last-child {
  margin-bottom: 0;
}

/* ── footer ────────────────────────────────────────────── */
footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0;
  margin-top: 1.5rem;
}

footer .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
}

footer .footer-left {
  font-family: "Space Mono", monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

footer .footer-right {
  font-family: "Space Mono", monospace;
  font-size: 0.75rem;
  color: var(--muted);
}

footer a { color: var(--muted); }
footer a:hover { color: var(--text); }

/* ── responsive ────────────────────────────────────────── */
@media (max-width: 768px) {
  .hero h1 { font-size: 2.5rem; }
  h2 { font-size: 1.35rem; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .three-col,
  .card-grid {
    grid-template-columns: 1fr;
    gap: 1px;
  }

  .pipeline,
  .chart-pair {
    grid-template-columns: 1fr;
  }

  .pipeline-flow {
    flex-direction: column;
  }

  .pipeline-step {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .pipeline-step:last-child {
    border-bottom: none;
  }

  nav .container {
    flex-direction: column;
    gap: 0.5rem;
  }

  nav .links { gap: 1rem; }

  .hero { padding: 3rem 0 2.5rem; }

  footer .container {
    flex-direction: column;
    text-align: center;
  }

  pre { padding: 1rem; font-size: 0.75rem; }

  :root { --section-gap: 3rem; }
}
