/* YieldCurveUS — clean, professional, ad-free. Themeable (Dark / Light / Code). */

/* ---- Structural / non-themed vars ---- */
:root {
  --radius: 14px;
  --radius-sm: 8px;
  --maxw: 1080px;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, system-ui, sans-serif;
  --font: var(--sans);
}

/* ---- DARK (default) ---- */
:root,
:root[data-theme="dark"] {
  --bg: #0a0e1a;
  --surface: #111827;
  --surface-2: #0d1424;
  --ink: #f8fafc;
  --ink-soft: #cbd5e1;
  --ink-faint: #8b98ad;
  --border: #1e2638;
  --border-strong: #2d3a52;
  --accent: #38bdf8;          /* sky-400 */
  --accent-deep: #0ea5e9;
  --green: #34d399;
  --red: #fb7185;
  --amber: #fbbf24;
  --header-bg: rgba(10, 14, 26, 0.88);
  --green-soft: rgba(52, 211, 153, 0.14);
  --red-soft: rgba(251, 113, 133, 0.14);
  --accent-soft: rgba(56, 189, 248, 0.15);
  --accent-area: rgba(56, 189, 248, 0.08);
  --grid: #1e2638;
  --tooltip-bg: #0d1424;
  --tooltip-border: #1e2638;
  --markline: #64748b;
  --chart-line-1: #38bdf8;     /* sky */
  --chart-line-2: #fbbf24;     /* amber */
  --chart-line-3: #34d399;     /* emerald */
  --chart-line-4: #e879f9;     /* fuchsia */
  --chart-line-5: #fb7185;     /* rose-400 */
  --font: var(--sans);
}

/* ---- LIGHT ---- */
:root[data-theme="light"] {
  --bg: #ffffff;
  --surface: #f8fafc;
  --surface-2: #f1f5f9;
  --ink: #0f172a;
  --ink-soft: #475569;
  --ink-faint: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --accent: #0ea5e9;           /* sky-500 */
  --accent-deep: #0284c7;
  --green: #059669;
  --red: #dc2626;
  --amber: #d97706;
  --header-bg: rgba(255, 255, 255, 0.92);
  --green-soft: rgba(5, 150, 105, 0.14);
  --red-soft: rgba(220, 38, 38, 0.12);
  --accent-soft: rgba(14, 165, 233, 0.14);
  --accent-area: rgba(14, 165, 233, 0.10);
  --grid: #e2e8f0;
  --tooltip-bg: #ffffff;
  --tooltip-border: #e2e8f0;
  --markline: #94a3b8;
  --chart-line-1: #0891b2;     /* cyan-600 */
  --chart-line-2: #d97706;     /* amber-600 */
  --chart-line-3: #059669;     /* emerald-600 */
  --chart-line-4: #c026d3;     /* fuchsia-600 */
  --chart-line-5: #e11d48;     /* rose-600 */
  --font: var(--sans);
}

