:root {
  --ink: #1d2327;
  --muted: #5b6770;
  --line: #dfe3e6;
  --paper: #fbfbf9;
  --accent: #1a7773; /* 5.2:1 on --paper, for small link text (WCAG AA 4.5:1) */
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
}

* { box-sizing: border-box; }
body { margin: 0; }
main, .top { max-width: 72rem; margin: 0 auto; padding: 0 1rem; }
.top { padding-top: 0.75rem; }
h1 { margin: 0; font-size: 1.6rem; letter-spacing: -0.01em; }
h1 a { color: inherit; text-decoration: none; }
.lede { margin: 0.2rem 0 0.6rem; color: var(--muted); }

.picker { min-width: 0; display: grid; gap: 0.6rem; grid-template-columns: minmax(0, 1fr); margin: 0 0 0.75rem; }
.picker-group { display: flex; flex-wrap: wrap; gap: 0.4rem; border: 0; padding: 0; margin: 0; min-width: 0; }
.picker-group legend { padding: 0; margin-bottom: 0.3rem; color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
@media (max-width: 40rem) {
  .picker { gap: 0.2rem; }
  .picker-group { flex-wrap: nowrap; overflow-x: auto; gap: 0.3rem; padding-bottom: 0.2rem; scrollbar-width: none; }
  .picker label { flex: none; }
  .picker span { padding: 0.25rem 0.65rem; font-size: 0.85rem; }
}
.picker label { position: relative; cursor: pointer; }
.picker input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.picker span {
  display: inline-block; padding: 0.35rem 0.8rem; border: 1px solid var(--line);
  border-radius: 999px; background: #fff; font-size: 0.9rem;
}
.picker input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.picker input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }

.map-frame { position: relative; margin: 0; }
#map { width: 100%; height: auto; max-height: calc(100vh - 17.5rem); display: block; }
#map path { stroke: #fff; stroke-width: 0.4; cursor: pointer; transition: fill 0.25s; }
#map path:hover { stroke: var(--ink); stroke-width: 1; }
#map path:focus-visible { outline: none; stroke: var(--ink); stroke-width: 2; }

