/* Layout: app shell with a header and tabs; the map view is a sidebar beside a full-height map. */
:root {
  --ink: #10233f; --ink-soft: #4a5b73; --paper: #f3f5f8; --panel: #ffffff; --line: #d6dde6;
  --ocean: #e3eaf2; --land: #f4f6f9; --land-in: #ffffff; --coast: #9fb0c3; --state: #b7c3d1; --state-label: #6c7d93;
  --r0: #1f5fd1; --r1: #d98e04; --r2: #b0407a; --accent: #1f5fd1;
  --display: 'Archivo', 'Arial Narrow', sans-serif; --body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  /* tokens the chart code expects */
  --color-fg: var(--ink); --color-fg-muted: var(--ink-soft); --color-bg: var(--paper); --color-panel: var(--panel);
  --color-border-line: var(--line); --color-bad: #c0392b; --color-ok: #1e8e5a; --color-warn: #b7791f;
  --cds-gap-xs: 4px; --cds-gap-sm: 8px; --cds-gap-md: 16px; --cds-gap-lg: 24px; --cds-gap-xl: 36px;
  --cds-pad-xs: 4px; --cds-pad-sm: 8px; --cds-pad-md: 12px; --cds-pad-lg: 20px; --cds-pad-xl: 28px; --cds-radius: 8px;
  --cds-font-size-caption: 12.5px; --cds-font-size-body: 14.5px; --cds-font-size-heading: 18px; --cds-font-size-title: 28px;
  --cds-font-weight-medium: 600; --cds-chart-muted: #c3ccd7; --cds-chart-grid: #e3e8ee; --cds-chart-axis: #b8c2ce;
  --cds-surface-popover: #ffffff; --cds-border: var(--line); --cds-shadow-popover: 0 6px 24px rgba(16, 35, 63, .14);
  --cds-text-secondary: var(--ink-soft); --cds-dur-slow: .35s; --cds-ease-out: cubic-bezier(.2, .7, .2, 1);
  --font-anthropic-sans: var(--body); --font-anthropic-serif: var(--display);
  color-scheme: light;
}
/* Themes: beige (default), light and dark. With no saved choice and a dark system, dark applies until the page sets one. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --ink: #e8edf4; --ink-soft: #9aa8ba; --paper: #0e1622; --panel: #152131; --line: #26364a;
    --ocean: #0b131d; --land: #162232; --land-in: #1d2c40; --coast: #3b506a; --state: #34485f; --state-label: #8193aa;
    --r0: #5b93f5; --r1: #f0a92e; --r2: #e071a9; --accent: #5b93f5;
    --cds-chart-muted: #3a4a5e; --cds-chart-grid: #223246; --cds-chart-axis: #3a4c62;
    --cds-surface-popover: #1b2a3d; --cds-shadow-popover: 0 6px 24px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #e8edf4; --ink-soft: #9aa8ba; --paper: #0e1622; --panel: #152131; --line: #26364a;
  --ocean: #0b131d; --land: #162232; --land-in: #1d2c40; --coast: #3b506a; --state: #34485f; --state-label: #8193aa;
  --r0: #5b93f5; --r1: #f0a92e; --r2: #e071a9; --accent: #5b93f5;
  --cds-chart-muted: #3a4a5e; --cds-chart-grid: #223246; --cds-chart-axis: #3a4c62;
  --cds-surface-popover: #1b2a3d; --cds-shadow-popover: 0 6px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
}
/* Beige: an atlas-paper look; warm sand land on a muted sea, brown ink. */
:root[data-theme="beige"] {
  --ink: #2e261d; --ink-soft: #6f6250; --paper: #efe7d8; --panel: #f8f2e6; --line: #ddd0b9;
  --ocean: #d5dfdc; --land: #ece2cf; --land-in: #f7efe0; --coast: #b4a284; --state: #c8b594; --state-label: #8a775a;
  --r0: #2563a8; --r1: #b9741a; --r2: #9b3e6c; --accent: #2563a8;
  --cds-chart-muted: #d3c6ae; --cds-chart-grid: #e6dccb; --cds-chart-axis: #c4b598;
  --cds-surface-popover: #fbf7ee; --cds-shadow-popover: 0 6px 24px rgba(60, 44, 20, .16);
  color-scheme: light;
}
:root[data-theme="light"] { color-scheme: light; }

