/* ==========================================================================
   World Oil — shared design system
   One stylesheet for index.html and dashboard.html: fonts, colors, layout,
   nav, ticker, stat tiles, globe, chart cards, filters, table, and motion.
   Colors are role tokens; pages and page JS never hard-code hex.
   Default look: dark "energy terminal". <html data-theme="light"> opts into light.
   Fonts are loaded in each page's <head> (Inter + JetBrains Mono, Google Fonts).
   ========================================================================== */

/* ---------- Tokens: dark (default) ---------- */
:root {
  color-scheme: dark;

  /* type */
  --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
  --fs-xs: 0.75rem;
  --fs-sm: 0.875rem;
  --fs-md: 1rem;
  --fs-lg: 1.2rem;
  --fs-xl: clamp(1.4rem, 2.6vw, 1.85rem);
  --fs-hero: clamp(2.4rem, 7vw, 4.75rem);

  /* surfaces & ink */
  --page: #0b0c0e;
  --page-glow: rgba(245, 158, 11, 0.07);
  --surface: #15171a;
  --surface-2: #1d2024;
  --ink: #f4f3ef;
  --ink-2: #c3c2b7;
  --ink-muted: #8b8a84;
  --grid: #2a2c2f;
  --axis: #3a3c40;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 8px 24px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 1px 0 rgba(255, 255, 255, 0.05) inset, 0 14px 36px rgba(0, 0, 0, 0.5);
  --nav-bg: rgba(11, 12, 14, 0.78);

  /* UI accent: crude amber (interactive chrome only — never a data series) */
  --accent: #f5a524;
  --accent-ink: #1a1204;
  --accent-wash: rgba(245, 165, 36, 0.14);
  --accent-glow: rgba(245, 165, 36, 0.35);

  /* categorical series — validated order; never re-order, never cycle past 8 */
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #008300;
  --series-7: #9085e9;
  --series-8: #e66767;
  --series-other: #6f6e69;

  /* sequential (globe shading, heat): one hue, dim → bright on dark */
  --seq-0: #2a1a0e;
  --seq-1: #5a2d10;
  --seq-2: #8f4214;
  --seq-3: #c65a1c;
  --seq-4: #ec7a2e;
  --seq-5: #f8a95c;
  --seq-6: #ffd7a8;

  /* delta text */
  --up: #2fbf5b;
  --down: #f06a6a;

  /* spacing & shape */
  --gutter: clamp(16px, 4vw, 40px);
  --maxw: 1200px;
  --nav-h: 56px;
  --ticker-h: 46px;
  --radius: 14px;
  --radius-sm: 8px;

  /* motion */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --dur-fast: 150ms;
  --dur: 300ms;
  --dur-slow: 700ms;
}

/* ---------- Tokens: light (opt-in) ---------- */
:root[data-theme="light"] {
  color-scheme: light;
  --page: #f6f5f1;
  --page-glow: rgba(245, 158, 11, 0.10);
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --ink-muted: #7a7973;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --border-strong: rgba(11, 11, 11, 0.20);
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.05);
  --shadow-hover: 0 2px 4px rgba(11, 11, 11, 0.06), 0 12px 32px rgba(11, 11, 11, 0.10);
  --nav-bg: rgba(14, 14, 13, 0.88);
  --accent: #c47a00;
  --accent-ink: #ffffff;
  --accent-wash: rgba(196, 122, 0, 0.12);
  --accent-glow: rgba(196, 122, 0, 0.25);
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --series-4: #eda100;
  --series-5: #e87ba4;
  --series-6: #008300;
  --series-7: #4a3aa7;
  --series-8: #e34948;
  --series-other: #a3a29c;
  --seq-0: #fdf0e3;
  --seq-1: #fbd7b4;
  --seq-2: #f6b57f;
  --seq-3: #ec8a47;
  --seq-4: #d2651f;
  --seq-5: #a04812;
  --seq-6: #6b2e0a;
  --up: #006300;
  --down: #d03b3b;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: calc(var(--nav-h) + 16px); }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 85% -10%, var(--page-glow), transparent 70%),
    var(--page);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, h4 { line-height: 1.15; margin: 0 0 0.5em; letter-spacing: -0.02em; font-weight: 650; }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-md); font-weight: 600; letter-spacing: -0.01em; }
