@font-face {
  font-family: "Heebo";
  src: url("/static/heebo.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f1efe9;
  --text: #17201d;
  --muted: #59645f;
  --line: #e3e0d8;
  --brand: #0d5c4c;
  --brand-ink: #ffffff;
  --brand-soft: #e2f0eb;
  --accent: #a8501f;
  --bar: #9ccabb;
  --bar-current: #0d5c4c;
  --dot: #7fae9f;
  --ref: #a8501f;
  --caveat-bg: #fbf3e2;
  --caveat-line: #e6c784;
  --focus: #1a56db;
  --shadow: 0 1px 2px rgb(20 30 25 / .06), 0 4px 16px rgb(20 30 25 / .06);
  --radius: 14px;
  --radius-sm: 8px;
  --wrap: 1040px;
  --font: "Heebo", system-ui, "Segoe UI", Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f1312;
    --surface: #171d1b;
    --surface-2: #1e2623;
    --text: #e7ecea;
    --muted: #a3afaa;
    --line: #2a3330;
    --brand: #6cc7ad;
    --brand-ink: #0f1312;
    --brand-soft: #1b2e28;
    --accent: #f0a37c;
    --bar: #2f6355;
    --bar-current: #6cc7ad;
    --dot: #4f8b7a;
    --ref: #f0a37c;
    --caveat-bg: #29231a;
    --caveat-line: #6b5527;
    --focus: #8ab4ff;
    --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1312;
  --surface: #171d1b;
  --surface-2: #1e2623;
  --text: #e7ecea;
  --muted: #a3afaa;
  --line: #2a3330;
  --brand: #6cc7ad;
  --brand-ink: #0f1312;
  --brand-soft: #1b2e28;
  --accent: #f0a37c;
  --bar: #2f6355;
  --bar-current: #6cc7ad;
  --dot: #4f8b7a;
  --ref: #f0a37c;
  --caveat-bg: #29231a;
  --caveat-line: #6b5527;
  --focus: #8ab4ff;
  --shadow: 0 1px 2px rgb(0 0 0 / .3), 0 4px 16px rgb(0 0 0 / .25);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.7;
  font-feature-settings: "tnum" 1;
}
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

.wrap { max-width: var(--wrap); margin-inline: auto; padding-inline: 16px; }
a { color: var(--brand); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.skip {
  position: absolute; inset-inline-start: 8px; top: -60px; z-index: 50;
  background: var(--surface); padding: 8px 14px; border-radius: var(--radius-sm);
}
.skip:focus { top: 8px; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 12px; padding-block: 10px; }
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); text-decoration: none; display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand img { width: 26px; height: 26px; }
.site-nav { margin-inline-start: auto; }
.site-nav ul { list-style: none; display: flex; gap: 2px; margin: 0; padding: 0; }
.site-nav a { color: var(--muted); text-decoration: none; font-weight: 600; font-size: .95rem; padding: 6px 10px; border-radius: 999px; display: inline-block; white-space: nowrap; }
.site-nav a:hover { color: var(--text); background: var(--surface-2); }
.site-nav a[aria-current="page"] { color: var(--brand); background: var(--brand-soft); }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); cursor: pointer;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn svg { width: 20px; height: 20px; }
.search-trigger {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px; min-width: 200px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted);
  font: inherit; font-size: .95rem; cursor: pointer;
}
.search-trigger:hover { border-color: var(--brand); }
.search-trigger svg { width: 18px; height: 18px; }
.menu-btn { display: none; }

@media (max-width: 860px) {
  .search-trigger { min-width: 0; padding: 0; width: 40px; justify-content: center; }
  .search-trigger span { display: none; }
  .menu-btn { display: inline-grid; }
  .site-nav { position: fixed; inset: 61px 0 auto 0; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: var(--shadow); display: none; }
  .site-nav.open { display: block; }
  .site-nav ul { flex-direction: column; padding: 8px 16px 14px; }
  .site-nav a { display: block; padding: 10px 12px; font-size: 1.05rem; }
  .header-tools { margin-inline-start: auto; }
}
.header-tools { display: flex; gap: 8px; align-items: center; }

.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 4px; padding: 0; margin: 16px auto 0; font-size: .875rem; color: var(--muted); }
.crumbs li + li::before { content: "‹"; margin-inline-end: 6px; }
.crumbs a { color: var(--muted); }

main { padding-block: 4px 56px; }

