/* Design tokens per the dataviz reference palette (light + selected dark). */
:root {
  --surface-1: #fcfcfb;
  --page: #f9f9f7;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --ring: rgba(11, 11, 11, 0.10);
  --accent: #2a78d6;
  --no-data: #e1e0d9;
}
@media (prefers-color-scheme: dark) {
  :root {
    --surface-1: #1a1a19;
    --page: #0d0d0d;
    --ink: #ffffff;
    --ink-2: #c3c2b7;
    --muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --ring: rgba(255, 255, 255, 0.10);
    --accent: #3987e5;
    --no-data: #2c2c2a;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  /* Content pages (About, county pages, etc.) grow with their content and scroll
     normally. Map/app pages get an exact viewport height below so the map fills
     the leftover space and the side panel scrolls internally. */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
/* Interactive map pages (which contain .layout) are locked to one viewport tall
   so the map fits with no page scroll — UNLESS the page also carries an SEO
   directory below (.home-seo), in which case the map takes a tall-but-bounded
   height and the page scrolls to the directory instead of squashing the map. */
body:has(.layout):not(:has(.home-seo)), body:has(.afford-main):not(:has(.faq)) { height: 100vh; }
body:has(.home-seo) .layout,
body:has(.afford-main):has(.faq) .afford-main { flex: none; height: 82vh; min-height: 420px; }
/* Sticky footer on content pages: let the main grow so the footer sits at the
   bottom of the viewport instead of floating mid-screen on short pages. Map and
   afford pages manage their own height and are excluded. */
body:not(:has(.layout)):not(:has(.afford-main)) main { flex: 1 0 auto; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- header ---------- */
.topbar {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 14px 20px 10px;
  flex-wrap: wrap;
}
.brand, .brand:hover { display: inline-flex; align-items: center; color: var(--ink); text-decoration: none; }
.brand::before {
  content: ""; width: 26px; height: 26px; margin-right: 9px; flex: 0 0 auto;
  background: url("/favicon.svg") center / contain no-repeat;
}
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: -0.01em; }
.brand-sub { color: var(--ink-2); margin-left: 10px; font-size: 13px; }
.nav { display: flex; flex-wrap: wrap; gap: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.prose .callout {
  border: 1px solid var(--grid); border-left: 4px solid var(--accent);
  background: var(--surface-1); border-radius: 8px; padding: 4px 18px 14px; margin: 20px 0;
}
.prose .callout h2 { margin-top: 14px; font-size: 17px; }
.prose .callout p, .prose .callout li { color: var(--ink-2); }
/* Social share bar */
.share-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 20px 0; }
.share-label { font-size: 13px; font-weight: 700; color: var(--ink-2); margin-right: 2px; }
.share-btn {
  display: inline-flex; align-items: center; padding: 7px 14px; border: 1px solid var(--grid);
  border-radius: 999px; background: var(--surface-1); color: var(--ink); font-size: 13px;
  font-weight: 600; cursor: pointer; line-height: 1; transition: transform .12s, background .15s, border-color .15s, color .15s;
}
.share-btn:hover { text-decoration: none; transform: translateY(-1px); }
.share-btn:active { transform: scale(.96); }
.share-x:hover { background: #0f0f0f; color: #fff; border-color: #0f0f0f; }
.share-reddit:hover { background: #ff4500; color: #fff; border-color: #ff4500; }
.share-facebook:hover { background: #1877f2; color: #fff; border-color: #1877f2; }
.share-whatsapp:hover { background: #25d366; color: #fff; border-color: #25d366; }
.share-copy { color: var(--accent); border-color: var(--accent); }
/* City dots (zoomed-in level of detail on the US map) */
.city-dot { stroke: #ffffff; stroke-opacity: 0.85; cursor: pointer; }
.city-dot:hover { stroke: var(--ink); stroke-opacity: 1; }
@media (prefers-color-scheme: dark) { .city-dot { stroke: #0d0d0d; } }
.nav-link {
  color: var(--ink-2); padding: 5px 10px; border-radius: 7px; font-size: 14px;
}
.nav-link:hover { color: var(--ink); text-decoration: none; background: var(--grid); }
.nav-link.active { color: var(--ink); font-weight: 600; }

/* ---------- controls ---------- */
.controls {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 6px 20px 12px;
}
.segmented {
  display: inline-flex; flex-wrap: wrap; max-width: 100%; background: var(--surface-1);
  border: 1px solid var(--ring); border-radius: 9px; padding: 2px;
}
.segmented button {
  appearance: none; border: 0; background: transparent; color: var(--ink-2);
  font: 600 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 7px 12px; border-radius: 7px; cursor: pointer; white-space: nowrap;
}
.segmented button:hover { color: var(--ink); }
.segmented button[aria-selected="true"] { background: var(--grid); color: var(--ink); }

.zip-lookup { display: flex; gap: 8px; max-width: 360px; margin: 16px 0 8px; }
.zip-lookup input {
  flex: 1; padding: 12px 15px; font-size: 19px; letter-spacing: 1px; font-variant-numeric: tabular-nums;
  border: 1px solid var(--grid); border-radius: 10px; background: var(--surface-1); color: var(--ink);
}
.zip-lookup button {
  padding: 0 20px; border: 0; border-radius: 10px; background: var(--accent); color: #fff;
  font-weight: 600; font-size: 15px; cursor: pointer;
}
.zip-lookup button:active { transform: scale(.97); }
.zip-h { margin: 6px 0 0; }
.zip-place { margin-top: 2px !important; font-size: 14px; }
.zip-h3 { margin-bottom: 6px; }
.gdetail { background: var(--surface-1); border: 1px solid var(--grid); border-radius: 10px; padding: 10px 12px; margin: 4px 0 12px; }
.gd-name { font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.gd-row { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; margin: 3px 0; }
.gd-lbl { color: var(--muted); font-size: 11px; width: 54px; flex: 0 0 54px; }
.gd-w { color: var(--muted); font-size: 10.5px; }
.gd-cell b { font-variant-numeric: tabular-nums; }
.gd-cell b.neg { color: #e14b34; }
.gd-span { color: var(--muted); font-size: 10.5px; margin-top: 6px; }
/* E-E-A-T byline + FAQ accordion + ad-slot CLS reservation (SEO audit) */
.byline { color: var(--muted); font-size: 12.5px; margin: 2px 0 14px; }
.byline a { color: var(--ink-2); }
.faq { margin: 28px 0 8px; }
.faq-q { border: 1px solid var(--grid); border-radius: 9px; margin: 8px 0; background: var(--surface-1); }
.faq-q > summary { cursor: pointer; padding: 11px 14px; font-weight: 600; font-size: 14.5px; list-style: none; }
.faq-q > summary::-webkit-details-marker { display: none; }
.faq-q > summary::after { content: "+"; float: right; color: var(--muted); font-weight: 400; }
.faq-q[open] > summary::after { content: "\2013"; }
.faq-a { padding: 0 14px 12px; color: var(--ink-2); font-size: 14px; }
.faq-a b { color: var(--ink); }
.ad-slot { min-height: 90px; }
/* Collapse an ad slot AdSense reports as unfilled so it leaves no empty gap on
   the live site (still reserved while loading, to avoid layout shift). */
.ad-slot:has(> .adsbygoogle[data-ad-status="unfilled"]) { display: none; }
.home-seo { max-width: 1120px; margin: 6px auto 0; padding: 20px 20px 6px; color: var(--ink-2); }
.home-seo h2 { font-size: 18px; margin: 0 0 8px; color: var(--ink); }
.home-seo > p { font-size: 14px; line-height: 1.62; margin: 0 0 12px; max-width: 74ch; }
.state-dir { display: flex; flex-wrap: wrap; gap: 3px 16px; font-size: 13.5px; line-height: 1.7; margin-bottom: 12px; }
.state-dir a { color: var(--ink-2); text-decoration: none; }
.state-dir a:hover { color: var(--accent); text-decoration: underline; }
.home-seo-hubs { font-size: 13px; color: var(--muted); }
.home-seo-hubs a { color: var(--ink-2); }
.verdict { margin: 8px 0 20px; padding: 15px 17px; border: 1px solid var(--grid); border-radius: 13px; background: var(--surface-1); }
.verdict-lead { font-size: 17.5px; font-weight: 650; color: var(--ink); margin: 0 0 12px; line-height: 1.42; }
.score-badges { display: flex; flex-wrap: wrap; gap: 9px; }
.sbadge { flex: 1 1 128px; min-width: 116px; border: 1px solid var(--grid); border-left-width: 3px; border-radius: 9px; padding: 8px 12px; background: var(--page); }
.sb-k { display: block; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.sb-v { display: block; font-size: 20px; font-weight: 800; letter-spacing: -.01em; font-variant-numeric: tabular-nums; margin: 1px 0 0; }
.sb-l { display: block; font-size: 12px; color: var(--ink-2); }
.sb-green { border-left-color: #12a37f; } .sb-green .sb-v { color: #12a37f; }
.sb-red { border-left-color: #e5484d; } .sb-red .sb-v { color: #e5484d; }
.sb-amber { border-left-color: #d9821a; } .sb-amber .sb-v { color: #d9821a; }
.sb-grey { border-left-color: var(--baseline); } .sb-grey .sb-v { color: var(--ink); }
.verdict-note { font-size: 11px; color: var(--muted); margin: 11px 0 0; }
.recent { margin-top: 28px; padding-top: 18px; border-top: 1px solid var(--grid); }
.chart-tools { display: flex; gap: 6px; justify-content: flex-end; margin-top: 5px; }
.chart-tools button { font: inherit; font-size: 11.5px; font-weight: 600; color: var(--ink-2);
  background: var(--surface-1); border: 1px solid var(--grid); border-radius: 6px; padding: 3px 9px; cursor: pointer; }
.chart-tools button:hover { border-color: var(--accent); color: var(--accent); }
.embed-box { margin: 12px 0; border: 1px solid var(--grid); border-radius: 9px; background: var(--surface-1); }
.embed-box > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: 14px; list-style: none; }
.embed-box > summary::-webkit-details-marker { display: none; }
.embed-box > summary::after { content: "▾"; float: right; color: var(--muted); }
.embed-box[open] > summary::after { content: "▴"; }
.embed-box .chart-note { padding: 0 14px; }
.embed-code { display: block; width: calc(100% - 28px); margin: 4px 14px 12px; padding: 9px 11px;
  font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 12px; line-height: 1.5;
  border: 1px solid var(--grid); border-radius: 7px; background: var(--page); color: var(--ink-2); resize: vertical; }
.search-page-box { margin: 4px 0 18px; max-width: 620px; }
.search-page-input { width: 100%; box-sizing: border-box; padding: 13px 16px; font-size: 16px;
  border: 1px solid var(--grid); border-radius: 11px; background: var(--surface-1); color: var(--ink); }
.search-page-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--ring); }
.search-page-results { display: flex; flex-direction: column; gap: 2px; max-width: 620px; }
.search-page-results .muted { color: var(--muted); font-size: 14px; padding: 6px 2px; }
.sr-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px;
  text-decoration: none; color: var(--ink); border: 1px solid transparent; }
.sr-item:hover { background: var(--surface-1); border-color: var(--grid); }
.sr-t { flex: 0 0 auto; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); width: 54px; }
.sr-t-city { color: var(--accent); }
.sr-l { flex: 1 1 auto; font-size: 14.5px; }
.sr-v { flex: 0 0 auto; font-variant-numeric: tabular-nums; color: var(--ink-2); font-size: 14px; }
.map-pick { display: inline-flex; align-items: center; gap: 7px; }
.map-pick-label { color: var(--muted); font-size: 13px; font-weight: 600; }
.year-wrap { display: inline-flex; flex-wrap: wrap; max-width: 100%; align-items: center; gap: 9px; }
.year-label { color: var(--muted); font-size: 13px; }
.year-wrap.disabled { opacity: 0.45; pointer-events: none; }

.play-btn {
  appearance: none; border: 1px solid var(--ring); background: var(--surface-1);
  color: var(--ink); width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
  font-size: 12px; line-height: 1; display: inline-flex; align-items: center;
  justify-content: center; flex: none;
}
.play-btn:hover { background: var(--grid); }
.play-btn:disabled { cursor: default; }

.year-slider {
  appearance: none; -webkit-appearance: none; height: 4px; width: 190px;
  border-radius: 3px; background: var(--ring); outline: none; cursor: pointer;
}
.year-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 16px; height: 16px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--page); cursor: pointer;
}
.year-slider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--page); cursor: pointer;
}
.year-readout {
  color: var(--ink); font-size: 13px; font-variant-numeric: tabular-nums;
  min-width: 84px; white-space: nowrap;
}
.mortgage-readout {
  color: var(--ink-2); font-size: 12.5px; white-space: nowrap;
  padding-left: 10px; border-left: 1px solid var(--ring);
}
.mortgage-readout:empty { display: none; }
.mortgage-readout .mtg-label { color: var(--muted); font-size: 11px; margin-right: 4px; }
.mortgage-readout b { color: var(--ink); font-variant-numeric: tabular-nums; }

.price-wrap { display: inline-flex; align-items: center; gap: 6px; }
.price-wrap.disabled { opacity: 0.45; pointer-events: none; }
.price-input {
  background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--ring); border-radius: 7px; padding: 6px 8px;
  font-size: 13px; width: 78px; outline: none; -moz-appearance: textfield;
}
.price-input::-webkit-outer-spin-button,
.price-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.price-dash { color: var(--muted); }
.price-clear {
  appearance: none; border: 1px solid var(--ring); background: var(--surface-1);
  color: var(--ink-2); width: 26px; height: 26px; border-radius: 7px; cursor: pointer;
  font-size: 14px; line-height: 1;
}
.price-clear:hover { background: var(--grid); color: var(--ink); }

/* ---------- compare tray ---------- */
.compare-tray {
  position: sticky; bottom: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px; margin-top: auto;
  background: var(--surface-1); border-top: 1px solid var(--ring);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.10);
}
/* the display:flex above overrode the [hidden] attribute, leaving an empty bar */
.compare-tray[hidden] { display: none; }
.compare-tray .cmp-label {
  color: var(--muted); font-size: 12px; font-weight: 600; white-space: nowrap;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.compare-tray .cmp-chips {
  display: flex; gap: 8px; overflow-x: auto; flex: 1; padding-bottom: 2px;
}
.cmp-chip {
  appearance: none; cursor: pointer; flex: none;
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--page); border: 1px solid var(--ring); border-radius: 999px;
  padding: 5px 6px 5px 12px; color: var(--ink); font-size: 13px;
}
.cmp-chip:hover { border-color: var(--accent); }
.cmp-chip .cmp-name { white-space: nowrap; }
.cmp-chip .cmp-val { font-weight: 700; font-variant-numeric: tabular-nums; }
.cmp-chip .cmp-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; background: var(--grid);
  color: var(--ink-2); font-size: 13px; line-height: 1;
}
.cmp-chip .cmp-x:hover { background: var(--accent); color: #fff; }
.cmp-clear {
  appearance: none; border: 1px solid var(--ring); background: transparent;
  color: var(--ink-2); border-radius: 7px; padding: 6px 10px; cursor: pointer;
  font-size: 12px; white-space: nowrap; flex: none;
}
.cmp-clear:hover { background: var(--grid); color: var(--ink); }

/* ---------- rankings page ---------- */
.rank-select {
  background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--ring); border-radius: 7px; padding: 6px 8px; font-size: 13px;
}
.segmented.disabled { opacity: 0.4; pointer-events: none; }
.segmented button:disabled { opacity: 0.4; cursor: not-allowed; }
.rank-main { padding: 8px 20px 28px; max-width: 820px; width: 100%; margin: 0 auto; }
.rank-title { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; margin: 10px 0 16px; }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row {
  appearance: none; cursor: pointer; text-align: left; width: 100%;
  display: grid; grid-template-columns: 34px minmax(110px, 210px) 1fr auto;
  align-items: center; gap: 14px;
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 12px;
  padding: 11px 14px; color: var(--ink); font-size: 14px;
  transition: transform 0.08s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.rank-row:hover {
  transform: translateY(-1px); border-color: var(--accent);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}
.rank-num {
  width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px; font-variant-numeric: tabular-nums;
  background: var(--grid); color: var(--ink-2);
}
.rank-num.medal { color: #1a1400; box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12); }
.rank-num.m1 { background: linear-gradient(150deg, #ffe08a, #e6b422); }
.rank-num.m2 { background: linear-gradient(150deg, #eef0f3, #b9bfc9); }
.rank-num.m3 { background: linear-gradient(150deg, #f0c199, #cd8a54); }
.rank-name { min-width: 0; display: flex; align-items: baseline; gap: 8px; }
.rank-county {
  font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-st {
  flex: none; font-size: 11px; font-weight: 700; color: var(--ink-2);
  background: var(--grid); border-radius: 5px; padding: 1px 6px; letter-spacing: 0.02em;
}
.rank-bar-wrap { height: 18px; display: flex; align-items: center; }
.rank-bar { height: 12px; border-radius: 6px; min-width: 3px; }
.rank-bar.val { background: linear-gradient(90deg, #256abf, #6da7ec); }
.rank-bar.pos { background: linear-gradient(90deg, #1c7d37, #57bf6a); }
.rank-bar.neg { background: linear-gradient(90deg, #a11810, #f67c46); }
.rank-val { font-weight: 700; font-size: 16px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-val.pos { color: #2a9d54; }
.rank-val.neg { color: #e0524f; }
.rank-val .rank-arrow { font-size: 11px; margin-right: 2px; vertical-align: 1px; }
@media (max-width: 620px) {
  .rank-row { grid-template-columns: 30px 1fr auto; gap: 10px; }
  .rank-bar-wrap { display: none; }
}

/* ---------- cookie consent ---------- */
.consent-banner {
  position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 1000;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; max-width: 720px; margin: 0 auto;
  background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--ring); border-radius: 12px; padding: 12px 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.22);
}
.consent-banner .consent-text { font-size: 13px; flex: 1 1 260px; color: var(--ink-2); }
.consent-banner .consent-actions { display: flex; gap: 8px; }
.consent-btn {
  appearance: none; border: 1px solid var(--ring); border-radius: 8px;
  padding: 8px 16px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.consent-btn.decline { background: transparent; color: var(--ink-2); }
.consent-btn.decline:hover { background: var(--grid); color: var(--ink); }
.consent-btn.accept { background: var(--accent); color: #fff; border-color: var(--accent); }
.consent-btn.accept:hover { filter: brightness(1.05); }

.search-wrap { position: relative; margin-left: auto; }
#county-search {
  background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--ring); border-radius: 9px;
  padding: 8px 12px; font-size: 14px; width: 240px; outline: none;
}
#county-search:focus { border-color: var(--accent); }
.search-results {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  width: 300px; max-height: 320px; overflow-y: auto;
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
  list-style: none; margin: 0; padding: 4px;
}
.search-results li {
  padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 14px;
  display: flex; justify-content: space-between; gap: 10px;
}
.search-results li .sr-val { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.search-results li:hover, .search-results li.sel { background: var(--grid); }

/* ---------- layout ---------- */
.layout {
  flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  gap: 14px; padding: 0 20px 16px; align-items: stretch;
}
.layout.has-detail { grid-template-columns: minmax(0, 1fr) 400px; }

.map-wrap {
  position: relative; background: var(--surface-1);
  border: 1px solid var(--ring); border-radius: 14px; overflow: hidden;
  /* Fill the space the flex layout leaves (below header + controls, above
     footer) so the whole map fits the viewport without a fragile fixed offset;
     the SVG viewBox letterboxes to fit. */
  height: 100%; min-height: 340px;
}
#map { display: block; width: 100%; height: 100%; cursor: grab; }
#map:active { cursor: grabbing; }
#map .county { stroke: var(--surface-1); stroke-width: 0.25; }
#map .county.hover { stroke: var(--ink); stroke-width: 1; }
#map .county.selected { stroke: var(--ink); stroke-width: 1.2; }
#map .county.filtered { fill-opacity: 0.07; }
#map .state-borders {
  fill: none; stroke: var(--surface-1); stroke-width: 0.9; pointer-events: none;
}

/* ---------- legend ---------- */
.legend {
  position: absolute; left: 14px; bottom: 12px;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  border: 1px solid var(--ring); border-radius: 10px; padding: 8px 12px 9px;
  font-size: 11px; color: var(--ink-2); backdrop-filter: blur(3px);
}
.legend-title { font-weight: 600; color: var(--ink); margin-bottom: 5px; font-size: 12px; }
.legend-swatches { display: flex; gap: 1px; }
.legend-swatches .sw { height: 9px; border-radius: 2px; flex: none; }
.legend-labels { position: relative; height: 14px; margin-top: 2px; }
.legend-labels .lb {
  position: absolute; top: 0; transform: translateX(-50%); white-space: nowrap;
  font-variant-numeric: tabular-nums; color: var(--muted); font-size: 10px;
}
.legend-nodata { display: flex; align-items: center; gap: 6px; margin-top: 7px; color: var(--muted); }
.legend-nodata .sw { width: 12px; height: 9px; border-radius: 2px; background: var(--no-data); }

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed; z-index: 40; pointer-events: none;
  background: var(--surface-1); color: var(--ink);
  border: 1px solid var(--ring); border-radius: 9px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.16);
  padding: 8px 11px; font-size: 13px; max-width: 260px;
}
.tooltip .tt-name { font-weight: 600; }
.tooltip .tt-val { color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* ---------- detail panel ---------- */
.detail {
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 14px;
  padding: 16px; overflow-y: auto;
  /* Fill the row (same height as the map) and scroll internally, so the page
     itself doesn't scroll to reach the charts. */
  max-height: 100%; min-height: 0;
}
.detail h2 { margin: 0 0 2px; font-size: 17px; }
.detail .d-state { color: var(--ink-2); font-size: 13px; margin-bottom: 10px; }
.detail .d-coverage {
  display: inline-block; color: var(--ink-2); font-size: 11.5px;
  background: var(--page); border: 1px solid var(--ring); border-radius: 999px;
  padding: 4px 10px; margin-bottom: 12px; font-variant-numeric: tabular-nums;
}
.detail .d-close {
  float: right; appearance: none; border: 0; background: transparent; color: var(--muted);
  font-size: 18px; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.detail .d-close:hover { background: var(--grid); color: var(--ink); }
.thennow {
  background: var(--page); border: 1px solid var(--ring); border-radius: 10px;
  padding: 10px 12px; margin: 10px 0 12px; font-size: 14px;
}
.thennow b { font-variant-numeric: tabular-nums; }
.statrow { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.stat {
  flex: 1 1 70px; background: var(--page); border: 1px solid var(--ring);
  border-radius: 10px; padding: 8px 10px;
}
.stat .s-label { color: var(--muted); font-size: 11px; }
.stat .s-value { font-weight: 700; font-size: 15px; font-variant-numeric: tabular-nums; }

.d-year {
  display: flex; align-items: center; gap: 12px;
  background: var(--page); border: 1px solid var(--ring); border-radius: 10px;
  padding: 10px 12px; margin-bottom: 14px;
}
.d-year .d-year-slider {
  appearance: none; -webkit-appearance: none; height: 4px; flex: 1;
  border-radius: 3px; background: var(--ring); outline: none; cursor: pointer;
}
.d-year .d-year-slider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 15px; height: 15px;
  border-radius: 50%; background: var(--accent); border: 2px solid var(--page); cursor: pointer;
}
.d-year .d-year-slider::-moz-range-thumb {
  width: 15px; height: 15px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--page); cursor: pointer;
}
.d-year-readout {
  font-size: 14px; white-space: nowrap; display: flex; gap: 6px; align-items: baseline;
}
.d-year-readout .dy-label { color: var(--muted); font-size: 12px; }
.d-year-readout b { font-variant-numeric: tabular-nums; }

.d-pop {
  background: var(--page); border: 1px solid var(--ring); border-radius: 10px;
  padding: 8px 12px; margin-bottom: 14px; font-size: 14px;
}
.d-pop .dy-label { color: var(--muted); font-size: 12px; margin-right: 4px; }
.d-pop b { font-variant-numeric: tabular-nums; }
.d-pop .pop-growth { color: var(--muted); font-size: 12px; margin-left: 4px; }

.d-wiki { margin-top: 4px; padding-top: 12px; border-top: 1px solid var(--ring); }
.d-wiki h3 { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.d-wiki .d-wiki-text { font-size: 13px; line-height: 1.5; color: var(--ink); margin: 0 0 6px; }
.d-wiki .d-wiki-link { font-size: 12px; color: var(--accent); }

/* ---------- under-map "closer look" county section ---------- */
.county-deep { padding: 0 20px 8px; }
.deep-inner {
  max-width: 1120px; margin: 0 auto;
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 14px;
  padding: 16px 20px 18px;
}
.deep-title { font-size: 17px; font-weight: 700; letter-spacing: -0.01em; margin: 0 0 14px; }
.deep-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px 26px;
}
.deep-grid .chart-block { margin-bottom: 0; }
.deep-inner .d-wiki { margin-top: 16px; padding-top: 14px; }
.deep-inner .d-wiki .d-wiki-text { font-size: 14px; max-width: 760px; }

.d-industry { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--ring); }
.d-industry h3 { margin: 0 0 10px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.ind-rows { display: flex; flex-direction: column; gap: 7px; max-width: 580px; }
.ind-row { display: grid; grid-template-columns: 150px 1fr 42px; align-items: center; gap: 12px; font-size: 13px; }
.ind-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ind-bar-wrap { height: 12px; background: var(--grid); border-radius: 6px; overflow: hidden; }
.ind-bar { display: block; height: 100%; background: linear-gradient(90deg, #256abf, #6da7ec); border-radius: 6px; }
.ind-pct { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 620px) { .ind-row { grid-template-columns: 120px 1fr 38px; gap: 8px; } }

.chart-block { margin-bottom: 14px; }
.chart-block h3 { margin: 0 0 6px; font-size: 13px; color: var(--ink-2); font-weight: 600; }
.chart-block svg { display: block; width: 100%; height: auto; }
.chart-note { color: var(--muted); font-size: 11px; margin-top: 4px; }
.chart-tip {
  position: absolute; top: -4px; transform: translateX(-50%);
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 7px;
  padding: 3px 8px; font-size: 11.5px; color: var(--ink); white-space: nowrap;
  pointer-events: none; font-variant-numeric: tabular-nums;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.14);
}

/* ---------- global page ---------- */
.glayout {
  flex: 1; display: grid; grid-template-columns: minmax(300px, 520px) minmax(0, 1fr);
  gap: 14px; padding: 0 20px 16px; align-items: start;
}
.bars-panel, .gchart-panel {
  background: var(--surface-1); border: 1px solid var(--ring); border-radius: 14px;
  padding: 14px 16px;
}
.gchart-panel { position: sticky; top: 12px; }
.panel-title { margin: 0 0 10px; font-size: 14px; color: var(--ink); font-weight: 600; }
.bars-scroll { max-height: calc(100vh - 210px); overflow-y: auto; }
#bars { display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; min-height: 24px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--page); border: 1px solid var(--ring); border-radius: 999px;
  padding: 3px 6px 3px 9px; font-size: 12px;
}
.chip button {
  appearance: none; border: 0; background: transparent; color: var(--muted);
  cursor: pointer; font-size: 13px; padding: 0 4px; border-radius: 999px;
}
.chip button:hover { color: var(--ink); background: var(--grid); }
.dotsw {
  display: inline-block; width: 9px; height: 9px; border-radius: 3px; flex: none;
}
#gchart { position: relative; }
#gchart svg { display: block; width: 100%; height: auto; }
.chart-tip.multi { top: 6px; }
.chart-tip .mut { color: var(--muted); }
.chart-tip div { display: flex; align-items: center; gap: 5px; padding: 1px 0; }

@media (max-width: 900px) {
  .glayout { grid-template-columns: minmax(0, 1fr); }
  .gchart-panel { position: static; }
  .bars-scroll { max-height: 420px; }
}

/* ---------- about page ---------- */
.prose { max-width: 720px; margin: 0 auto; padding: 8px 20px 32px; flex: 1; }
.prose h1 { font-size: 24px; margin: 10px 0 12px; }
.prose h2 { font-size: 17px; margin: 26px 0 8px; }
.prose h3 { font-size: 14.5px; margin: 16px 0 6px; }
.prose p, .prose li { color: var(--ink-2); font-size: 14.5px; line-height: 1.6; }
.prose b { color: var(--ink); }
.prose ul { padding-left: 20px; }
.prose li { margin-bottom: 7px; }

/* ---------- footer ---------- */
.foot {
  display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 20px 16px; color: var(--muted); font-size: 12.5px;
}

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  /* Stack: map on top (fixed height), detail below; the page scrolls normally. */
  body, body:has(.layout) { height: auto; min-height: 100vh; }
  .layout { grid-template-rows: auto; align-items: start; min-height: 0; }
  .layout.has-detail { grid-template-columns: minmax(0, 1fr); }
  .map-wrap { height: 72vh; }
  body:has(.home-seo) .layout,
  body:has(.afford-main):has(.faq) .afford-main { height: auto; min-height: 0; }
  .detail { position: static; max-height: none; }
  .search-wrap { margin-left: 0; width: 100%; }
  #county-search { width: 100%; }
  .search-results { left: 0; right: auto; width: 100%; }
}
@media (max-width: 600px) {
  .legend { transform: scale(0.78); transform-origin: left bottom; left: 8px; bottom: 8px; }
}

/* ============================ juice: motion + sound ======================== */
/* Sound on/off toggle injected into the nav by juice.js. */
.sfx-toggle {
  background: none; border: 1px solid var(--grid); color: var(--ink);
  border-radius: 8px; padding: 1px 8px; margin-left: 10px; cursor: pointer;
  font-size: 15px; line-height: 1.5; transition: transform .12s ease, background .2s;
}
.sfx-toggle:hover { background: var(--surface-1); }
.sfx-toggle:active { transform: scale(.85); }

/* Ripple emitted from clicked buttons. */
.j-ripple {
  position: absolute; border-radius: 50%; background: currentColor; opacity: .28;
  transform: scale(0); pointer-events: none; animation: j-ripple .6s ease-out forwards;
}
@keyframes j-ripple { to { transform: scale(2.6); opacity: 0; } }

/* Satisfying pop-in for detail cards, compare-tray items, etc. */
@keyframes j-pop {
  0%   { transform: translateY(7px) scale(.985); opacity: .25; }
  55%  { transform: translateY(-2px) scale(1.006); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
.j-pop { animation: j-pop .34s cubic-bezier(.22, 1.2, .36, 1); }

/* Springy press feedback on interactive chrome. */
button, .nav-link { position: relative; }
.play-btn:active, .segmented button:active, .rank-select:active,
.d-close:active, .filter-btn:active, .compare-clear:active { transform: scale(.93); }
.nav-link { transition: color .18s, transform .12s; }
.nav-link:active { transform: scale(.96); }
.segmented button { transition: background .2s, color .2s, transform .12s; }

/* Play button breathes while it's running (main JS swaps its label to ⏸). */
@keyframes j-breathe { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }

/* Maps: smooth colour changes when scrubbing years + a lift on hover. The
   transition is armed only after first paint (.j-ready) so load doesn't flash. */
#map.j-ready path { transition: fill .28s ease, opacity .2s ease; }
#map path.county:hover, #map path.region:hover, #map path.country:hover {
  filter: brightness(1.13) saturate(1.05);
}
#map path.selected { animation: j-flash .55s ease; }
@keyframes j-flash { 0% { filter: brightness(1.6); } 100% { filter: brightness(1); } }

/* Legend swatches wipe in. */
.legend .sw { animation: j-fade .5s ease both; }
@keyframes j-fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  #map.j-ready path { transition: none; }
  .j-pop, .j-ripple, #map path.selected, .legend .sw { animation: none; }
  .play-btn:active, .segmented button:active, .nav-link:active { transform: none; }
}

/* ============================ county SEO pages ============================ */
.cty { max-width: 860px; margin: 0 auto; padding: 22px 20px 44px; width: 100%; }
.crumbs { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }
.cty h1 { font-size: 26px; line-height: 1.2; margin: 4px 0 8px; }
.cty-lede { color: var(--ink-2); max-width: 660px; margin: 0 0 16px; }
.cty-hero {
  font-size: 18px; margin: 0 0 20px; padding: 12px 15px; background: var(--surface-1);
  border: 1px solid var(--grid); border-radius: 10px;
}
.cty-hero .cty-mult { color: var(--muted); }
.cty-hero .cty-sub { display: block; font-size: 11.5px; color: var(--muted); margin-top: 3px; }
.cty-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px; margin: 0 0 26px;
}
.cty-stat { background: var(--surface-1); border: 1px solid var(--grid); border-radius: 10px; padding: 10px 12px; }
.cty-stat .cty-k { display: block; font-size: 11.5px; color: var(--muted); margin-bottom: 3px; }
.cty-stat b { font-size: 18px; }
.cty-stat .cty-sub { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; }
.cty h2 { font-size: 17px; margin: 18px 0 10px; }
.cty-read { margin: 0 0 9px; color: var(--ink-2); line-height: 1.55; max-width: 680px; }
.cty-read b { color: var(--ink); font-weight: 600; }
.cty-chart { position: relative; max-width: 560px; }
.cty-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 8px; }
.cty-btn {
  display: inline-block; padding: 9px 14px; border: 1px solid var(--grid); border-radius: 9px;
  background: var(--surface-1); color: var(--ink); font-size: 13.5px; font-weight: 600;
  transition: transform .12s, border-color .2s;
}
.cty-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.cty-btn:active { transform: scale(.96); }
/* hub directory */
.cty-hub .hub-state { margin: 16px 0; }
.cty-hub .hub-state h2 { font-size: 15px; border-bottom: 1px solid var(--grid); padding-bottom: 4px; margin-bottom: 6px; }
.hub-list { columns: 4 180px; column-gap: 22px; list-style: none; padding: 4px 0 0; margin: 0; font-size: 13px; }
.hub-list li { break-inside: avoid; margin-bottom: 3px; }
/* "Full page" link inside the map's detail card */
.d-fullpage { display: inline-block; margin: 8px 0 2px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.d-fullpage:hover { text-decoration: underline; }

/* ======================= mortgage calculator page ======================== */
.calc-page { max-width: 1000px; margin: 0 auto; padding: 22px 20px 44px; width: 100%; }
.calc-right { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.calc-right h2 { margin-top: 12px; }
.calc-page h1 { font-size: 26px; margin: 4px 0 6px; }
.calc-page h2 { font-size: 17px; margin: 26px 0 6px; }
.calc-lede { color: var(--ink-2); margin: 0 0 20px; }
.calc-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.calc-form { display: flex; flex-direction: column; gap: 14px; }
.calc-field { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.calc-field > input, .calc-in {
  border: 1px solid var(--grid); border-radius: 8px; background: var(--surface-1); color: var(--ink);
}
.calc-field > input { padding: 9px 11px; font-size: 15px; }
.calc-in { display: flex; align-items: center; overflow: hidden; }
.calc-in input { border: none; background: none; color: var(--ink); padding: 9px 11px; width: 100%; outline: none; font-size: 15px; }
.calc-pre, .calc-post { padding: 0 10px; color: var(--muted); font-size: 13px; white-space: nowrap; }
.calc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.calc-result { background: var(--surface-1); border: 1px solid var(--grid); border-radius: 12px; padding: 18px; }
.cr-big { display: flex; flex-direction: column; margin-bottom: 12px; }
.cr-big .cr-k { font-size: 12.5px; color: var(--muted); }
.cr-big b { font-size: 34px; line-height: 1.1; }
.cr-row { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-top: 1px solid var(--grid); font-size: 14px; }
.cr-row.cr-total b { font-size: 17px; }
.cr-verdict { margin-top: 12px; font-size: 14px; line-height: 1.5; }
.cr-sub { color: var(--muted); font-size: 12px; }
.v-good { color: #22a355; font-weight: 700; }
.v-mid { color: #d38b00; font-weight: 700; }
.v-bad { color: #e14b34; font-weight: 700; }
.calc-chart { position: relative; }
.calc-fine { color: var(--muted); font-size: 11.5px; margin-top: 18px; max-width: 720px; line-height: 1.5; }
@media (max-width: 760px) { .calc-wrap { grid-template-columns: 1fr; } }

/* ============================== compare page ============================= */
.compare-page { max-width: 1000px; margin: 0 auto; padding: 22px 20px 44px; width: 100%; }
.compare-page h1 { font-size: 26px; margin: 4px 0 6px; }
.compare-page h2 { font-size: 17px; margin: 26px 0 8px; }
.cmp-add { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0 20px; align-items: center; }
.cmp-add input { flex: 1; min-width: 200px; padding: 9px 11px; border: 1px solid var(--grid); border-radius: 8px; background: var(--surface-1); color: var(--ink); font-size: 15px; }
.cmp-add .cty-btn { cursor: pointer; }
.cmp-empty { color: var(--muted); padding: 30px 0; }
.cmp-table-wrap { overflow-x: auto; }
.cmp-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.cmp-table th, .cmp-table td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.cmp-table th { font-size: 13px; vertical-align: top; }
.cmp-table thead th:first-child { border: none; }
.cmp-metric { text-align: left; color: var(--muted); font-weight: 600; }
.cmp-name { display: block; max-width: 150px; white-space: normal; }
.cmp-x { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 15px; padding: 0 0 0 6px; }
.cmp-x:hover { color: #e14b34; }

/* ============================ "Where can I afford?" ======================= */
.controls .year-wrap .year-label { font-size: 11.5px; color: var(--muted); margin-right: 7px; font-weight: 600; }
.afford-headline {
  padding: 9px 20px; font-size: 14.5px; color: var(--ink);
  background: var(--surface-1); border-bottom: 1px solid var(--grid);
}
.afford-headline b { color: var(--accent); }
.afford-note { color: var(--muted); font-size: 12.5px; margin: 0 0 12px; }
.afford-list { list-style: none; padding: 0; margin: 0; counter-reset: af; }
.afford-list li {
  display: flex; align-items: baseline; gap: 10px; padding: 7px 0;
  border-bottom: 1px solid var(--grid); font-size: 14px;
}
.afford-list li::before {
  counter-increment: af; content: counter(af); color: var(--muted); font-size: 12px;
  flex: 0 0 18px; text-align: right;
}
.af-name { flex: 1; }
.af-val { color: var(--muted); font-variant-numeric: tabular-nums; }
/* Afford uses its own scrolling grid (NOT the viewport-locked .layout) so the
   extra income/rate chrome never squeezes the map off-screen. */
.afford-main { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 0; align-items: stretch; }
.afford-main .map-wrap { height: 100%; min-height: 0; }
.afford-main .detail { max-height: 100%; overflow-y: auto; padding: 14px 18px; }
@media (max-width: 900px) {
  body:has(.afford-main) { height: auto; }
  .afford-main { grid-template-columns: 1fr; }
  .afford-main .map-wrap { height: 60vh; min-height: 300px; }
  .afford-main .detail { max-height: none; }
}

/* ---- "best places" list pages ---- */
.bl-table th, .bl-table td { text-align: left; }
.bl-table th:nth-child(3), .bl-table td:nth-child(3),
.bl-table th:nth-child(4), .bl-table td:nth-child(4) { text-align: right; font-variant-numeric: tabular-nums; }
.bl-rank { color: var(--muted); width: 34px; }
.best-index { list-style: none; padding: 0; margin: 16px 0; max-width: 700px; }
.best-index li { padding: 11px 0; border-bottom: 1px solid var(--grid); font-size: 14px; color: var(--ink-2); }
.best-index a { font-size: 15.5px; }

/* Real-$ (inflation-adjusted) toggle on the US map controls */
.real-toggle {
  padding: 6px 12px; border: 1px solid var(--grid); border-radius: 999px;
  background: var(--surface-1); color: var(--ink); font-size: 12.5px; font-weight: 600;
  cursor: pointer; white-space: nowrap; transition: transform .12s, border-color .2s, color .2s;
}
.real-toggle[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }
.real-toggle:active { transform: scale(.94); }

/* AdSense in-content slot — the responsive unit sizes itself. */
.ad-slot { margin: 24px auto; text-align: center; overflow: hidden; }
/* When AdSense has no ad to serve it leaves the <ins> at a fixed height, which
   shows as a blank gap. Collapse it so the page closes up (no ad = no space). */
ins.adsbygoogle[data-ad-status="unfilled"] { display: none !important; }
