/**
 * ISSE — Global States of Emergency Dashboard
 * Design system: editorial serif display, sans interface, monospaced data.
 * Dual theme (dark default, light opt-in) driven by [data-theme] on <html>.
 */

@import url('https://fonts.googleapis.com/css2?family=Gilda+Display&family=IBM+Plex+Mono:wght@400;500;600&family=PT+Serif:ital,wght@0,400;0,700;1,400&family=Inter:wght@300;400;500;600;700&display=swap');

/* ═══════════════════════════════════════════════════════════════
   Tokens
   ═══════════════════════════════════════════════════════════════ */
:root {
    /* Type families */
    --font-display: 'Gilda Display', Georgia, serif;
    --font-serif: 'PT Serif', Georgia, serif;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'IBM Plex Mono', 'SF Mono', ui-monospace, monospace;

    /* Type scale — 1.25 minor third */
    --text-2xs: 0.6875rem;
    --text-xs: 0.75rem;
    --text-sm: 0.8125rem;
    --text-base: 0.9375rem;
    --text-md: 1.0625rem;
    --text-lg: 1.375rem;
    --text-xl: 1.75rem;
    --text-2xl: 2.25rem;
    --text-3xl: 3rem;
    --text-4xl: 4.5rem;
    --text-hero: clamp(3rem, 9vw, 7rem);

    /* Spacing — 8pt */
    --space-1: 0.5rem;
    --space-2: 1rem;
    --space-3: 1.5rem;
    --space-4: 2rem;
    --space-5: 3rem;
    --space-6: 4rem;
    --space-7: 6rem;

    --radius-sm: 2px;
    --radius: 3px;
    --radius-lg: 4px;

    --max-width: 1440px;
    --reading-width: 68ch;

    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
    --transition-fast: 0.16s var(--ease);
    --transition: 0.28s var(--ease);

    /* Emergency type palette — muted, colour-blind distinguishable.
       These values are the dark-theme ones; [data-theme="light"] restates
       every one of them because a hue that clears 4.5:1 on #101216 does not
       clear it on #f7f5f1. Each is chosen to pass AA as label text on its own
       tinted badge as well as on the plain panel, so a badge sitting in a
       hovered table row stays readable. */
    --c-disaster: #cf7a66;
    --c-public-health: #6fa287;
    --c-conflict: #c08a4a;
    --c-migration: #ab93c9;
    --c-governance: #6f95b0;

    /* Semantic */
    --c-crisis: #cf7a66;
    --c-overlap: #ab93c9;
    --c-soe: #6f95b0;
    --c-watchlist: #c49a6c;

    /* Badge tints are mixed against a named surface rather than `transparent`
       so the resulting contrast is the same whatever the row underneath is
       doing — a translucent tint over a hover-highlighted row silently drops
       the label below AA. */
    --badge-tint: 13%;
}

/* ── Dark theme (default) ── */
:root,
[data-theme="dark"] {
    --bg: #101216;
    --bg-raised: #171a20;
    --bg-panel: #1c2027;
    --bg-inset: #14171c;
    --bg-hover: #232832;

    --ink: #ecebe8;
    --ink-secondary: #a9a69f;
    /* Muted body copy carries real information (chart sub-labels, table meta,
       captions), so it is set to clear 4.5:1 against the *lightest* surface it
       ever lands on — --bg-hover, not --bg. Warm neutral, still visibly a step
       down from --ink-secondary. */
    --ink-muted: #94918b;
    /* --ink-faint is for non-text marks only: separator glyphs, the hollow
       baseline ring in the dumbbell. Held at ≥3:1 on the panel surfaces. */
    --ink-faint: #6f6c66;

    --line: #2a2f39;
    --line-strong: #3a404d;

    --accent: #cfa878;
    --accent-hover: #e0bb8c;
    --accent-soft: rgba(207, 168, 120, 0.12);

    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: -12px 0 32px rgba(0, 0, 0, 0.4);

    --map-void: #171a20;
    --map-line: #2c313b;

    --scrim: rgba(8, 9, 11, 0.72);
    color-scheme: dark;
}

