/* Expansion Atlas v2 ("country brief"). Tokens: design-system/expansion-atlas/MASTER.md (source of truth). */
:root {
  color-scheme: light;
  --ink: #15202B; --ink-2: #47525E; --paper: #FFFFFF; --band: #F3F5F7;
  --rule: rgba(21, 32, 43, 0.12); --rule-strong: #7D8995;
  --stamp: #8C2F39; --stamp-wash: rgba(140, 47, 57, 0.07);
  --line-sea: #2C62B5; --line-gc: #14855C; --line-latam: #9A6A12;
  --popover-shadow: 0 8px 24px rgba(15, 23, 32, 0.12);
  --font: "Atkinson Hyperlegible Next", system-ui, -apple-system, "Segoe UI", sans-serif;
  --measure: 70ch; --max: 1120px; --gutter: 24px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #E3E8ED; --ink-2: #A9B4BF; --paper: #0F1720; --band: #18222D;
  --rule: rgba(227, 232, 237, 0.12); --rule-strong: #5F6D7B;
  --stamp: #E2808A; --stamp-wash: rgba(226, 128, 138, 0.12);
  --line-sea: #6690DA; --line-gc: #2FA376; --line-latam: #BE8A2A; --popover-shadow: none;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --ink: #E3E8ED; --ink-2: #A9B4BF; --paper: #0F1720; --band: #18222D;
    --rule: rgba(227, 232, 237, 0.12); --rule-strong: #5F6D7B;
    --stamp: #E2808A; --stamp-wash: rgba(226, 128, 138, 0.12);
    --line-sea: #6690DA; --line-gc: #2FA376; --line-latam: #BE8A2A; --popover-shadow: none;
  }
}

/* Base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 17px/28px var(--font); -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4 { margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }
a { color: var(--stamp); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--stamp); outline-offset: 2px; }
button { font: inherit; color: inherit; cursor: pointer; }
a, button, select, summary, input { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 16px; top: -48px; background: var(--ink); color: var(--paper); padding: 8px 12px; border-radius: 4px; z-index: 100; }
.skip-link:focus { top: 8px; }
.muted { color: var(--ink-2); }
.small { font-size: 15px; line-height: 24px; }

/* Top bar */
.topbar { position: sticky; top: 0; z-index: 30; background: var(--paper); border-bottom: 1px solid var(--rule); }
.topbar-inner { max-width: var(--max); margin: 0 auto; padding: 0 var(--gutter); min-height: 64px; display: flex; align-items: center; gap: 24px; }
.wordmark { font-size: 18px; font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; }
.topnav { display: flex; gap: 16px; flex: 1; align-items: center; }
.nav-sep { width: 1px; height: 20px; background: var(--rule-strong); margin: 0 4px; }
.topnav a { color: var(--ink-2); text-decoration: none; font-weight: 500; font-size: 15px; white-space: nowrap; padding: 18px 0; border-bottom: 2px solid transparent; }
.topnav a:hover { color: var(--ink); }
.topnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--stamp); }
.theme-toggle, .menu-button, .button {
  min-height: 36px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 4px; background: transparent; font-size: 15px; font-weight: 500;
}
.theme-toggle:hover, .menu-button:hover, .button:hover { background: var(--stamp-wash); }
.menu-button { display: none; }
@media (max-width: 1099px) {
  .topbar-inner { gap: 12px; flex-wrap: wrap; }
  .wordmark { flex: 1; }
  .menu-button { display: inline-flex; align-items: center; min-height: 44px; }
  .theme-toggle { min-height: 44px; }
  .topnav { display: none; order: 3; flex-basis: 100%; flex-direction: column; gap: 0; padding-bottom: 8px; }
  .topbar[data-open="true"] .topnav { display: flex; }
  .topnav a { padding: 10px 0; border-bottom: 0; }
  .topnav a[aria-current="page"] { text-decoration: underline; text-decoration-color: var(--stamp); text-decoration-thickness: 2px; }
  .nav-sep { width: 100%; height: 1px; margin: 4px 0; }
}