.theme, .country { display: inline-flex; gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--paper); align-self: center; margin-bottom: 8px; }
.theme button, .country button { border: 0; background: transparent; border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer; color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.theme button[aria-pressed="true"], .country button[aria-pressed="true"] { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
.theme i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; border: 1px solid rgba(0, 0, 0, .2); }
.theme .sw-beige { background: #ece2cf; } .theme .sw-light { background: #ffffff; } .theme .sw-dark { background: #152131; }
.country button { font-weight: 600; }
.country-pick { display: none; font-family: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background-color: var(--paper); border: 1px solid var(--line); border-radius: 999px; padding: 5px 28px 5px 12px; align-self: center; appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-soft) 50%), linear-gradient(135deg, var(--ink-soft) 50%, transparent 50%); background-position: right 13px center, right 8px center; background-size: 5px 5px; background-repeat: no-repeat; }
.country-pick:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
/* Thirteen and more countries don't fit in a row of buttons at any width: the dropdown takes their place everywhere. */
.country { display: none; }
.country-pick { display: block; margin-bottom: 8px; }
.theme button:focus-visible, .country button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14.5px/1.5 var(--body); display: flex; flex-direction: column; }
button { font: inherit; color: inherit; }
.muted { color: var(--ink-soft); font-size: 12.5px; }