h1 { font-size: clamp(1.8rem, 1.2rem + 2.6vw, 2.75rem); line-height: 1.15; margin: 18px 0 12px; letter-spacing: -.015em; font-weight: 800; }
h2 { font-size: clamp(1.3rem, 1.1rem + .8vw, 1.6rem); line-height: 1.3; margin: 48px 0 14px; font-weight: 750; letter-spacing: -.01em; }
h3 { font-size: 1.05rem; margin: 0 0 6px; font-weight: 700; }
.lead { font-size: 1.18rem; max-width: 70ch; }
.eyebrow { margin: 22px 0 0; color: var(--accent); font-weight: 700; font-size: .9rem; }
.what { color: var(--muted); margin-top: -4px; }
.note { color: var(--muted); font-size: .95rem; }
.hero { padding-block: 24px 8px; }
.hero h1 { font-size: clamp(2rem, 1.3rem + 3.4vw, 3.3rem); max-width: 18ch; }
.hero .search-trigger.big { height: 56px; width: 100%; max-width: 620px; font-size: 1.1rem; padding: 0 20px; background: var(--surface); box-shadow: var(--shadow); margin-top: 8px; }
.hero .search-trigger.big svg { width: 22px; height: 22px; }
.hero .search-trigger.big span { display: inline; }
.hero-hints { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chip { display: inline-block; padding: 4px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); text-decoration: none; font-size: .9rem; }
.chip:hover { border-color: var(--brand); color: var(--brand); }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 22px 0 10px; }
.stat {
  display: flex; flex-direction: column; gap: 4px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; color: var(--text); text-decoration: none; box-shadow: var(--shadow);
}
a.stat { transition: transform .15s ease, border-color .15s ease; }
a.stat:hover { border-color: var(--brand); }
@media (prefers-reduced-motion: no-preference) { a.stat:hover { transform: translateY(-2px); } }
.stat-value { font-size: 2.15rem; font-weight: 800; color: var(--brand); line-height: 1.1; }
.stat-label { color: var(--muted); font-size: .93rem; line-height: 1.45; }