p { margin: 0 0 1em; max-width: 70ch; }
a { color: var(--accent); text-underline-offset: 3px; }
code, kbd { font-family: var(--font-mono); font-size: 0.9em; }
img, svg, canvas { max-width: 100%; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
::selection { background: var(--accent); color: var(--accent-ink); }

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.muted { color: var(--ink-muted); }
.eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent); margin: 0 0 0.6rem;
}
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Page sections are direct children of <main> or <body>; center them. */
main > section, body > section, main > div.chart-grid, main > div.switches, main > .table-wrap, main > #mini-globe {
  width: 100%; max-width: var(--maxw); margin-left: auto; margin-right: auto;
  padding-left: var(--gutter); padding-right: var(--gutter);
}

/* ---------- Scroll progress bar (injected by theme.js) ---------- */
.progress {
  position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 70;
  background: linear-gradient(90deg, var(--series-2), var(--accent));
  box-shadow: 0 0 10px var(--accent-glow);
  transform-origin: 0 50%; transform: scaleX(var(--progress, 0));
  pointer-events: none;
}

/* ---------- Nav (shared) ---------- */
nav.topnav {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 1.5rem;
  min-height: var(--nav-h); padding: 0 max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter)));
  background: var(--nav-bg);
  backdrop-filter: saturate(1.5) blur(12px);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  transition: box-shadow var(--dur) var(--ease-out), background var(--dur) ease;
}
nav.topnav.is-scrolled { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); }
nav.topnav .brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: #f4f3ef; text-decoration: none; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap;
}
/* a drop of crude: the brand glyph — works with or without an inline SVG */
nav.topnav .brand::before {
  content: ""; width: 14px; height: 14px; flex: none;
  border-radius: 50% 0 50% 50%; transform: rotate(-45deg);
  background: linear-gradient(135deg, var(--accent), var(--series-2));
  box-shadow: 0 0 12px var(--accent-glow);
}
nav.topnav .nav-links { display: flex; gap: 0.25rem; margin-left: auto; list-style: none; padding: 0; margin-block: 0; }
nav.topnav .nav-links a {
  position: relative; display: block; padding: 0.4rem 0.8rem;
  color: #c3c2b7; text-decoration: none; font-size: var(--fs-sm); font-weight: 500;
  border-radius: 6px; transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}
