/* ===== TOKENS ===== */
:root {
  --bg: #0a0f1a;
  --bg-surface: #111827;
  --bg-card: #1a2332;
  --bg-hover: #1f2b3d;
  --text: #f1f5f9;
  --text-muted: #cbd5e1;
  --text-dim: #94a3b8;
  --accent: #3b82f6;
  --accent-dim: #2563eb;
  --accent-green: #22c55e;
  --accent-red: #ef4444;
  --accent-orange: #f97316;
  --accent-purple: #a855f7;
  --border: #1e293b;
  --border-light: #334155;
  --radius: 12px;
  --radius-sm: 8px;
  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;
  --max-width: 1200px;
  --section-pad: 6rem 0;
}

[data-theme="light"] {
  --bg: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #f1f5f9;
  --bg-hover: #e2e8f0;
  --text: #1e293b;
  --text-muted: #475569;
  --text-dim: #94a3b8;
  --border: #e2e8f0;
  --border-light: #cbd5e1;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; height: auto; display: block; border-radius: var(--radius-sm); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--font-mono); font-size: 0.88em; background: var(--bg-card); padding: 2px 6px; border-radius: 4px; }
ul, ol { padding-left: 1.4em; }

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 2rem; }

/* ===== HERO ===== */
.hero {
  padding: 8rem 0 5rem;
  text-align: center;
  background: linear-gradient(180deg, #0c1424 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}
.hero-label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
}
.hero-title {
  font-family: var(--font-serif);
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 700;
  line-height: 1.05;
  margin-bottom: 1.5rem;
  background: linear-gradient(135deg, var(--text) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-subtitle {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--text-muted);
  max-width: 700px;
  margin: 0 auto 2.5rem;
  line-height: 1.6;
}
.hero-stats {
  display: flex;
  justify-content: center;
  gap: 3rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}
.hero-stat {
  text-align: center;
}
.hero-stat-value {
  display: block;
  font-family: var(--font-mono);
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent);
}
.hero-stat-label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.hero-nav {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  padding: 0.65rem 1.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  border: 1px solid transparent;
  cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dim); text-decoration: none; }
.btn-outline { border-color: var(--border-light); color: var(--text-muted); }
.btn-outline:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }
.btn-ghost { color: var(--text-dim); }
.btn-ghost:hover { color: var(--text); text-decoration: none; }

/* ===== SECTIONS ===== */
.section { padding: var(--section-pad); }
.section-dark { background: var(--bg-surface); }
.section-header {
  display: flex;
  align-items: baseline;
  gap: 1.2rem;
  margin-bottom: 3rem;
}
.section-number {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--accent);
  letter-spacing: 1px;
}
.section-header h2 {
  font-family: var(--font-serif);
  font-size: 2.2rem;
  font-weight: 700;
}
.lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  line-height: 1.8;
  max-width: 800px;
  margin-bottom: 2rem;
}

/* ===== THESIS ===== */
.thesis-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 3rem;
  align-items: start;
}
.thesis-main p { margin-bottom: 1.2rem; }
.thesis-main em { color: var(--accent); font-style: italic; }
.callout {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  padding: 1.5rem;
  border-radius: var(--radius-sm);
}
.callout h3 {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  margin-bottom: 1rem;
}
.callout ol { font-size: 0.95rem; color: var(--text-muted); }
.callout li { margin-bottom: 0.5rem; }

/* ===== FINDING CARDS ===== */
.finding-card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
  margin-bottom: 5rem;
  padding: 2.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.finding-card-reverse { direction: rtl; }
.finding-card-reverse > * { direction: ltr; }
.finding-text h3 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  margin-bottom: 1rem;
}
.finding-text p { color: var(--text-muted); margin-bottom: 1rem; }
.finding-text strong { color: var(--text); }
.figure-caption {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 0.5rem;
  font-style: italic;
}
.finding-chart { min-height: 350px; }
.finding-chart .js-plotly-plot { border-radius: var(--radius-sm); }
.hl-blue { color: var(--accent); font-weight: 600; }

/* ===== STATS ROW ===== */
.stat-row {
  display: flex;
  gap: 2rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}
.stat {
  display: flex;
  flex-direction: column;
}
.stat-value {
  font-family: var(--font-mono);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}
.stat-value.accent-red { color: var(--accent-red); }
.stat-value.accent-green { color: var(--accent-green); }
.stat-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ===== METHODS ===== */
.method-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 2rem;
}
.method-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
}
.method-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 1rem;
  border-radius: 10px;
  margin-bottom: 1rem;
}
.method-card h3 {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
}
.method-card p { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1rem; }
.method-spec {
  background: var(--bg);
  padding: 0.8rem 1rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--accent);
  overflow-x: auto;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
}
.method-spec code { background: none; padding: 0; font-size: inherit; }
.method-details {
  list-style: none;
  padding: 0;
  font-size: 0.88rem;
}
.method-details li {
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}
.method-details li:last-child { border-bottom: none; }
.method-details strong { color: var(--text); font-weight: 600; }

