/* Hoodwinked — dark theme. Blue + orange carry the brand; red/blue are reserved for party. */
:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border: rgba(255, 255, 255, 0.10);
  --text-primary: #f0efec;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --grid: #2c2c2a;
  --axis: #383835;

  --blue: #3987e5;
  --blue-strong: #5598e7;
  --orange: #d95926;
  --orange-bright: #f08a4b;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --series-5: #d55181;
  --series-6: #9085e9;
  --series-other: #6b6a65;

  --dem: #3987e5;
  --rep: #e66767;
  --ind: #898781;

  --good: #0ca30c;
  --critical: #d03b3b;
  --dark-money: #c98500;

  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--text-primary); font-family: var(--font); }
body { line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--blue-strong); }
button, select, input { font: inherit; color: inherit; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.header-inner { max-width: 1280px; margin: 0 auto; padding: 14px 24px 0; }
.brand { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; }
.brand h1 { margin: 0; font-size: 26px; letter-spacing: 0.14em; font-weight: 800; }
.brand h1 .o { color: var(--orange); }
.brand p { margin: 0; color: var(--text-secondary); font-size: 14px; }

.tabs { display: flex; gap: 4px; margin-top: 12px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none; background: none; border: 0; cursor: pointer;
  padding: 10px 16px 12px; font-size: 15px; font-weight: 600; color: var(--text-secondary);
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text-primary); }
.tab[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--orange); }
.tab:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }

/* ---------- layout ---------- */
main { max-width: 1280px; margin: 0 auto; padding: 24px 24px 64px; }
.panel[hidden] { display: none; }
.lede { max-width: 820px; color: var(--text-secondary); font-size: 16px; margin: 0 0 20px; }
.lede strong { color: var(--text-primary); }

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tile { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px; }
.tile .label { font-size: 13px; color: var(--text-secondary); }
.tile .value { font-size: 32px; font-weight: 650; line-height: 1.15; margin-top: 4px; }
.tile .delta { font-size: 13px; color: var(--text-secondary); margin-top: 4px; }
.tile .delta .up-bad, .tile .delta .down-bad { color: var(--orange-bright); font-weight: 600; }
.tile .delta .up-good { color: var(--good); font-weight: 600; }
.tile.accent { border-color: color-mix(in srgb, var(--orange) 45%, transparent); }

.controls { display: flex; flex-wrap: wrap; gap: 12px 20px; align-items: center; margin: 4px 0 16px; }
.control { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-secondary); min-width: 0; max-width: 100%; flex-wrap: wrap; }
.control select { max-width: 100%; min-width: 0; }
.control select {
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 6px 10px; color: var(--text-primary);
}
.control input[type="range"] { accent-color: var(--orange); width: 180px; }
.control output { color: var(--text-primary); font-weight: 600; min-width: 3.5em; font-variant-numeric: tabular-nums; }
.seg { display: inline-flex; flex-wrap: wrap; max-width: 100%; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--surface-2); border: 0; padding: 6px 12px; cursor: pointer; color: var(--text-secondary); }
.seg button + button { border-left: 1px solid var(--border); }
.seg button[aria-pressed="true"] { background: color-mix(in srgb, var(--blue) 28%, var(--surface-2)); color: var(--text-primary); }

.grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 16px; }
.card {
  grid-column: span 12; background: var(--surface-1); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px 14px; min-width: 0;
}
.card.half { grid-column: span 6; }
.card.third { grid-column: span 4; }
.card.two-thirds { grid-column: span 8; }
@media (max-width: 960px) { .card.half, .card.third, .card.two-thirds { grid-column: span 12; } }

