/* Commonwealth Atlas - site styles. Mobile first. */
:root {
  --navy: #0B1226;
  --violet: #5F32D2;
  --violet-hover: #4A24A8;
  --violet-start: #8658ED;
  --gradient: linear-gradient(135deg, #8658ED, #5F32D2);
  --pale: #F5F2FE;
  --border: #E4DDF8;
  --border-strong: #CFC4F1;
  --accent-dark: #C6B4FA;
  --text-2: #3A3F52;
  --line-dark: #4A5068;
  --white: #FFFFFF;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --radius: 12px;
  --wrap: 1120px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
body {
  margin: 0;
  background: var(--white);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}
img, video, svg { max-width: 100%; }
a { color: var(--violet); }
a:hover { color: var(--violet-hover); }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; line-height: 1.15; }
p { margin: 0; }

:focus-visible { outline: 3px solid var(--violet); outline-offset: 3px; border-radius: 4px; }
.band-dark :focus-visible { outline-color: var(--accent-dark); }

.skip-link {
  position: absolute; left: 16px; top: -60px; z-index: 100;
  background: var(--navy); color: var(--white); padding: 12px 16px; border-radius: 8px;
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { top: 12px; color: var(--white); }

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

.wrap { max-width: var(--wrap); margin: 0 auto; padding-left: 16px; padding-right: 16px; }
@media (min-width: 640px) { .wrap { padding-left: 24px; padding-right: 24px; } }

/* Header */
.site-header .wrap {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 24px; padding-top: 16px;
}
.brand { display: inline-flex; align-items: center; min-height: 44px; }
.brand img { display: block; height: 36px; width: auto; }
.site-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0 20px; }
.site-nav a {
  display: inline-flex; align-items: center; min-height: 44px;
  color: var(--navy); text-decoration: none; font-size: 15px; font-weight: 500;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--violet); }
.site-nav a[aria-current="page"] { color: var(--violet); border-bottom-color: var(--violet); }
@media (min-width: 640px) { .site-header .wrap { padding-top: 24px; } .brand img { height: 40px; } .site-nav ul { gap: 0 24px; } }

/* Common type */
.eyebrow { font-size: 14px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--violet); }
.label { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-2); }
.lede { font-size: 18px; color: var(--text-2); max-width: 760px; }
.muted { color: var(--text-2); }
.small { font-size: 14px; }
.h1 { font-size: 40px; line-height: 1.08; }
.h2 { font-size: 28px; }
.h2-sm { font-size: 26px; }
@media (min-width: 640px) {
  .h1 { font-size: 56px; }
  .h1-sm { font-size: 48px; }
  .h2 { font-size: 36px; }
  .h2-sm { font-size: 30px; }
  .lede { font-size: 19px; }
}

