/* ===== Tokens (validated palette — see dataviz skill references/palette.md) ===== */
.viz-root {
  color-scheme: light;
  --surface-1:      #ffffff;
  --page-plane:     #f2f3f5;
  --text-primary:   #0a1628;
  --text-secondary: #47536b;
  --text-muted:     #8b93a3;
  --gridline:       #e6e8ec;
  --axis:           #c7cbd6;
  --border:         rgba(10,22,40,0.12);
  --accent:         #a9832f;
  --accent-strong:  #7c611f;
  --accent-wash:    rgba(169,131,47,0.10);

  /* categorical, fixed order: US, UK, Germany, Japan, Australia */
  --series-1: #2a78d6; /* US */
  --series-2: #eb6834; /* UK */
  --series-3: #1baf7a; /* Germany */
  --series-4: #eda100; /* Japan */
  --series-5: #e87ba4; /* Australia */
}
@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) .viz-root {
    color-scheme: dark;
    --surface-1:      #0d1420;
    --page-plane:     #060a12;
    --text-primary:   #f2f4f7;
    --text-secondary: #9aa7bb;
    --text-muted:     #647089;
    --gridline:       #1b2536;
    --axis:           #2c3850;
    --border:         rgba(255,255,255,0.10);
    --accent:         #c9a227;
    --accent-strong:  #e0b62e;
    --accent-wash:    rgba(201,162,39,0.12);
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --series-4: #c98500;
    --series-5: #d55181;
  }
}
:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --surface-1:      #0d1420;
  --page-plane:     #060a12;
  --text-primary:   #f2f4f7;
  --text-secondary: #9aa7bb;
  --text-muted:     #647089;
  --gridline:       #1b2536;
  --axis:           #2c3850;
  --border:         rgba(255,255,255,0.10);
  --accent:         #c9a227;
  --accent-strong:  #e0b62e;
  --accent-wash:    rgba(201,162,39,0.12);
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  background: var(--page-plane);
  color: var(--text-primary);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15.5px;
  line-height: 1.6;
}

a { color: inherit; }
button, select, input { font-family: inherit; }

.serif { font-family: 'Source Serif 4', Georgia, 'Times New Roman', serif; }

