/* ===== Design System ===== */
:root {
  --bg: #fbfaf7;
  --bg-elevated: #ffffff;
  --ink: #15212e;
  --ink-soft: #3a4a5c;
  --ink-muted: #6b7785;
  --rule: #e3e0d8;
  --upstream: #1f3a52;
  --midmarket: #4a7396;
  --downstream: #7aa6cc;
  --feedback: #16a085;
  --accent: #c8392c;
  --gold: #d4a843;
  --family-qwen: #2b7bba;
  --family-gemma: #e67e22;
  --family-ling: #8e44ad;
  --family-gptoss: #27ae60;
  --tier-low: #16a085;
  --tier-med: #f39c12;
  --tier-high: #e74c3c;
}

/* ===== Reset & Base ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }
body {
  font-family: 'Newsreader', Georgia, serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.75;
  font-size: 17px;
}

/* ===== Google Fonts ===== */
/* Loaded via <link> in head: Newsreader, Inter, JetBrains Mono */

/* ===== Navigation Bar ===== */
.nav-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(251,250,247,0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  height: 52px;
}
.nav-inner {
  max-width: 920px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 100%;
}
.nav-paper {
  font-family: 'Inter', sans-serif;
  font-size: 13px; font-weight: 600; color: var(--ink);
  letter-spacing: 0.01em;
}
.nav-sub {
  font-family: 'Inter', sans-serif;
  font-size: 11px; color: var(--ink-muted); margin-left: 12px;
}
.nav-progress {
  position: absolute; bottom: 0; left: 0; right: 0; height: 3px;
  background: var(--rule);
}
.nav-progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  transition: width 0.1s linear;
}

/* ===== Chapter Rail ===== */
.chapter-rail {
  position: fixed; left: 24px; top: 50%; transform: translateY(-50%);
  z-index: 90;
}
.chapter-rail ol {
  list-style: none; margin: 0; padding: 0;
}
.chapter-rail li {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; cursor: pointer;
  transition: opacity 0.2s;
}
.chapter-rail li:hover { opacity: 0.8; }
.chapter-rail .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--rule); border: 2px solid var(--ink-muted);
  transition: all 0.25s;
}
.chapter-rail li.active .dot {
  background: var(--accent); border-color: var(--accent);
  transform: scale(1.3);
}
.chapter-rail .label {
  font-family: 'Inter', sans-serif;
  font-size: 10px; color: var(--ink-muted); text-transform: uppercase;
  letter-spacing: 0.06em; white-space: nowrap;
  opacity: 0; transition: opacity 0.2s;
}
.chapter-rail li:hover .label,
.chapter-rail li.active .label { opacity: 1; }

@media (max-width: 1100px) {
  .chapter-rail { display: none; }
}

/* ===== Sections / Chapters ===== */
.chapter {
  max-width: 920px; margin: 0 auto;
  padding: 7rem 24px 4rem;
}
.chapter-head { margin-bottom: 2rem; }
.chapter-num {
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--accent); margin-bottom: 0.5rem;
}
.chapter h2 {
  font-size: 2rem; font-weight: 700; line-height: 1.2;
  margin-bottom: 1rem; font-style: normal;
}
.lede {
  font-size: 1.1rem; color: var(--ink-soft);
  line-height: 1.7; max-width: 680px;
}

/* ===== Cover Page ===== */
.cover { padding-top: 8rem; padding-bottom: 5rem; text-align: center; }
.cover-inner { max-width: 720px; margin: 0 auto; }
.cover-eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.12em; color: var(--accent); margin-bottom: 1.5rem;
}
.cover-title {
  font-size: 2.6rem; font-weight: 400; line-height: 1.2;
  margin-bottom: 1.5rem;
}
.cover-title em { color: var(--accent); font-style: italic; }
.cover-byline {
  font-family: 'Inter', sans-serif;
  font-size: 13px; color: var(--ink-muted); margin-bottom: 3rem; line-height: 1.6;
}
.cover-byline .muted { color: var(--ink-muted); }
.cover-abstract {
  background: var(--bg);
  border-left: 4px solid var(--gold);
  padding: 1.5rem 2rem;
  text-align: left;
  margin-bottom: 3rem;
  border-radius: 0 8px 8px 0;
}
.cover-abstract-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--gold); margin-bottom: 0.75rem;
}
.cover-abstract p {
  font-size: 0.97rem; line-height: 1.7; color: var(--ink-soft);
  margin-bottom: 0.75rem;
}
.cover-abstract p:last-child { margin-bottom: 0; }
.cover-pillars {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
  text-align: left;
}
.pillar {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.25rem 1.1rem;
}
.pillar-num {
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: 0.08em; margin-bottom: 0.5rem;
}
.pillar-title {
  font-weight: 700; font-size: 0.95rem; margin-bottom: 0.4rem;
}
.pillar-text {
  font-size: 0.85rem; color: var(--ink-muted); line-height: 1.55;
}

@media (max-width: 640px) {
  .cover-pillars { grid-template-columns: 1fr; }
  .cover-title { font-size: 1.8rem; }
}

/* ===== Plain English Card ===== */
.plain-card {
  background: var(--bg);
  border-left: 4px solid var(--gold);
  padding: 1.25rem 1.5rem;
  margin: 2rem 0;
  border-radius: 0 8px 8px 0;
}
.plain-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--gold); margin-bottom: 0.6rem;
}
.plain-card p {
  font-size: 0.95rem; color: var(--ink-soft); line-height: 1.65;
  margin-bottom: 0.5rem;
}
.plain-card p:last-child { margin-bottom: 0; }

/* ===== Prose ===== */
.prose { margin: 1.5rem 0; }
.prose p {
  margin-bottom: 1rem; line-height: 1.75; max-width: 680px;
}
.prose p:last-child { margin-bottom: 0; }

