/* Financial Interconnections Explorers — shared design system.
   Loaded by every explorer's index.html (and the landing page) via
   <link rel="stylesheet" href="../shared.css">. Edit tokens/components here,
   not per-explorer template.html files, so the suite stays visually consistent. */

.viz-root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface-1: #fcfcfb;
  --surface-1-alpha: rgba(252, 252, 251, 0.88);
  --surface-2: #f2f1ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --hover-wash: rgba(11, 11, 11, 0.04);
  --edge: #b3b1a8;
  --edge-hi: #0b0b0b;
  --accent: #2a78d6;
  --flow-asset: #006300;
  --flow-liability: #b3261e;
  --sec-0: #2a78d6;
  --sec-1: #eb6834;
  --sec-2: #1baf7a;
  --sec-3: #eda100;
  --sec-4: #e87ba4;
  --sec-5: #008300;
  --sec-6: #4a3aa7;
  --sec-7: #e34948;
  --sec-8: #17becf;
  --sec-9: #a8a628;
  --sec-10: #8c4fa0;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .viz-root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface-1: #1a1a19;
    --surface-1-alpha: rgba(26, 26, 25, 0.88);
    --surface-2: #232322;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --hover-wash: rgba(255, 255, 255, 0.06);
    --edge: #4a4a46;
    --edge-hi: #ffffff;
    --accent: #3987e5;
    --flow-asset: #0ca30c;
    --flow-liability: #e66767;
    --sec-0: #3987e5;
    --sec-1: #d95926;
    --sec-2: #199e70;
    --sec-3: #c98500;
    --sec-4: #d55181;
    --sec-5: #008300;
    --sec-6: #9085e9;
    --sec-7: #e66767;
    --sec-8: #01a5c6;
    --sec-9: #798217;
    --sec-10: #be1ecc;
  }
}

:root[data-theme="dark"] .viz-root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-1-alpha: rgba(26, 26, 25, 0.88);
  --surface-2: #232322;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --hover-wash: rgba(255, 255, 255, 0.06);
  --edge: #4a4a46;
  --edge-hi: #ffffff;
  --accent: #3987e5;
  --flow-asset: #0ca30c;
  --flow-liability: #e66767;
  --sec-0: #3987e5;
  --sec-1: #d95926;
  --sec-2: #199e70;
  --sec-3: #c98500;
  --sec-4: #d55181;
  --sec-5: #008300;
  --sec-6: #9085e9;
  --sec-7: #e66767;
  --sec-8: #01a5c6;
  --sec-9: #798217;
  --sec-10: #be1ecc;
}

* { box-sizing: border-box; }

/* Scoped, not a blanket ".viz-root a" rule: that would outrank page-specific link
   styling (e.g. a card that's itself an <a> and wants its heading in the normal text
   color, only its "Open ->" affordance in accent). This only colors plain prose links
   inside footnotes/info panels/callouts that would otherwise fall back to the browser
   default link color. */
.info-panel a, footer.note a, .callout a, header p a { color: var(--accent); }

/* Nav */
.explorer-nav {
  --nav-surface: #fcfcfb;
  --nav-border: rgba(11, 11, 11, 0.10);
  --nav-text: #52514e;
  --nav-text-active: #0b0b0b;
  --nav-accent: #2a78d6;
  background: var(--nav-surface);
  border-bottom: 1px solid var(--nav-border);
  position: sticky;
  top: 0;
  z-index: 40;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .explorer-nav {
    --nav-surface: #1a1a19;
    --nav-border: rgba(255, 255, 255, 0.10);
    --nav-text: #c3c2b7;
    --nav-text-active: #ffffff;
    --nav-accent: #3987e5;
  }
}

:root[data-theme="dark"] .explorer-nav {
  --nav-surface: #1a1a19;
  --nav-border: rgba(255, 255, 255, 0.10);
  --nav-text: #c3c2b7;
  --nav-text-active: #ffffff;
  --nav-accent: #3987e5;
}

.explorer-nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  gap: 2px;
  padding: 0 16px;
  overflow-x: auto;
}

.explorer-nav a {
  display: inline-flex;
  align-items: center;
  padding: 13px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--nav-text);
  text-decoration: none;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}

.explorer-nav a:hover { color: var(--nav-text-active); }
.explorer-nav a.active { color: var(--nav-text-active); border-bottom-color: var(--nav-accent); }

/* Page shell */
.viz-root {
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  padding: 28px 16px 44px;
  min-height: 100%;
}

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Header: <header><p class="eyebrow">…</p><h1>…</h1><p>…</p><p class="src">Data source: …</p></header> */
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 8px;
}

header h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

header p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.55;
}

header .src {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

header .src a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: underline;
}

/* Cards / callouts */
.card, .callout {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
}

.callout {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-secondary);
}

.callout strong { color: var(--text-primary); }

.callout-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-primary);
  margin: 0 0 4px;
}

.section-title-row { display: flex; align-items: center; gap: 6px; }

/* Info icon + modals */
.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 14px;
  vertical-align: -2px;
}

.info-icon:hover, .info-icon:focus-visible { color: var(--accent); }

.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(11, 11, 11, 0.45);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop.visible { display: flex; }

.modal-box {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 22px;
  width: 460px;
  max-width: 100%;
  max-height: 82vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-box h3 {
  margin: 0 0 10px;
  font-size: 16px;
  font-weight: 700;
  padding-right: 24px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 20px;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
}

.modal-close:hover { color: var(--text-primary); }

.info-panel {
  font-size: 12.5px;
  font-weight: 400;
  text-transform: none;
  letter-spacing: normal;
  line-height: 1.6;
  color: var(--text-secondary);
  white-space: normal;
}

.info-panel b, .info-panel strong { color: var(--text-primary); }

.info-panel .t-sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

/* Math formula display */
.formula {
  display: block;
  text-align: center;
  font-family: "Cambria Math", "STIX Two Math", Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--surface-2);
  border-radius: 6px;
  padding: 8px 10px;
  margin: 6px 0;
  max-width: 100%;
  overflow-wrap: break-word;
}

.formula .op, .formula .rm { font-style: normal; }
.formula sub, .formula sup { font-style: italic; font-size: 0.72em; }

.formula .frac {
  display: inline-flex;
  flex-direction: column;
  vertical-align: middle;
  text-align: center;
  margin: 0 0.15em;
  line-height: 1.15;
}

.formula .frac .num { border-bottom: 1px solid currentColor; padding: 0 0.2em 0.12em; }
.formula .frac .den { padding: 0.12em 0.2em 0; }
.formula .big { font-size: 1.5em; font-style: normal; line-height: 1; }

/* Footer */
footer.note {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

footer.note code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--grid);
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 11px;
}

/* Chart/table export controls (shared.js's attachChartExport, and per-table CSV buttons).
   Inside a .chart-shell (position:relative), the icon floats over the chart's corner;
   anywhere else (e.g. a .card-head next to a title) it's just a normal inline icon. */
.chart-export-icon {
  border-radius: 6px;
  padding: 4px;
  flex: none;
}

.chart-shell .chart-export-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  background: var(--surface-1-alpha, var(--surface-1));
}

.chart-export-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
}

.chart-export-bar + .chart-export-bar {
  margin-top: 14px;
}

.chart-export-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-left: 4px;
}

.chart-export-label:first-child { margin-left: 0; }

.chart-export-select {
  font: inherit;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

.chart-export-btn, .table-export-btn {
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 12px;
  cursor: pointer;
}

.chart-export-btn:hover, .table-export-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.table-export-row {
  display: flex;
  justify-content: flex-end;
  margin: 6px 0 4px;
}