/* ── Light theme ── */
[data-theme="light"] {
    --bg: #f7f5f1;
    --bg-raised: #ffffff;
    --bg-panel: #ffffff;
    --bg-inset: #f1eee8;
    --bg-hover: #efebe3;

    --ink: #1b1a17;
    --ink-secondary: #55524c;
    --ink-muted: #696560;
    --ink-faint: #928c84;

    --line: #e2ddd4;
    --line-strong: #cec8bd;

    --accent: #8a6230;
    --accent-hover: #6f4f26;
    --accent-soft: rgba(138, 98, 48, 0.12);

    --shadow-sm: none;
    --shadow: none;
    --shadow-lg: -12px 0 32px rgba(60, 50, 35, 0.16);

    --map-void: #e8e3da;
    --map-line: #cfc8bc;

    --scrim: rgba(30, 26, 20, 0.42);

    --c-disaster: #a04d3a;
    --c-public-health: #416f59;
    --c-conflict: #92561a;
    --c-migration: #7d5aa3;
    --c-governance: #40657f;

    /* The semantic aliases are restated here too. Left at their dark values
       they render as pale washes on a near-white page: --c-watchlist at
       #c49a6c is 2.6:1 on #ffffff, below the 3:1 a legend swatch or a map fill
       needs to read as a distinct category. */
    --c-crisis: #a04d3a;
    --c-overlap: #7d5aa3;
    --c-soe: #40657f;
    --c-watchlist: #a8813c;
    color-scheme: light;
}

/* ═══════════════════════════════════════════════════════════════
   Base
   ═══════════════════════════════════════════════════════════════ */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 84px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.65;
    color: var(--ink);
    background: var(--bg);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    transition: background var(--transition), color var(--transition);
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
}

/* Underline links inside running prose only */
.prose a {
    text-decoration: underline;
    text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
    text-underline-offset: 0.18em;
}

button {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    background: none;
    border: none;
    cursor: pointer;
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 3px;
}

::selection {
    background: var(--accent-soft);
    color: var(--ink);
}

/* Captions and sub-labels are the lines most likely to leave a single word
   stranded on the last row, and they are also the lines carrying the direction
   of an index. Where the browser supports it, they wrap without orphans; where
   it does not, nothing changes. */
h1,
h2,
h3,
.hero-sub {
    text-wrap: balance;
}

.chart-sub,
.waffle-caption,
.map-note,
.chart-note,
.access-note,
.prose p,
.section-head p {
    text-wrap: pretty;
}

.skip-link {
    position: absolute;
    top: -100px;
    left: var(--space-2);
    z-index: 200;
    padding: 0.6rem 1rem;
    background: var(--accent);
    color: var(--bg);
    border-radius: var(--radius-sm);
    font-weight: 600;
}

.skip-link:focus {
    top: var(--space-2);
}

/* ═══════════════════════════════════════════════════════════════
   Navigation
   ═══════════════════════════════════════════════════════════════ */
.nav {
    position: sticky;
    top: 0;
    z-index: 90;
    background: var(--bg);
    border-bottom: 1px solid var(--line-strong);
}

.nav-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-3);
    height: 64px;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    flex-shrink: 0;
    color: var(--ink);
}

.nav-brand:hover {
    color: var(--ink);
}

.nav-logo {
    height: 30px;
    width: auto;
}

.nav-wordmark {
    font-family: var(--font-display);
    font-size: var(--text-md);
    letter-spacing: 0.01em;
    line-height: 1.1;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    gap: 0.25rem;
    margin-left: auto;
    align-items: center;
}

.nav-links a {
    padding: 0.4rem 0.7rem;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--ink-secondary);
    white-space: nowrap;
    transition: color var(--transition-fast), background var(--transition-fast);
}

.nav-links a:hover {
    color: var(--ink);
    background: var(--bg-hover);
}

