/* Mise en page : bandeau d'état en haut, grille de cartes candidats, colonnes sobres ; couleurs vives réservées aux partis */
:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --surface-2: #eef1f6;
  --ink: #161b26;
  --muted: #5a6376;
  --line: #dde2ea;
  --accent: #1f3a8a;
  --accent-soft: #e3e9f8;
  --up: #1a7f4b;
  --down: #b4232f;
  --warn-bg: #fff6dc;
  --warn-ink: #6b5200;
  --shadow: 0 1px 2px rgba(22, 27, 38, .06), 0 4px 14px rgba(22, 27, 38, .05);
  --f-display: "Archivo", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Public Sans", "Segoe UI", system-ui, sans-serif;
  --radius: 10px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1218; --surface: #171b24; --surface-2: #1e2330; --ink: #e7eaf1; --muted: #98a1b4;
    --line: #2a3141; --accent: #8fa8ff; --accent-soft: #1d2647; --up: #4cc58a; --down: #ff6b76;
    --warn-bg: #2d2610; --warn-ink: #f0d37a; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1218; --surface: #171b24; --surface-2: #1e2330; --ink: #e7eaf1; --muted: #98a1b4;
  --line: #2a3141; --accent: #8fa8ff; --accent-soft: #1d2647; --up: #4cc58a; --down: #ff6b76;
  --warn-bg: #2d2610; --warn-ink: #f0d37a; --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 var(--f-body);
  font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