/* ===== TABLES ===== */
.table-wrapper { overflow-x: auto; margin: 1.5rem 0; }
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.data-table th {
  text-align: left;
  padding: 0.8rem 1rem;
  border-bottom: 2px solid var(--border-light);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  white-space: nowrap;
}
.data-table td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.data-table tbody tr:hover { background: var(--bg-hover); }
.table-note { font-size: 0.82rem; color: var(--text-dim); margin-top: 0.5rem; }
.sig { color: var(--accent-green); font-weight: 700; }
.not-sig { color: var(--text-muted); }

/* ===== PRESSURE MONITOR ===== */
.pressure-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}
.pressure-explainer {
  margin: -0.5rem 0 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.pressure-explainer summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
}
.pressure-explainer p {
  margin-top: 0.85rem;
  color: var(--text-muted);
}
.pressure-table-wrapper {
  margin: 1rem 0 0;
}
.pressure-table {
  font-size: 0.86rem;
}
.pressure-empty {
  margin-top: 1rem;
  padding: 1rem 1.2rem;
  border: 1px dashed var(--border-light);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: var(--bg);
}

/* ===== DATA SOURCES ===== */
.source-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-bottom: 3rem;
}
.source-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: border-color 0.2s;
}
.source-card:hover { border-color: var(--accent); }
.source-card h4 { font-family: var(--font-serif); margin-bottom: 0.5rem; }
.source-meta {
  display: flex;
  gap: 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}
.source-badge {
  display: inline-flex;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--bg);
  border: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-dim);
}
.source-desc {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  line-height: 1.6;
}
.source-fields {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-bottom: 0.75rem;
}
.source-fields code { font-size: 0.75rem; }
.source-card a {
  font-size: 0.85rem;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ===== CHART CONTAINERS ===== */
.chart-full { min-height: 400px; margin: 1.5rem 0; }
.chart-toggle-row {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 1rem;
}
.chart-btn {
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.5rem 1.2rem;
  border-radius: 20px;
  border: 1px solid var(--border-light);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
}
.chart-btn:hover { border-color: var(--accent); color: var(--accent); }
.chart-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Sequential subtle glow on inactive buttons */
@keyframes btn-glow {
  0%   { box-shadow: 0 0 0 0 rgba(59,130,246,0); border-color: var(--border-light); }
  50%  { box-shadow: 0 0 12px 2px rgba(59,130,246,0.25); border-color: var(--accent); }
  100% { box-shadow: 0 0 0 0 rgba(59,130,246,0); border-color: var(--border-light); }
}
.chart-btn.glow:not(.active) {
  animation: btn-glow 2.2s ease-in-out 1;
}

/* ===== PIPELINE FLOW ===== */
.pipeline-flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem 0;
  flex-wrap: wrap;
}
.pipe-step {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.5rem;
  text-align: center;
  font-weight: 600;
  font-size: 0.95rem;
  min-width: 140px;
}
.pipe-detail {
  display: block;
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
  margin-top: 0.3rem;
}
.pipe-arrow {
  font-size: 1.5rem;
  color: var(--accent);
}

/* ===== TWO COLUMN ===== */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: start;
}
.figure-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
.full-width-fig { width: 100%; }
.figure-full { margin: 2rem 0; }
.figure-full img { width: 100%; border-radius: var(--radius); }

/* ===== GALLERY ===== */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
}
.gallery-item {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  transition: transform 0.2s, border-color 0.2s;
}
.gallery-item:hover { transform: translateY(-2px); border-color: var(--accent); }
.gallery-item img { margin-bottom: 1rem; }
.gallery-item h4 { font-family: var(--font-serif); font-size: 1.05rem; margin-bottom: 0.5rem; }
.gallery-item p { font-size: 0.85rem; color: var(--text-muted); }

/* ===== FOOTER ===== */
.footer {
  padding: 4rem 0 2rem;
  border-top: 1px solid var(--border);
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
  margin-bottom: 2rem;
}
.footer h4 { font-family: var(--font-serif); margin-bottom: 0.75rem; }
.footer p { font-size: 0.9rem; color: var(--text-muted); }
.footer-list {
  list-style: none;
  padding: 0;
  font-size: 0.88rem;
}
.footer-list li { padding: 0.3rem 0; color: var(--text-muted); }
.footer-list code { font-size: 0.82rem; }
.footer-note {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-dim);
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

/* ===== THEME TOGGLE ===== */
.theme-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  transition: background 0.2s;
}
.theme-toggle:hover { background: var(--bg-hover); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
  .finding-card, .finding-card-reverse { grid-template-columns: 1fr; direction: ltr; }
  .thesis-grid { grid-template-columns: 1fr; }
  .method-grid { grid-template-columns: 1fr; }
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .hero { padding: 5rem 0 3rem; }
  .hero-title { font-size: 2.5rem; }
  .hero-stats { gap: 1.5rem; }
  .section { padding: 3rem 0; }
  .gallery-grid { grid-template-columns: 1fr; }
  .pipeline-flow { flex-direction: column; }
  .pipe-arrow { transform: rotate(90deg); }
  .stat-row { flex-direction: column; gap: 1rem; }
  .figure-pair { grid-template-columns: 1fr; }
  .pressure-panel { padding: 1rem; }
}