/* ---- CODE (Monokai-inspired developer palette) ---- */
:root[data-theme="code"] {
  --bg: #272822;               /* Monokai background */
  --surface: #1e1f1c;
  --surface-2: #2d2e28;
  --ink: #f8f8f2;              /* Monokai foreground */
  --ink-soft: #cfcfc2;
  --ink-faint: #75715e;        /* Monokai comments */
  --border: #3e3f3a;
  --border-strong: #5b5b50;
  --accent: #a6e22e;           /* Monokai green */
  --accent-deep: #66d9ef;      /* Monokai blue */
  --green: #a6e22e;
  --red: #f92672;              /* Monokai pink/red */
  --amber: #fd971f;            /* Monokai orange */
  --header-bg: rgba(39, 40, 34, 0.92);
  --green-soft: rgba(166, 226, 46, 0.14);
  --red-soft: rgba(249, 38, 114, 0.14);
  --accent-soft: rgba(166, 226, 46, 0.16);
  --accent-area: rgba(166, 226, 46, 0.08);
  --grid: #3e3f3a;
  --tooltip-bg: #1e1f1c;
  --tooltip-border: #3e3f3a;
  --markline: #75715e;
  --chart-line-1: #66d9ef;     /* Monokai blue */
  --chart-line-2: #fd971f;     /* Monokai orange */
  --chart-line-3: #a6e22e;     /* Monokai green */
  --chart-line-4: #ae81ff;     /* Monokai purple */
  --chart-line-5: #f92672;     /* Monokai pink */
  --font: var(--mono);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { background: var(--bg); color: var(--ink); font-family: var(--font); line-height: 1.6; -webkit-font-smoothing: antialiased; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 14px clamp(16px, 4vw, 44px); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--header-bg); backdrop-filter: blur(10px); z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.brand-mark { display: grid; place-items: center; width: 32px; height: 32px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 9px; color: var(--accent); }
.brand-mark svg path { stroke: var(--accent); }
.brand-word { font-weight: 800; font-size: 19px; letter-spacing: -0.3px; }
.brand-us { color: var(--accent); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs a { color: var(--ink-faint); text-decoration: none; font-size: 14px; font-weight: 500; padding: 8px 14px; border-radius: 999px; transition: color .15s, background .15s; white-space: nowrap; }
.tabs a:hover { color: var(--ink); background: var(--surface); }
.tabs a.active { color: var(--ink); background: var(--surface); box-shadow: inset 0 0 0 1px var(--border-strong); }

/* On narrow viewports (≤ 760px) the 10-tab nav stops wrapping and switches to
   horizontal scroll with momentum — gives a clean single-row strip that's
   thumb-swipe friendly. Visual cue: a faint right-edge gradient hints at
   "more". Touch devices keep native scrollbar; desktop fades it. */
@media (max-width: 760px) {
  .tabs {
    flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch;
    scrollbar-width: thin; scroll-snap-type: x proximity;
    /* Hide visible scrollbar on desktop while keeping scroll functional. */
    scrollbar-color: var(--border-strong) transparent;
    /* Soft right-edge fade hints at overflow content. */
    mask-image: linear-gradient(to right, black 0, black calc(100% - 18px), transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 0, black calc(100% - 18px), transparent 100%);
    padding-right: 4px;
  }
  .tabs a { scroll-snap-align: start; font-size: 13px; padding: 7px 12px; }
  .tabs::-webkit-scrollbar { height: 4px; }
  .tabs::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
}

/* Theme switcher */
.theme-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--ink-soft); font-family: inherit;
  font-size: 13px; font-weight: 600;
  padding: 6px 12px; border-radius: 999px; cursor: pointer;
  transition: color .15s, background .15s, border-color .15s, transform .12s;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--accent); }
.theme-toggle:active { transform: scale(0.97); }
.theme-toggle .theme-icon { font-size: 14px; line-height: 1; }
.theme-toggle .theme-name { letter-spacing: 0.2px; }

/* Layout */
.app { max-width: var(--maxw); margin: 0 auto; padding: clamp(20px, 4vw, 44px); min-height: 62vh; }
.site-footer { max-width: var(--maxw); margin: 48px auto 0; padding: 24px clamp(16px,4vw,44px); border-top: 1px solid var(--border); color: var(--ink-faint); font-size: 13px; display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; }

.view-head { margin-bottom: 18px; }
.view-head h1 { font-size: clamp(26px, 4.5vw, 38px); margin: 0 0 8px; letter-spacing: -0.6px; }
.view-head p { color: var(--ink-soft); font-size: 16px; margin: 0; max-width: 64ch; }

/* Chart shell */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.chart { width: 100%; height: 440px; }
.chart-sm { width: 100%; height: 300px; }

/* Curve controls */
.curve-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.spread-badge { font-family: var(--mono); font-size: 15px; font-weight: 600; padding: 6px 14px; border-radius: 999px; }
.spread-badge.green { background: var(--green-soft); color: var(--green); }
.spread-badge.red { background: var(--red-soft); color: var(--red); }
.asof { color: var(--ink-faint); font-size: 13px; font-family: var(--mono); }
/* Quick views (preset selectors) — sits between the curve scrubber and the chart.
   Lets a user pin common time spans (last quarter / year / 4 quarters) or jump
   to a curated historical moment with one click. Themed via theme vars so it
   matches Dark / Light / Code without overrides. */
.quick-views { margin: 14px 0 6px; padding: 14px 0 0; border-top: 1px dashed var(--border); }
.quick-views-title { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--ink-faint); margin: 0 0 10px; }
.preset-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.preset-row:last-child { margin-bottom: 0; }
.preset-row-event { gap: 10px; }
.preset-row-label { font-size: 12px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; flex: none; }
.preset-btn {
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--ink-soft);
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 10px 14px; min-height: 44px; border-radius: var(--radius-sm);
  cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.preset-btn:hover { color: var(--ink); border-color: var(--accent); background: var(--surface); }
.preset-btn:active { transform: scale(0.98); }
.preset-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.preset-select {
  flex: 1; min-width: 220px; min-height: 44px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--ink);
  font-family: inherit; font-size: 13px;
  padding: 8px 36px 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8' fill='none' stroke='%238b98ad' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'><path d='M1.5 1.75 L6 6.25 L10.5 1.75'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 12px 8px;
  transition: color .15s, border-color .15s, background-color .15s;
}
.preset-select:hover { border-color: var(--accent); }
.preset-select:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.preset-select option { background: var(--surface); color: var(--ink); }

