/* ===== OpenCompass Interactive Companion ===== */
/* Design system: editorial / long-form journalism */

: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: #b8860b;
  --gold-light: #f5e6c8;
  --nav-h: 3.25rem;
}

*, *::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.72;
  font-size: 1.05rem;
}

/* ---------- NAV ---------- */
.nav-bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: rgba(251,250,247,.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  display: flex; align-items: center;
}
.nav-inner {
  width: 100%; max-width: 920px; margin: 0 auto; padding: 0 1.5rem;
  display: flex; flex-direction: column; gap: 2px;
}
.nav-title { display: flex; justify-content: space-between; align-items: baseline; }
.nav-paper {
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 600; color: var(--upstream);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.nav-sub {
  font-family: 'Inter', sans-serif;
  font-size: .68rem; color: var(--ink-muted);
}
.nav-progress {
  height: 2px; background: var(--rule); border-radius: 1px; width: 100%;
}
.nav-progress-fill {
  height: 100%; width: 0%; background: var(--accent);
  transition: width .15s ease;
}

/* ---------- CHAPTER RAIL ---------- */
.chapter-rail {
  position: fixed; left: 1.5rem; top: 50%; transform: translateY(-50%);
  z-index: 90;
}
.chapter-rail ol {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 1.1rem;
}
.chapter-rail li {
  display: flex; align-items: center; gap: .55rem; cursor: pointer;
  transition: opacity .2s;
}
.chapter-rail li:hover { opacity: 1 !important; }
.chapter-rail .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--rule); transition: all .2s;
  flex-shrink: 0;
}
.chapter-rail li.active .dot {
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(200,57,44,.15);
}
.chapter-rail .label {
  font-family: 'Inter', sans-serif;
  font-size: .65rem; color: var(--ink-muted);
  white-space: nowrap; opacity: 0; transition: opacity .2s;
  max-width: 0; overflow: hidden;
}
.chapter-rail li:hover .label,
.chapter-rail li.active .label { opacity: 1; max-width: 12rem; }

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

/* ---------- CHAPTER SECTIONS ---------- */
.chapter {
  max-width: 920px; margin: 0 auto;
  padding: 7rem 1.5rem 2rem;
}
.chapter + .chapter { border-top: 1px solid var(--rule); }

/* ---------- COVER ---------- */
.cover { padding-top: 10rem; padding-bottom: 4rem; }
.cover-inner { display: flex; flex-direction: column; gap: 1.5rem; }
.cover-eyebrow {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent);
}
.cover-title {
  font-size: 2.6rem; font-weight: 700; line-height: 1.18;
  color: var(--ink);
}
.cover-title em { color: var(--accent); font-style: italic; }
.cover-subtitle {
  font-size: 1.15rem; color: var(--ink-soft);
  font-style: italic; margin-top: -.25rem;
}
.cover-byline {
  font-family: 'Inter', sans-serif;
  font-size: .82rem; color: var(--ink-soft); line-height: 1.6;
}
.cover-byline .muted { color: var(--ink-muted); }

/* cover abstract */
.cover-abstract {
  background: var(--bg);
  border-left: 4px solid var(--gold);
  padding: 1.5rem 1.75rem;
  border-radius: 0 .5rem .5rem 0;
  margin-top: 1rem;
}
.cover-abstract-label {
  font-family: 'Inter', sans-serif;
  font-size: .7rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold); margin-bottom: .75rem;
}
.cover-abstract p { margin-bottom: .85rem; }
.cover-abstract p:last-child { margin-bottom: 0; }

/* pillar cards */
.cover-pillars {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.25rem;
  margin-top: 1.5rem;
}
.pillar {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: .5rem;
  padding: 1.25rem 1.15rem;
}
.pillar-num {
  font-family: 'Newsreader', serif;
  font-size: 1.6rem; font-weight: 700; color: var(--accent);
  line-height: 1; margin-bottom: .5rem;
}
.pillar-title {
  font-family: 'Inter', sans-serif;
  font-weight: 600; font-size: .85rem; color: var(--upstream);
  margin-bottom: .4rem;
}
.pillar-text {
  font-size: .85rem; color: var(--ink-soft); line-height: 1.55;
}
@media (max-width: 680px) {
  .cover-pillars { grid-template-columns: 1fr; }
  .cover-title { font-size: 1.9rem; }
}