.nav-links a.active {
    color: var(--accent);
    background: var(--accent-soft);
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.icon-btn {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    color: var(--ink-secondary);
    background: var(--bg-raised);
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* ═══════════════════════════════════════════════════════════════
   Layout primitives
   ═══════════════════════════════════════════════════════════════ */
.wrap {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-3);
}

section[id] {
    scroll-margin-top: 84px;
}

.section {
    padding: var(--space-6) 0;
    border-top: 1px solid var(--line);
}

.section:first-of-type {
    border-top: none;
}

/* The indicator strip reads as part of the hero, so it carries no top rule
   and no top padding. */
.section.flush-top {
    padding-top: 0;
}

/* Small layout utilities, so the markup carries no inline style attributes. */
.gap-below {
    margin-bottom: var(--space-3);
}

.block-below {
    margin-bottom: var(--space-4);
}

.block-above {
    margin-top: var(--space-4);
}

.subhead {
    font-size: var(--text-md);
    margin-bottom: var(--space-2);
}

.subhead.spaced {
    margin: var(--space-4) 0 var(--space-2);
}

.centered {
    text-align: center;
    margin-top: var(--space-2);
}

.is-hidden {
    display: none;
}

.chip-row.stacked {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
}

.section-head {
    margin-bottom: var(--space-4);
}

.section-head h2 {
    max-width: 34ch;
}

.section-head p {
    max-width: var(--reading-width);
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 400;
    letter-spacing: 0.005em;
    line-height: 1.15;
    color: var(--ink);
}

h2 {
    font-size: clamp(1.7rem, 3.3vw, 2.55rem);
    letter-spacing: -0.012em;
}

h3 {
    font-size: var(--text-lg);
}

.section-head p {
    font-family: var(--font-serif);
    font-size: var(--text-md);
    line-height: 1.7;
    color: var(--ink-secondary);
    margin-top: var(--space-2);
}

.prose {
    font-family: var(--font-serif);
    font-size: var(--text-base);
    line-height: 1.75;
    color: var(--ink-secondary);
    max-width: var(--reading-width);
}

.prose p + p {
    margin-top: var(--space-2);
}

.prose strong {
    color: var(--ink);
    font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════════
   Hero
   ═══════════════════════════════════════════════════════════════ */
.hero {
    padding: var(--space-6) 0 var(--space-5);
    position: relative;
    overflow: hidden;
}

.hero-inner {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
    gap: var(--space-6);
    align-items: center;
}

.hero h1 {
    font-size: var(--text-3xl);
    line-height: 1.08;
    letter-spacing: -0.01em;
}

.hero-figure {
    font-family: var(--font-display);
    font-size: var(--text-hero);
    line-height: 0.9;
    letter-spacing: -0.03em;
    color: var(--ink);
    display: block;
    margin: var(--space-2) 0 0.4rem;
    font-variant-numeric: tabular-nums;
}

.hero-figure .unit {
    font-size: 0.42em;
    letter-spacing: 0;
    color: var(--ink-secondary);
    margin-left: 0.18em;
}

.hero-sub {
    font-family: var(--font-serif);
    font-size: var(--text-md);
    line-height: 1.62;
    color: var(--ink-secondary);
    max-width: 54ch;
    margin-top: var(--space-3);
}

.hero-sub strong {
    color: var(--ink);
    font-weight: 700;
}

.hero-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--ink-muted);
}

.hero-meta span {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.stale-flag {
    color: var(--c-disaster) !important;
    font-weight: 600;
}

/* Waffle grid: 100 squares, each = 1% of world population */
.waffle {
    display: grid;
    grid-template-columns: repeat(10, 1fr);
    gap: 4px;
    aspect-ratio: 1;
    max-width: 340px;
    margin-left: auto;
}

.waffle-cell {
    aspect-ratio: 1;
    border-radius: 2px;
    background: var(--bg-hover);
    transition: background var(--transition), transform var(--transition);
}

.waffle-cell.on {
    background: var(--accent);
}

.waffle-cell.partial {
    background: color-mix(in srgb, var(--accent) 45%, var(--bg-hover));
}

.waffle-caption {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    text-align: right;
    margin-top: var(--space-2);
    max-width: 340px;
    margin-left: auto;
    line-height: 1.6;
}

.waffle-caption .swatch {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: var(--accent);
    margin-right: 0.35rem;
    vertical-align: -1px;
}

/* ═══════════════════════════════════════════════════════════════
   Stat cards
   ═══════════════════════════════════════════════════════════════ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    column-gap: var(--space-3);
    row-gap: var(--space-2);
}

/* Pin four columns on wide screens so the eight headline figures land as two
   even rows rather than leaving orphans on a second line. */
@media (min-width: 1080px) {
    .stat-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.stat {
    padding: 0.85rem 0 0;
    position: relative;
    border-top: 1px solid var(--line-strong);
}

/* Only where the colour carries meaning, matching a map legend. */
.stat.keyed {
    border-top: 2px solid var(--stat-accent, var(--accent));
}

.stat-value {
    font-family: var(--font-display);
    font-size: clamp(1.9rem, 3.1vw, 2.5rem);
    line-height: 1;
    color: var(--ink);
    display: block;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.stat-value .unit {
    font-size: 0.5em;
    color: var(--ink-secondary);
    margin-left: 0.12em;
}

.stat-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--ink);
    margin-top: 0.45rem;
    line-height: 1.35;
}

.stat-note {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    margin-top: 0.3rem;
    line-height: 1.5;
}

.stat-spark {
    margin-top: 0.6rem;
    height: 26px;
}

.stat-spark svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

/* ═══════════════════════════════════════════════════════════════
   Chips / badges
   ═══════════════════════════════════════════════════════════════ */
.chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.32rem 0.7rem;
    border-radius: 100px;
    border: 1px solid var(--line);
    background: var(--bg-raised);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--ink-secondary);
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.chip:hover {
    border-color: var(--line-strong);
    color: var(--ink);
}

.chip.active {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--ink);
}

.chip .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.chip .count {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: var(--text-2xs);
    font-weight: 600;
    letter-spacing: 0.02em;
    white-space: nowrap;
    border: 1px solid transparent;
}