/* ===== Equation Block ===== */
.equation-block {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}

/* ===== Interactive Section ===== */
.interactive-section {
  margin: 2.5rem 0;
  padding: 2rem;
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: 12px;
}
.interactive-section h3 {
  font-family: 'Inter', sans-serif;
  font-size: 14px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--upstream);
  margin-bottom: 0.75rem;
}
.interactive-section .hint {
  font-family: 'Inter', sans-serif;
  font-size: 12px; color: var(--ink-muted); margin-bottom: 1rem;
}

/* Controls */
.ctrl { margin-bottom: 1rem; }
.ctrl-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 0.75rem; flex-wrap: wrap;
}
.ctrl label {
  font-family: 'Inter', sans-serif;
  font-size: 13px; color: var(--ink-soft); min-width: 180px;
}
.ctrl input[type="range"] {
  flex: 1; min-width: 120px; max-width: 300px;
  accent-color: var(--accent);
}
.ctrl .val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px; color: var(--ink); min-width: 60px;
}

.btn-row {
  display: flex; gap: 10px; margin-bottom: 1rem; flex-wrap: wrap;
}
.primary-btn, .ghost-btn {
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 600;
  padding: 6px 16px; border-radius: 6px; cursor: pointer;
  transition: all 0.2s; border: none;
}
.primary-btn {
  background: var(--accent); color: #fff;
}
.primary-btn:hover { background: #a52e23; }
.ghost-btn {
  background: transparent; color: var(--ink-soft);
  border: 1px solid var(--rule);
}
.ghost-btn:hover { border-color: var(--ink-muted); }
.ghost-btn.active {
  background: var(--upstream); color: #fff; border-color: var(--upstream);
}

/* Strategy / Selection Cards */
.strategy-cards {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px; margin-bottom: 1.25rem;
}
.strat-card {
  border: 2px solid var(--rule);
  border-radius: 8px; padding: 10px 12px;
  cursor: pointer; transition: all 0.2s;
  text-align: center;
}
.strat-card:hover { border-color: var(--midmarket); }
.strat-card.selected {
  border-color: var(--accent);
  background: rgba(200,57,44,0.06);
}
.strat-card-title {
  font-family: 'Inter', sans-serif;
  font-size: 12px; font-weight: 700; color: var(--ink);
}
.strat-card-desc {
  font-family: 'Inter', sans-serif;
  font-size: 10px; color: var(--ink-muted); margin-top: 4px;
}

/* Viz Container */
.viz-container {
  width: 100%; height: 420px; margin-top: 1rem;
}
.viz-container.short { height: 300px; }
.viz-container.tall { height: 520px; }

/* Grid of charts */
.chart-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
  margin-top: 1rem;
}
.chart-grid .viz-container { height: 350px; }
@media (max-width: 700px) {
  .chart-grid { grid-template-columns: 1fr; }
}

/* Readout cards */
.readout {
  display: flex; gap: 16px; flex-wrap: wrap; margin-top: 1rem;
}
.readout-card {
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 8px; padding: 10px 16px;
  flex: 1; min-width: 120px;
}
.readout-label {
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-muted);
}
.readout-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.3rem; font-weight: 700; color: var(--accent);
  margin-top: 2px;
}

/* ===== Callout ===== */
.callout {
  border-left: 4px solid var(--accent);
  padding: 1rem 1.5rem;
  margin: 2rem 0;
  background: rgba(200,57,44,0.04);
  border-radius: 0 8px 8px 0;
}
.callout-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.08em; color: var(--accent); margin-bottom: 0.4rem;
}
.callout-body {
  font-size: 0.95rem; color: var(--ink-soft); line-height: 1.6;
}
.callout.subtle {
  border-color: var(--ink-muted);
  background: rgba(107,119,133,0.06);
}
.callout.subtle .callout-label { color: var(--ink-muted); }

/* ===== Chapter Foot Link ===== */
.chapter-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 3rem; padding: 1rem 0;
  border-top: 1px solid var(--rule);
  text-decoration: none; color: var(--ink-soft);
  transition: color 0.2s;
}
.chapter-foot:hover { color: var(--accent); }
.next-hint {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
}
.next-arrow {
  font-size: 18px; transition: transform 0.2s;
}
.chapter-foot:hover .next-arrow { transform: translateX(4px); }

/* ===== Footer ===== */
.site-footer {
  max-width: 920px; margin: 0 auto;
  padding: 3rem 24px 4rem;
  border-top: 1px solid var(--rule);
  text-align: center;
}
.site-footer p {
  font-family: 'Inter', sans-serif;
  font-size: 12px; color: var(--ink-muted);
}

/* ===== Utility ===== */
.muted { color: var(--ink-muted); }
.mono { font-family: 'JetBrains Mono', monospace; }
.tag {
  display: inline-block;
  font-family: 'Inter', sans-serif;
  font-size: 10px; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.tag-low { background: rgba(22,160,133,0.12); color: var(--tier-low); }
.tag-med { background: rgba(243,156,18,0.12); color: var(--tier-med); }
.tag-high { background: rgba(231,76,60,0.12); color: var(--tier-high); }

/* ===== Tier Badge ===== */
.tier-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: 'Inter', sans-serif;
  font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 4px;
}
.tier-badge.low { background: rgba(22,160,133,0.12); color: var(--tier-low); }
.tier-badge.medium { background: rgba(243,156,18,0.12); color: var(--tier-med); }
.tier-badge.high { background: rgba(231,76,60,0.12); color: var(--tier-high); }

/* ===== Plotly overrides ===== */
.js-plotly-plot .plotly .modebar { display: none !important; }