.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.card h2 { margin: 0; font-size: 17px; font-weight: 650; }
.card .sub { margin: 2px 0 10px; color: var(--text-secondary); font-size: 13px; }
.card-tools { display: flex; gap: 6px; flex-shrink: 0; }
.card-tools button {
  background: none; border: 1px solid var(--border); border-radius: 6px; padding: 3px 8px;
  font-size: 12px; color: var(--text-secondary); cursor: pointer;
}
.card-tools button:hover { color: var(--text-primary); border-color: var(--text-muted); }
.card .controls { margin: 0 0 8px; }
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.source { margin-top: 10px; font-size: 12px; color: var(--text-muted); }
.source a { color: var(--text-muted); }

.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--text-secondary); margin: 2px 0 8px; }
.legend .item { display: inline-flex; align-items: center; gap: 6px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.legend .line { width: 16px; height: 2px; border-radius: 2px; display: inline-block; }
.legend .item.toggle { cursor: pointer; user-select: none; }
.legend .item.off { opacity: 0.4; }

.scale-legend { font-size: 12px; color: var(--text-muted); display: flex; align-items: center; gap: 8px; }
.scale-legend .bar { height: 10px; width: 180px; border-radius: 3px; }

/* ---------- chart chrome ---------- */
.axis text { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.axis path, .axis line { stroke: var(--axis); }
.axis.y path { display: none; }
.axis.y line { display: none; }
.gridline line { stroke: var(--grid); stroke-width: 1; }
.gridline path { display: none; }
.label-text { fill: var(--text-secondary); font-size: 12px; }
.label-strong { fill: var(--text-primary); font-size: 12px; font-weight: 600; }
.band-label { fill: var(--text-muted); font-size: 11px; }
.crosshair { stroke: var(--text-muted); stroke-width: 1; }
.state { stroke: var(--surface-1); stroke-width: 0.75; cursor: pointer; }
.state:hover, .state.hover { stroke: var(--text-primary); stroke-width: 1.5; }
.state.selected { stroke: var(--orange-bright); stroke-width: 2; }
.state.nodata { fill: var(--surface-2); }
.mark { transition: opacity 120ms; }
.mark:hover { filter: brightness(1.2); }
.dimmed { opacity: 0.25; }

/* ---------- dark money labeling ---------- */
.dm-tag {
  display: inline-block; font-size: 10px; font-weight: 800; letter-spacing: 0.08em;
  padding: 1px 6px; border-radius: 4px; vertical-align: middle;
  background: var(--dark-money); color: #0b0b0b;
}
.callout {
  border: 1px solid color-mix(in srgb, var(--dark-money) 55%, transparent);
  background: color-mix(in srgb, var(--dark-money) 9%, var(--surface-1));
  border-radius: var(--radius); padding: 12px 16px; margin: 0 0 16px; font-size: 14px; color: var(--text-secondary);
}
.callout strong { color: var(--text-primary); }
.note {
  border-left: 3px solid var(--blue); padding: 6px 12px; margin: 16px 0;
  color: var(--text-secondary); font-size: 13px; background: var(--surface-1); border-radius: 0 8px 8px 0;
}

/* ---------- tooltip ---------- */
.tooltip {
  position: fixed; z-index: 50; pointer-events: none; opacity: 0; transition: opacity 80ms;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; min-width: 140px; max-width: 300px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.tooltip.show { opacity: 1; }
.tooltip .tt-title { color: var(--text-secondary); margin-bottom: 4px; }
.tooltip .tt-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.tooltip .tt-key { display: inline-flex; align-items: center; gap: 6px; color: var(--text-secondary); }
.tooltip .tt-key i { width: 12px; height: 2px; border-radius: 2px; display: inline-block; }
.tooltip .tt-val { color: var(--text-primary); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---------- table view ---------- */
.table-wrap { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; margin-top: 8px; }
table.data { border-collapse: collapse; width: 100%; font-size: 12px; }
table.data th, table.data td { padding: 5px 10px; border-bottom: 1px solid var(--grid); text-align: left; white-space: nowrap; }
table.data th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-secondary); font-weight: 600; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }

.list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--grid); }
.list li .who { display: flex; align-items: center; gap: 8px; min-width: 0; }
.list li .who span.name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list li .num { font-variant-numeric: tabular-nums; color: var(--text-primary); font-weight: 600; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; display: inline-block; }