nav.topnav .nav-links a:hover { color: #fff; background: rgba(255, 255, 255, 0.06); }
nav.topnav .nav-links a::after {
  content: ""; position: absolute; left: 0.8rem; right: 0.8rem; bottom: 0.1rem; height: 2px;
  background: currentColor; border-radius: 2px;
  transform: scaleX(0); transform-origin: 0 50%; transition: transform var(--dur) var(--ease-out);
}
nav.topnav .nav-links a:hover::after { transform: scaleX(1); }
nav.topnav .nav-links a.active, nav.topnav .nav-links a[aria-current="page"] { color: #fff; }
nav.topnav .nav-links a.active::after, nav.topnav .nav-links a[aria-current="page"]::after {
  transform: scaleX(1); background: var(--accent); box-shadow: 0 0 8px var(--accent-glow);
}
@media (max-width: 560px) {
  nav.topnav { gap: 0.5rem; }
  nav.topnav .nav-links a { padding: 0.4rem 0.55rem; }
}

/* ---------- Ticker tape (TradingView iframe lives inside) ---------- */
.ticker, #ticker-tape {
  min-height: var(--ticker-h); overflow: hidden;
  background: var(--surface); border-bottom: 1px solid var(--border);
  /* soft fade at both edges so the scrolling tape eases in/out */
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 4%, #000 96%, transparent);
}
.ticker iframe, #ticker-tape iframe { display: block; border: 0; }

/* ---------- Hero ---------- */
header.hero {
  position: relative; overflow: hidden; isolation: isolate;
  /* same left edge as the nav and the centered sections */
  padding: clamp(3.5rem, 10vw, 7rem) max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter))) clamp(4rem, 8vw, 6rem);
  border-bottom: 1px solid var(--border);
}
header.hero h1 {
  font-size: var(--fs-hero); font-weight: 750; letter-spacing: -0.035em; line-height: 1.02;
  max-width: 15ch; margin-bottom: 1rem;
  background: linear-gradient(180deg, var(--ink) 30%, color-mix(in srgb, var(--ink) 65%, var(--accent)));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
header.hero .byline { font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-muted); margin-bottom: 1.5rem; }
header.hero .summary { font-size: var(--fs-lg); color: var(--ink-2); max-width: 62ch; }
/* slow-drifting oil-slick sheen */
header.hero::before {
  content: ""; position: absolute; inset: -40% -25%; z-index: -1;
  background:
    radial-gradient(38% 48% at 18% 30%, rgba(57, 135, 229, 0.20), transparent 70%),
    radial-gradient(34% 44% at 82% 58%, rgba(217, 89, 38, 0.20), transparent 70%),
    radial-gradient(30% 40% at 55% 18%, rgba(245, 165, 36, 0.14), transparent 70%),
    radial-gradient(28% 36% at 40% 85%, rgba(144, 133, 233, 0.12), transparent 70%);
  filter: blur(8px);
  animation: sheen 30s var(--ease-in-out) infinite alternate;
}
/* faint terminal grid over the sheen */
header.hero::after {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 48px 48px;
  opacity: 0.35;
  -webkit-mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
          mask-image: radial-gradient(ellipse at 50% 0%, #000 20%, transparent 75%);
}
@keyframes sheen {
  from { transform: translate3d(-4%, -2%, 0) rotate(0deg) scale(1); }
  to   { transform: translate3d(4%, 3%, 0) rotate(10deg) scale(1.08); }
}
/* hero lines rise in sequence on load */
header.hero h1, header.hero .byline, header.hero .summary, header.hero .eyebrow {
  opacity: 0; transform: translateY(16px);
  animation: rise var(--dur-slow) var(--ease-out) forwards;
}
header.hero .eyebrow { animation-delay: 40ms; }
header.hero h1 { animation-delay: 120ms; }
header.hero .byline { animation-delay: 260ms; }
header.hero .summary { animation-delay: 380ms; }
@keyframes rise { to { opacity: 1; transform: none; } }

/* ---------- Stat tiles (headline numbers) ---------- */
section.stats {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  padding-top: 1.75rem; padding-bottom: 1.75rem;
}
header.hero + section.stats, header.hero + main > section.stats:first-child { margin-top: -3.25rem; position: relative; z-index: 2; }
.stat {
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 0.35rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.15rem 1.25rem 1.2rem;
  transition: transform var(--dur) var(--ease-out), box-shadow var(--dur) var(--ease-out), border-color var(--dur) ease;
}
/* thin accent rule along the top edge that lights on hover */
.stat::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--series-2));
  transform: scaleX(0.18); transform-origin: 0 50%; opacity: 0.7;
  transition: transform var(--dur-slow) var(--ease-out), opacity var(--dur) ease;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.stat:hover::before { transform: scaleX(1); opacity: 1; }
