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

/* ── Design tokens ──────────────────────────────────────────────────────── */
:root {
  --bg: #0a0a0f;
  --bg2: #12121a;
  --fg: #e0e0e8;
  --fg2: #888894;
}

/* ── Base ───────────────────────────────────────────────────────────────── */
body {
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

#wrapper {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* ── Header & intro ─────────────────────────────────────────────────────── */
#header {
  padding: 20px 28px 16px;
  flex-shrink: 0;
}

.intro {
  margin-bottom: 18px;
}
.intro h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.intro h1 a {
  font-size: 13px;
  font-weight: 400;
  color: var(--fg2);
  text-decoration: none;
}
.intro h1 a:hover { text-decoration: underline; }
.intro p {
  font-size: 15px;
  line-height: 1.6;
  color: var(--fg2);
  margin-bottom: 8px;
}
.intro a { color: var(--fg2); }
.intro strong, .intro b { color: var(--fg); font-weight: 600; }

/* ── Stats ──────────────────────────────────────────────────────────────── */
.stats-row {
  display: flex;
  flex-wrap: wrap;
  gap: 20px 28px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.stat-section {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.stat-section h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--fg2);
}
.stat-big {
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1;
}
.stat-label {
  font-size: 11px;
  color: var(--fg2);
}

/* ── Controls ───────────────────────────────────────────────────────────── */
.controls-row {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.color-toggle {
  display: flex;
  gap: 4px;
}
.color-toggle button {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 4px;
  background: transparent;
  color: var(--fg2);
  cursor: pointer;
  transition: all 0.15s;
}
.color-toggle button.active {
  background: rgba(255,255,255,0.08);
  color: var(--fg);
  border-color: rgba(255,255,255,0.2);
}
.color-toggle button:hover:not(.active):not(:disabled) {
  background: rgba(255,255,255,0.04);
}
.color-toggle button:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* ── Gradient legend ────────────────────────────────────────────────────── */
.gradient-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--fg2);
}
.gradient-legend canvas { border-radius: 2px; }

/* ── Main canvas ────────────────────────────────────────────────────────── */
canvas#canvas {
  display: block;
  cursor: default;
}

/* ── Tooltip ────────────────────────────────────────────────────────────── */
#tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--bg2);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 340px;
  opacity: 0;
  transition: opacity 0.12s;
  z-index: 20;
  box-shadow: 0 8px 32px rgba(0,0,0,0.6);
}
#tooltip.visible { opacity: 1; }
#tooltip .tt-title { font-weight: 600; font-size: 14px; margin-bottom: 6px; color: #fff; }
#tooltip .tt-exposure { font-size: 12px; margin-bottom: 8px; }
#tooltip .tt-stats { display: grid; grid-template-columns: auto auto; gap: 2px 12px; font-size: 12px; }
#tooltip .tt-stats .label { color: var(--fg2); }
#tooltip .tt-stats .value { color: var(--fg); text-align: right; }
#tooltip .tt-rationale { font-size: 11px; color: var(--fg2); margin-top: 8px; line-height: 1.4; border-top: 1px solid rgba(255,255,255,0.06); padding-top: 8px; }

/* ── Site nav ───────────────────────────────────────────────────────────── */
.site-nav {
  max-width: 1400px;
  margin: 0 auto;
  padding: 12px 28px;
  display: flex;
  gap: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.nav-link {
  font-size: 14px;
  font-weight: 500;
  color: var(--fg2);
  text-decoration: none;
  padding-bottom: 10px;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}
.nav-link:hover { color: var(--fg); }
.nav-link.active {
  color: var(--fg);
  font-weight: 600;
  border-bottom-color: var(--fg);
}

/* ── Horizontal bar chart ───────────────────────────────────────────────── */
.hbar-chart { display: flex; flex-direction: column; gap: 3px; }
.hbar-row { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.hbar-label { width: 72px; flex-shrink: 0; color: var(--fg2); font-size: 11px; text-align: right; }
.hbar-track { flex: 1; height: 12px; background: rgba(255,255,255,0.04); border-radius: 2px; overflow: hidden; min-width: 36px; }
.hbar-fill { height: 100%; border-radius: 2px; }
.hbar-val { width: 30px; flex-shrink: 0; font-size: 11px; color: var(--fg); text-align: right; }

/* ── Heatmap ────────────────────────────────────────────────────────────── */
.heatmap { margin-top: 24px; padding: 0 28px; }
.heatmap-title { font-size: 13px; font-weight: 600; margin-bottom: 10px; }
.heatmap-grid { display: flex; flex-direction: column; gap: 2px; }
.heatmap-row { display: flex; align-items: center; gap: 2px; }
.heatmap-label { width: 140px; flex-shrink: 0; font-size: 10px; color: var(--fg2); text-align: right; padding-right: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.heatmap-cell { width: 36px; height: 20px; border-radius: 2px; display: flex; align-items: center; justify-content: center; font-size: 8px; color: rgba(255,255,255,0.6); cursor: default; transition: opacity 0.1s; }
.heatmap-cell:hover { opacity: 0.8; }
.heatmap-cell.empty { background: rgba(255,255,255,0.03); }
.heatmap-months { display: flex; gap: 2px; margin-left: 142px; margin-bottom: 4px; }
.heatmap-months span { width: 36px; text-align: center; font-size: 9px; color: var(--fg2); }

/* ── Footer ─────────────────────────────────────────────────────────────── */
.site-footer {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 28px 48px;
  text-align: center;
}
.footer-partner a {
  display: inline-block;
  transition: opacity 0.15s;
}
.footer-partner a:hover { opacity: 0.85; }
.footer-partner img {
  max-width: 728px;
  max-height: 90px;
  width: auto;
  height: auto;
  border-radius: 8px;
}
.footer-meta {
  margin-top: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--fg2);
}