.badge.disaster { color: var(--c-disaster); background: color-mix(in srgb, var(--c-disaster) var(--badge-tint), var(--bg-raised)); border-color: color-mix(in srgb, var(--c-disaster) 34%, var(--bg-raised)); }
.badge.public_health { color: var(--c-public-health); background: color-mix(in srgb, var(--c-public-health) var(--badge-tint), var(--bg-raised)); border-color: color-mix(in srgb, var(--c-public-health) 34%, var(--bg-raised)); }
.badge.conflict { color: var(--c-conflict); background: color-mix(in srgb, var(--c-conflict) var(--badge-tint), var(--bg-raised)); border-color: color-mix(in srgb, var(--c-conflict) 34%, var(--bg-raised)); }
.badge.migration { color: var(--c-migration); background: color-mix(in srgb, var(--c-migration) var(--badge-tint), var(--bg-raised)); border-color: color-mix(in srgb, var(--c-migration) 34%, var(--bg-raised)); }
.badge.governance { color: var(--c-governance); background: color-mix(in srgb, var(--c-governance) var(--badge-tint), var(--bg-raised)); border-color: color-mix(in srgb, var(--c-governance) 34%, var(--bg-raised)); }

.scope-tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
    border: 1px solid var(--line-strong);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.conf {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.conf::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.conf-verified { color: var(--c-public-health); }
.conf-likely { color: var(--accent); }
.conf-unconfirmed { color: var(--ink-muted); }

/* ═══════════════════════════════════════════════════════════════
   Maps
   ═══════════════════════════════════════════════════════════════ */
.map-shell {
    position: relative;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--map-void);
    box-shadow: var(--shadow-sm);
}

.map-canvas {
    height: 620px;
    width: 100%;
    background: var(--map-void);
}

.map-canvas.short {
    height: 480px;
}

.leaflet-container {
    background: var(--map-void) !important;
    font-family: var(--font-sans);
}

.leaflet-control-zoom a {
    background: var(--bg-panel) !important;
    color: var(--ink-secondary) !important;
    border-color: var(--line) !important;
}

.leaflet-control-zoom a:hover {
    background: var(--bg-hover) !important;
    color: var(--accent) !important;
}

/* Opaque, not translucent: these controls float over country polygons whose
   fill is whatever the emergency-type palette gave them, so a see-through
   plate makes their contrast a lottery. */
.leaflet-control-attribution {
    background: var(--bg) !important;
    color: var(--ink-muted) !important;
    font-size: 10px !important;
    padding: 1px 5px !important;
}

.leaflet-control-attribution a {
    color: var(--ink-secondary) !important;
}

.map-tip {
    background: var(--bg-panel) !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: var(--radius-sm) !important;
    color: var(--ink) !important;
    box-shadow: var(--shadow) !important;
    padding: 0.6rem 0.75rem !important;
    font-family: var(--font-sans) !important;
    font-size: var(--text-xs) !important;
    line-height: 1.55 !important;
    max-width: 290px;
    white-space: normal !important;
}

.map-tip::before {
    border-top-color: var(--line-strong) !important;
}

.map-tip .tip-name {
    font-family: var(--font-display);
    font-size: var(--text-base);
    display: block;
    margin-bottom: 0.15rem;
}

.map-tip .tip-row {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-secondary);
    margin-top: 0.2rem;
}

.map-tip .tip-hint {
    color: var(--ink-muted);
    font-size: var(--text-2xs);
    margin-top: 0.45rem;
    display: block;
    border-top: 1px solid var(--line);
    padding-top: 0.35rem;
}

.map-toolbar {
    position: absolute;
    top: var(--space-2);
    left: var(--space-2);
    z-index: 500;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    max-width: calc(100% - 100px);
}

.map-toolbar .chip {
    background: var(--bg-panel);
}

.map-toolbar .chip.active {
    background: color-mix(in srgb, var(--accent) 12%, var(--bg-panel));
}

/* Scroll-wheel zoom needs a deliberate click, which is worth saying out loud. */
.map-hint {
    padding: 0.3rem 0.55rem;
    border-radius: var(--radius-sm);
    background: var(--bg-panel);
    border: 1px solid var(--line);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    pointer-events: none;
}

.map-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: 0.85rem var(--space-2);
    border-top: 1px solid var(--line);
    background: var(--bg-panel);
    font-size: var(--text-xs);
    color: var(--ink-secondary);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
}

.legend-swatch {
    width: 10px;
    height: 10px;
    flex-shrink: 0;
}

.map-note {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    margin-top: var(--space-2);
    line-height: 1.65;
    max-width: var(--reading-width);
}

/* ═══════════════════════════════════════════════════════════════
   Charts
   ═══════════════════════════════════════════════════════════════ */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: var(--space-3);
}

.chart-card {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-3);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.chart-card h3 {
    font-size: var(--text-md);
    margin-bottom: 0.25rem;
}