.top { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding: 14px max(16px, 2vw) 0; border-bottom: 1px solid var(--line); background: var(--panel); }
.brand { display: grid; gap: 2px; padding-bottom: 10px; }
.kicker { font: 600 11px/1.2 var(--display); font-stretch: 112%; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft); }
.brand h1 { margin: 0; font: 850 30px/1 var(--display); font-stretch: 88%; letter-spacing: -.01em; }
.tabs { display: flex; gap: 2px; overflow-x: auto; }
.tabs button { border: 0; background: transparent; padding: 10px 14px 12px; cursor: pointer; color: var(--ink-soft); border-bottom: 3px solid transparent; font-weight: 500; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.tabs button:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

main { flex: 1; min-height: 0; position: relative; }
.view { position: absolute; inset: 0; overflow: auto; }
.view[hidden] { display: none !important; }

/* Map view */
.view-map { display: grid; grid-template-columns: minmax(300px, 380px) 1fr; overflow: hidden; }
.side { border-right: 1px solid var(--line); background: var(--panel); display: flex; flex-direction: column; min-height: 0; }
.find { position: relative; padding: 14px 14px 8px; }
.find input, .dirbar input { width: 100%; padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--paper); color: var(--ink); font: inherit; }
.find input:focus-visible, .dirbar input:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hits { position: absolute; left: 14px; right: 14px; top: calc(100% - 4px); z-index: 20; margin: 0; padding: 4px; list-style: none; background: var(--cds-surface-popover); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--cds-shadow-popover); max-height: 360px; overflow: auto; }
.hits button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 8px; border: 0; background: transparent; text-align: left; cursor: pointer; border-radius: 6px; }
.hits button:hover, .hits button:focus-visible { background: var(--paper); outline: none; }
.hits .kind { margin-left: auto; font-size: 11px; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 14px 12px; border-bottom: 1px solid var(--line); }
.chips button, .mapctl button { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 11px; cursor: pointer; font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.chips button[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.dot.r0 { background: var(--r0); } .dot.r1 { background: var(--r1); } .dot.r2 { background: var(--r2); }
.panel { flex: 1; overflow: auto; padding: 14px; display: grid; align-content: start; gap: 14px; }

.logo { width: 36px; height: 36px; border-radius: 8px; background: #fff; border: 1px solid var(--line); object-fit: contain; padding: 3px; flex: none; }
.logo.sm { width: 26px; height: 26px; border-radius: 6px; padding: 2px; }
.logo.lg { width: 56px; height: 56px; border-radius: 12px; padding: 5px; }
.mono { display: inline-grid; place-items: center; color: #fff; font: 700 13px/1 var(--display); letter-spacing: .02em; padding: 0; border: 0; }
.mono.sm { font-size: 10.5px; } .mono.lg { font-size: 19px; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; display: grid; gap: 10px; }
.panel .card { border: 0; padding: 0; }
.head { display: flex; gap: 12px; align-items: center; }
.head h2 { margin: 0; font: 800 21px/1.1 var(--display); font-stretch: 92%; }
.head .sub { color: var(--ink-soft); font-size: 12.5px; }
.kpis { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.kpi { background: var(--paper); border-radius: 8px; padding: 10px 12px; }
.kpi b { display: block; font: 850 26px/1 var(--display); font-stretch: 85%; }
.kpi span { font-size: 12px; color: var(--ink-soft); }
.sect { font: 600 11px/1.2 var(--display); letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); margin: 6px 0 0; }

.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; position: relative; }
.steps li { display: grid; grid-template-columns: 26px 36px 1fr; gap: 10px; align-items: start; padding: 8px 0; position: relative; }
.steps li::before { content: ""; position: absolute; left: 12px; top: 30px; bottom: -8px; width: 2px; background: var(--line); }
.steps li:last-child::before { display: none; }
.steps .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font: 700 12px/1 var(--display); color: #fff; background: var(--accent); position: relative; z-index: 1; }
.steps .k { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.steps .p { font-weight: 600; }
.steps .d { color: var(--ink-soft); font-size: 12.5px; }
.list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.list button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 6px; border: 0; background: transparent; cursor: pointer; text-align: left; border-radius: 8px; }
.list button:hover, .list button:focus-visible { background: var(--paper); outline: none; }
.list .meta { display: grid; line-height: 1.3; min-width: 0; }
.list .meta small { color: var(--ink-soft); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.back { justify-self: start; border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 4px 11px; cursor: pointer; font-size: 12.5px; }
.quals { display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); }

.mapwrap { position: relative; min-width: 0; }
#map { position: absolute; inset: 0; }
.mapctl { position: absolute; left: 12px; top: 12px; display: flex; gap: 6px; }
.mapctl button { box-shadow: 0 1px 4px rgba(0,0,0,.12); }
.maplegend { position: absolute; left: 12px; bottom: 26px; display: flex; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; font-size: 12px; }
.maplegend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; }
.maplegend .ring { border: 2px solid var(--ink); background: var(--panel); }
.maplegend .disc { background: var(--ink); }
.maplibregl-popup-content { background: var(--cds-surface-popover); color: var(--ink); border-radius: 8px; box-shadow: var(--cds-shadow-popover); padding: 8px 10px; font: 12.5px/1.4 var(--body); }
.maplibregl-popup-tip { border-top-color: var(--cds-surface-popover) !important; border-bottom-color: var(--cds-surface-popover) !important; }
.maplibregl-ctrl-attrib { font-size: 10.5px; }

/* Insights */
.insights { padding: 24px max(16px, 3vw) 48px; }

/* Directory */
.view-dir { padding: 18px max(16px, 2vw); }
.dirbar { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; max-width: 760px; }
.dirbox { border: 1px solid var(--line); border-radius: 10px; overflow: auto; background: var(--panel); max-height: calc(100% - 64px); }
.dir { border-collapse: collapse; width: 100%; font-size: 13px; }
.dir th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 600; padding: 10px; border-bottom: 1px solid var(--line); white-space: nowrap; z-index: 1; }
.dir td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.dir .co { display: flex; align-items: center; gap: 10px; min-width: 220px; }
.dir .who { font-weight: 600; cursor: pointer; color: var(--accent); background: none; border: 0; padding: 0; text-align: left; }
.dir .sch { display: flex; align-items: center; gap: 8px; }

.about { max-width: 70ch; padding: 28px max(16px, 3vw); display: grid; gap: 12px; }
.about h2 { font: 800 26px/1.1 var(--display); margin: 0; }
.about p { margin: 0; }

@media (max-width: 820px) {
  /* Phone: compact header (title + theme dots on one row, tabs below), map on top, cards flow under it and the page scrolls. */
  .top { padding: 8px 12px 0; gap: 4px 10px; align-items: center; }
  .brand { flex: 1 1 190px; min-width: 0; padding-bottom: 2px; }
  .kicker { display: none; }
  .theme, .country { margin: 0; padding: 2px; }
  /* Four countries don't fit beside the title: the switcher drops to its own row under it. */
  .theme { order: 1; }
  .country { order: 2; }
  /* Seven countries don't fit in a row of buttons on a phone: a dropdown takes their place. */
  .country { display: none; }
  .country-pick { display: block; order: 2; }
  .tabs { order: 3; }
  .country button { padding: 5px 9px; }
  .brand h1 { font-size: 19px; line-height: 1.1; }
  .theme button { font-size: 0; gap: 0; padding: 6px; }
  .theme i { width: 15px; height: 15px; }
  .tabs { width: 100%; margin: 0 -12px; padding: 0 6px; }
  .tabs button { padding: 8px 10px 10px; font-size: 13.5px; }
  .view-map { display: flex; flex-direction: column; overflow: auto; -webkit-overflow-scrolling: touch; }
  .mapwrap { order: -1; flex: none; height: 58vh; min-height: 300px; }
  .side { flex: none; border-right: 0; border-top: 1px solid var(--line); }
  .panel { overflow: visible; }
  .find { padding: 12px 12px 6px; }
  .chips { padding: 4px 12px 10px; }
  .mapctl { left: 8px; top: 8px; }
  .mapctl button { padding: 6px 12px; }
  .maplegend { left: 8px; bottom: 8px; gap: 10px; padding: 4px 8px; font-size: 11px; }
  .maplegend .muted { display: none; }
  .view-dir { padding: 12px; }
  .dirbar { flex-wrap: wrap; gap: 6px; }
  .dir .opt { display: none; }
  .dir .co { min-width: 150px; }
  .insights { padding: 16px 12px 40px; }
  .about { padding: 20px 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* The app header already carries the title, so the insights page starts at the takeaway. */
#insights .lede .eyebrow, #insights .lede h1 { display: none; }