/* Tables */
.table-wrap { overflow-x: auto; margin: 14px 0 6px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
table.data { width: 100%; border-collapse: collapse; }
table.data caption { text-align: start; padding: 14px 16px 6px; font-weight: 700; color: var(--muted); font-size: .9rem; }
table.data th, table.data td { padding: 10px 16px; text-align: start; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data thead th { font-size: .82rem; color: var(--muted); font-weight: 700; white-space: nowrap; position: sticky; top: 0; background: var(--surface); }
table.data tbody tr:last-child > * { border-bottom: 0; }
table.data tbody th { font-weight: 600; }
table.data tbody th a { color: var(--text); text-decoration: none; }
table.data tbody th a:hover { color: var(--brand); text-decoration: underline; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tr.current { background: var(--brand-soft); }
table.data tr.current th a { color: var(--brand); font-weight: 750; }

.bar-cell { white-space: nowrap; }
.bars .bar-cell { width: 50%; }
.bar { display: inline-block; height: 10px; width: calc(var(--w) * .8); background: var(--bar); border-radius: 99px; margin-inline-end: 10px; vertical-align: middle; }
tr.current .bar { background: var(--bar-current); }
.na { color: var(--muted); font-size: .92rem; }

.sort-btn { all: unset; cursor: pointer; font: inherit; color: inherit; display: inline-flex; align-items: center; gap: 4px; }
.sort-btn:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sort-btn::after { content: "↕"; font-size: .8em; opacity: .45; }
th[aria-sort="ascending"] .sort-btn::after { content: "▲"; opacity: 1; font-size: .65em; }
th[aria-sort="descending"] .sort-btn::after { content: "▼"; opacity: 1; font-size: .65em; }

/* Mobile cards: app.js marks simple tables with data-cards and labels each cell */
@media (max-width: 640px) {
  .table-wrap:has(table[data-cards]) { border: 0; background: none; box-shadow: none; overflow: visible; }
  table[data-cards] thead tr { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 0 8px; }
  table[data-cards] thead th { position: static; padding: 0; border: 0; background: none; }
  table[data-cards] thead th .sort-btn { padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); font-size: .8rem; }
  table[data-cards] thead th[aria-sort] .sort-btn { border-color: var(--brand); color: var(--brand); }
  table[data-cards] tbody { display: grid; gap: 10px; }
  table[data-cards] tbody tr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px 12px; padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
  table[data-cards] tbody tr.current { border-color: var(--brand); background: var(--brand-soft); }
  table[data-cards] tbody th { grid-column: 1 / -1; padding: 0; border: 0; font-size: 1.05rem; }
  table[data-cards] tbody td { padding: 0; border: 0; display: flex; flex-direction: column; font-size: 1.05rem; font-weight: 650; }
  table[data-cards] tbody td::before { content: attr(data-label); font-size: .78rem; font-weight: 500; color: var(--muted); }
  table[data-cards] .bar-cell { width: auto; grid-column: 1 / -1; }
  table[data-cards] .bar { width: calc(var(--w) * .9); margin: 4px 0 0; order: 2; }
  table[data-cards] caption { padding: 0 0 8px; }
}

/* Provenance: every number is a <data> that opens the source drawer */
data[data-obs] { cursor: pointer; text-decoration: underline dotted color-mix(in srgb, var(--muted) 55%, transparent); text-underline-offset: 4px; border-radius: 4px; }
data[data-obs]:hover { color: var(--brand); text-decoration-color: var(--brand); }
data.suppressed { color: var(--muted); }

dialog.drawer {
  border: 0; padding: 0; color: var(--text); background: var(--surface);
  width: min(460px, 100vw); max-height: 85vh; border-radius: var(--radius); box-shadow: 0 20px 60px rgb(0 0 0 / .3);
}
dialog.drawer::backdrop { background: rgb(10 15 13 / .45); }
@media (max-width: 640px) {
  dialog.drawer { margin: auto 0 0; width: 100vw; max-width: 100vw; border-radius: 20px 20px 0 0; }
}
@media (prefers-reduced-motion: no-preference) {
  dialog.drawer[open] { animation: rise .18s ease-out; }
  @keyframes rise { from { transform: translateY(16px); opacity: 0; } }
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px 6px; }
.drawer-head h2 { margin: 0; font-size: 1.05rem; }
.drawer-body { padding: 4px 18px 20px; }
.drawer-value { font-size: 2.1rem; font-weight: 800; color: var(--brand); line-height: 1.2; }
.drawer-body dl { grid-template-columns: max-content 1fr; font-size: .95rem; }
.drawer-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 999px; font-weight: 650; text-decoration: none; border: 1px solid var(--line); color: var(--text); background: var(--surface); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn:hover { border-color: var(--brand); }

/* Search */
dialog.search { border: 0; padding: 0; width: min(640px, calc(100vw - 24px)); margin: 10vh auto auto; border-radius: var(--radius); background: var(--surface); color: var(--text); box-shadow: 0 20px 60px rgb(0 0 0 / .3); }
dialog.search::backdrop { background: rgb(10 15 13 / .45); }
@media (max-width: 640px) { dialog.search { margin: 0; width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; } }
.search-box { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.search-box svg { width: 22px; height: 22px; color: var(--muted); flex: none; }
.search-box input { flex: 1; border: 0; outline: 0; background: none; color: var(--text); font: inherit; font-size: 1.15rem; padding: 6px 0; min-width: 0; }
.search-results { list-style: none; margin: 0; padding: 6px; max-height: 60vh; overflow-y: auto; }
@media (max-width: 640px) { .search-results { max-height: none; } }
.search-results a { display: flex; flex-direction: column; padding: 10px 12px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; }
.search-results a .kind { font-size: .78rem; color: var(--muted); }
.search-results a[aria-selected="true"], .search-results a:hover { background: var(--brand-soft); }
.search-empty { padding: 18px; color: var(--muted); }

/* Dot chart */
.dotchart { margin: 14px 0 6px; padding: 14px 10px 6px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.dotchart svg { display: block; width: 100%; height: auto; overflow: visible; }
.dotchart .axis text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.dotchart .axis line { stroke: var(--line); }
.dotchart .dot { fill: var(--dot); stroke: var(--surface); stroke-width: 1.5; cursor: pointer; }
.dotchart .dot:hover, .dotchart .dot:focus { fill: var(--brand); outline: none; }
.dotchart .dot.current { fill: var(--accent); }
.dotchart .ref { stroke: var(--ref); stroke-width: 2; stroke-dasharray: 4 3; }
.dotchart .ref-label, .dotchart .cur-label { font-size: 12px; font-weight: 700; font-family: var(--font); }
.dotchart .ref-label { fill: var(--ref); }
.dotchart .cur-label { fill: var(--accent); }
.dotchart .tip { font-size: 12px; font-family: var(--font); fill: var(--text); font-weight: 700; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .85rem; color: var(--muted); padding: 2px 8px 6px; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--dot); margin-inline-end: 6px; vertical-align: middle; }
.chart-legend i.ref { width: 14px; height: 0; border-top: 2px dashed var(--ref); border-radius: 0; }
.chart-legend i.cur { background: var(--accent); }

.source-note { font-size: .85rem; color: var(--muted); margin: 6px 0 16px; }

.caveat { display: flex; gap: 12px; background: var(--caveat-bg); border: 1px solid var(--caveat-line); border-radius: var(--radius); padding: 14px 16px; margin: 18px 0; }
.caveat p { margin: 0; }
.caveat::before { content: "ℹ"; font-weight: 800; color: var(--accent); }

.says { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.says > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; }
.says ul { margin: 0; padding-inline-start: 20px; }

details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 18px; margin-bottom: 8px; }
summary { cursor: pointer; font-weight: 650; }
details p { margin-bottom: 4px; }

.cta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; margin-top: 36px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: border-color .15s ease; }
.card:hover { border-color: var(--brand); }
.card h2 { margin: 0 0 6px; font-size: 1.15rem; color: var(--brand); }
.card p { margin: 0; color: var(--muted); }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; padding: 0; list-style: none; }
.card-grid a { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; color: var(--text); text-decoration: none; font-weight: 650; box-shadow: var(--shadow); }
.card-grid a:hover { border-color: var(--brand); color: var(--brand); }
.card-grid small { display: block; color: var(--muted); font-weight: 400; }