/* Page */
main { max-width: var(--max); margin: 0 auto; padding: 48px var(--gutter) 96px; }
main:focus { outline: none; }
.crumb { font-size: 15px; margin-bottom: 12px; }
h1 { font-size: clamp(32px, 4vw, 42px); line-height: 1.15; font-weight: 700; letter-spacing: -0.015em; max-width: 26ch; }
.summary { font-size: 19px; line-height: 30px; max-width: 66ch; margin-top: 16px; }
.asof { color: var(--ink-2); font-size: 15px; line-height: 24px; margin-top: 8px; }
h2 { font-size: 28px; line-height: 36px; font-weight: 700; margin-top: 64px; scroll-margin-top: 80px; }
h3 { font-size: 20px; line-height: 28px; font-weight: 700; margin-top: 40px; }
h4, .item-title { font-size: 18px; line-height: 26px; font-weight: 700; margin: 0; }
.lead { color: var(--ink-2); max-width: var(--measure); margin-top: 8px; }
.section-body { margin-top: 20px; }
.prose { max-width: var(--measure); }
.prose p + p { margin-top: 12px; }
.no-data { color: var(--ink-2); }
.note-box { margin-top: 24px; padding: 16px 20px; background: var(--band); border-radius: 8px; color: var(--ink-2); font-size: 15px; line-height: 24px; max-width: 80ch; }
.conflict { font-size: 15px; line-height: 24px; font-weight: 600; margin-top: 4px; }

/* Facts band */
.facts-band { margin-top: 32px; padding: 24px 32px; background: var(--band); border-radius: 8px; }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px 32px; margin: 0; }
.facts dt { font-size: 15px; line-height: 24px; color: var(--ink-2); }
.facts dd { margin: 2px 0 0; font-weight: 600; }
@media (max-width: 719px) { .facts-band { padding: 20px; } }

/* Footnotes, terms, popover */
sup.fn-wrap { line-height: 0; }
.fn {
  border: 0; background: none; color: var(--stamp); font-size: 12px; font-weight: 700; line-height: 1;
  padding: 6px 3px; margin: -6px -1px; border-radius: 4px; vertical-align: baseline;
}
.fn:hover { background: var(--stamp-wash); }
.term { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-decoration: underline dotted var(--ink-2); text-underline-offset: 4px; text-align: inherit; }
.term:hover { text-decoration-color: var(--stamp); }
.popover {
  position: absolute; z-index: 50; width: min(380px, calc(100vw - 32px)); max-height: min(70vh, 560px); overflow-y: auto; overscroll-behavior: contain;
  padding: 16px 20px; background: var(--paper); color: var(--ink); border-radius: 10px; box-shadow: 0 0 0 1px var(--rule), var(--popover-shadow);
  display: grid; gap: 12px; font-size: 15px; line-height: 24px;
}
.popover h2 { margin: 0; font-size: 17px; line-height: 26px; }
.popover dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; }
.popover dt { color: var(--ink-2); }
.popover dd { margin: 0; overflow-wrap: anywhere; }
.popover .src + .src { border-top: 1px solid var(--rule); padding-top: 12px; }
.popover-close { justify-self: end; }
.sources-list { margin: 20px 0 0; padding-left: 28px; max-width: 80ch; font-size: 15px; line-height: 24px; color: var(--ink-2); }
.sources-list li { margin-bottom: 8px; padding-left: 4px; overflow-wrap: anywhere; }
.sources-list li::marker { color: var(--stamp); font-weight: 700; }

