/* State Insight. Night mode swaps these variables. */
:root {
  --ink: #1c2430;
  --muted: #5c6770;
  --line: #d5dbe0;
  --paper: #f4f6f7;
  --panel: #ffffff;
  --water: #d5e0ea;
  --state: #f7f5f1;
  --state-line: #8ea0ae;
  --hover: #f3e2c4;
  --county: #fbfaf7;
  --county-line: #c5ced6;
  --selected: #1f4b6e;
  --label: #1c2430;
  --label-on: #f4f7fb;
}
body.night {
  --ink: #e7eef4;
  --muted: #b7c3ce;
  --line: #31404d;
  --paper: #10161c;
  --panel: #1a232c;
  --water: #0c1218;
  --state: #243140;
  --state-line: #8aa0b4;
  --hover: #3a4a3c;
  --county: #1c2833;
  --county-line: #6d7c8a;
  --selected: #8fb4d4;
  --label: #e7eef4;
  --label-on: #10202c;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  color: var(--ink);
  background: var(--paper);
  font-family: "Segoe UI", system-ui, sans-serif;
  display: flex;
  flex-direction: column;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.wordmark a { color: inherit; text-decoration: none; }
.wordmark {
  margin: 0;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
#theme, .map-reset {
  appearance: none;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
#theme[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 400px;
}
#map, .leaflet-container { height: 100%; background: var(--water); font: inherit; }
.leaflet-bar a { background: var(--panel); color: var(--ink); border-bottom-color: var(--line); }
aside {
  background: var(--panel);
  border-left: 1px solid var(--line);
  overflow: auto;
  padding: 22px 22px 32px;
}
.kicker {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
h1#place {
  margin: 4px 0 8px;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.hint { margin: 0 0 18px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.metric { border-top: 1px solid var(--line); }
.metric summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 0;
  cursor: pointer;
}
.metric summary::-webkit-details-marker { display: none; }
.ico { width: 20px; height: 20px; flex: 0 0 20px; color: var(--ink); }
.ico svg { display: block; width: 20px; height: 20px; }
.metric h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.base {
  margin-left: auto;
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.caret {
  width: 0;
  height: 0;
  flex: 0 0 auto;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 6px solid var(--ink);
}
details[open] > summary .caret {
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 6px solid var(--ink);
  border-bottom: 0;
}
.sub { margin-top: 8px; border-top: 1px solid var(--line); }
.sub summary {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0 4px;
  cursor: pointer;
}
.sub summary::-webkit-details-marker { display: none; }
.sub-title {
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.sub .base { font-size: 14px; }
.sub > summary .caret {
  border-top-width: 3px;
  border-bottom-width: 3px;
  border-left-width: 5px;
}
.sub[open] > summary .caret {
  border-left-width: 3px;
  border-right-width: 3px;
  border-top-width: 5px;
}
.sub-body { padding: 0 0 8px 12px; }
.detail { padding: 0 0 12px 28px; }
.rate {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 0;
  font-size: 14px;
  line-height: 1.35;
}
.rate b { font-weight: 600; font-variant-numeric: tabular-nums; }
.what, .source { margin: 4px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; }
.source a { color: var(--ink); }
.group {
  margin: 12px 0 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 650;
}
.leaders {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 450;
  overflow: visible;
}
.leaders text { font-family: "Segoe UI", system-ui, sans-serif; fill: var(--ink); }
.leaders text.callout { fill: #1c2430; }
.leaders rect.leader-back { fill: #ffffff; stroke: #d5dbe0; stroke-width: 1; }
.leaders line { stroke: var(--ink); stroke-width: 1; opacity: 0.7; }
.neighbors { padding-top: 14px; border-top: 1px solid var(--line); }
.neighbors h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.neighbors p { margin: 8px 0 0; line-height: 1.45; }
.foot { margin: 22px 0 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.leaflet-tooltip, .map-label {
  background: transparent;
  border: 0;
  box-shadow: none;
  color: var(--label);
  text-align: center;
  line-height: 1.15;
  white-space: nowrap;
  text-shadow: 0 0 3px var(--water), 0 0 3px var(--water);
}
.map-label.on-fill { color: var(--label-on); text-shadow: none; }
.map-label b, .map-label span { display: block; font-weight: 650; }
.map-label span { font-weight: 550; }
.leaflet-tooltip { background: var(--ink); color: var(--panel); font-size: 12px; padding: 4px 6px; text-shadow: none; }
.leaflet-tooltip:before { display: none; }
.leaflet-top.leaflet-right { margin-top: 8px; margin-right: 8px; }
.leaflet-control.map-reset-wrap {
  border: 0;
  background: transparent;
  box-shadow: none;
}

.city-symbol {
  background: transparent;
  border: 0;
}
.city-symbol svg { display: block; overflow: visible; }

.city-key {
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  box-shadow: none;
  line-height: 1;
}
.city-key p {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}
.city-key p + p { margin-top: 4px; }
.city-key-mark {
  display: flex;
  width: 14px;
  height: 14px;
  align-items: center;
  justify-content: center;
  flex: 0 0 14px;
}
.city-key-mark svg { display: block; }
.city-key.is-hidden { display: none; }

.city-toggle {
  appearance: none;
  display: block;
  width: 100%;
  margin-top: 6px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 4px 8px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}
.city-toggle[aria-pressed="false"] {
  background: var(--ink);
  color: var(--panel);
}

.leaflet-top.leaflet-left {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
}
.leaflet-top.leaflet-left .leaflet-control {
  float: none;
  clear: none;
}
.label-toggles {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 10px 0 0 0;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 6px 8px;
  box-shadow: none;
}
.check-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.check-toggle input {
  appearance: none;
  -webkit-appearance: none;
  position: absolute;
  opacity: 0;
  width: 14px;
  height: 14px;
  margin: 0;
  pointer-events: none;
}
.check-toggle input::before,
.check-toggle input::after,
.check-toggle input:checked + .check-box::before,
.check-toggle input:checked + .check-box::after {
  content: none;
}
.check-box {
  width: 14px;
  height: 14px;
  box-sizing: border-box;
  border: 1.5px solid var(--ink);
  background: var(--panel);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 14px;
  font-size: 11px;
  font-weight: 750;
  line-height: 1;
}
.check-toggle input:checked + .check-box {
  background: var(--ink);
}
.check-toggle input:focus-visible + .check-box {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}
.map-label span.gdp-line,
.map-label span.pop-line,
.map-label span.housing-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
}
.map-label span.gdp-line svg,
.map-label span.pop-line svg,
.map-label span.housing-line svg {
  display: block;
  flex: none;
  width: 1em;
  height: 1em;
}
.bin-note {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
  letter-spacing: 0;
  text-transform: none;
}

.rate.industry { flex-wrap: nowrap; }
.rate.industry span { min-width: 0; }
.rate.industry b { white-space: nowrap; flex: none; }
.group { display: flex; align-items: center; gap: 6px; }
.info-dot {
  appearance: none;
  width: 15px;
  height: 15px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid currentColor;
  background: transparent;
  color: var(--muted);
  font: 700 10px/1 Georgia, "Iowan Old Style", serif;
  letter-spacing: 0;
  text-transform: none;
  cursor: help;
  flex: none;
}
.rate .info-dot { margin-left: 6px; vertical-align: 1px; }
.site-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 8px 20px 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.site-foot p { margin: 0; color: var(--muted); }
.site-foot a, .sources a { color: var(--ink); }
body.sources-page { height: auto; min-height: 100%; }
.sources {
  max-width: 760px;
  margin: 0 auto;
  padding: 28px 22px 64px;
}
.sources h1 {
  margin: 8px 0 12px;
  font-family: Georgia, "Iowan Old Style", Palatino, serif;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.sources p { line-height: 1.5; }
.sources ul { padding-left: 18px; }
.sources li { margin: 12px 0; line-height: 1.45; }
.sources .back { color: var(--muted); font-size: 14px; }

.sub-body:has(> .rate.age) {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  column-gap: 12px;
  row-gap: 6px;
  align-items: center;
}
.rate.age { display: contents; }
.rate.age b { white-space: nowrap; text-align: right; }
.age-track {
  width: 100%;
  height: 8px;
  min-width: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  box-sizing: border-box;
}
.age-fill {
  display: block;
  height: 100%;
  background: var(--ink);
  max-width: 100%;
}
.sub-body:has(> .rate.race) {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  column-gap: 12px;
  row-gap: 6px;
  align-items: center;
}
.rate.race { display: contents; }
.rate.race b { white-space: nowrap; text-align: right; }
.race-track {
  width: 100%;
  height: 8px;
  min-width: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
  box-sizing: border-box;
}
.race-fill {
  display: block;
  height: 100%;
  background: var(--ink);
  max-width: 100%;
}
details.metric.is-muted,
details.metric.is-muted .ico,
details.metric.is-muted h2,
details.metric.is-muted .base,
details.metric.is-muted .what,
details.metric.is-muted .source,
details.metric.is-muted .source a {
  color: var(--muted);
}
