/* Shared chrome for all three page types: the chooser, the four model maps, and
   the Illinois page. Kept in one file so they cannot drift apart -- a reader is
   meant to flip between them and notice only the districting change. */

:root {
  /* Light-only by design -- the palette is tuned against white. Declared so a
     dark-theme OS does not restyle native controls. */
  color-scheme: light;
  --surface: #fff;
  --ink: #1a1a1a;
  --ink-muted: #6b7280;
  --rule: #e5e7eb;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
main { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1.25rem 4rem; }

h1 { font-size: 1.7rem; line-height: 1.25; margin: 0 0 .6rem; font-weight: 650; letter-spacing: -.01em; }
.blurb { max-width: 62ch; margin: 0 0 .5rem; }
.note { max-width: 62ch; margin: 0 0 1.75rem; color: var(--ink-muted); font-size: .9rem; }

/* Model switcher, on every map page so the four are one step apart. */
#nav, .sitenav {
  display: flex; flex-wrap: wrap; gap: .1rem; align-items: center;
  margin: 0 0 1.5rem; font-size: .85rem;
  border-bottom: 1px solid var(--rule); padding-bottom: .5rem;
}
#nav a, #nav .here, .sitenav a {
  padding: .3rem .6rem; border-radius: 5px; text-decoration: none; color: var(--ink-muted);
}
#nav a:hover, .sitenav a:hover { background: #f3f4f6; color: var(--ink); }
#nav .here { color: var(--ink); font-weight: 650; background: #f3f4f6; }
#nav .aside { margin-left: auto; }

.stats { display: flex; flex-wrap: wrap; gap: 2rem; margin: 0 0 1.75rem; padding: 0; list-style: none; }
.stats div { font-variant-numeric: tabular-nums; }
.stats .n { font-size: 1.45rem; font-weight: 650; display: block; line-height: 1.15; }
.stats .k { font-size: .78rem; color: var(--ink-muted); text-transform: uppercase; letter-spacing: .05em; }

#figure { position: relative; }
svg { display: block; width: 100%; height: auto; overflow: visible; }
[data-k] { cursor: crosshair; }

#tooltip {
  position: absolute; pointer-events: none; opacity: 0;
  transition: opacity .1s; background: #fff; color: var(--ink);
  border: 1px solid var(--rule); border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0,0,0,.10);
  padding: .55rem .7rem; font-size: .82rem; line-height: 1.45;
  max-width: 15rem; z-index: 5;
}
#tooltip .t-state { font-weight: 650; }
#tooltip .t-row { display: flex; justify-content: space-between; gap: 1.25rem; }
#tooltip .t-row span:last-child { font-variant-numeric: tabular-nums; }
#tooltip .t-note { color: var(--ink-muted); margin-top: .3rem; }

#legend {
  display: flex; flex-wrap: wrap; gap: 1.75rem; align-items: center;
  margin: 0 0 1.25rem; padding: .75rem .9rem;
  border: 1px solid var(--rule); border-radius: 7px; font-size: .82rem;
}
#legend .item { display: flex; align-items: center; gap: .55rem; flex: 1 1 16rem; }
#legend .item span { line-height: 1.35; }
/* Override the full-bleed rule above: these swatches are fixed-size icons, not
   the chart. Without this they inflate to the container width. */
#legend svg { display: block; flex: none; width: 44px; height: 44px; }

/* The table has many columns and a min-content width wider than a phone. It
   scrolls inside itself; without this the whole page scrolls sideways. */
#table { overflow-x: auto; }
table.districts { border-collapse: collapse; width: 100%; min-width: 32rem; font-size: .8rem; margin-top: 1rem; }
table.districts th, table.districts td { text-align: right; padding: .25rem .5rem; border-bottom: 1px solid var(--rule); }
table.districts th:first-child, table.districts td:first-child { text-align: left; }
table.districts td { font-variant-numeric: tabular-nums; }

/* The preflight report: what a bundle got wrong, in place of the figure. Only
   ever seen while adapting this engine to new data. */
.dataerr { border: 1px solid #fca5a5; background: #fef2f2; border-radius: 7px;
           padding: .9rem 1.1rem; font-size: .88rem; max-width: 62ch; }
.dataerr ul { margin: .5rem 0; padding-left: 1.2rem; }
.dataerr li { margin: .2rem 0; }
.dataerr code { background: #fff; padding: 0 .2rem; border-radius: 3px; }

details { margin-top: 1.5rem; }
summary { cursor: pointer; font-size: .85rem; color: var(--ink-muted); }

footer {
  margin-top: 2.5rem; padding-top: 1.25rem; border-top: 1px solid var(--rule);
  font-size: .82rem; color: var(--ink-muted);
}
footer a { color: inherit; }
#credit { max-width: 74ch; }