/* Tables */
.table-wrap { overflow-x: auto; margin-top: 20px; }
table { border-collapse: collapse; width: 100%; font-size: 16px; line-height: 24px; }
caption { text-align: left; }
th, td { text-align: left; padding: 12px 16px 12px 0; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { font-weight: 600; color: var(--ink-2); border-bottom: 2px solid var(--ink); white-space: nowrap; }
tbody th { font-weight: 700; }
tbody th a { color: var(--ink); }
tbody th a:hover { color: var(--stamp); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.group th { padding-top: 28px; font-size: 15px; color: var(--ink-2); font-weight: 600; border-bottom: 1px solid var(--ink); }
.sub { display: block; color: var(--ink-2); font-size: 15px; line-height: 22px; font-weight: 400; }
@media (max-width: 719px) { table { min-width: 640px; } }

/* Licence block */
.licence { border-top: 2px solid var(--ink); padding-top: 16px; margin-top: 32px; max-width: 860px; }
.licence .local { color: var(--ink-2); font-size: 15px; line-height: 24px; }
.licence > p { margin-top: 8px; max-width: var(--measure); }
.req { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 12px 24px; margin: 16px 0 0; }
.req dt { color: var(--ink-2); }
.req dd { margin: 0; max-width: var(--measure); }
.req dd + dt, .req dd + dt + dd { padding-top: 12px; border-top: 1px solid var(--rule); }
.req strong { font-weight: 700; }
details.more summary { cursor: pointer; color: var(--stamp); font-size: 15px; margin-top: 4px; width: fit-content; }
details.more p { margin-top: 4px; font-size: 15px; line-height: 24px; color: var(--ink-2); }
@media (max-width: 719px) { .req { grid-template-columns: 1fr; gap: 0; } .req dd { margin-bottom: 12px; } .req dd + dt { border-top: 1px solid var(--rule); padding-top: 12px; } .req dd + dt + dd { border-top: 0; padding-top: 0; } }

/* Charts */
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 32px 48px; margin-top: 20px; }
.chart { margin: 0; }
.chart figcaption { font-weight: 700; }
.chart .src { color: var(--ink-2); font-size: 15px; line-height: 24px; margin-bottom: 12px; }
.bar { display: grid; grid-template-columns: minmax(120px, 170px) minmax(0, 1fr) 64px; align-items: center; gap: 12px; padding: 6px 0; font-size: 16px; line-height: 24px; }
.bar .track { height: 14px; background: var(--band); border-radius: 0 4px 4px 0; }
.bar .fill { display: block; height: 14px; border-radius: 0 4px 4px 0; min-width: 2px; }
.bar b { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.bar-note { grid-column: 1 / -1; font-size: 15px; line-height: 22px; color: var(--ink-2); margin-top: -2px; }

/* Lists */
.events { list-style: none; margin: 20px 0 0; padding: 0; border-top: 1px solid var(--rule); max-width: 900px; }
.event { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--rule); content-visibility: auto; contain-intrinsic-size: auto 110px; }
.event-date { color: var(--ink-2); font-size: 15px; line-height: 28px; }
.event-title { font-weight: 700; }
.event-meta { color: var(--ink-2); font-size: 15px; line-height: 24px; }
.event-desc { margin-top: 4px; max-width: var(--measure); }
@media (max-width: 599px) { .event { grid-template-columns: 1fr; gap: 0; } }
.risk { margin-top: 20px; max-width: var(--measure); }
.risk .item-title { margin-bottom: 4px; }
.held-by { margin-top: 12px; }
.all-sources { list-style: none; padding-left: 0; }
.all-sources li { content-visibility: auto; contain-intrinsic-size: auto 48px; }
.plain-list { margin: 12px 0 0; padding-left: 20px; max-width: var(--measure); }
.plain-list li + li { margin-top: 6px; }

/* Controls */
.controls { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 16px 24px; margin-top: 20px; }
.field { display: grid; gap: 6px; }
.field label, fieldset legend { font-weight: 600; font-size: 15px; }
.select, .input {
  min-height: 40px; padding: 0 12px; border: 1px solid var(--rule-strong); border-radius: 4px;
  background: var(--paper); color: var(--ink); font: 400 16px/24px var(--font);
}
.input { min-width: 280px; }
fieldset { border: 0; margin: 0; padding: 0; }
.checks { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-top: 8px; }
.checks label { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 16px; cursor: pointer; }
.checks input { width: 18px; height: 18px; accent-color: var(--stamp); }
.checks-group { margin-top: 12px; }
.checks-group > span { display: block; font-size: 15px; color: var(--ink-2); }
.count { color: var(--ink-2); font-size: 15px; margin-top: 16px; }
.button-primary { background: var(--ink); color: var(--paper); border-color: var(--ink); min-height: 40px; padding: 0 16px; }
.button-primary:hover { background: var(--ink); opacity: 0.92; }
.button-primary:disabled { opacity: 0.4; cursor: not-allowed; }

/* Compare */
.compare table { min-width: 720px; }
.compare td, .compare th { width: auto; }
.compare tbody th { width: 200px; color: var(--ink-2); font-weight: 600; }
@media (max-width: 719px) { .facts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; } }

/* ---------- Motion (Emil's animate skill; decisions in .interface-design/system.md) ----------
   Animated: popover (grows from its trigger), mobile menu, press feedback.
   Instant on purpose: page changes, theme, "Full text" expansion, tables and charts. */
