/* Party heat map. Layout: coalition panels wrap left-to-right by weight; a sticky detail
   panel on the right (stacked below on phones); a table twin underneath.
   Heat ramp: one red hue in OKLCH, monotone lightness; in dark mode the anchor flips so
   "more" is brighter. Steps computed in OKLCH (L .90→.46 light, .36→.79 dark). */
:root {
  --heat-0: #e3e7e4;
  --heat-1: #fed2cc;
  --heat-2: #fcada3;
  --heat-3: #f38279;
  --heat-4: #e5554f;
  --heat-5: #cb2b2d;
  --heat-6: #a3141f;
  --heat-ink-0: #17201d;
  --heat-ink-1: #17201d;
  --heat-ink-2: #17201d;
  --heat-ink-3: #17201d;
  --heat-ink-4: #17201d;
  --heat-ink-5: #ffffff;
  --heat-ink-6: #ffffff;
  --panel: #fbfcfb;
  --tip-bg: #17201d;
  --tip-fg: #f3f6f4;
  --tip-muted: #b5c1bc;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --heat-0: #2e3833;
    --heat-1: #59302c;
    --heat-2: #833833;
    --heat-3: #b2403b;
    --heat-4: #e04c47;
    --heat-5: #f66d64;
    --heat-6: #fe9c91;
    --heat-ink-0: #e7ece9;
    --heat-ink-1: #ffffff;
    --heat-ink-2: #ffffff;
    --heat-ink-3: #ffffff;
    --heat-ink-4: #0f1412;
    --heat-ink-5: #0f1412;
    --heat-ink-6: #0f1412;
    --panel: #141a17;
    --tip-bg: #e7ece9;
    --tip-fg: #0f1412;
    --tip-muted: #4b5652;
  }
}
:root[data-theme="dark"] {
  --heat-0: #2e3833;
  --heat-1: #59302c;
  --heat-2: #833833;
  --heat-3: #b2403b;
  --heat-4: #e04c47;
  --heat-5: #f66d64;
  --heat-6: #fe9c91;
  --heat-ink-0: #e7ece9;
  --heat-ink-1: #ffffff;
  --heat-ink-2: #ffffff;
  --heat-ink-3: #ffffff;
  --heat-ink-4: #0f1412;
  --heat-ink-5: #0f1412;
  --heat-ink-6: #0f1412;
  --panel: #141a17;
  --tip-bg: #e7ece9;
  --tip-fg: #0f1412;
  --tip-muted: #4b5652;
}

.heat-page { display: flex; flex-direction: column; gap: 18px; }
.heat-intro { max-width: 760px; font-size: 14.5px; }
.heat-intro p { margin: 0 0 8px; }
.heat-caveat { color: var(--muted); font-size: 13.5px; }

.heat-controls { display: flex; flex-wrap: wrap; gap: 12px 24px; align-items: flex-end; }
.seg { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; }
.seg legend { font-size: 12px; color: var(--muted); padding: 0; margin-bottom: 4px; width: 100%; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span {
  display: inline-block; font-size: 13.5px; padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer;
}
.seg input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }

.heat-legend { display: flex; flex-wrap: wrap; gap: 12px 32px; align-items: flex-end; font-size: 12px; color: var(--muted); }
.legend-block { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.legend-title { font-size: 12px; color: var(--muted); }
.legend-ramp { display: flex; gap: 2px; flex-wrap: wrap; }
.legend-ramp .sw { display: flex; flex-direction: column; gap: 3px; min-width: 52px; }
.legend-ramp .sw i { display: block; height: 12px; border-radius: 3px; }
.legend-ramp .sw:first-child i { border-radius: 3px; }
.legend-ramp .sw b { font-weight: 500; color: var(--text); font-variant-numeric: tabular-nums; font-size: 11.5px; }
.legend-size text { fill: var(--muted); font-size: 11px; }
.legend-size circle { fill: none; stroke: var(--muted); stroke-width: 1; }

.heat-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.blocs { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-start; min-width: 0; }
.bloc {
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  padding: 12px 14px 10px; display: flex; flex-direction: column; gap: 6px; min-width: 0; max-width: 100%;
}
.bloc h3 { font-size: 14px; margin: 0; text-wrap: balance; }
.bloc .gov { font-size: 12px; color: var(--muted); margin: 0; }
.bloc .bstats { font-size: 12px; color: var(--muted); margin: 0; font-variant-numeric: tabular-nums; }
.bloc .bstats b { color: var(--text); }
.bloc svg { display: block; overflow: visible; max-width: 100%; height: auto; align-self: center; }

.bubble { cursor: pointer; outline: none; }
.bubble circle { stroke: var(--panel); stroke-width: 2; transition: stroke .12s; }
.bubble:hover circle, .bubble:focus-visible circle { stroke: var(--text); stroke-width: 2; }
.bubble.selected circle { stroke: var(--accent); stroke-width: 3; }
.bubble text { pointer-events: none; font-weight: 700; text-anchor: middle; dominant-baseline: central; }
.bubble .hit { fill: transparent; stroke: none; }

.detail {
  position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px);
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.detail .d-head { display: flex; gap: 10px; align-items: center; }
.detail .d-dot { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.detail h2 { font-size: 20px; margin: 0; }
.detail .d-name { margin: 0; font-size: 12.5px; color: var(--muted); }
.detail .d-bloc { margin: 0; font-size: 12.5px; }
.d-figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.d-figs div { display: flex; flex-direction: column; }
.d-figs b { font-size: 22px; line-height: 1.1; }
.d-figs span { font-size: 11.5px; color: var(--muted); }
.d-figs div + div { border-left: 1px solid var(--border); padding-left: 8px; }
.d-break { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.d-break li { display: flex; justify-content: space-between; gap: 8px; }
.d-break b { font-variant-numeric: tabular-nums; }
.d-sub { font-size: 12px; font-weight: 600; color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.d-top { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.d-top li { display: flex; flex-direction: column; gap: 1px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.d-top li:last-child { border-bottom: 0; }
.d-top .who { font-weight: 600; overflow-wrap: anywhere; }
.d-top .meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.d-link { font-weight: 600; font-size: 13.5px; }
.d-empty { color: var(--muted); font-size: 13px; margin: 0; }

.heat-table h2 { font-size: 17px; margin: 0 0 4px; }
.heat-table .muted { font-size: 13px; margin: 0 0 8px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
#table { border-collapse: collapse; width: 100%; font-size: 13px; }
#table th, #table td { padding: 7px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
#table th { font-size: 11.5px; color: var(--muted); font-weight: 600; background: var(--surface-2); position: sticky; top: 0; }
#table td.num, #table th.num { text-align: right; font-variant-numeric: tabular-nums; }
#table tbody tr { cursor: pointer; }
#table tbody tr:hover { background: var(--surface-2); }
#table tbody tr.selected { background: var(--accent-soft); }
#table .p-cell { display: flex; align-items: center; gap: 8px; font-weight: 700; }
#table .p-cell i { width: 12px; height: 12px; border-radius: 50%; flex: none; }
#table td.bloc-cell { white-space: normal; min-width: 160px; color: var(--muted); }

.tip {
  position: fixed; z-index: 20; pointer-events: none; max-width: 260px;
  background: var(--tip-bg); color: var(--tip-fg); border-radius: 8px; padding: 8px 10px;
  font-size: 12.5px; line-height: 1.4; box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
}
.tip strong { font-size: 15px; display: block; }
.tip .t-muted { color: var(--tip-muted); }

@media (max-width: 900px) {
  .heat-layout { grid-template-columns: minmax(0, 1fr); }
  .detail { position: static; }
}
@media (max-width: 720px) {
  .blocs { gap: 10px; }
  .bloc { padding: 10px; flex: 1 1 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .bubble circle { transition: none; }
}