.loading { color: var(--text-muted); padding: 40px 0; }
.error { color: var(--orange-bright); }

footer { max-width: 1280px; margin: 0 auto; padding: 0 24px 40px; color: var(--text-muted); font-size: 12px; }

@media (max-width: 640px) {
  .header-inner { padding: 12px 16px 0; }
  main { padding: 16px 16px 48px; }
  footer { padding: 0 16px 32px; }
  .tile .value { font-size: 26px; }
  .card { padding: 14px 14px 12px; }
  .control input[type="range"] { width: 130px; }
}

@media (forced-colors: active) {
  .dm-tag { border: 1px solid CanvasText; }
}

/* ---------- section headings & presidential deals ---------- */
.section-title { margin: 28px 0 4px; font-size: 20px; font-weight: 700; }
.section-title:first-child { margin-top: 0; }
.section-sub { margin: 0 0 14px; color: var(--text-secondary); font-size: 14px; max-width: 820px; }
.pres-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; }
.pres-col h3 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.deal { border-top: 1px solid var(--grid); padding: 10px 0; }
.deal .amt { font-size: 20px; font-weight: 650; }
.deal .amt.none { font-size: 14px; color: var(--text-muted); font-weight: 500; }
.deal .what { font-size: 13px; color: var(--text-primary); margin-top: 2px; }
.deal .who { font-size: 12px; color: var(--text-secondary); }
.deal .meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; font-size: 11px; }
.deal .deal-note { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.deal .meta a { color: var(--text-muted); }
.badge { border: 1px solid var(--border); border-radius: 999px; padding: 0 8px; color: var(--text-secondary); white-space: nowrap; }
.badge.disclosed { border-color: color-mix(in srgb, var(--blue) 60%, transparent); }
.badge.alleged { border-color: color-mix(in srgb, var(--orange) 70%, transparent); color: var(--orange-bright); }

/* ---------- wealth segment key ---------- */
.seg-key { margin-top: 12px; border-top: 1px solid var(--grid); padding-top: 10px; }
.seg-key-top { display: flex; justify-content: space-between; align-items: center; gap: 8px 16px; flex-wrap: wrap; margin-bottom: 6px; font-size: 13px; color: var(--text-secondary); }
.seg-key-top strong { color: var(--text-primary); }
.seg-key .seg button { padding: 3px 10px; font-size: 12px; }
.seg-key-scroll { overflow-x: auto; }
.seg-table th.num, .seg-table td.num { text-align: right; }
.seg-table td .swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; margin-right: 8px; vertical-align: -1px; }
.seg-table th { position: static; }

/* ---------- donuts ---------- */
.donut-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 32px; margin: 6px 0 4px; }
@media (max-width: 760px) { .donut-row { grid-template-columns: 1fr; } }
.donut-row h3 { margin: 0 0 8px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-svg { flex-shrink: 0; }
@media (max-width: 420px) { .donut-wrap { flex-wrap: wrap; } }
.donut-svg svg { display: block; max-width: 100%; height: auto; }
.donut-list { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 180px; font-size: 13px; }
.donut-list li { display: grid; grid-template-columns: 12px 1fr auto 36px; gap: 8px; align-items: center; padding: 4px 0; border-bottom: 1px solid var(--grid); cursor: default; }
.donut-list .swatch { width: 10px; height: 10px; border-radius: 3px; }
.donut-list .dl-name { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-list .dl-val { color: var(--text-primary); font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-list .dl-pct { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }
.list-toggle { background: none; border: 1px solid var(--border); border-radius: 6px; padding: 4px 10px; color: var(--text-secondary); cursor: pointer; font-size: 13px; margin: 12px 0 4px; }
.list-toggle:hover { color: var(--text-primary); }

[hidden] { display: none !important; }