.section { padding-top: 48px; padding-bottom: 48px; }
@media (min-width: 640px) { .section { padding-top: 64px; padding-bottom: 64px; } }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 28px; }
.band-pale { background: var(--pale); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.band-rule { border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.band-dark { background: var(--navy); color: var(--white); }
.band-dark h2 { color: var(--white); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 12px 22px; border-radius: 8px;
  font-family: inherit; font-size: 16px; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 2px solid transparent; line-height: 1.2;
}
.btn-primary { background-color: var(--violet); background-image: var(--gradient); color: var(--white); }
.btn-primary:hover { color: var(--white); background-image: none; background-color: var(--violet-hover); }
.btn-gold { background: #F3D98B; color: var(--navy); border-color: #F3D98B; }
.btn-gold:hover { background: #EBCB6A; border-color: #EBCB6A; color: var(--navy); }
.btn-outline { background: transparent; color: var(--navy); border-color: var(--navy); }
.btn-outline:hover { color: var(--violet); border-color: var(--violet); }
.btn-row { display: flex; flex-wrap: wrap; gap: 12px; }
.pill-link {
  display: inline-flex; align-items: center; gap: 10px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 999px; padding: 8px 18px;
  text-decoration: none; color: var(--navy); font-weight: 600; font-size: 15px; background: var(--white);
}
.pill-link:hover { border-color: var(--violet); color: var(--violet); }
.pill-link svg { flex: none; }

/* Grids and cards */
.grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 960px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.card { background: var(--white); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.card-pale { background: var(--pale); border-color: transparent; }
@media (min-width: 640px) { .card-lg { padding: 32px; } }
.card-title { font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.25; }
@media (min-width: 640px) { .card-title-lg { font-size: 26px; } }
.card-dark { background: var(--navy); border: 1px solid var(--line-dark); border-radius: var(--radius); padding: 28px; display: flex; flex-direction: column; gap: 10px; color: var(--white); }
.card-dark .tag { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--accent-dark); }
.card-dark .card-title { color: var(--white); }
.card-dark .post-date, .post-list .post-date { font-size: 14px; color: var(--accent-dark); }
a.card-link { text-decoration: none; }
a.card-link:hover { border-color: var(--accent-dark); color: var(--white); }
a.card-link:hover .card-title { text-decoration: underline; }
.more-h { font-size: 22px; color: var(--white); margin-top: 8px; }
.post-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line-dark); }
.post-list li { border-bottom: 1px solid var(--line-dark); }
.post-list a { display: flex; flex-direction: column; gap: 2px; padding: 14px 0; color: var(--white); text-decoration: none; }
@media (min-width: 640px) { .post-list a { flex-direction: row; justify-content: space-between; align-items: baseline; gap: 24px; } .post-list .post-date { flex: none; } }
.post-list a:hover .post-title { text-decoration: underline; }
.post-title { font-weight: 500; }
.btn-light { background: var(--white); color: var(--navy); }
.btn-light:hover { background: var(--accent-dark); color: var(--navy); }

/* Home hero */
.hero { display: grid; gap: 32px; padding-top: 40px; padding-bottom: 40px; align-items: center; }
@media (min-width: 860px) { .hero { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 48px; padding-top: 72px; padding-bottom: 64px; } }
.hero-copy { display: flex; flex-direction: column; gap: 20px; }

/* Country search (combobox) */
.finder { position: relative; display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 380px; }
.finder label { font-size: 14px; font-weight: 600; color: var(--text-2); }
.input, .finder input, .form input[type="text"], .form input[type="email"], .form textarea {
  font-family: inherit; font-size: 16px; padding: 13px 16px; min-height: 50px;
  border: 2px solid var(--navy); border-radius: 8px; background: var(--white); color: var(--navy); width: 100%;
}
.input:focus-visible, .finder input:focus-visible, .form input:focus-visible, .form textarea:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; border-color: var(--violet); }
.finder-list {
  position: absolute; top: 100%; left: 0; right: 0; z-index: 20; margin: 6px 0 0; padding: 6px; list-style: none;
  background: var(--white); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(11, 18, 38, 0.14); max-height: 300px; overflow-y: auto;
}
.finder-list[hidden] { display: none; }
.finder-list li { padding: 11px 12px; border-radius: 6px; cursor: pointer; font-size: 16px; }
.finder-list li[aria-selected="true"], .finder-list li:hover { background: var(--pale); color: var(--violet); }
.finder-list .finder-empty { cursor: default; color: var(--text-2); }
.finder-list .finder-empty:hover { background: none; color: var(--text-2); }

/* Map band */
.map-scroll { overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; border-radius: 8px; }
.map-inner { position: relative; width: 100%; min-width: 720px; line-height: 0; padding: 12px 0; }
@media (min-width: 760px) { .map-inner { min-width: 0; padding: 0; } }
.map-box { position: relative; }
.map-box img { width: 100%; height: auto; display: block; }
.map-lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.node {
  position: absolute; width: 15px; height: 15px; border-radius: 50%;
  background: var(--flag); border: 2px solid var(--white);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 1px rgba(11, 18, 38, 0.3);
  transition: box-shadow 0.15s, width 0.15s, height 0.15s;
}
.node:hover, .node:focus-visible { width: 20px; height: 20px; z-index: 5; box-shadow: 0 0 0 2px var(--navy); outline: none; }
.node::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  white-space: pre; text-align: left; background: var(--navy); color: var(--white);
  font: 600 13px/1.45 var(--sans); padding: 7px 9px; border-radius: 6px;
  display: none; pointer-events: none; z-index: 6;
}
.node.tip-left::after { left: auto; right: -6px; transform: none; }
.node.tip-right::after { left: -6px; transform: none; }
.node.tip-below::after { bottom: auto; top: calc(100% + 8px); }
.node:hover::after, .node:focus-visible::after { display: block; }
/* Trade lines: default lines show; the extra top-5 lines appear on hover or focus */
.map-lines .tl { stroke-opacity: 0.55; transition: stroke-opacity 0.15s; }
.map-lines .tl-extra { stroke-opacity: 0; }
.map-lines.is-focus .tl { stroke-opacity: 0.12; }
.map-lines.is-focus .tl-extra { stroke-opacity: 0; }
.map-lines.is-focus .tl.on { stroke-opacity: 0.95; stroke: #5F32D2; stroke-width: 2.4; }
.map-info { margin-top: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 8px; background: var(--pale); min-height: 56px; }
.map-info h3 { font-size: 16px; margin: 0 0 6px; }
.map-info ol { margin: 0; padding-left: 20px; font-size: 15px; line-height: 1.5; }
/* Map line in the ocean below southern Africa. It scales with the map (15px when the map is
   at its widest, 1072px). Where it would drop below 12px (map under 857px wide, including phones,
   where the map is 720px and scrolls) it moves to a caption directly under the map instead.
   Its place (55% across, 86% down) is clear of every node and trade line. */
#map { container: mapsec / inline-size; }
.map-box { container-type: inline-size; }
.map-tagline { position: absolute; left: 55%; top: 86.2%; transform: translate(-50%, -50%); margin: 0; white-space: nowrap;
  font-size: max(12px, 1.4cqw); line-height: 1.3; font-weight: 400; color: var(--violet); pointer-events: none; }
.map-caption { display: none; margin: 10px 0 0; font-size: 15px; line-height: 1.4; font-weight: 400; color: var(--violet); text-align: center; }
@container mapsec (max-width: 856px) { .map-tagline { display: none; } .map-caption { display: block; } }
.map-hint { display: block; }
@media (min-width: 760px) { .map-hint { display: none; } }

/* Video */
.video-frame { width: 100%; max-width: 880px; border-radius: var(--radius); overflow: hidden; box-shadow: 0 0 0 1px var(--border); background: var(--navy); }
.video-frame video { display: block; width: 100%; height: auto; aspect-ratio: 16 / 9; background: var(--navy); }
/* Portrait video (home page welcome video, 1080x1350): narrower frame, 4:5 shape, centred */
.video-frame.video-portrait { max-width: 480px; margin-left: auto; margin-right: auto; }
.video-frame.video-portrait video { aspect-ratio: 4 / 5; }
.center { text-align: center; align-items: center; }

/* Region directory */
.region-card h3 { font-size: 22px; }
.region-card ul { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; }
.region-card li a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 4px 0; text-decoration: none; color: var(--navy); font-size: 15px; }
.region-card li a:hover { color: var(--violet); text-decoration: underline; }
.swatch { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--flag); box-shadow: 0 0 0 1px rgba(11, 18, 38, 0.3); }
.count { font-size: 14px; color: var(--text-2); }