@media (max-width: 560px) {
  .preset-row-time { gap: 6px; }
  .preset-row-time .preset-btn { flex: 1 1 calc(50% - 3px); min-width: 0; }
  .preset-row-event { flex-direction: column; align-items: stretch; }
  .preset-row-event .preset-row-label { margin-bottom: 2px; }
  .preset-select { width: 100%; min-width: 0; }
}

.curves-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.curve-row { display: flex; align-items: center; gap: 10px; }
.curve-swatch { width: 12px; height: 12px; border-radius: 3px; flex: none; }
.curve-label { font-family: var(--mono); font-size: 13px; min-width: 130px; color: var(--ink-soft); }
.curve-slider { flex: 1; min-width: 160px; accent-color: var(--accent); }
.curve-remove { background: none; border: none; color: var(--ink-faint); font-size: 18px; cursor: pointer; line-height: 1; padding: 0 4px; }
.curve-remove:hover { color: var(--red); }
.btn-add { margin-top: 12px; background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--accent); font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; }
.btn-add:hover { border-color: var(--accent); }
.btn-add:disabled { opacity: .5; cursor: default; }

/* Prose / learn / upcoming */
.prose { max-width: 70ch; }
.prose h2 { font-size: 20px; margin: 28px 0 8px; }
.prose p { color: var(--ink-soft); }
.prose .analogy { margin: 14px 0; padding: 14px 18px; border-left: 3px solid var(--accent); background: var(--surface-2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; color: var(--ink-soft); }
.callout { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; margin: 16px 0; }

/* FOMC list */
.fomc-list { list-style: none; padding: 0; margin: 16px 0; }
.fomc-item { display: flex; align-items: center; gap: 14px; padding: 12px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: 8px; background: var(--surface); }
.fomc-item.next { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.fomc-date { font-family: var(--mono); font-weight: 600; min-width: 150px; }
.fomc-tag { font-size: 11px; padding: 2px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.fomc-note { color: var(--ink-faint); font-size: 13.5px; }

.ticker { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 8px 0 20px; }
.tick { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.tick .k { font-size: 12px; color: var(--ink-faint); }
.tick .v { font-family: var(--mono); font-size: 18px; font-weight: 600; margin-top: 2px; }
.tick .v.red { color: var(--red); } .tick .v.green { color: var(--green); }

/* ---- Chart header row (chart title + CSV export buttons) ----
   Sits directly above every chart container so the export affordance is
   discoverable but doesn't compete with the chart visual. Wraps on narrow
   screens — title falls onto its own line, buttons stay grouped. */
.chart-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin: 8px 0 6px;
}
.chart-title { color: var(--ink-faint); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.6px; }
.csv-group { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.csv-btn {
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--ink-soft);
  font-family: inherit; font-size: 12px; font-weight: 500;
  padding: 6px 10px; border-radius: var(--radius-sm); cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
  transition: color .15s, border-color .15s, background .15s;
}
.csv-btn:hover { color: var(--ink); border-color: var(--accent); background: var(--surface); }
.csv-btn:active { transform: scale(0.97); }
.csv-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.csv-btn .csv-icon { font-size: 13px; line-height: 1; }

/* ---- Source attribution caption (under every chart) ----
   Small, --ink-faint so it themes correctly without competing with chart ink. */
.source-caption { color: var(--ink-faint); font-size: 12px; margin-top: 8px; line-height: 1.5; }
.source-caption a { color: var(--ink-faint); text-decoration: underline; text-decoration-color: var(--border-strong); }
.source-caption a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ---- Sources block (bottom of every tab) ---- */
.sources-block { margin-top: 28px; padding-top: 16px; border-top: 1px dashed var(--border); }
.sources-block h3 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px; color: var(--ink-faint); margin: 0 0 10px; }
.sources-block ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.sources-block li { color: var(--ink-faint); font-size: 13px; }
.sources-block a { color: var(--ink-soft); text-decoration: underline; text-decoration-color: var(--border-strong); }
.sources-block a:hover { color: var(--accent); text-decoration-color: var(--accent); }

/* ---- Big-number readout (Fed Funds latest value, etc.) ---- */
.big-number {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 12px; margin-bottom: 14px;
}
.big-value { font-family: var(--mono); font-size: clamp(32px, 6vw, 44px); font-weight: 700; color: var(--ink); letter-spacing: -1px; }
.big-context { color: var(--ink-faint); font-size: 14px; }
.mock-tag {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.8px;
  padding: 3px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-soft);
}

/* ---- Release selector (dot plot tab) ---- */
.release-controls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 8px 0 14px; }
.release-controls label { font-size: 12px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.release-controls .preset-select { flex: 1; min-width: 200px; max-width: 360px; }
.release-help { color: var(--ink-faint); font-size: 12px; line-height: 1.5; max-width: 60ch; }

/* ---- Big-number secondary metrics ----
   Used by mortgage / swap / LIBOR tabs where the headline is one figure (e.g.
   30-yr fixed) and 1-3 supplementary figures sit beside it. Each pill carries a
   label-on-top, value-below pattern so it reads as a unit. */
.big-secondary { display: flex; gap: 16px; flex-wrap: wrap; margin-left: 6px; }
.big-secondary .pill { display: flex; flex-direction: column; gap: 1px; }
.big-secondary .pill-label { font-size: 11px; color: var(--ink-faint); font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.big-secondary .pill-value { font-family: var(--mono); font-size: 18px; font-weight: 600; color: var(--ink-soft); letter-spacing: -0.5px; }

/* ---- Series toggle chips ----
   Multi-select toggle row used for picking which series render on charts that
   carry several lines (mortgages, swaps, LIBOR, deposit rates). Each chip has
   an off and on state, with a color swatch inheriting the series color. */
.toggle-chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--ink-faint);
  font-family: inherit; font-size: 13px; font-weight: 500;
  padding: 7px 12px; border-radius: 999px; cursor: pointer;
  transition: color .15s, border-color .15s, background .15s, opacity .15s;
  user-select: none;
}
.chip:hover { color: var(--ink); border-color: var(--accent); }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chip .chip-dot { width: 10px; height: 10px; border-radius: 3px; background: currentColor; flex: none; }
.chip.off { opacity: 0.5; background: transparent; }
.chip.off .chip-dot { opacity: 0.45; }
.chip.on { color: var(--ink); background: var(--surface); }