/* markup order is value then label; label reads first visually */
.stat-label { order: -1; font-size: var(--fs-sm); color: var(--ink-2); font-weight: 500; }
.stat-value {
  font-size: clamp(1.75rem, 3.2vw, 2.35rem); font-weight: 700; letter-spacing: -0.03em; line-height: 1.05;
  color: var(--ink);
}
.stat-note { font-size: var(--fs-xs); color: var(--ink-muted); }
.delta { font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 600; }
.delta.up { color: var(--up); }
.delta.down { color: var(--down); }
/* value flash when a dashboard filter changes a number */
.stat-value.is-changed { animation: flash 900ms var(--ease-out); }
@keyframes flash { 0% { color: var(--accent); text-shadow: 0 0 18px var(--accent-glow); } 100% { color: var(--ink); text-shadow: none; } }

/* ---------- Globe (report) ---------- */
section.globe-section {
  display: grid; gap: 1.25rem; grid-template-columns: minmax(0, 1fr);
  padding-top: clamp(2rem, 5vw, 3.5rem); padding-bottom: clamp(2rem, 5vw, 3.5rem);
}
@media (min-width: 960px) { section.globe-section { grid-template-columns: minmax(0, 8fr) minmax(0, 4fr); } }
#globe, #mini-globe {
  position: relative; border-radius: var(--radius); overflow: hidden; min-width: 0;
  background: radial-gradient(circle at 50% 45%, #13161b 0%, #07080a 70%);
  border: 1px solid var(--border);
  cursor: grab;
}
#globe { height: clamp(360px, 60vw, 580px); }
#mini-globe { height: 340px; }
#globe:active, #mini-globe:active { cursor: grabbing; }
#globe canvas, #mini-globe canvas { display: block; }
aside.globe-panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.25rem; min-width: 0;
  display: flex; flex-direction: column; gap: 0.75rem;
  max-height: clamp(360px, 60vw, 580px); overflow: auto;
}
aside.globe-panel h3, aside.globe-panel h2 { font-size: var(--fs-lg); margin: 0; }
/* panel content swaps with a quick fade when a new country is clicked */
aside.globe-panel.is-swapping > * { opacity: 0; transform: translateY(6px); }
aside.globe-panel > * { transition: opacity var(--dur) var(--ease-out), transform var(--dur) var(--ease-out); }
ul.news { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.5rem; }
ul.news li {
  border-left: 2px solid var(--axis); padding: 0.3rem 0 0.3rem 0.75rem; font-size: var(--fs-sm);
  transition: border-color var(--dur-fast) ease, background var(--dur-fast) ease;
}
ul.news li:hover { border-left-color: var(--accent); background: var(--accent-wash); }
ul.news a { color: var(--ink); text-decoration: none; }
ul.news a:hover { text-decoration: underline; }
ul.news time, ul.news .source { display: block; font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--ink-muted); }
/* globe hover label (globe.gl renders it as HTML) */
.globe-tip {
  font-family: var(--font-sans); font-size: var(--fs-sm); color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0.45rem 0.65rem; box-shadow: var(--shadow);
}
.globe-tip b { display: block; font-weight: 600; }
.globe-legend { display: flex; align-items: center; gap: 0.5rem; font-size: var(--fs-xs); color: var(--ink-muted); }
.globe-legend .ramp {
  flex: 1; height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--seq-0), var(--seq-1), var(--seq-2), var(--seq-3), var(--seq-4), var(--seq-5), var(--seq-6));
}