:root { --ease-out: cubic-bezier(0.23, 1, 0.32, 1); --dur-press: 160ms; --dur-popover: 200ms; }
.button, .theme-toggle, .menu-button, .fn {
  transition: transform var(--dur-press) var(--ease-out), background-color 120ms ease;
}
.button:active, .theme-toggle:active, .menu-button:active { transform: scale(0.97); }
.popover { transition: opacity var(--dur-popover) var(--ease-out), transform var(--dur-popover) var(--ease-out); }
@starting-style { .popover { opacity: 0; transform: scale(0.97); } }
@media (max-width: 719px) {
  .topbar[data-open="true"] .topnav { transition: opacity var(--dur-popover) var(--ease-out), transform var(--dur-popover) var(--ease-out); }
  @starting-style { .topbar[data-open="true"] .topnav { opacity: 0; transform: translateY(-6px); } }
}
@media (prefers-reduced-motion: reduce) {
  .button:active, .theme-toggle:active, .menu-button:active { transform: none; }
  @starting-style { .popover { transform: none; } }
  @starting-style { .topbar[data-open="true"] .topnav { transform: none; } }
}

/* ---------- Decision pages (v3 "question first") ---------- */
.question-lead { font-size: 19px; line-height: 30px; max-width: 66ch; margin-top: 16px; color: var(--ink-2); }
.takeaways { margin: 20px 0 0; padding: 0; list-style: none; max-width: 76ch; display: grid; gap: 14px; }
.takeaways li { position: relative; padding-left: 28px; font-size: 18px; line-height: 28px; }
.takeaways li::before { content: ""; position: absolute; left: 4px; top: 11px; width: 8px; height: 8px; border-radius: 2px; background: var(--stamp); }
.grid-table td { white-space: nowrap; }
.grid-table td.wrap { white-space: normal; min-width: 180px; max-width: 260px; }
.cell-value { font-weight: 600; font-variant-numeric: tabular-nums; }
.minibar { display: block; width: 96px; height: 6px; margin-top: 6px; background: var(--band); border-radius: 0 3px 3px 0; }
.minibar > i { display: block; height: 6px; background: var(--ink-2); border-radius: 0 3px 3px 0; }
td.num .minibar { margin-left: auto; }
.analysis { margin-top: 20px; padding: 20px 24px; background: var(--band); border-left: 3px solid var(--stamp); border-radius: 0 8px 8px 0; max-width: 860px; }
.analysis-label { font-size: 15px; line-height: 24px; font-weight: 700; color: var(--stamp); }
.analysis-note { margin-top: 12px; max-width: var(--measure); }
.analysis-note + .analysis-note { padding-top: 12px; border-top: 1px solid var(--rule); }
.analysis-note h3 { margin: 0 0 4px; font-size: 18px; line-height: 26px; }
.analysis-basis { display: block; margin-top: 6px; font-size: 15px; line-height: 24px; color: var(--ink-2); }
.gaps { margin: 16px 0 0; padding-left: 20px; max-width: var(--measure); }
.gaps li + li { margin-top: 8px; }
/* Overview: the five questions */
.questions { list-style: none; margin: 32px 0 0; padding: 0; display: grid; gap: 0; border-top: 1px solid var(--rule); max-width: 900px; }
.questions li { border-bottom: 1px solid var(--rule); }
.q-link { display: grid; grid-template-columns: 48px minmax(0, 1fr); gap: 16px; padding: 20px 0; color: var(--ink); text-decoration: none; }
.q-link:hover .q-title { color: var(--stamp); text-decoration: underline; text-underline-offset: 4px; }
.q-num { font-size: 28px; line-height: 36px; font-weight: 700; color: var(--stamp); font-variant-numeric: tabular-nums; }
.q-title { display: block; font-size: 24px; line-height: 32px; font-weight: 700; }
.q-answer { display: block; margin-top: 4px; color: var(--ink-2); max-width: 70ch; }
/* Presence grid (Who would we face?) */
.presence table { font-size: 14px; line-height: 20px; min-width: 980px; }
.presence th.region-head { text-align: left; color: var(--ink); border-bottom: 1px solid var(--ink); padding-bottom: 6px; }
.presence th.mhead { white-space: normal; font-size: 14px; line-height: 18px; vertical-align: bottom; min-width: 0; width: 56px; padding-right: 6px; }
.presence tbody th { white-space: normal; min-width: 120px; }
.presence td.pcell { padding: 10px 6px 10px 0; color: var(--ink-2); white-space: nowrap; }
.presence td.p-live { font-weight: 700; color: var(--ink); }
.presence td.p-live::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 2px; background: var(--ink); vertical-align: 1px; }
.presence td.p-partner { color: var(--ink); }
.presence td.p-planned { font-style: italic; }