/* ---------- CHAPTER ANATOMY ---------- */
.chapter-number {
  font-family: 'Inter', sans-serif;
  font-size: .68rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--accent); margin-bottom: .4rem;
}
.chapter h2 {
  font-size: 1.85rem; font-weight: 700; line-height: 1.2;
  color: var(--ink); margin-bottom: .75rem;
}
.chapter .lede {
  font-size: 1.1rem; color: var(--ink-soft);
  line-height: 1.7; margin-bottom: 1.25rem;
  max-width: 52rem;
}

/* plain-English card */
.plain-card {
  background: var(--bg);
  border-left: 4px solid var(--gold);
  padding: 1.25rem 1.5rem;
  border-radius: 0 .5rem .5rem 0;
  margin: 1.5rem 0;
}
.plain-label {
  font-family: 'Inter', sans-serif;
  font-size: .65rem; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--gold); margin-bottom: .6rem;
}
.plain-card p { font-size: .95rem; margin-bottom: .7rem; line-height: 1.65; }
.plain-card p:last-child { margin-bottom: 0; }

/* equation block */
.equation-block {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: .5rem;
  padding: 1.25rem 1.5rem;
  margin: 1.5rem 0;
  overflow-x: auto;
}
.equation-block .eq-label {
  font-family: 'Inter', sans-serif;
  font-size: .68rem; font-weight: 600;
  color: var(--ink-muted); text-transform: uppercase;
  letter-spacing: .06em; margin-bottom: .5rem;
}
.equation-block .eq-explain {
  font-size: .88rem; color: var(--ink-soft); margin-top: .6rem; line-height: 1.6;
}

/* interactive section */
.interactive-section {
  margin: 2rem 0;
}
.interactive-section .hint {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; color: var(--ink-muted);
  margin-bottom: .5rem; font-style: italic;
}
.controls-row {
  display: flex; flex-wrap: wrap; gap: 1.25rem;
  margin-bottom: 1rem; align-items: flex-end;
}
.control-group {
  display: flex; flex-direction: column; gap: .25rem; min-width: 160px;
}
.control-group label {
  font-family: 'Inter', sans-serif;
  font-size: .72rem; font-weight: 600; color: var(--ink-soft);
}
.control-group input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 6px; border-radius: 3px;
  background: var(--rule); outline: none;
}
.control-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent); cursor: pointer;
  border: 2px solid var(--bg-elevated);
}
.control-group .value-display {
  font-family: 'JetBrains Mono', monospace;
  font-size: .75rem; color: var(--accent); font-weight: 500;
}
.chart-grid {
  display: grid; gap: 1rem;
}
.chart-grid.g2 { grid-template-columns: repeat(2, 1fr); }
.chart-grid.g3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) {
  .chart-grid.g2, .chart-grid.g3 { grid-template-columns: 1fr; }
}
.chart-cell {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: .5rem;
  overflow: hidden;
}
.readout-cards {
  display: flex; flex-wrap: wrap; gap: .75rem; margin-top: .75rem;
}
.readout-card {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: .4rem;
  padding: .6rem 1rem;
  display: flex; flex-direction: column;
}
.readout-card .readout-label {
  font-family: 'Inter', sans-serif;
  font-size: .62rem; font-weight: 600; color: var(--ink-muted);
  text-transform: uppercase; letter-spacing: .06em;
}
.readout-card .readout-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem; font-weight: 500; color: var(--upstream);
}

/* strategy cards */
.strategy-cards {
  display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem;
}
.strategy-card {
  background: var(--bg-elevated);
  border: 2px solid var(--rule);
  border-radius: .5rem;
  padding: .75rem 1.1rem;
  cursor: pointer; transition: all .15s;
  font-family: 'Inter', sans-serif;
  font-size: .82rem; color: var(--ink-soft);
}
.strategy-card:hover { border-color: var(--midmarket); }
.strategy-card.selected {
  border-color: var(--accent);
  background: rgba(200,57,44,.04);
  color: var(--ink);
}