.tooltip {
  position: absolute; pointer-events: none; max-width: 18rem; padding: 0.4rem 0.6rem;
  background: rgba(29, 35, 39, 0.92); color: #fff; border-radius: 0.3rem; font-size: 0.85rem;
}
figcaption p { margin: 0.5rem 0; color: var(--muted); font-size: 0.9rem; }
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; list-style: none; padding: 0; margin: 0; font-size: 0.8rem; }
.legend li { display: flex; align-items: center; gap: 0.3rem; }
.swatch { display: inline-block; width: 0.9rem; height: 0.9rem; border-radius: 2px; }
.swatch.hatch { background: repeating-linear-gradient(45deg, #8a8a8a 0 2px, #ececec 2px 5px); }
.status { color: var(--muted); }

#country-view a, #compare-view a { color: var(--accent); }
#country-name { font-size: 1.8rem; margin: 0.25rem 0 1rem; outline: none; }
.charts { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 0.5rem; padding: 0.8rem 0.9rem 0.4rem; }
.chart-group { margin: 0 0 1.5rem; }
.group-title { margin: 0 0 0.5rem; font-size: 1.1rem; scroll-margin-top: 0.75rem; outline: none; }
.section-index ul { display: flex; flex-wrap: wrap; gap: 0.5rem; list-style: none; padding: 0; margin: 0 0 1.25rem; }
.section-index a { display: block; padding: 0.5rem 0.8rem; border: 1px solid var(--line); border-radius: 1rem; background: #fff; text-decoration: none; }
.card h4 { margin: 0; font-size: 0.95rem; font-weight: 600; }
.latest { margin: 0.2rem 0 0.4rem; color: var(--muted); font-size: 0.85rem; }
.latest strong { color: var(--ink); font-size: 1.5rem; font-weight: 650; margin-right: 0.15rem; }
.asof { white-space: nowrap; }
.card svg { width: 100%; height: auto; display: block; }
.card .dot { fill: var(--accent); }
.card .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.card .band { fill: var(--accent); fill-opacity: 0.22; stroke: none; }
.card .projected { stroke-dasharray: 5 4; }
.proj-note { margin: 0.1rem 0 0.4rem; color: var(--muted); font-size: 0.75rem; }
.card .grid { stroke: var(--line); stroke-width: 1; }
.card .tick { fill: var(--muted); font-size: 10px; }

.sources { max-width: 72rem; margin: 2.5rem auto 0; padding: 1rem 1rem 2rem; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
.sources h2 { font-size: 1rem; color: var(--ink); margin: 0 0 0.4rem; }
.sources ul { padding-left: 1.1rem; margin: 0.4rem 0; }
.sources li { margin: 0.2rem 0; }
.sources a { color: var(--accent); }
.small { font-size: 0.8rem; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  #map path { transition: none; }
}
.toggles { margin-bottom: 0.5rem; }
.toggle-note { margin: 0; color: var(--muted); font-size: 0.8rem; }
.picker-group:disabled { opacity: 0.55; }
.picker-group:disabled label { cursor: not-allowed; }

.add-compare { margin: -0.6rem 0 1rem; font-size: 0.9rem; }
.compare-legend { display: flex; flex-wrap: wrap; gap: 0.4rem 1.2rem; list-style: none; padding: 0; margin: 0 0 1rem; }
.compare-legend li { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; }
.compare-legend a { font-weight: 400; font-size: 0.85rem; color: var(--accent); }
.card svg.key, .key { width: 1.6rem; height: 0.5rem; flex: none; display: inline-block; }
.key line { stroke-width: 2.5; }
.values { list-style: none; margin: 0.2rem 0 0.4rem; padding: 0; font-size: 0.85rem; color: var(--muted); }
.values li { margin: 0.1rem 0; }
.values .key { margin-right: 0.4rem; vertical-align: middle; }
.values strong { color: var(--ink); }
.card .cline { fill: none; stroke-width: 2.25; stroke-linejoin: round; }

.search { display: flex; margin: 0 0 0.6rem; }
.search input { flex: 1 1 14rem; max-width: 22rem; min-height: 2.25rem; padding: 0 0.6rem; font: inherit; border: 1px solid var(--muted); border-radius: 4px; }
.view-switch { margin: 0 0 0.5rem; font-size: 0.9rem; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
.data-table caption { text-align: left; color: var(--muted); padding-bottom: 0.5rem; }
.data-table th, .data-table td { padding: 0.35rem 0.5rem; border-bottom: 1px solid var(--line); text-align: left; font-weight: normal; }
.data-table thead th { font-weight: 600; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table th button { font: inherit; font-weight: 600; background: none; border: 0; padding: 0.25rem 0; cursor: pointer; color: inherit; }
.data-table th[aria-sort] button::after { content: " ▲"; font-size: 0.75em; }
.data-table th[aria-sort="descending"] button::after { content: " ▼"; }

#method-view { max-width: 44rem; }
#method-view h3 { margin: 1.6rem 0 0.3rem; font-size: 1.05rem; }
#method-view p { line-height: 1.55; }
.method-built { font-weight: 600; }
.method-sources { padding-left: 1.1rem; }
.method-sources li { margin: 0.5rem 0; font-size: 0.9rem; }
#toggles[hidden] { display: none; }

/* The controls above the map: one compact picker and, for a metric with a counterpart, the toggles. */
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem 1rem; margin: 0 0 0.5rem; }
.controls .picker { display: flex; flex-wrap: wrap; gap: 0.2rem 0.8rem; margin: 0; }
.controls .picker-group { gap: 0.3rem; align-items: center; }
.controls .picker-group legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.controls .picker span { padding: 0.2rem 0.65rem; font-size: 0.85rem; }
.controls .toggle-note { flex-basis: 100%; }
.metric-select { display: flex; align-items: center; gap: 0.5rem; flex: 1 1 14rem; max-width: 22rem; }
.metric-select label { color: var(--muted); font-size: 0.75rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase; }
.metric-select select { flex: 1; min-width: 0; min-height: 2.25rem; padding: 0 0.4rem; font: inherit; border: 1px solid var(--muted); border-radius: 4px; background: #fff; }
.metric-select[hidden] { display: none; }
.controls .toggles[hidden] { display: none; }

/* Every link in the main content has the link colour of the site, the same as the footer. */
main a { color: var(--accent); }

/* Hidden until app.js has drawn the views, so the footer does not jump down (layout shift). */
body:not(.ready) > footer.sources, body.pending > footer.sources { visibility: hidden; }
