/* IRS migration explorer — DFW lens */
:root {
  --ink: #14171a;
  --paper: #fdfcf8;
  --rule: #e6e1d2;
  --muted: #6c6557;
  --accent: #b3471f;
  --accent-soft: #d6926a;
  --texas: #2c5d2f;
  --calif: #b3471f;
  --intra: #2b5d8a;
  --other: #8a6d3b;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 4px 16px rgba(0,0,0,.06);
}

*,*::before,*::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 17px/1.55 "Charter","Iowan Old Style","Source Serif Pro",Georgia,serif;
  color: var(--ink);
  background: var(--paper);
  text-rendering: optimizeLegibility;
}
.container { max-width: 1080px; margin: 0 auto; padding-left: 24px; padding-right: 24px; }

header {
  border-bottom: 1px solid var(--rule);
  padding: 96px 0 88px;
  background: #f7f3e8;
}
header h1 {
  font: 700 46px/1.15 "Charter","Iowan Old Style",Georgia,serif;
  margin: 12px 0 24px;
  letter-spacing: -0.01em;
  max-width: 24ch;
}
.kicker {
  font: 600 13px/1 "Helvetica Neue",Arial,sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0;
}
.dek {
  font-size: 19px;
  color: var(--muted);
  margin: 0;
  max-width: 60ch;
}

section { padding-top: 96px; padding-bottom: 96px; border-bottom: 1px solid var(--rule); }
section.article { padding-top: 80px; padding-bottom: 80px; }
section:last-of-type { border-bottom: none; }
section h2 {
  font: 700 32px/1.25 "Charter",Georgia,serif;
  margin: 0 0 16px;
  letter-spacing: -0.005em;
  max-width: 28ch;
}
.article p { font-size: 19px; line-height: 1.7; max-width: 64ch; margin: 0 0 1.25em; }
.article p:last-child { margin-bottom: 0; }
.article p.lead { font-size: 22px; margin-top: 0; line-height: 1.55; }
.article p strong { background: linear-gradient(transparent 60%, #ffe6c2 60%); }
.article em { font-style: italic; color: var(--muted); }
.explainer {
  font: 16px/1.6 "Charter",Georgia,serif;
  color: var(--muted);
  max-width: 70ch;
  margin: 0 0 36px;
}

/* sticky chart region — slider rides at top of viewport through every chart section */
.sticky-region { position: relative; }

.year-control-bar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(247, 243, 232, 0.96);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 12px 0;
  margin-bottom: 12px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.04);
}
.year-control {
  display: flex; align-items: center; gap: 16px;
  flex-wrap: wrap;
}
.year-control label { font-weight: 600; font: 600 14px/1 "Helvetica Neue", Arial, sans-serif; color: var(--ink); }
.year-control input[type=range] {
  flex: 1; min-width: 240px; max-width: 600px;
  accent-color: var(--accent);
}
.year-control output {
  font: 700 20px/1 "Charter",Georgia,serif;
  color: var(--accent);
  min-width: 4ch;
  font-variant-numeric: tabular-nums;
}
.year-control .hint {
  font: 12px/1.3 "Helvetica Neue", Arial, sans-serif;
  color: var(--muted);
  margin-left: auto;
  max-width: 38ch;
  text-align: right;
}
@media (max-width: 720px) {
  .year-control .hint { display: none; }
}

/* charts */
.plot { width: 100%; min-height: 320px; }
.plot.small { min-height: 240px; }
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
  margin-top: 8px;
}
section + section .grid-2 { margin-top: 0; }
.plot + .explainer, .plot + h2 { margin-top: 28px; }
section > * + h2 { margin-top: 48px; }
@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  header h1 { font-size: 32px; }
  .article p.lead { font-size: 19px; }
}

/* map mode toggle */
.map-mode-toggle {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
  flex-wrap: wrap;
}
.map-mode-btn {
  font: 600 13px/1 "Helvetica Neue", Arial, sans-serif;
  background: #f3eedc;
  border: 1px solid var(--rule);
  color: var(--ink);
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s;
}
.map-mode-btn:hover { background: #efe7d0; }
.map-mode-btn.active {
  background: var(--accent);
  color: #fdfcf8;
  border-color: var(--accent);
}

/* checkbox row (DFW counties) */
.checkbox-line {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 14px/1.4 "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: #f3eedc;
  padding: 10px 14px;
  border-radius: 6px;
  margin: 0 0 16px;
  cursor: pointer;
  border: 1px solid var(--rule);
}
.checkbox-line input { accent-color: var(--accent); margin-right: 4px; }
.checkbox-line:hover { background: #efe7d0; }

/* map */
.map-pane {
  height: 540px;
  border-radius: 8px;
  border: 1px solid var(--rule);
  background: #fafaf5;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.legend {
  display: flex; align-items: center; gap: 6px;
  margin-top: 8px;
  font: 13px/1 "Helvetica Neue",Arial,sans-serif;
  color: var(--muted);
}
.legend-label { margin-right: 4px; }
.legend-grad {
  display: inline-block;
  height: 12px;
  width: 200px;
  background: linear-gradient(to right, #fff8ee, #f4d4a3, #e1955a, #ad4b16, #5e1a00);
  border-radius: 2px;
  border: 1px solid var(--rule);
}
.legend-tick { font-variant-numeric: tabular-nums; }

/* DFW tiles */
#dfw-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tile {
  background: #f7f3e8;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
  font: inherit;
  color: inherit;
}
.tile:hover { background: #efe7d0; transform: translateY(-1px); }
.tile.selected {
  border-color: var(--accent);
  background: #fff1e0;
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.tile .tile-name { font-weight: 700; font-size: 15px; }
.tile .tile-stat { font-size: 13px; color: var(--muted); margin-top: 2px; font-variant-numeric: tabular-nums; }
.detail-pane {
  background: #f7f3e8;
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 18px 20px;
  min-height: 360px;
}
.detail-pane h3 { margin: 0 0 4px; font: 700 20px "Charter",Georgia,serif; }
.detail-pane .subhead { margin: 0 0 16px; color: var(--muted); font-size: 14px; }
.detail-pane table { width: 100%; border-collapse: collapse; font-size: 14px; }
.detail-pane th { text-align: left; font-weight: 600; padding: 6px 8px 6px 0; color: var(--muted); border-bottom: 1px solid var(--rule); }
.detail-pane td { padding: 8px 0; border-bottom: 1px solid #f0ead8; font-variant-numeric: tabular-nums; }
.detail-pane td:nth-child(2),
.detail-pane td:nth-child(3) { text-align: right; }
.muted { color: var(--muted); font-style: italic; }

/* misc */
.caveats { font-size: 15px; color: var(--ink); padding-left: 18px; }
.caveats li { margin-bottom: 8px; max-width: 70ch; }
footer {
  padding: 32px 0 64px;
  font-size: 14px;
  color: var(--muted);
}
footer a { color: var(--accent); }

.tooltip {
  position: fixed;
  pointer-events: none;
  background: var(--ink);
  color: #fdfcf8;
  font: 13px/1.4 "Helvetica Neue",Arial,sans-serif;
  padding: 8px 11px;
  border-radius: 4px;
  z-index: 1000;
  box-shadow: 0 6px 20px rgba(0,0,0,0.18);
  max-width: 280px;
}
.tooltip strong { color: #ffe6c2; }
.tooltip .num { font-variant-numeric: tabular-nums; }

.yr { color: var(--accent); font-weight: 700; }