/* ---- Section header (e.g., savings tab has Deposit + Personal sections) ---- */
.section-head { margin: 28px 0 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.section-head:first-of-type { margin-top: 6px; padding-top: 0; border-top: none; }
.section-head h2 { font-size: 19px; margin: 0 0 4px; color: var(--ink); letter-spacing: -0.3px; }
.section-head p { color: var(--ink-soft); font-size: 14px; margin: 0; max-width: 64ch; }

/* ---- Discontinued-data banner (LIBOR tab) ---- */
.discontinued-banner {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px;
  padding: 3px 9px; border-radius: 999px;
  background: var(--red-soft); color: var(--red); border: 1px solid var(--red-soft);
  margin-left: 6px;
}

/* ---- Reference Rates tab: mode toggle + chips + base-rate dropdown ----
   Mode toggle is a segmented control [Levels | Spreads]. The spread base
   dropdown only renders when spreads mode is active. */
.refrates-mode-row {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  margin: 4px 0 12px;
}
.mode-toggle {
  display: inline-flex; background: var(--surface-2); border: 1px solid var(--border-strong);
  border-radius: 999px; padding: 3px;
}
.mode-btn {
  background: transparent; border: none; color: var(--ink-faint);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 6px 16px; border-radius: 999px; cursor: pointer;
  transition: color .15s, background .15s;
}
.mode-btn:hover { color: var(--ink); }
.mode-btn.active { background: var(--accent-soft); color: var(--accent); }
.mode-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.spread-base-wrap { display: inline-flex; align-items: center; gap: 8px; }
.spread-base-wrap label {
  font-size: 12px; color: var(--ink-faint); font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.4px;
}
.spread-base-wrap .preset-select { flex: none; min-width: 180px; max-width: 260px; }

/* Reference Rates chip strip — mostly inherits .toggle-chips / .chip styles. */
.refrates-chips-wrap { margin: 4px 0 12px; }
.refrates-chips-toggle {
  display: none;
  background: var(--surface-2); border: 1px solid var(--border-strong); color: var(--ink-soft);
  font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 8px 14px; border-radius: var(--radius-sm); cursor: pointer;
  width: 100%; text-align: left;
}
.refrates-chips-toggle:hover { color: var(--ink); border-color: var(--accent); }
.refrates-chips-toggle::after { content: " ▾"; color: var(--ink-faint); }
.refrates-chips-toggle[aria-expanded="true"]::after { content: " ▴"; }
.chip-mock-tag {
  display: inline-block; font-size: 9px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.5px; padding: 1px 5px; margin-left: 4px;
  border-radius: 999px; background: var(--accent-soft); color: var(--accent);
}

/* Mobile (≤ 560px): collapse the chip strip behind a "Select rates" toggle.
   Default-show first 3 chips inline-style; the rest hide unless open. */
@media (max-width: 560px) {
  .refrates-chips-toggle { display: block; }
  .refrates-chips { display: none; margin-top: 8px; }
  .refrates-chips.open { display: flex; }
  .refrates-mode-row { gap: 10px; }
  .spread-base-wrap { width: 100%; }
  .spread-base-wrap .preset-select { flex: 1; max-width: none; }
}