.source { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 18px 12px; margin: 16px 0; }
.source h2 { font-size: 1.15rem; margin-top: 16px; }
dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; }
dt { font-weight: 700; color: var(--muted); }
dd { margin: 0; overflow-wrap: anywhere; }
@media (max-width: 560px) { .source dl { grid-template-columns: 1fr; } .source dt { margin-top: 8px; } }

.compare { font-weight: 700; }
.back { margin-top: 32px; }
.cites { margin-top: 56px; border-top: 1px solid var(--line); padding-top: 8px; font-size: .85rem; color: var(--muted); }
.cites h2 { font-size: 1rem; margin: 12px 0 6px; }
.cites ul { padding-inline-start: 18px; margin: 0; }

.site-footer { border-top: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .92rem; padding-block: 24px 36px; }
.footer-links { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.footer-links a { color: var(--muted); }

@media (max-width: 560px) {
  body { font-size: 1rem; }
  table.data th, table.data td { padding: 9px 12px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat { padding: 14px; }
  .stat-value { font-size: 1.6rem; }
  .stat-label { font-size: .85rem; }
}

.place { display: block; font-size: .8rem; font-weight: 400; color: var(--muted); }

.badge { display: inline-block; margin-inline-start: 6px; padding: 1px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: .75rem; font-weight: 700; vertical-align: middle; white-space: nowrap; }

.trend { font-size: .85rem; font-weight: 700; white-space: nowrap; color: var(--muted); }
.trend.good { color: var(--brand); }

/* Sprint 3: city pages, near me, compare */
.city-list { list-style: none; padding: 0; columns: 3 11rem; column-gap: 24px; }
.city-list li { padding: 3px 0; break-inside: avoid; }
.near-list li { margin: 6px 0; }
th.muted { color: var(--muted); font-weight: 400; font-size: .9rem; }
.compare-pick { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; margin: 16px 0; }
.compare-pick label { display: grid; gap: 4px; font-weight: 600; }
.compare-pick select { font: inherit; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); max-width: 100%; }
.term { text-decoration: underline dotted; text-underline-offset: 3px; cursor: help; color: inherit; }
.term-tip { position: absolute; z-index: 30; max-width: min(320px, 90vw); background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; box-shadow: 0 6px 24px rgb(0 0 0 / .15); font-size: .95rem; line-height: 1.5; }
.glossary dt { font-weight: 700; margin-top: 18px; }
.glossary dd { margin: 4px 0 0; }
/* ER targets: the ministry's met / not-met verdict next to each value */
.met { display: inline-block; margin-inline-start: 6px; padding: 0 7px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.met:has(data[value="1"]) { background: var(--brand-soft); color: var(--brand); }
.met:has(data[value="0"]) { background: var(--caveat-bg); color: var(--accent); }
.switch { font-weight: 700; }