a:focus-visible, button:focus-visible, [tabindex]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--f-display); text-wrap: balance; margin: 0; line-height: 1.15; }
.wrap {
  max-width: 1180px; margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

/* Bandeau */
.topbar { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--surface); }
.topbar .wrap { display: flex; align-items: center; gap: 16px; padding-block: 10px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; text-decoration: none; color: var(--ink); }
.brand b { font-family: var(--f-display); font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.brand span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.status { margin-left: auto; display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.status strong { color: var(--ink); font-weight: 700; }
.countdown strong { color: var(--accent); font-family: var(--f-display); font-size: 15px; }

main { padding-block: 28px 56px; display: grid; gap: 40px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.section-head h2 { font-size: 22px; font-weight: 800; }
.section-head p { margin: 0; color: var(--muted); font-size: 13px; }
.eyebrow { font-size: 11px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted); font-weight: 600; }

/* Cartes principales */
.grid-main { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); text-decoration: none; color: inherit; position: relative; overflow: hidden;
  display: flex; flex-direction: column; transition: transform .15s ease, border-color .15s ease;
}
.card:hover { transform: translateY(-2px); border-color: var(--party); }
.card .stripe { height: 5px; background: var(--party); }
.card .photo { aspect-ratio: 4 / 4.2; background: var(--surface-2); display: grid; place-items: center; overflow: hidden; }
.card .photo img { width: 100%; height: 100%; object-fit: cover; }
.initials { font-family: var(--f-display); font-weight: 800; color: var(--party); letter-spacing: .02em; }
.card .photo .initials { font-size: 54px; opacity: .85; }
.card .body { padding: 12px 14px 14px; display: grid; gap: 6px; }
.card .name { font-family: var(--f-display); font-weight: 700; font-size: 17px; line-height: 1.2; }
.card .party { display: flex; align-items: center; gap: 7px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.card .party span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-row { display: flex; align-items: baseline; gap: 10px; margin-top: 2px; }
.score { font-family: var(--f-display); font-weight: 800; font-size: 34px; letter-spacing: -.02em; line-height: 1; }
.score small { font-size: 16px; font-weight: 700; margin-left: 2px; }
.delta { font-size: 13px; font-weight: 700; }
.delta.up { color: var(--up); } .delta.down { color: var(--down); } .delta.flat { color: var(--muted); }
.last { font-size: 12px; color: var(--muted); }
.rank { position: absolute; top: 12px; left: 10px; background: var(--surface); color: var(--ink); font-weight: 700; font-size: 12px; border-radius: 999px; padding: 1px 8px; border: 1px solid var(--line); }

.logo { width: 20px; height: 20px; border-radius: 4px; flex: none; object-fit: contain; }
.pastille { width: 20px; height: 20px; border-radius: 5px; flex: none; display: inline-grid; place-items: center; font-size: 8px; font-weight: 800; letter-spacing: -.02em; line-height: 1; }

/* Cartes compactes */
.grid-compact { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.mini {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; background: var(--surface);
  border: 1px solid var(--line); border-left: 4px solid var(--party); border-radius: 8px; text-decoration: none; color: inherit; min-width: 0;
}
.mini:hover { border-color: var(--party); }
.mini .avatar { width: 44px; height: 44px; border-radius: 50%; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; flex: none; }
.mini .avatar img { width: 100%; height: 100%; object-fit: cover; }
.mini .avatar .initials { font-size: 15px; }
.mini .txt { min-width: 0; flex: 1; }
.mini .n { font-weight: 700; font-size: 14.5px; }
.mini .p { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini .s { font-family: var(--f-display); font-weight: 800; font-size: 18px; text-align: right; }
.mini .s small { display: block; font-size: 11px; font-weight: 600; color: var(--muted); font-family: var(--f-body); }
.pill { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.pill.pressenti { background: var(--surface-2); color: var(--muted); border: 1px dashed var(--muted); }

/* Panneaux */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; min-width: 0; }
.two-cols { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 860px) { .two-cols { grid-template-columns: 1fr; } }
.chart-box { position: relative; height: 340px; }
.chart-box.small { height: 260px; }

/* Duels */
.duels { display: grid; gap: 14px; }
.duel .names { display: flex; justify-content: space-between; font-size: 13px; font-weight: 600; gap: 8px; }
.duel .bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; margin-top: 5px; font-size: 12.5px; font-weight: 800; }
.duel .bar div { display: flex; align-items: center; padding-inline: 8px; white-space: nowrap; }
.duel .bar div + div { justify-content: flex-end; }
.duel .meta { font-size: 11.5px; color: var(--muted); margin-top: 3px; }

/* Fiche */
.back { font-size: 14px; text-decoration: none; font-weight: 600; }
.hero { display: grid; grid-template-columns: 220px minmax(0, 1fr) auto; gap: 24px; align-items: start; }
@media (max-width: 860px) { .hero { grid-template-columns: 120px minmax(0, 1fr); } .hero .hero-score { grid-column: 1 / -1; } }
.hero .portrait { aspect-ratio: 4 / 4.6; border-radius: var(--radius); overflow: hidden; background: var(--surface-2); display: grid; place-items: center; border-bottom: 6px solid var(--party); }
.hero .portrait img { width: 100%; height: 100%; object-fit: cover; }
.hero .portrait .initials { font-size: 64px; }
.hero h1 { font-size: clamp(28px, 4.5vw, 46px); font-weight: 800; letter-spacing: -.02em; }
.hero .party { display: flex; align-items: center; gap: 8px; margin-top: 8px; font-weight: 600; flex-wrap: wrap; }
.hero .party .logo, .hero .party .pastille { width: 28px; height: 28px; }
.hero .resume { max-width: 65ch; margin: 12px 0 0; }
.facts { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.facts b { color: var(--ink); font-weight: 600; }
.hero-score { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; min-width: 190px; }
.hero-score .score { font-size: 48px; }
.verify { background: var(--warn-bg); color: var(--warn-ink); border-radius: 8px; padding: 9px 14px; font-size: 13px; }

.mandats { list-style: none; margin: 0; padding: 0; display: grid; }
.mandats li { display: grid; grid-template-columns: 110px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.mandats li:last-child { border-bottom: 0; }
.mandats .y { color: var(--muted); font-size: 13px; }
.mandats .en-cours .y { color: var(--accent); font-weight: 700; }
.faits { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 2px solid var(--line); display: grid; gap: 12px; }
.faits li { position: relative; font-size: 14px; }
.faits li::before { content: ""; position: absolute; left: -24px; top: 6px; width: 10px; height: 10px; border-radius: 50%; background: var(--surface); border: 2px solid var(--party); }
.faits .y { font-weight: 800; font-family: var(--f-display); margin-right: 8px; }

/* Frise */
.frise-scroll { overflow-x: auto; }
.frise { position: relative; min-width: 560px; padding-top: 6px; }
.frise .track { position: relative; height: 46px; background: var(--surface-2); border-radius: 6px; }
.frise .seg { position: absolute; top: 0; bottom: 0; display: flex; align-items: center; padding-inline: 8px; font-size: 12px; font-weight: 700; overflow: hidden; white-space: nowrap; border-right: 2px solid var(--surface); }
.frise .seg.approx { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); }
.frise .axis { position: relative; height: 22px; margin-top: 4px; font-size: 11px; color: var(--muted); }
.frise .axis span { position: absolute; transform: translateX(-50%); }
.frise .axis span::before { content: ""; position: absolute; left: 50%; top: -4px; height: 4px; border-left: 1px solid var(--muted); }
.frise-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 12.5px; color: var(--muted); }
.frise-legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* Galaxie */
.galaxy-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 220px; gap: 16px; align-items: start; }
@media (max-width: 760px) { .galaxy-wrap { grid-template-columns: 1fr; } }
.galaxy svg { width: 100%; height: auto; display: block; }
.galaxy .node { cursor: default; }
.galaxy .node.link { cursor: pointer; }
.galaxy .node:hover circle.ring, .galaxy .node:focus circle.ring { stroke-width: 5; }
.galaxy text { fill: var(--ink); font-family: var(--f-body); }
.galaxy .orbit { fill: none; stroke: var(--line); stroke-dasharray: 2 5; }
.legend { font-size: 13px; display: grid; gap: 8px; }
.legend svg { vertical-align: middle; margin-right: 8px; }
.empty { color: var(--muted); font-size: 14px; }

footer { border-top: 1px solid var(--line); color: var(--muted); font-size: 12.5px; }
footer .wrap { padding-block: 18px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between; }
.err { background: var(--warn-bg); color: var(--warn-ink); padding: 14px; border-radius: 8px; }
@media (prefers-reduced-motion: reduce) { .card { transition: none; } .card:hover { transform: none; } }
@media (max-width: 520px) {
  .grid-main { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .score { font-size: 28px; }
  .card .photo .initials { font-size: 40px; }
  .status { margin-left: 0; gap: 12px; }
  .mandats li { grid-template-columns: 88px minmax(0, 1fr); }
}