/* ---------- Report: finding sections ---------- */
section.finding {
  display: grid; gap: 1rem 2.5rem; grid-template-columns: minmax(0, 1fr); align-items: start;
  padding-top: clamp(2.5rem, 6vw, 4.5rem); padding-bottom: clamp(2.5rem, 6vw, 4.5rem);
  border-top: 1px solid var(--border);
  counter-increment: finding;
}
main { counter-reset: finding; }
@media (min-width: 960px) {
  section.finding { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  section.finding > h2, section.finding > p, section.finding > .eyebrow { grid-column: 1; }
  section.finding > .chart-card { grid-column: 2; grid-row: 1 / span 6; }
  /* alternate sides so the page has rhythm */
  section.finding:nth-of-type(even) { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); }
  section.finding:nth-of-type(even) > h2,
  section.finding:nth-of-type(even) > p,
  section.finding:nth-of-type(even) > .eyebrow { grid-column: 2; }
  section.finding:nth-of-type(even) > .chart-card { grid-column: 1; }
}
section.finding > h2::before {
  content: "Finding " counter(finding, decimal-leading-zero);
  display: block; margin-bottom: 0.6rem;
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
section.finding > p { color: var(--ink-2); }
section.finding > p:first-of-type { font-size: var(--fs-lg); color: var(--ink); }

/* ---------- Chart cards ---------- */
.chart-card {
  position: relative; min-width: 0;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 1.1rem 1.25rem 1rem;
  transition: box-shadow var(--dur) var(--ease-out), border-color var(--dur) ease, opacity var(--dur) ease;
}
.chart-card:hover { box-shadow: var(--shadow-hover); border-color: var(--border-strong); }
.chart-card > h3 { margin: 0 0 0.2rem; }
.chart-card .chart-sub { font-size: var(--fs-sm); color: var(--ink-muted); margin: 0 0 0.75rem; }
/* theme.js wraps each canvas in .chart-box; the box includes the axis band */
.chart-box { position: relative; width: 100%; height: 320px; }
.chart-card.tall .chart-box { height: 420px; }
.chart-card.short .chart-box { height: 240px; }
@media (max-width: 600px) { .chart-box, .chart-card.tall .chart-box { height: 280px; } }
.chart-source { font-size: var(--fs-xs); color: var(--ink-muted); margin: 0.6rem 0 0; }
/* dashboard re-render: hold the old frame dimmed — never a skeleton flash */
.chart-card.is-updating { opacity: 0.55; }

/* HTML legend (theme.js renders it; identity never rides on color alone) */
.legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; list-style: none; padding: 0; margin: 0 0 0.6rem; font-size: var(--fs-sm); color: var(--ink-2); }
.legend li { display: inline-flex; align-items: center; gap: 0.4rem; cursor: pointer; user-select: none; transition: opacity var(--dur-fast) ease; }
.legend li.off { opacity: 0.4; }
.legend li.off span:last-child { text-decoration: line-through; }
.legend .swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend .swatch.line { height: 3px; width: 14px; border-radius: 2px; }

/* ---------- TradingView chart container ---------- */
section.stocks { padding-top: clamp(2.5rem, 6vw, 4.5rem); padding-bottom: clamp(2.5rem, 6vw, 4.5rem); border-top: 1px solid var(--border); }
#tv-chart {
  height: clamp(380px, 55vw, 520px); border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow);
}
#tv-chart iframe { display: block; border: 0; }

/* ---------- Dashboard ---------- */
aside.filters {
  position: sticky; top: var(--nav-h); z-index: 50;
  display: flex; flex-wrap: wrap; align-items: end; gap: 0.75rem 1rem;
  width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0.9rem var(--gutter);
  background: color-mix(in srgb, var(--page) 86%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
label.filter, .switches label {
  display: flex; flex-direction: column; gap: 0.3rem; min-width: 150px; flex: 1 1 150px;
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted);
}
select, input[type="text"], input[type="search"], input[type="number"], input[type="month"], input[type="date"] {
  font: inherit; font-family: var(--font-sans); font-size: var(--fs-sm); letter-spacing: 0; text-transform: none;
  color: var(--ink); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem; min-height: 38px; width: 100%;
  transition: border-color var(--dur-fast) ease, box-shadow var(--dur-fast) ease;
}
select[multiple] { min-height: 38px; padding: 0.25rem; }
select:hover, input:hover { border-color: var(--axis); }
select:focus, input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

button#reset, .btn {
  font: inherit; font-size: var(--fs-sm); font-weight: 600; cursor: pointer;
  border-radius: var(--radius-sm); padding: 0.5rem 1rem; min-height: 38px; flex: none;
  border: 1px solid var(--accent); background: transparent; color: var(--accent);
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease, transform var(--dur-fast) ease, box-shadow var(--dur) ease;
}
button#reset:hover, .btn:hover { background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 18px var(--accent-glow); }
button#reset:active, .btn:active { transform: scale(0.96); }
button#reset.is-resetting { animation: pulse 600ms var(--ease-out); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-glow); } 100% { box-shadow: 0 0 0 14px transparent; } }