/* action buttons */
.action-btn {
  font-family: 'Inter', sans-serif;
  font-size: .78rem; font-weight: 600;
  padding: .5rem 1.1rem;
  border: 2px solid var(--accent);
  border-radius: .35rem;
  background: transparent; color: var(--accent);
  cursor: pointer; transition: all .15s;
}
.action-btn:hover { background: var(--accent); color: #fff; }
.action-btn.active { background: var(--accent); color: #fff; }

/* callout */
.callout {
  border-left: 4px solid var(--accent);
  padding: 1rem 1.25rem;
  margin: 2rem 0;
  background: rgba(200,57,44,.03);
  border-radius: 0 .35rem .35rem 0;
}
.callout p {
  font-size: .95rem; color: var(--ink-soft); line-height: 1.6;
  font-style: italic;
}

/* chapter foot link */
.chapter-foot {
  display: inline-flex; align-items: center; gap: .4rem;
  font-family: 'Inter', sans-serif;
  font-size: .82rem; font-weight: 600;
  color: var(--midmarket); text-decoration: none;
  margin-top: 1.5rem;
  transition: color .15s;
}
.chapter-foot:hover { color: var(--accent); }
.chapter-foot .arrow {
  display: inline-block; transition: transform .15s;
}
.chapter-foot:hover .arrow { transform: translateX(4px); }

/* ---------- INTERACTIVE SVG DIAGRAM ---------- */
.arch-diagram {
  width: 100%; max-width: 820px;
  margin: 1.5rem auto; display: block;
}
.arch-diagram .node {
  cursor: pointer; transition: opacity .2s;
}
.arch-diagram .node:hover { opacity: .85; }
.arch-diagram .node rect { rx: 6; ry: 6; }
.arch-diagram .node text {
  font-family: 'Inter', sans-serif;
  font-size: 12px; fill: var(--ink);
  pointer-events: none;
}
.arch-diagram .flow-arrow {
  fill: none; stroke: var(--midmarket); stroke-width: 1.5;
  marker-end: url(#arrowhead);
}
.detail-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--rule);
  border-radius: .5rem;
  padding: 1.25rem 1.5rem;
  margin-top: 1rem;
  min-height: 4rem;
}
.detail-panel h4 {
  font-family: 'Inter', sans-serif;
  font-size: .95rem; font-weight: 700; color: var(--upstream);
  margin-bottom: .4rem;
}
.detail-panel p {
  font-size: .88rem; color: var(--ink-soft); line-height: 1.6;
}

/* ---------- LEADERBOARD TABLE ---------- */
.lb-table-wrap {
  overflow-x: auto; margin: 1rem 0;
}
.lb-table {
  width: 100%; border-collapse: collapse;
  font-family: 'JetBrains Mono', monospace;
  font-size: .72rem;
}
.lb-table th, .lb-table td {
  padding: .45rem .6rem; text-align: right;
  border-bottom: 1px solid var(--rule);
}
.lb-table th:first-child, .lb-table td:first-child { text-align: left; }
.lb-table th {
  font-family: 'Inter', sans-serif;
  font-weight: 700; color: var(--ink-soft);
  font-size: .68rem; text-transform: uppercase;
  letter-spacing: .04em;
  position: sticky; top: 0; background: var(--bg-elevated);
  cursor: pointer; user-select: none;
}
.lb-table th:hover { color: var(--accent); }
.lb-table th.sorted-asc::after { content: ' \25B2'; color: var(--accent); }
.lb-table th.sorted-desc::after { content: ' \25BC'; color: var(--accent); }
.lb-table tr:hover { background: rgba(79,115,150,.04); }
.lb-table .model-name {
  font-family: 'Inter', sans-serif;
  font-weight: 600; color: var(--upstream);
  white-space: nowrap;
}
.lb-table .highlight-val { color: var(--accent); font-weight: 600; }

/* ---------- PROSE HELPER ---------- */
.prose { line-height: 1.72; color: var(--ink-soft); }
.prose p { margin-bottom: .85rem; }
.prose strong { color: var(--ink); }
.prose em { font-style: italic; }

/* ---------- UTILITY ---------- */
.mono { font-family: 'JetBrains Mono', monospace; }
.muted { color: var(--ink-muted); }
.accent { color: var(--accent); }
.teal { color: var(--feedback); }
.navy { color: var(--upstream); }