/* Before the fetch resolves a chart holder is an empty div, so the cards
   collapse and the page jumps when the data lands. `:empty` reserves a plausible
   height and says what is happening, and stops applying the moment the <svg>
   is inserted — so there is nothing to tear down and no whitespace left under
   a short chart. */
.chart-holder:empty {
    min-height: 160px;
    display: grid;
    place-items: center;
}

.chart-holder:empty::after {
    content: "Loading…";
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.06em;
    color: var(--ink-muted);
}

.chart-card .chart-sub {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    line-height: 1.6;
    margin-bottom: var(--space-2);
}

.chart-holder {
    width: 100%;
    overflow-x: auto;
}

.chart-holder svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.chart-axis-line { stroke: var(--line); stroke-width: 1; }
.chart-grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.7; }
.chart-label { font-family: var(--font-mono); font-size: 10px; fill: var(--ink-muted); }
.chart-label-strong { font-family: var(--font-sans); font-size: 11px; font-weight: 500; fill: var(--ink-secondary); }
.chart-value { font-family: var(--font-mono); font-size: 10px; fill: var(--ink-secondary); }
.chart-bar { transition: opacity var(--transition-fast); cursor: default; }
.chart-bar:hover { opacity: 0.78; }
.chart-dot { transition: r var(--transition-fast); }

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
}

/* Round and hollow legend markers, matching the dots a dumbbell or scatter
   draws. The hollow one takes its border colour from the legend entry. */
.legend-swatch.round {
    border-radius: 50%;
}

.legend-swatch.ring {
    border-radius: 50%;
    background: var(--bg-panel);
    border: 1.6px solid var(--ink-faint);
}

/* Caption under a chart: the text alternative to the chart's shape, so it is
   ordinary readable body text rather than fine print. */
.chart-note {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    line-height: 1.65;
    margin-top: var(--space-2);
    max-width: var(--reading-width);
}

/* The rights chart is the argument of its section, not one card among six, so
   it gets the full width of the wrap and room to breathe. */
.feature-card {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.feature-head {
    margin-bottom: var(--space-3);
}

.feature-head h3 {
    margin-bottom: 0.35rem;
}

.feature-head .chart-sub {
    font-size: var(--text-sm);
    color: var(--ink-secondary);
    line-height: 1.65;
    max-width: var(--reading-width);
}

.feature-card .chip-row {
    margin-bottom: var(--space-3);
}

.feature-holder {
    margin-top: var(--space-1);
}

@media (max-width: 760px) {
    .feature-card {
        padding: var(--space-2);
    }
}

/* ═══════════════════════════════════════════════════════════════
   Controls / filters
   ═══════════════════════════════════════════════════════════════ */
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    align-items: flex-end;
    margin-bottom: var(--space-3);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 150px;
}

.field.grow {
    flex: 1;
    min-width: 240px;
}

.field label {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--ink-muted);
}

.field input,
.field select {
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    color: var(--ink);
    background: var(--bg-raised);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    width: 100%;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* The soft ring above is --accent at 12% alpha, which is a tint, not a focus
   indicator. Keyboard focus gets the same 2px accent outline as every other
   control on the page, so the affordance is consistent wherever the caret is. */
.field input:focus-visible,
.field select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.field input::placeholder {
    color: var(--ink-muted);
    opacity: 1;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.55rem 0.95rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: var(--bg-raised);
    color: var(--ink-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--accent-soft);
}

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
    color: var(--bg);
}

/* ═══════════════════════════════════════════════════════════════
   Table
   ═══════════════════════════════════════════════════════════════ */
.table-shell {
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-panel);
}

.table-scroll {
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

table.data thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--bg-inset);
    text-align: left;
    padding: 0.7rem var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 500;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--ink-muted);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    transition: color var(--transition-fast);
}

table.data thead th:hover {
    color: var(--ink);
}

/* The arrow used to sit at opacity 0.3, which put it at 1.4:1 — invisible
   rather than subtle. It is drawn at full strength now; the sorted column is
   still obvious because the glyph changes to ↑ or ↓ and the whole header turns
   accent-coloured, so state is carried by shape and colour, not opacity. */
table.data thead th .sort-arrow {
    margin-left: 0.25rem;
}

table.data thead th.sorted {
    color: var(--accent);
}

table.data tbody tr {
    border-bottom: 1px solid var(--line);
    cursor: pointer;
    transition: background var(--transition-fast);
}

table.data tbody tr:last-child {
    border-bottom: none;
}

table.data tbody tr:hover {
    background: var(--bg-hover);
}

/* Rows are keyboard-operable, and an outline on a <tr> is clipped in several
   browsers, so mark focus with the background and an inset ring instead. */
table.data tbody tr:focus-visible {
    outline: none;
    background: var(--bg-hover);
    box-shadow: inset 0 0 0 2px var(--accent);
}

table.data td {
    padding: 0.7rem var(--space-2);
    vertical-align: middle;
}