div.switches {
  display: flex; flex-wrap: wrap; gap: 0.75rem 1rem; align-items: end;
  padding-top: 0.5rem; padding-bottom: 0.5rem;
}
div.switches label { flex: 0 1 240px; }

div.chart-grid {
  display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr);
  padding-top: 1rem; padding-bottom: 1.5rem;
}
@media (min-width: 900px) {
  div.chart-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  div.chart-grid > .span-2 { grid-column: 1 / -1; }
}

/* ---------- Data table ---------- */
.table-wrap {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: auto; max-height: 540px; margin-top: 1rem; margin-bottom: 2rem;
}
table.data-table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
table.data-table th, table.data-table td { padding: 0.55rem 0.9rem; text-align: left; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.data-table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2);
  font-family: var(--font-mono); font-size: var(--fs-xs); font-weight: 500;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted);
}
table.data-table td.num, table.data-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.data-table tbody tr { transition: background var(--dur-fast) ease; }
table.data-table tbody tr:hover { background: var(--accent-wash); }
/* new rows fade in after a filter change */
table.data-table tbody.is-fresh tr { animation: rowIn 380ms var(--ease-out) both; }
@keyframes rowIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- Methods & footer ---------- */
section.methods {
  padding-top: clamp(2.5rem, 6vw, 4rem); padding-bottom: clamp(2.5rem, 6vw, 4rem);
  border-top: 1px solid var(--border);
}
section.methods p, section.methods li { color: var(--ink-2); font-size: var(--fs-sm); }
section.methods dl { display: grid; gap: 0.25rem 1.5rem; grid-template-columns: minmax(0, 1fr); }
@media (min-width: 700px) { section.methods dl { grid-template-columns: 200px minmax(0, 1fr); } }
section.methods dt { font-weight: 600; font-size: var(--fs-sm); }
section.methods dd { margin: 0 0 0.75rem; color: var(--ink-2); font-size: var(--fs-sm); }
footer.site-footer {
  padding: 2rem max(var(--gutter), calc((100% - var(--maxw)) / 2 + var(--gutter))) 3rem;
  font-size: var(--fs-sm); color: var(--ink-muted); border-top: 1px solid var(--border);
}

/* ---------- Globe panel controls (mode switch, year slider, play) ---------- */
[hidden] { display: none !important; }
.globe-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 0.75rem; }
.seg .btn {
  border: 0; background: transparent; color: var(--ink-2); min-height: 30px;
  padding: 0.3rem 0.85rem; border-radius: 999px; font-size: var(--fs-xs); box-shadow: none;
}
.seg .btn:hover { background: var(--accent-wash); color: var(--ink); box-shadow: none; }
.seg .btn[aria-pressed="true"], .seg .btn[aria-pressed="true"]:hover {
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 0 14px var(--accent-glow);
}
label.year-slider {
  display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 0.1rem 0.6rem; flex: 1 1 100%;
  font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-muted);
}
label.year-slider output {
  justify-self: end; font-size: var(--fs-md); font-weight: 600; letter-spacing: 0; color: var(--ink);
  font-variant-numeric: tabular-nums;
}
label.year-slider input[type="range"] { grid-column: 1 / -1; }
/* range track + thumb in the accent, both engines */
input[type="range"] { -webkit-appearance: none; appearance: none; height: 22px; background: transparent; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--accent) var(--fill, 100%), var(--grid) var(--fill, 100%)); }
input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--grid); }
input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; margin-top: -6px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface); box-shadow: 0 0 10px var(--accent-glow);
  transition: transform var(--dur-fast) ease;
}
input[type="range"]::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%; background: var(--accent);
  border: 2px solid var(--surface); box-shadow: 0 0 10px var(--accent-glow);
}
input[type="range"]:hover::-webkit-slider-thumb, input[type="range"]:focus-visible::-webkit-slider-thumb { transform: scale(1.2); }
button#g-play { font-size: var(--fs-xs); min-height: 30px; padding: 0.3rem 0.8rem; }
button#g-play[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); animation: playing 1.6s ease-in-out infinite; }
@keyframes playing { 0%, 100% { box-shadow: 0 0 0 0 var(--accent-glow); } 50% { box-shadow: 0 0 0 6px transparent; } }

