/* ── Design System ─────────────────────────────────────────────────── */
:root {
  /* Dataset colors */
  --acic: #1F5AA6;
  --acic2016: #C48A97;
  --ihdp: #2B7A78;
  --lalonde: #E69F00;

  /* Model colors */
  --gemini: #4285F4;
  --gpt5: #10A37F;

  /* Neutrals */
  --bg: #FAFBFC;
  --surface: #FFFFFF;
  --border: #E1E4E8;
  --text: #1B1F23;
  --text-secondary: #586069;
  --text-muted: #959DA5;

  /* Accent */
  --accent: #1F5AA6;
  --accent-light: #E8F0FE;

  /* Spacing */
  --section-pad: 80px;
  --card-radius: 12px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Avenir Next', 'Avenir', -apple-system, 'Segoe UI', sans-serif;
  font-weight: 400;
  color: var(--text);
  background: var(--bg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ───────────────────────────────────────────────────── */
h1 { font-weight: 700; font-size: 2.8rem; line-height: 1.15; letter-spacing: -0.02em; }
h2 { font-weight: 700; font-size: 1.8rem; letter-spacing: -0.01em; margin-bottom: 0.5em; }
h3 { font-weight: 600; font-size: 1.15rem; margin-bottom: 0.4em; }
.subtitle { font-weight: 300; font-size: 1.25rem; color: var(--text-secondary); }
.section-desc { font-weight: 400; color: var(--text-secondary); max-width: 640px; margin-bottom: 2rem; }

/* ── Layout ───────────────────────────────────────────────────────── */
.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }
section { padding: var(--section-pad) 0; }
section + section { border-top: 1px solid var(--border); }

/* ── Nav ──────────────────────────────────────────────────────────── */
nav {
  position: sticky; top: 0; z-index: 100;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
}
nav .nav-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; gap: 40px;
  height: 64px;
}
nav .logo {
  font-weight: 700; font-size: 1.2rem; color: var(--accent);
  text-decoration: none; letter-spacing: -0.01em; white-space: nowrap;
}
nav a {
  text-decoration: none; font-size: 0.95rem; color: var(--text-secondary);
  font-weight: 500; transition: color 0.15s;
  padding: 6px 0;
}
nav a:hover, nav a.active { color: var(--accent); }
nav .nav-links { display: flex; gap: 28px; }

/* ── Hero ─────────────────────────────────────────────────────────── */
#hero {
  padding: 60px 0 48px;
  text-align: center;
  border-top: none;
}
.hero-header {
  text-align: left;
  margin-bottom: 32px;
}
.hero-header h1 { font-size: 2rem; margin-bottom: 4px; }
.hero-header .subtitle { font-size: 1.05rem; margin-bottom: 6px; }
.hero-header .authors { font-size: 0.88rem; color: var(--text-muted); margin: 0; }
.hero-header .authors a { color: var(--accent); text-decoration: none; }
.hero-header .authors a:hover { text-decoration: underline; }
.hero-header .authors sup { font-size: 0.7em; }
.hero-links { margin: 2px 0 8px; font-size: 0.88rem; }
.hero-link { color: var(--accent); text-decoration: none; font-weight: 500; }
.hero-link:hover { text-decoration: underline; }
.hero-link.paper-link { color: var(--text-muted); cursor: default; }
.hero-link.paper-link:hover { text-decoration: none; }
.hero-link-sep { color: var(--text-muted); margin: 0 6px; }

.stat-cards {
  display: flex; gap: 20px; justify-content: center;
  flex-wrap: wrap; margin-bottom: 48px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 20px 32px;
  text-align: center;
  min-width: 140px;
}
.stat-card .num { font-size: 2rem; font-weight: 700; color: var(--accent); }
.stat-card .label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ── Cards ────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--card-radius);
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