/* ===== Header ===== */
.site-header {
  background: var(--surface-1);
  border-bottom: 1px solid var(--border);
  border-top: 3px solid var(--accent);
}
.header-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 24px; height: 24px; color: var(--accent); display: flex; }
.brand-mark svg { width: 100%; height: 100%; }
.brand-text {
  font-family: 'Source Serif 4', Georgia, serif;
  font-weight: 600;
  font-size: 1.2rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.theme-toggle {
  width: 34px; height: 34px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.theme-toggle:hover { background: var(--accent-wash); color: var(--accent); border-color: var(--accent); }
.theme-toggle svg { width: 17px; height: 17px; }
.icon-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .icon-sun { display: none; }
  :root:not([data-theme="light"]) .icon-moon { display: block; }
}
:root[data-theme="dark"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: block; }
:root[data-theme="light"] .icon-sun { display: block; }
:root[data-theme="light"] .icon-moon { display: none; }

/* ===== Layout ===== */
.container { max-width: 1120px; margin: 0 auto; padding: 44px 28px 64px; }

.error-banner {
  background: #fdecea;
  border: 1px solid #e34948;
  color: #7a1414;
  border-radius: 2px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 0.86rem;
}
.error-banner strong { display: block; margin-bottom: 6px; }
.error-banner ul { margin: 0; padding-left: 20px; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .error-banner { background: #2a1414; border-color: #e66767; color: #ffb4b4; }
}
:root[data-theme="dark"] .error-banner { background: #2a1414; border-color: #e66767; color: #ffb4b4; }

.page-intro { margin-bottom: 32px; padding-bottom: 24px; border-bottom: 1px solid var(--border); }
.page-intro .kicker {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin-bottom: 10px;
}
.page-intro h1 {
  font-family: 'Source Serif 4', Georgia, serif;
  font-size: clamp(1.7rem, 3.5vw, 2.3rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 10px;
  color: var(--text-primary);
}
.page-intro p { color: var(--text-secondary); max-width: 620px; font-size: 0.96rem; }

/* ===== Controls row ===== */
.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.country-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px 8px 11px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, opacity 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--axis); }
.chip .swatch { width: 8px; height: 8px; border-radius: 50%; background: var(--dot-color, currentColor); flex-shrink: 0; }
.chip.is-off { opacity: 0.4; }
.chip.is-off .swatch { background: var(--text-muted); }
.chip.is-on { color: var(--text-primary); border-color: var(--text-primary); }

.view-toggle { display: flex; border: 1px solid var(--border); border-radius: 2px; overflow: hidden; }
.btn-toggle {
  padding: 8px 18px;
  background: var(--surface-1);
  border: none;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-toggle + .btn-toggle { border-left: 1px solid var(--border); }
.btn-toggle.is-active { background: var(--text-primary); color: var(--surface-1); }
:root[data-theme="dark"] .btn-toggle.is-active { background: var(--accent); color: #0a0e14; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-toggle.is-active { background: var(--accent); color: #0a0e14; }
}

/* ===== Card ===== */
.card {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 2px;
  padding: 26px 28px;
  margin-bottom: 16px;
}

/* ===== Chart ===== */
.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.chart-legend { display: flex; gap: 18px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: 0.76rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }
.legend-item .swatch-line { width: 14px; height: 2px; }
.legend-item.is-off { opacity: 0.35; }

.chart-date {
  font-size: 0.82rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.chart-date::before {
  content: 'As of';
  font-weight: 500;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: normal;
  margin-right: 6px;
}

.chart-wrap { position: relative; }
#curve-svg { width: 100%; height: auto; display: block; }

.axis-label { fill: var(--text-muted); font-size: 10.5px; font-family: 'Inter', sans-serif; font-variant-numeric: tabular-nums; }
.grid-line { stroke: var(--gridline); stroke-width: 1; }
.baseline { stroke: var(--axis); stroke-width: 1; }
.curve-line { fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; transition: opacity 0.15s; }
.curve-dot { stroke: var(--surface-1); stroke-width: 2; transition: opacity 0.15s; }
.curve-hit { fill: transparent; cursor: pointer; }
.end-label { font-size: 10.5px; font-weight: 700; letter-spacing: 0.02em; font-family: 'Inter', sans-serif; }

/* Series color classes — deliberately real stylesheet rules (not inline SVG
   presentation attributes) so var() resolution is guaranteed cross-browser.
   Dots intentionally get fill only here — stroke stays the surface-color
   ring from the base .curve-dot rule above (mark spec), never overridden. */
.curve-line.s1 { stroke: var(--series-1); fill: none; }
.curve-line.s2 { stroke: var(--series-2); fill: none; }
.curve-line.s3 { stroke: var(--series-3); fill: none; }
.curve-line.s4 { stroke: var(--series-4); fill: none; }
.curve-line.s5 { stroke: var(--series-5); fill: none; }
.curve-dot.s1, .end-label.s1 { fill: var(--series-1); }
.curve-dot.s2, .end-label.s2 { fill: var(--series-2); }
.curve-dot.s3, .end-label.s3 { fill: var(--series-3); }
.curve-dot.s4, .end-label.s4 { fill: var(--series-4); }
.curve-dot.s5, .end-label.s5 { fill: var(--series-5); }

.crosshair-line { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 3 3; pointer-events: none; }

.tooltip {
  position: absolute;
  top: 0; left: 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-top: 2px solid var(--accent);
  border-radius: 2px;
  padding: 11px 13px;
  box-shadow: 0 10px 28px -10px rgba(10,22,40,0.35);
  pointer-events: none;
  min-width: 155px;
  z-index: 10;
}
.tooltip-maturity { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 7px; }
.tooltip-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; font-size: 0.84rem; padding: 2px 0; }
.tooltip-row .key { display: flex; align-items: center; gap: 6px; color: var(--text-secondary); font-weight: 600; }
.tooltip-row .key .line-key { width: 11px; height: 2px; }
.tooltip-row .val { font-weight: 700; color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }
#data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
#data-table th, #data-table td { text-align: right; padding: 11px 12px; border-bottom: 1px solid var(--gridline); font-variant-numeric: tabular-nums; }
#data-table thead th { border-bottom: 1.5px solid var(--text-primary); }
#data-table th:first-child, #data-table td:first-child { text-align: left; font-variant-numeric: normal; }
#data-table th { color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; }
#data-table td:first-child { display: flex; align-items: center; gap: 8px; font-weight: 600; color: var(--text-primary); }
#data-table .swatch { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
#data-table tbody tr:hover { background: var(--accent-wash); }

/* ===== Scrubber ===== */
.scrubber-controls { display: flex; align-items: center; gap: 16px; }
.btn-play {
  width: 38px; height: 38px;
  border-radius: 2px;
  border: 1px solid var(--text-primary);
  background: var(--text-primary);
  color: var(--surface-1);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.btn-play:hover { opacity: 0.85; }
.btn-play svg { width: 16px; height: 16px; }
:root[data-theme="dark"] .btn-play { background: var(--accent); border-color: var(--accent); color: #0a0e14; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .btn-play { background: var(--accent); border-color: var(--accent); color: #0a0e14; }
}

#date-slider {
  flex: 1;
  appearance: none;
  height: 2px;
  border-radius: 0;
  background: var(--axis);
  outline: none;
}
#date-slider::-webkit-slider-thumb {
  appearance: none;
  width: 3px; height: 18px;
  border-radius: 0;
  background: var(--accent);
  cursor: pointer;
}
#date-slider::-moz-range-thumb {
  width: 3px; height: 18px;
  border-radius: 0;
  border: none;
  background: var(--accent);
  cursor: pointer;
}

#speed-select {
  padding: 8px 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
  background: var(--surface-1);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.scrubber-range { display: flex; justify-content: space-between; margin-top: 12px; font-size: 0.74rem; color: var(--text-muted); font-variant-numeric: tabular-nums; text-transform: uppercase; letter-spacing: 0.04em; }

/* ===== Disclaimer / footer ===== */
.disclaimer { font-size: 0.78rem; color: var(--text-muted); max-width: 720px; margin-top: 10px; line-height: 1.7; }

.site-footer { border-top: 1px solid var(--border); background: var(--surface-1); }
.footer-inner { max-width: 1120px; margin: 0 auto; padding: 26px 28px; display: flex; flex-direction: column; gap: 8px; }
.footer-sources { font-size: 0.76rem; color: var(--text-muted); line-height: 1.7; }
.footer-parent { font-size: 0.78rem; color: var(--text-secondary); }
.footer-parent a { color: var(--accent); font-weight: 600; text-decoration: none; }
.footer-parent a:hover { text-decoration: underline; }
.footer-copy { font-size: 0.74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .controls-row { flex-direction: column; align-items: stretch; }
  .card { padding: 18px; }
  .chart-date { order: -1; }
}
