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

:root {
  --ink:       #0D1117;
  --ink2:      #1C2333;
  --paper:     #F7F4EE;
  --paper2:    #EDEAE2;
  --accent:    #C84B31;
  --accent2:   #E8724A;
  --blue:      #2563A8;
  --green:     #1A6B3C;
  --yellow:    #C9960C;
  --orange:    #C05E1A;
  --muted:     #6B7280;
  --border:    #D4CEBC;
  --mono:      'JetBrains Mono', monospace;
  --serif:     'DM Serif Display', serif;
  --sans:      'DM Sans', sans-serif;

  --thriving:  #1A6B3C;
  --stable:    #C9960C;
  --atrisk:    #C05E1A;
  --critical:  #C84B31;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--paper);
  color: var(--ink);
  overflow-x: hidden;
}

/* ── Typography ──────────────────────────────────────── */
h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.15; }
p { line-height: 1.75; color: #2C3345; }

/* ── Nav ─────────────────────────────────────────────── */
nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2.5rem;
  height: 56px;
  background: rgba(13,17,23,0.96);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.nav-logo {
  font-family: var(--serif);
  font-size: 1.25rem;
  color: #fff;
  letter-spacing: 0.02em;
}

.nav-logo span { color: var(--accent2); }

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

.nav-links a {
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.2s;
}

.nav-links a:hover { color: #fff; }

/* ── Hero ────────────────────────────────────────────── */
.hero {
  min-height: 100vh;
  background: var(--ink);
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  padding: 0 5vw;
  gap: 4rem;
  position: relative;
  overflow: hidden;
}

.hero::before {
  content: '';
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.04'/%3E%3C/svg%3E");
  pointer-events: none;
  opacity: 0.4;
}

.hero-text { position: relative; z-index: 2; padding-top: 56px; }

.hero-eyebrow {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent2);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  display: flex; align-items: center; gap: 0.75rem;
}

.hero-eyebrow::before {
  content: '';
  display: block; width: 32px; height: 1px;
  background: var(--accent2);
}

.hero h1 {
  font-size: clamp(2.8rem, 5vw, 4.5rem);
  color: #fff;
  line-height: 1.08;
  margin-bottom: 1.5rem;
}

.hero h1 em {
  font-style: italic;
  color: var(--accent2);
}

.hero-sub {
  font-size: 1.05rem;
  color: rgba(255,255,255,0.55);
  max-width: 480px;
  margin-bottom: 2.5rem;
  line-height: 1.8;
}

.hero-cta {
  display: inline-flex; align-items: center; gap: 0.75rem;
  background: var(--accent);
  color: #fff;
  padding: 0.85rem 1.75rem;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  transition: background 0.2s, transform 0.2s;
}

.hero-cta:hover { background: var(--accent2); transform: translateY(-1px); }

.hero-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.06);
  margin-top: 3rem;
}

.hero-stat {
  padding: 1.25rem 1.5rem;
  background: rgba(255,255,255,0.02);
}

.hero-stat-number {
  font-family: var(--serif);
  font-size: 2.2rem;
  color: #fff;
  line-height: 1;
  margin-bottom: 0.35rem;
}

.hero-stat-number.red   { color: var(--accent2); }
.hero-stat-number.green { color: #4ADE80; }

.hero-stat-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.hero-map-side {
  position: relative; z-index: 2;
  padding-top: 56px;
  display: flex; align-items: center; justify-content: center;
}

#hero-map svg {
  width: 100%;
  max-width: 480px;
  height: auto;
  filter: drop-shadow(0 0 40px rgba(200,75,49,0.15));
}

/* ── Section Base ────────────────────────────────────── */
section { padding: 7rem 5vw; }

.section-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 1rem;
  display: flex; align-items: center; gap: 0.75rem;
}

.section-label::before {
  content: ''; display: block;
  width: 24px; height: 1px; background: var(--accent);
}

.section-title {
  font-size: clamp(2rem, 3.5vw, 3rem);
  color: var(--ink);
  margin-bottom: 1.5rem;
  max-width: 700px;
}

.section-intro {
  font-size: 1.05rem;
  max-width: 680px;
  margin-bottom: 4rem;
  color: #3D4455;
  line-height: 1.85;
}

/* ── Insight Strip ───────────────────────────────────── */
.insight-strip {
  background: var(--ink2);
  padding: 2.5rem 5vw;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-top: 3px solid var(--accent);
}

.insight-item {
  padding: 1.5rem 2rem;
  border-right: 1px solid rgba(255,255,255,0.07);
}

.insight-item:last-child { border-right: none; }