/* ── Filter controls ──────────────────────────────────────────────── */
.controls { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 24px; align-items: center; }
.control-group { display: flex; align-items: center; gap: 6px; }
.control-group .label { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.btn-group { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.btn-group button {
  border: none; background: var(--surface); padding: 6px 14px;
  font-size: 0.82rem; font-weight: 500; cursor: pointer;
  color: var(--text-secondary); transition: all 0.15s;
  border-right: 1px solid var(--border);
  font-family: inherit;
}
.btn-group button:last-child { border-right: none; }
.btn-group button.active { background: var(--accent); color: #fff; }
.btn-group button:hover:not(.active) { background: var(--accent-light); }

/* Dataset color chips */
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; cursor: pointer; border: 2px solid transparent; transition: all 0.15s; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; }
.chip.active { border-color: currentColor; }
.chip[data-ds="acic"], .chip[data-ds="ACIC 2022"] { color: var(--acic); }
.chip[data-ds="acic2016"], .chip[data-ds="ACIC 2016"] { color: var(--acic2016); }
.chip[data-ds="ihdp"], .chip[data-ds="IHDP"] { color: var(--ihdp); }
.chip[data-ds="lalonde"], .chip[data-ds="LaLonde"] { color: var(--lalonde); }

.chip .dot { background: currentColor; }

/* ── Chart containers ─────────────────────────────────────────────── */
.chart-wrap { width: 100%; min-height: 420px; }
.chart-row { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 16px; }
@media (max-width: 800px) { .chart-row { grid-template-columns: 1fr; } }

/* ── Results table ────────────────────────────────────────────────── */
.results-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin-top: 16px; }
.results-table th { text-align: left; font-weight: 600; color: var(--text-muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; padding: 8px 12px; border-bottom: 2px solid var(--border); }
.results-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
.results-table tr:hover { background: var(--accent-light); }

/* ── Code viewer ──────────────────────────────────────────────────── */
.code-viewer-layout { display: grid; grid-template-columns: 260px 1fr; gap: 24px; margin-top: 16px; }
@media (max-width: 800px) { .code-viewer-layout { grid-template-columns: 1fr; } }

.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  cursor: pointer; border-radius: 8px; transition: background 0.15s;
  font-size: 0.85rem; position: relative;
}
.timeline-item:hover { background: var(--accent-light); }
.timeline-item.active { background: var(--accent-light); font-weight: 600; }
.timeline-item .dot-outer {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.timeline-item .dot-inner { width: 6px; height: 6px; border-radius: 50%; }
.timeline-item + .timeline-item::before {
  content: ''; position: absolute; left: 18px; top: -4px;
  width: 2px; height: 8px; background: var(--border);
}
.timeline-score { margin-left: auto; font-size: 0.78rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.code-pane { overflow: hidden; }
.code-tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 0; }
.code-tab {
  padding: 8px 18px; font-size: 0.85rem; font-weight: 500; cursor: pointer;
  border: none; background: none; color: var(--text-muted);
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s;
  font-family: inherit;
}
.code-tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.code-content { max-height: 520px; overflow: auto; padding: 16px; background: #f6f8fa; border-radius: 0 0 8px 8px; }
.code-content pre { margin: 0; font-size: 0.82rem; line-height: 1.55; }
.code-content code { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; }
.metrics-bar { display: flex; gap: 16px; padding: 10px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.metric-item { font-size: 0.82rem; }
.metric-item .metric-label { color: var(--text-muted); }
.metric-item .metric-val { font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Playback controls ────────────────────────────────────────────── */
.playback-controls { display: flex; align-items: center; gap: 8px; }
.play-btn {
  width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--accent); background: var(--surface);
  color: var(--accent); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.play-btn:hover { background: var(--accent); color: #fff; }
.play-btn.playing { background: var(--accent); color: #fff; }

/* ── Judge cards ──────────────────────────────────────────────────── */
.judge-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; margin-top: 16px; }
@media (max-width: 900px) { .judge-grid { grid-template-columns: 1fr; } }
.judge-card { padding: 20px; }
.judge-card .judge-name { font-weight: 700; font-size: 1rem; margin-bottom: 12px; }
.judge-tag { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.75rem; font-weight: 600; background: var(--accent-light); color: var(--accent); margin-bottom: 8px; }
.sim-bar-wrap { margin: 10px 0; }
.sim-bar-bg { height: 8px; background: #e9ecef; border-radius: 4px; overflow: hidden; }
.sim-bar-fill { height: 100%; border-radius: 4px; transition: width 0.4s ease; }
.sim-label { display: flex; justify-content: space-between; font-size: 0.78rem; color: var(--text-muted); margin-bottom: 4px; }
.novel-list { list-style: none; padding: 0; margin: 8px 0; }
.novel-list li { font-size: 0.82rem; padding: 2px 0; color: var(--text-secondary); }
.novel-list li::before { content: '+ '; color: var(--accent); font-weight: 700; }
.consensus-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.78rem; font-weight: 600; background: #d4edda; color: #155724; }

/* Judge selector */
.judge-run-select { margin-bottom: 16px; }
.judge-run-select select {
  font-family: inherit; font-size: 0.88rem; padding: 6px 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}

/* ── Baseline comparison ──────────────────────────────────────────── */
.baseline-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
@media (max-width: 800px) { .baseline-grid { grid-template-columns: 1fr; } }
.win-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 0.78rem; font-weight: 700; }
.win-badge.high { background: #d4edda; color: #155724; }
.win-badge.med { background: #fff3cd; color: #856404; }
.win-badge.low { background: #f8d7da; color: #721c24; }

/* ── Quick start ──────────────────────────────────────────────────── */
.quickstart pre {
  background: #1e1e2e; color: #cdd6f4; padding: 20px; border-radius: 8px;
  font-size: 0.85rem; overflow-x: auto; line-height: 1.6;
}
.quickstart code { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; }

/* ── Scroll animations ────────────────────────────────────────────── */
.fade-up { opacity: 0; transform: translateY(24px); transition: opacity 0.5s ease, transform 0.5s ease; }
.fade-up.visible { opacity: 1; transform: translateY(0); }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
  h1 { font-size: 2rem; }
  :root { --section-pad: 48px; }
  .stat-cards { gap: 12px; }
  .stat-card { padding: 14px 20px; min-width: 100px; }
  nav .nav-links { gap: 14px; }
  nav a { font-size: 0.85rem; }
  .code-viewer-layout { grid-template-columns: 1fr; }
}

/* ── Loading state ────────────────────────────────────────────────── */
.loading { display: flex; align-items: center; justify-content: center; min-height: 200px; color: var(--text-muted); font-size: 0.9rem; }
.spinner { width: 20px; height: 20px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; margin-right: 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ───────────────────────────────────────────────────────── */
footer { padding: 32px 0; text-align: center; font-size: 0.82rem; color: var(--text-muted); border-top: 1px solid var(--border); }
footer a { color: var(--accent); text-decoration: none; }

/* ── Diff view ────────────────────────────────────────────────────── */
.diff-view { font-size: 0.82rem; }
.diff-line { font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace; white-space: pre; }
.diff-add { background: #dafbe1; color: #1a7f37; }
.diff-del { background: #ffebe9; color: #cf222e; }
.diff-hunk { color: var(--text-muted); font-style: italic; padding: 4px 0; }

/* ── Expandable ───────────────────────────────────────────────────── */
.expandable-toggle {
  background: none; border: none; color: var(--accent); font-size: 0.82rem;
  cursor: pointer; padding: 4px 0; font-family: inherit;
}
.expandable-content { display: none; margin-top: 8px; font-size: 0.85rem; color: var(--text-secondary); line-height: 1.5; }
.expandable-content.open { display: block; }

/* Run selector */
.run-selector { margin-bottom: 16px; }
.run-selector select {
  font-family: inherit; font-size: 0.88rem; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
  min-width: 320px;
}

/* ── Code transition animation ────────────────────────────────────── */
.code-content.transitioning {
  animation: codeFlash 0.3s ease;
}
@keyframes codeFlash {
  0% { opacity: 1; }
  30% { opacity: 0.3; background: var(--accent-light); }
  100% { opacity: 1; }
}