td.num {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    color: var(--ink-secondary);
    text-align: right;
    white-space: nowrap;
}

td.country-cell {
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
}

/* The ISO3 code is data, not decoration — a reader may be scanning for "SSD"
   — so it takes the muted text colour rather than the non-text --ink-faint. */
td.country-cell .iso {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    margin-left: 0.4rem;
    font-weight: 400;
}

td.title-cell {
    color: var(--ink-secondary);
    min-width: 230px;
    max-width: 400px;
}

/* Numeric columns are tabular and short. Tighter side padding is what lets the
   register carry its two indicator columns without pushing the status column
   off the end of a laptop screen. */
table.data thead th.num-col,
table.data td.num {
    padding-left: 0.65rem;
    padding-right: 0.65rem;
}

.dur-bar {
    display: inline-block;
    height: 4px;
    border-radius: 2px;
    background: var(--accent);
    vertical-align: middle;
    margin-right: 0.4rem;
    min-width: 2px;
}

.table-foot {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem var(--space-2);
    border-top: 1px solid var(--line);
    background: var(--bg-inset);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
}

.empty-state {
    padding: var(--space-5) var(--space-2);
    text-align: center;
    color: var(--ink-muted);
    font-size: var(--text-sm);
}

/* ═══════════════════════════════════════════════════════════════
   Feed
   ═══════════════════════════════════════════════════════════════ */
/* The live region: a one-line count, not the forty-item list beneath it. */
.feed-status {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    margin-bottom: 0.6rem;
    min-height: 1.2em;
}

.feed {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--bg-panel);
}

.feed-item {
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    gap: var(--space-2);
    padding: 0.9rem var(--space-2);
    border-bottom: 1px solid var(--line);
    transition: background var(--transition-fast);
}

.feed-item:last-child {
    border-bottom: none;
}

.feed-item:hover {
    background: var(--bg-hover);
}

.feed-date {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    padding-top: 0.15rem;
    white-space: nowrap;
}

.feed-title {
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--ink);
    display: block;
}

.feed-title a {
    color: var(--ink);
}

.feed-title a:hover {
    color: var(--accent);
}

.feed-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 0.4rem;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
}

.feed-meta .sep {
    color: var(--ink-muted);
}

/* ═══════════════════════════════════════════════════════════════
   Country drawer
   ═══════════════════════════════════════════════════════════════ */
.drawer-scrim {
    position: fixed;
    inset: 0;
    background: var(--scrim);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.drawer-scrim.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(560px, 100vw);
    z-index: 101;
    background: var(--bg-raised);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-lg);
    transform: translateX(102%);
    transition: transform var(--transition);
    display: flex;
    flex-direction: column;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-head {
    padding: var(--space-3) var(--space-3) var(--space-2);
    border-bottom: 1px solid var(--line);
    position: relative;
    flex-shrink: 0;
}

.drawer-head h2 {
    font-size: var(--text-xl);
    padding-right: 2.5rem;
}

.drawer-head .drawer-sub {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    margin-top: 0.3rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.drawer-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    color: var(--ink-secondary);
    transition: all var(--transition-fast);
}

.drawer-close:hover {
    color: var(--c-disaster);
    border-color: var(--c-disaster);
}

.drawer-body {
    padding: var(--space-3);
    overflow-y: auto;
    flex: 1;
}

.drawer-section {
    margin-bottom: var(--space-3);
}

.drawer-section:last-child {
    margin-bottom: 0;
}

.drawer-section h4 {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 500;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.7rem;
    padding-bottom: 0.4rem;
    border-bottom: 1px solid var(--line);
}

/* Caption under a drawer section heading, for statements a reader needs
   before the numbers make sense — e.g. which way an index points. */
.drawer-note {
    font-size: var(--text-2xs);
    line-height: 1.55;
    color: var(--ink-secondary);
    margin: -0.2rem 0 0.75rem;
}

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.85rem var(--space-2);
}

.kv {
    min-width: 0;
}

.kv-label {
    display: block;
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    margin-bottom: 0.15rem;
}

.kv-value {
    display: block;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.4;
    word-break: break-word;
}

.kv-value.small {
    font-size: var(--text-xs);
}

/* Signed change against the year before a declaration, shown next to the
   current V-Dem rights score. Colour is set inline, since the direction of
   the change decides it. */
.rights-change {
    font-size: var(--text-xs);
    margin-left: 0.3rem;
}

/* Observation year printed beside a structural context figure. Every one of
   those series resolves at its own latest year per country, and some are
   years behind (North Korea's internet share is a 2004 reading), so the year
   travels with the value rather than sitting in a caption a reader can skip.
   Muted against the value, but it is a token in both themes because
   --ink-muted is redefined under [data-theme]. */
.context-year {
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    margin-left: 0.3rem;
}