.insight-number {
  font-family: var(--serif);
  font-size: 2.8rem;
  color: #fff;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.insight-number.danger { color: var(--accent2); }
.insight-number.good   { color: #4ADE80; }
.insight-number.warn   { color: #FBBF24; }

.insight-desc {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.45);
  line-height: 1.6;
}

/* ── Map Section ─────────────────────────────────────── */
.map-section { background: var(--paper); }

.map-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 3rem;
  align-items: start;
}

#main-map {
  background: var(--paper2);
  border: 1px solid var(--border);
  position: relative;
  min-height: 520px;
  display: flex; align-items: center; justify-content: center;
}

#main-map svg { width: 100%; height: auto; }

.map-controls {
  display: flex; gap: 0.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.map-btn {
  padding: 0.5rem 1.1rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 1px solid var(--border);
  background: transparent;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--muted);
}

.map-btn.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.map-btn:hover:not(.active) {
  border-color: var(--ink);
  color: var(--ink);
}

/* State info panel */
.state-panel {
  position: sticky; top: 80px;
}

.state-card {
  background: var(--ink);
  color: #fff;
  padding: 2rem;
  margin-bottom: 1.5rem;
}

.state-card-name {
  font-family: var(--serif);
  font-size: 1.6rem;
  margin-bottom: 0.25rem;
}

.state-card-band {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
  opacity: 0.6;
}

.state-rsi-big {
  font-family: var(--serif);
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 0.25rem;
}

.state-rsi-label {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.4;
  margin-bottom: 1.5rem;
}

.state-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: rgba(255,255,255,0.08);
  margin-bottom: 1.5rem;
}

.state-metric {
  background: rgba(255,255,255,0.03);
  padding: 0.85rem;
}

.state-metric-val {
  font-family: var(--mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: #fff;
}

.state-metric-key {
  font-size: 0.68rem;
  color: rgba(255,255,255,0.35);
  margin-top: 0.2rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Dimension bars */
.dim-bars { margin-top: 0.5rem; }

.dim-bar-row {
  display: flex; align-items: center;
  gap: 0.75rem; margin-bottom: 0.6rem;
}

.dim-bar-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.4);
  width: 60px; flex-shrink: 0;
}

.dim-bar-track {
  flex: 1; height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.dim-bar-fill {
  height: 100%; border-radius: 2px;
  transition: width 0.6s ease;
}

.dim-bar-val {
  font-family: var(--mono);
  font-size: 0.62rem;
  color: rgba(255,255,255,0.4);
  width: 28px; text-align: right; flex-shrink: 0;
}

/* Map legend */
.map-legend {
  background: var(--paper2);
  border: 1px solid var(--border);
  padding: 1.25rem 1.5rem;
}

.legend-title {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.85rem;
}

.legend-items { display: flex; flex-direction: column; gap: 0.5rem; }
.legend-item  { display: flex; align-items: center; gap: 0.6rem; }

.legend-swatch {
  width: 14px; height: 14px; flex-shrink: 0;
}

.legend-label { font-size: 0.78rem; color: var(--muted); }
.legend-range { font-family: var(--mono); font-size: 0.68rem; color: var(--muted); margin-left: auto; }

/* ── Rankings ─────────────────────────────────────────── */
.rankings-section { background: var(--paper2); }

.rankings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
}

.ranking-group-title {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--muted);
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
}

.ranking-row {
  display: flex; align-items: center;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--border);
  gap: 1rem;
  cursor: pointer;
  transition: background 0.15s;
}

.ranking-row:hover { background: rgba(0,0,0,0.03); }

.ranking-num {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  width: 24px; flex-shrink: 0;
}

.ranking-state { flex: 1; font-size: 0.9rem; font-weight: 500; }

.ranking-score {
  font-family: var(--mono);
  font-size: 0.85rem;
  font-weight: 600;
}

.ranking-bar {
  width: 60px; height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.ranking-bar-fill { height: 100%; border-radius: 2px; }

.band-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

/* ── Game Theory ─────────────────────────────────────── */
.theory-section { background: var(--ink); color: #fff; }
.theory-section .section-title { color: #fff; }
.theory-section .section-intro { color: rgba(255,255,255,0.55); }
.theory-section .section-label { color: var(--accent2); }
.theory-section .section-label::before { background: var(--accent2); }

.theory-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  background: rgba(255,255,255,0.06);
  margin-top: 3rem;
}

.theory-card {
  background: var(--ink2);
  padding: 2.5rem 2rem;
  position: relative;
  overflow: hidden;
}

.theory-card::before {
  content: attr(data-num);
  position: absolute; top: -0.5rem; right: 1.5rem;
  font-family: var(--serif);
  font-size: 6rem;
  color: rgba(255,255,255,0.03);
  line-height: 1;
  pointer-events: none;
}

.theory-card-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-bottom: 1rem;
}

.theory-card h3 {
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 1rem;
  line-height: 1.3;
}

.theory-card p {
  font-size: 0.87rem;
  color: rgba(255,255,255,0.5);
  line-height: 1.75;
}

/* ── Findings ────────────────────────────────────────── */
.findings-section { background: var(--paper); }

.findings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4rem;
  align-items: start;
}