/* trade key: swatch before each label, colors match the globe columns */
.globe-legend.trade-key { flex-wrap: wrap; gap: 0.35rem 1rem; }
.trade-key .key-exports, .trade-key .key-imports { display: inline-flex; align-items: center; gap: 0.4rem; color: var(--ink-2); font-weight: 500; }
.trade-key .key-exports::before, .trade-key .key-imports::before {
  content: ""; width: 6px; height: 14px; border-radius: 2px 2px 0 0; flex: none;
}
.trade-key .key-exports::before { background: var(--accent); }
.trade-key .key-imports::before { background: var(--series-1); }
.trade-key .muted { flex: 1 1 100%; }
aside.globe-panel .chart-box.short { height: 180px; }

/* ---------- About ---------- */
section.about {
  padding-top: clamp(2.5rem, 6vw, 4.5rem); padding-bottom: clamp(2.5rem, 6vw, 4.5rem);
  border-top: 1px solid var(--border);
}
section.about > p { color: var(--ink-2); font-size: var(--fs-lg); max-width: 64ch; }
section.about > p.eyebrow { color: var(--accent); font-size: var(--fs-xs); }
section.about > p.muted {
  font-family: var(--font-mono); font-size: var(--fs-sm); color: var(--ink-muted);
  padding-left: 0.9rem; border-left: 2px solid var(--accent);
}

/* ---------- Dashboard: copy link (secondary to Reset) ---------- */
button#copy-link { border-color: var(--border-strong); color: var(--ink-2); }
button#copy-link:hover { background: var(--surface-2); color: var(--ink); border-color: var(--axis); box-shadow: none; }
button#copy-link.is-copied { border-color: var(--up); color: var(--up); animation: pulse 600ms var(--ease-out); }

/* ---------- Scroll reveal ----------
   theme.js adds .js-reveal to <html> and data-reveal to targets, so content
   is never hidden if scripts fail. */
.js-reveal [data-reveal] {
  opacity: 0; transform: translateY(28px);
  transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
  transition-delay: var(--reveal-delay, 0ms);
}
.js-reveal [data-reveal="scale"] { transform: scale(0.965); }
.js-reveal [data-reveal].is-visible { opacity: 1; transform: none; }

/* ---------- Reduced motion: keep every state change, drop the travel ---------- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important;
    transition-duration: 1ms !important; transition-delay: 0ms !important;
  }
  header.hero::before { animation: none; }
  .js-reveal [data-reveal] { opacity: 1; transform: none; }
  .stat:hover { transform: none; }
}

/* ---------- Forced colors / print ---------- */
@media (forced-colors: active) {
  .stat, .chart-card, .table-wrap, aside.globe-panel { border: 1px solid CanvasText; }
  header.hero h1 { color: CanvasText; background: none; }
}
@media print {
  nav.topnav, aside.filters, .progress, .ticker, #ticker-tape, header.hero::before, header.hero::after { display: none !important; }
  .js-reveal [data-reveal] { opacity: 1; transform: none; }
}