.meter {
    height: 5px;
    border-radius: 3px;
    background: var(--bg-hover);
    margin-top: 0.4rem;
    overflow: hidden;
}

.meter span {
    display: block;
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
}

.drawer-emergency {
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-left: 3px solid var(--stat-accent, var(--accent));
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    margin-bottom: 0.7rem;
}

.drawer-emergency .em-title {
    font-family: var(--font-serif);
    font-size: var(--text-sm);
    line-height: 1.55;
    color: var(--ink);
    margin: 0.45rem 0;
}

.drawer-emergency .em-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
}

.link-list {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.link-list a {
    font-size: var(--text-xs);
    line-height: 1.5;
    display: block;
}

.link-list .src-meta {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    display: block;
    margin-top: 0.1rem;
}

/* ═══════════════════════════════════════════════════════════════
   Sources / provenance table
   ═══════════════════════════════════════════════════════════════ */
.source-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--space-2);
}

.source-card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-2);
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.source-card .src-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--ink);
    line-height: 1.4;
}

.source-card .src-role {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}

.source-card .src-stats {
    display: flex;
    gap: var(--space-2);
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    color: var(--ink-muted);
    margin-top: 0.2rem;
    flex-wrap: wrap;
}

.status-dot {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.status-dot::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--c-public-health);
}

.status-dot.missing::before {
    background: var(--c-disaster);
}

/* ═══════════════════════════════════════════════════════════════
   Data access
   ═══════════════════════════════════════════════════════════════ */
.access-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.9fr) minmax(260px, 0.9fr);
    gap: var(--space-4);
    align-items: start;
}

.access-main {
    min-width: 0;
}

.access-lede {
    font-family: var(--font-serif);
    font-size: var(--text-base);
    color: var(--ink-secondary);
    line-height: 1.7;
    margin-bottom: var(--space-2);
    max-width: 62ch;
}

.access-side {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}

.access-card {
    background: var(--bg-panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-2);
}

.access-card h4 {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    font-weight: 500;
    letter-spacing: 0.13em;
    text-transform: uppercase;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.access-note {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    line-height: 1.65;
    margin: 0.75rem 0;
}

.inline-code {
    font-family: var(--font-mono);
    font-size: 0.88em;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 0.08em 0.35em;
    color: var(--ink);
}

/* Language tabs */
.tab-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: -1px;
    position: relative;
    z-index: 1;
}

.tab {
    padding: 0.45rem 0.9rem;
    font-size: var(--text-xs);
    font-weight: 500;
    font-family: var(--font-mono);
    letter-spacing: 0.03em;
    color: var(--ink-muted);
    border: 1px solid transparent;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: all var(--transition-fast);
}

.tab:hover {
    color: var(--ink);
}

.tab.active {
    color: var(--accent);
    background: var(--bg-inset);
    border-color: var(--line);
    border-bottom-color: var(--bg-inset);
}

.code-block {
    position: relative;
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: 0 var(--radius) var(--radius) var(--radius);
    padding: var(--space-2);
    padding-right: 5rem;
    overflow-x: auto;
}

.code-block pre {
    margin: 0;
    overflow-x: auto;
}

.code-block code {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    line-height: 1.75;
    color: var(--ink-secondary);
    white-space: pre;
    display: block;
}

.code-block .btn {
    position: absolute;
    top: 0.6rem;
    right: 0.6rem;
    padding: 0.25rem 0.6rem;
    font-size: var(--text-2xs);
}

td.dataset-cell {
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--ink);
    white-space: nowrap;
}

td.dataset-cell .dataset-desc {
    display: block;
    font-family: var(--font-sans);
    font-size: var(--text-2xs);
    font-weight: 400;
    color: var(--ink-muted);
    white-space: normal;
    max-width: 46ch;
    margin-top: 0.2rem;
    line-height: 1.55;
}

.cite-block {
    background: var(--bg-inset);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
    font-family: var(--font-mono);
    font-size: var(--text-xs);
    color: var(--ink-secondary);
    line-height: 1.7;
    position: relative;
    padding-right: 5rem;
}

.cite-block .btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    padding: 0.3rem 0.6rem;
    font-size: var(--text-2xs);
}

/* ═══════════════════════════════════════════════════════════════
   Footer
   ═══════════════════════════════════════════════════════════════ */
footer {
    border-top: 1px solid var(--line);
    background: var(--bg-raised);
    padding: var(--space-5) 0 var(--space-4);
    margin-top: var(--space-5);
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 var(--space-3);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
    align-items: flex-start;
    justify-content: space-between;
}

.footer-logo {
    height: 44px;
    width: auto;
    margin-bottom: var(--space-2);
}

.footer-block {
    max-width: 46ch;
}