.finding-item { margin-bottom: 3rem; }

.finding-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.75rem;
}

.finding-item h3 {
  font-size: 1.4rem;
  margin-bottom: 0.85rem;
  line-height: 1.3;
}

.finding-item p {
  font-size: 0.9rem;
  line-height: 1.8;
  color: #3D4455;
}

.pullquote {
  border-left: 3px solid var(--accent);
  padding: 1.25rem 1.75rem;
  margin: 2rem 0;
  background: var(--paper2);
}

.pullquote p {
  font-family: var(--serif);
  font-size: 1.15rem;
  font-style: italic;
  color: var(--ink);
  line-height: 1.65;
}

/* ── Charts ──────────────────────────────────────────── */
.charts-section { background: var(--paper2); }

.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin-bottom: 2rem;
}

.chart-block {
  background: var(--paper);
  border: 1px solid var(--border);
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.chart-block:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(0,0,0,0.1);
}

.chart-block.full-width { grid-column: 1 / -1; }

.chart-img {
  width: 100%;
  height: auto;
  display: block;
  border-bottom: 1px solid var(--border);
}

.chart-caption { padding: 1.5rem 1.75rem; }

.chart-caption-tag {
  font-family: var(--mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}

.chart-caption h3 {
  font-family: var(--serif);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: var(--ink);
  line-height: 1.3;
}

.chart-caption p {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.7;
}

.chart-phase-divider {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin: 3rem 0 2rem;
}

.chart-phase-divider-line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.chart-phase-divider-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

/* ── Footer ──────────────────────────────────────────── */
footer {
  background: var(--ink);
  padding: 3rem 5vw;
  display: flex; justify-content: space-between; align-items: center;
  border-top: 1px solid rgba(255,255,255,0.07);
}

.footer-logo {
  font-family: var(--serif);
  font-size: 1.1rem;
  color: #fff;
}

.footer-logo span { color: var(--accent2); }

.footer-meta {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: rgba(255,255,255,0.25);
  letter-spacing: 0.08em;
  text-align: right;
  line-height: 1.8;
}

/* ── Tooltip ─────────────────────────────────────────── */
.map-tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: #fff;
  padding: 0.75rem 1rem;
  font-size: 0.8rem;
  font-family: var(--sans);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.15s;
  border-left: 3px solid var(--accent);
  max-width: 220px;
}

.map-tooltip.visible { opacity: 1; }
.map-tooltip-name { font-weight: 600; margin-bottom: 0.25rem; }
.map-tooltip-val  { font-family: var(--mono); font-size: 0.72rem; color: rgba(255,255,255,0.6); }

/* ── Utilities ───────────────────────────────────────── */
.text-accent { color: var(--accent); }
.text-muted  { color: var(--muted); font-size: 0.85rem; }

.loading-msg {
  font-family: var(--mono);
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
  padding: 3rem;
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 900px) {
  .hero                { grid-template-columns: 1fr; }
  .hero-map-side       { display: none; }
  .map-container       { grid-template-columns: 1fr; }
  .state-panel         { position: static; }
  .rankings-grid       { grid-template-columns: 1fr; }
  .theory-cards        { grid-template-columns: 1fr; }
  .findings-grid       { grid-template-columns: 1fr; }
  .insight-strip       { grid-template-columns: 1fr 1fr; }
  .charts-grid         { grid-template-columns: 1fr; }
  .chart-block.full-width { grid-column: 1; }
}

@media (max-width: 540px) {
  .insight-strip { grid-template-columns: 1fr; }
  nav            { padding: 0 1.25rem; }
  .nav-links     { display: none; }
}


/* ── Map loader — paste into your existing <style> in index.html ──── */

.map-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  height: 100%;
  min-height: 200px;
}

.map-loader-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(200, 75, 49, 0.15);
  border-top-color: #C84B31;
  border-radius: 50%;
  animation: map-spin 0.8s linear infinite;
}

@keyframes map-spin {
  to { transform: rotate(360deg); }
}

.map-loader-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  color: #6B7280;
  text-transform: uppercase;
}

.map-loader-icon {
  font-size: 1.5rem;
  line-height: 1;
}

/* Also add these if not already present (state card projection block) */
.proj-divider {
  height: 1px;
  background: rgba(255,255,255,0.08);
  margin: 0.85rem 0 0.75rem;
}
.proj-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.proj-label {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}
.proj-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  color: rgba(255,255,255,0.85);
  font-weight: 600;
}
.proj-model-tag {
  font-size: 0.65rem !important;
  color: rgba(255,255,255,0.4) !important;
  font-weight: 400 !important;
}
.proj-link {
  display: block;
  margin-top: 0.85rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: #E8A87C;
  text-decoration: none;
  text-align: right;
  opacity: 0.8;
  transition: opacity 0.2s;
}
.proj-link:hover { opacity: 1; }