/* Country pages */
.country-hero { padding-top: 40px; padding-bottom: 32px; }
@media (min-width: 640px) { .country-hero { padding-top: 56px; padding-bottom: 40px; } }
.badge { display: inline-block; font-size: 14px; font-weight: 600; padding: 8px 14px; border-radius: 999px; background-color: var(--violet); background-image: var(--gradient); color: var(--white); }
.fact-value { font-family: var(--serif); font-weight: 600; font-size: 22px; line-height: 1.25; }
@media (min-width: 640px) { .fact-value { font-size: 24px; } }
.trade-side { padding: 4px 0; display: flex; flex-direction: column; gap: 10px; }
.trade-figure { font-family: var(--serif); font-weight: 600; font-size: 28px; line-height: 1.2; }
@media (min-width: 640px) { .trade-figure { font-size: 32px; } }
.trade-h4 { margin: 8px 0 0; font-size: 15px; }
.trade-list { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 4px; font-size: 15px; line-height: 1.45; }
.trade-note { font-size: 15px; padding: 12px 14px; border-left: 3px solid var(--violet); background: var(--pale); border-radius: 0 6px 6px 0; max-width: 860px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.trade-table { border-collapse: collapse; width: 100%; max-width: 760px; font-size: 15px; }
.trade-table th, .trade-table td { text-align: left; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
.trade-table thead th { font-size: 13px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-2); }
.trade-table tbody th { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  font-family: inherit; font-size: 15px; font-weight: 600; padding: 10px 18px; min-height: 44px;
  border-radius: 999px; border: 2px solid var(--violet); cursor: pointer; background: var(--white); color: var(--violet);
}
.chip[aria-pressed="true"] { background: var(--violet); color: var(--white); }
.story { display: flex; flex-direction: column; gap: 6px; padding: 20px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); text-decoration: none; color: var(--navy); }
@media (min-width: 640px) { .story { padding: 20px 24px; } }
.story:hover { border-color: var(--violet); color: var(--navy); }
.story .tag { font-size: 13px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--violet); }
.story .headline { font-family: var(--serif); font-weight: 600; font-size: 20px; line-height: 1.3; }
.story[hidden] { display: none; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }

/* Forms */
.form { display: grid; gap: 16px; max-width: 760px; }
@media (min-width: 640px) { .form-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .form-2 .full { grid-column: 1 / -1; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .field > .field-label { font-size: 14px; font-weight: 600; }
.band-dark .field > label { color: var(--white); }
.band-dark .form input[type="text"], .band-dark .form input[type="email"] { border-color: var(--white); }
.form textarea { resize: vertical; min-height: 150px; }
.check { display: flex; gap: 12px; align-items: flex-start; font-size: 15px; }
.check input { flex: none; width: 22px; height: 22px; margin: 2px 0 0; accent-color: var(--violet); }
.band-dark .check a { color: var(--accent-dark); }
.band-dark .check a:hover { color: var(--white); }
.hidden-field { display: none; }
.req { color: inherit; font-weight: 400; }

/* Join: opportunity list */
.opps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .opps { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 960px) { .opps { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.opps li { display: flex; align-items: center; gap: 14px; background: var(--white); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; font-weight: 500; }
.opps li::before { content: ""; flex: 0 0 22px; width: 22px; height: 22px; border: 2px solid var(--violet); border-radius: 5px; }

/* Insights panels */
.panel { border: 1px solid var(--border); border-radius: var(--radius); background: var(--white); overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.panel-head { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 12px; align-items: baseline; }
.panel-head h3 { font-size: 20px; }
.panel-body { padding: 8px 20px 16px; }
.news-list { list-style: none; margin: 0; padding: 0; }
.news-list li { border-bottom: 1px solid var(--border); }
.news-list li:last-child { border-bottom: 0; }
.news-list a { display: flex; flex-direction: column; gap: 4px; padding: 14px 0; text-decoration: none; color: var(--navy); }
.news-list a:hover .news-title { color: var(--violet); text-decoration: underline; }
.news-title { font-weight: 600; font-size: 16px; line-height: 1.4; }
.news-date { font-size: 13px; color: var(--text-2); }
.news-summary { font-size: 15px; color: var(--text-2); }
.panel-note { padding: 16px 0; color: var(--text-2); font-size: 15px; }
.tv-box { min-height: 400px; }
/* Blocks that load after the page appears keep a fixed height, so nothing below them jumps */
.wto-box { height: 480px; overflow-y: auto; overscroll-behavior: contain; }
.wto-box:focus-visible { outline: 3px solid var(--violet); outline-offset: -3px; }
.x-box { height: 560px; overflow: hidden; }
.x-box > a.twitter-timeline { display: inline-block; padding: 8px 0; }
/* Ask the Atlas: the main feature at the top of the Insights page */
.ask-feature { padding-bottom: 56px; }
.ask-card { max-width: 880px; background: var(--pale); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px 20px; gap: 16px; }
@media (min-width: 640px) { .ask-card { padding: 36px 40px; } }
.ask-intro { font-size: 18px; color: var(--text-2); max-width: 720px; }
.ask-form { display: flex; flex-direction: column; gap: 14px; }
.ask-label { font-weight: 600; font-size: 17px; color: var(--navy); }
.ask-input { width: 100%; min-height: 128px; font-size: 19px; line-height: 1.5; resize: vertical; border-color: var(--border-strong); background: var(--white); color: var(--navy); }
.ask-input:disabled { color: var(--text-2); cursor: not-allowed; }
.btn-lg { min-height: 54px; padding: 14px 28px; font-size: 18px; }
.btn[disabled] { opacity: 0.6; cursor: wait; }
.ask-out:empty { display: none; }
.ask-answer { background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 20px 22px; display: flex; flex-direction: column; gap: 12px; }
.ask-q { font-weight: 600; font-size: 17px; color: var(--text-2); }
.ask-a { font-size: 19px; line-height: 1.65; color: var(--navy); }
.ask-list { margin: 0; padding-left: 22px; font-size: 19px; line-height: 1.55; color: var(--navy); display: flex; flex-direction: column; gap: 6px; }
.ask-sources ul { margin: 4px 0 0; padding-left: 20px; font-size: 16px; }
.ask-error { font-size: 17px; color: var(--navy); border-left: 3px solid var(--violet); padding-left: 12px; }
.ask-closed { font-size: 17px; color: var(--navy); background: var(--white); border: 1px solid var(--border); border-left: 4px solid var(--violet); border-radius: 8px; padding: 14px 16px; }
.btn-navy { background: var(--navy); color: var(--white); border-color: var(--navy); }
.btn-navy:hover { background: #1E2A4A; border-color: #1E2A4A; color: var(--white); }

/* Ask Amara page: the question box at the top, and an answer area with a fixed height
   reserved from the start, so nothing moves when an answer appears (no footer below) */
.amara-page { max-width: 880px; padding-top: 16px; padding-bottom: 24px; }
@media (min-width: 640px) { .amara-page { padding-top: 24px; } }
.amara-page .ask-card { margin: 0 auto; }
.ask-out-fixed, .ask-out-fixed:empty { display: block; height: clamp(320px, 50vh, 560px); overflow-y: auto; overscroll-behavior: contain;
  background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 20px 22px; }
.ask-out-fixed:focus-visible { outline: 3px solid var(--violet); outline-offset: 2px; }
.ask-out-fixed .ask-answer { border: 0; padding: 0; background: none; }

/* Prose (privacy) */
.prose { max-width: 720px; display: flex; flex-direction: column; gap: 14px; }
.prose h2 { font-size: 24px; margin-top: 20px; }
.prose ul { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); }
.site-footer .wrap { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; padding-top: 32px; padding-bottom: 40px; font-size: 14px; color: var(--text-2); }
.site-footer img { display: block; height: 32px; width: auto; }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 18px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; color: var(--navy); }
.footer-links a.icon { min-width: 44px; justify-content: center; }
.footer-links a.icon:hover { color: var(--violet); }