.footer-block p {
    font-size: var(--text-xs);
    color: var(--ink-muted);
    line-height: 1.7;
}

.footer-block p + p {
    margin-top: 0.5rem;
}

.footer-nav {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: var(--text-xs);
}

.footer-nav strong {
    font-family: var(--font-mono);
    font-size: var(--text-2xs);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink-muted);
    font-weight: 500;
    margin-bottom: 0.2rem;
}

/* ═══════════════════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════════════════ */
@media (max-width: 1080px) {
    .hero-inner {
        grid-template-columns: 1fr;
        gap: var(--space-4);
    }

    .waffle,
    .waffle-caption {
        margin-left: 0;
    }

    .nav-links a:nth-child(n + 6) {
        display: none;
    }

    .access-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 760px) {
    :root {
        --text-2xl: 1.75rem;
        --text-3xl: 2.15rem;
    }

    .wrap,
    .nav-inner,
    .footer-inner {
        padding-left: var(--space-2);
        padding-right: var(--space-2);
    }

    .section {
        padding: var(--space-5) 0;
    }

    /* No hamburger: the eight links wrap onto their own row and scroll
       sideways, which keeps every section reachable on a phone. */
    .nav-inner {
        height: auto;
        flex-wrap: wrap;
        gap: 0.5rem var(--space-2);
        padding-top: 0.6rem;
        padding-bottom: 0.4rem;
    }

    .nav-links {
        order: 3;
        width: 100%;
        margin-left: 0;
        overflow-x: auto;
        scrollbar-width: none;
        padding-bottom: 0.2rem;
    }

    .nav-links::-webkit-scrollbar {
        display: none;
    }

    .nav-links a:nth-child(n + 6) {
        display: block;
    }

    .nav-actions {
        margin-left: auto;
    }

    /* The wrapped nav measures 116.2px once its links are 44px tall, so the
       old 116px offset clipped the first line of a jumped-to section by a
       fraction. 124px leaves a little air under the bar. */
    html {
        scroll-padding-top: 124px;
    }

    section[id] {
        scroll-margin-top: 124px;
    }

    .nav-wordmark {
        font-size: var(--text-base);
    }

    .map-canvas {
        height: 420px;
    }

    .map-canvas.short {
        height: 360px;
    }

    .chart-grid {
        grid-template-columns: 1fr;
    }

    .feed-item {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }

    .map-toolbar {
        position: static;
        max-width: none;
        padding: 0.7rem var(--space-2) 0;
    }

    /* Touch targets. The controls here were 27-37px tall, under the 44px
       every mobile platform guideline asks for, so on a phone they grow to 44
       without changing anything about how they look on a laptop. Inline links
       inside running prose are left alone — WCAG's inline exception covers
       them, and padding them out would break the paragraph. */
    .icon-btn {
        width: 44px;
        height: 44px;
    }

    .btn,
    .chip,
    .tab {
        min-height: 44px;
    }

    .field input,
    .field select {
        min-height: 44px;
    }

    .nav-links a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
    }

    .drawer-close {
        width: 44px;
        height: 44px;
    }

    .drawer {
        width: 100vw;
    }

    td.title-cell {
        min-width: 200px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

@media print {
    /* The map shells print as tall empty rectangles, so drop them entirely. */
    .nav, .drawer, .drawer-scrim, .map-toolbar, .controls, .btn, .map-shell,
    .skip-link, .tab-row, .map-hint {
        display: none !important;
    }

    body {
        background: #fff;
        color: #000;
    }

    /* Ink on paper: the muted greys that work on a lit screen print as a
       smudge, and the theme tokens are what every panel, chart label and
       table rule reads from. Overriding them at the root re-colours the whole
       document in one place rather than rule by rule. */
    :root,
    [data-theme="dark"],
    [data-theme="light"] {
        --bg: #fff;
        --bg-raised: #fff;
        --bg-panel: #fff;
        --bg-inset: #fff;
        --bg-hover: #fff;
        --ink: #000;
        --ink-secondary: #222;
        --ink-muted: #444;
        --ink-faint: #767676;
        --line: #bbb;
        --line-strong: #888;
        --accent: #5a3c14;
        --shadow: none;
        --shadow-sm: none;
        --shadow-lg: none;
    }

    /* A chart or a table split across a page break is unreadable, and the
       source list is what makes a printed copy checkable. */
    .chart-card,
    .table-shell,
    .feed-item,
    figure {
        break-inside: avoid;
    }

    .section {
        padding: var(--space-3) 0;
    }

    /* A printed link with no destination is a dead end. Only the running prose
       and the source list get the URL spelled out; nav-style links would fill
       the page with noise. */
    .prose a[href^="http"]::after,
    .source-grid a[href^="http"]::after {
        content: " (" attr(href) ")";
        font-size: 0.85em;
        word-break: break-all;
    }
}
