/* ---------- Jetons ---------- */
:root {
  color-scheme: light;
  --bg: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f2f1ed;
  --ink: #0b0b0b;
  --ink-2: #52514e;
  --muted: #6e6c66;
  --axis-text: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --focus: #2a78d6;
  --shadow: 0 1px 2px rgba(11, 11, 11, 0.04), 0 4px 16px rgba(11, 11, 11, 0.04);

  /* Couleurs des candidats (validées daltonisme, voir README) */
  --c-violet: #6250d6;
  --c-red: #e34948;
  --c-rasp: #b61b75;
  --c-aqua: #1baf7a;
  --c-blue: #2a78d6;
  --c-yellow: #eda100;
  --c-green: #008300;
  --c-ink: #52514e;
  --c-other: #b3b1aa;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232321;
    --ink: #f0efec;
    --ink-2: #c3c2b7;
    --muted: #a3a197;
    --axis-text: #898781;
    --grid: #2c2c2a;
    --axis: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --focus: #3987e5;
    --shadow: none;
    --c-violet: #9085e9;
    --c-red: #e66767;
    --c-rasp: #b4398a;
    --c-aqua: #199e70;
    --c-blue: #3987e5;
    --c-yellow: #c98500;
    --c-green: #008300;
    --c-ink: #c3c2b7;
    --c-other: #5c5b57;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --ink: #f0efec;
  --ink-2: #c3c2b7;
  --muted: #a3a197;
  --axis-text: #898781;
  --grid: #2c2c2a;
  --axis: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --focus: #3987e5;
  --shadow: none;
  --c-violet: #9085e9;
  --c-red: #e66767;
  --c-rasp: #b4398a;
  --c-aqua: #199e70;
  --c-blue: #3987e5;
  --c-yellow: #c98500;
  --c-green: #008300;
  --c-ink: #c3c2b7;
  --c-other: #5c5b57;
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 72px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration-color: var(--axis); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2 { line-height: 1.2; letter-spacing: -0.01em; }
h2 { font-size: 1.25rem; margin: 0; }

.tricolore { height: 4px; background: linear-gradient(90deg, #002395 0 33.3%, #f4f4f4 33.3% 66.6%, #ed2939 66.6%); }

/* ---------- En-tête ---------- */
.top {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.top-inner { display: flex; align-items: center; gap: 16px; height: 56px; }
.brand { text-decoration: none; font-size: 15px; color: var(--ink-2); white-space: nowrap; }
.brand strong { color: var(--ink); }
.nav { display: flex; gap: 4px; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav a { text-decoration: none; color: var(--ink-2); font-size: 14px; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); color: var(--ink); }
.icon-btn {
  flex: none; display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.icon-btn:hover { color: var(--ink); }

/* ---------- Héros ---------- */
.hero { padding: 40px 0 20px; }
.eyebrow { margin: 0 0 8px; color: var(--ink-2); font-size: 14px; }
.eyebrow #countdown { font-weight: 600; color: var(--ink); }
.hero h1 { font-size: clamp(28px, 4.4vw, 40px); margin: 0 0 12px; }
.lede { font-size: 18px; max-width: 760px; margin: 0 0 10px; color: var(--ink); }
.lede strong { font-weight: 650; }
.status { margin: 0; font-size: 13px; color: var(--muted); }

/* ---------- Contrôles ---------- */
.controls {
  display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px 20px;
  padding: 12px 0 16px; margin-bottom: 4px;
}
.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ink-2); }
.field.compact { flex-direction: row; }
select {
  font: inherit; font-size: 14px; color: var(--ink);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 32px 7px 10px; min-height: 36px; max-width: 100%;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='none' stroke='%23898781' stroke-width='2.5' d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center;
}
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button {
  font: inherit; font-size: 14px; border: 0; background: transparent; color: var(--ink-2);
  padding: 5px 12px; border-radius: 8px; cursor: pointer; min-height: 30px;
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.btn {
  display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 14px; text-decoration: none;
  color: var(--ink); background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 7px 12px; min-height: 36px; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn.small { font-size: 13px; padding: 5px 10px; min-height: 32px; }
#share-btn { margin-left: auto; }

/* ---------- Cartes ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow);
}
.card-head { margin-bottom: 16px; }
.card-head.row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.sub { margin: 4px 0 0; font-size: 14px; color: var(--ink-2); }
.note { margin: 16px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Classement ---------- */
.ranking { list-style: none; margin: 0; padding: 0; }
.rank-row {
  display: grid; grid-template-columns: minmax(150px, 220px) 1fr 64px 72px; align-items: center; gap: 12px;
  padding: 7px 8px; margin: 0 -8px; border-radius: 8px;
}
.rank-row:hover { background: var(--surface-2); }
.rank-row.qualified .name strong::after {
  content: "2nd tour"; margin-left: 8px; font-size: 11px; font-weight: 600; letter-spacing: .02em;
  color: var(--ink-2); border: 1px solid var(--border); border-radius: 99px; padding: 1px 7px; vertical-align: 2px;
}
.name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.name strong { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.name small { color: var(--muted); font-size: 12px; }
.dot { flex: none; width: 10px; height: 10px; border-radius: 50%; }
.bar-track { height: 12px; position: relative; }
.bar-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 0 4px 4px 0; min-width: 2px; transition: width .35s ease; }
.bar-range { position: absolute; top: 5px; height: 2px; background: var(--ink-2); opacity: .45; }
.value { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; font-size: 17px; }
.delta { text-align: right; font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.delta.flat { color: var(--muted); }
.rank-head { display: grid; grid-template-columns: minmax(150px, 220px) 1fr 64px 72px; gap: 12px; font-size: 12px; color: var(--muted); padding: 0 0 6px; border-bottom: 1px solid var(--grid); margin-bottom: 4px; }
.rank-head span:nth-child(3), .rank-head span:nth-child(4) { text-align: right; }

/* ---------- Graphique ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font: inherit; font-size: 13px; color: var(--ink);
  background: transparent; border: 1px solid var(--border); border-radius: 99px; padding: 4px 10px 4px 8px; cursor: pointer; min-height: 30px;
}
.chip:hover { background: var(--surface-2); }
.chip[aria-pressed="false"] { color: var(--muted); }
.chip[aria-pressed="false"] .key { opacity: .25; }
.key { width: 16px; height: 0; border-top: 3px solid; border-radius: 2px; }
.key.dashed { border-top-style: dashed; }
.chart { position: relative; width: 100%; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart svg:focus { outline: none; }
.chart svg:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.chart text { font-family: inherit; }
.axis-label { fill: var(--axis-text); font-size: 12px; font-variant-numeric: tabular-nums; }
.end-label { fill: var(--ink); font-size: 12.5px; }
.end-label tspan.v { font-weight: 650; font-variant-numeric: tabular-nums; }
.tooltip {
  position: absolute; z-index: 5; pointer-events: none; min-width: 190px;
  background: var(--surface); color: var(--ink); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .14); padding: 10px 12px; font-size: 13px;
}
.tooltip .t-date { color: var(--ink-2); font-size: 12px; margin-bottom: 6px; }
.tooltip .t-row { display: grid; grid-template-columns: 14px 44px 1fr; align-items: center; gap: 6px; line-height: 1.6; }
.tooltip .t-row b { font-variant-numeric: tabular-nums; text-align: right; }
.tooltip .t-row span:last-child { color: var(--ink-2); white-space: nowrap; }
.tooltip.docked { position: static; box-shadow: none; min-width: 0; margin-top: 10px; background: var(--surface-2); border-color: transparent; }
.tooltip.docked .t-rows { display: grid; grid-template-columns: 1fr 1fr; column-gap: 10px; }
.tooltip.docked .t-row { grid-template-columns: 12px 40px 1fr; }
.tooltip .t-row span:last-child { overflow: hidden; text-overflow: ellipsis; }
.tooltip .t-polls { border-top: 1px solid var(--grid); margin-top: 6px; padding-top: 6px; color: var(--ink-2); font-size: 12px; }

/* ---------- Duels ---------- */
.duels { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.duel { border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--surface); }
.duel.old { opacity: .75; }
.duel-names { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; }
.duel-names > span { display: flex; align-items: center; gap: 6px; min-width: 0; }
.duel-names > span:last-child { flex-direction: row-reverse; text-align: right; }
.duel-vals { display: flex; justify-content: space-between; font-size: 24px; font-weight: 650; margin: 2px 0 6px; }
.split { position: relative; display: flex; gap: 2px; height: 12px; }
.split > div { height: 100%; transition: width .35s ease; }
.split > div:first-child { border-radius: 4px 0 0 4px; }
.split > div:nth-child(2) { border-radius: 0 4px 4px 0; }
.split .mid { position: absolute; left: 50%; top: -4px; bottom: -4px; width: 1px; background: var(--ink-2); }
.duel-foot { margin: 8px 0 0; font-size: 12.5px; color: var(--muted); }
#duels-more { margin-top: 14px; }

/* ---------- Tableau ---------- */
.table-tools { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; margin: 0 -24px; padding: 0 24px; }
table.polls { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.polls th { text-align: right; font-weight: 600; font-size: 12.5px; color: var(--ink-2); padding: 8px 8px; border-bottom: 1px solid var(--axis); white-space: nowrap; vertical-align: bottom; }
.polls th .key { display: block; width: 100%; margin-bottom: 4px; }
.polls th:nth-child(-n+3), .polls td:nth-child(-n+3) { text-align: left; }
.polls td { padding: 8px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
.polls tbody tr.main { cursor: pointer; }
.polls tbody tr.main:hover td { background: var(--surface-2); }
.polls td.lead { font-weight: 700; }
.polls td.na { color: var(--axis-text); }
.polls td .inst { font-weight: 600; }
.polls td .n { color: var(--muted); }
.polls tr.hyp td { font-size: 13px; color: var(--ink-2); background: var(--surface-2); border-bottom-color: var(--surface); }
.polls tr.hyp td:first-child { padding-left: 20px; }
.polls .chev { display: inline-block; width: 10px; color: var(--muted); transition: transform .2s; }
.polls tr.open .chev { transform: rotate(90deg); }
.scroll-hint { display: none; font-size: 12px; color: var(--muted); margin: -6px 0 8px; }
.polls tr.hyp:has(+ .extra-row) td { border-bottom: 0; }
.polls tr.extra-row td { text-align: left; white-space: normal; padding-top: 0; font-size: 12px; color: var(--muted); }
.polls tr.extra-row td:first-child { padding-left: 20px; }
#more-btn { margin-top: 14px; }
.empty { color: var(--muted); padding: 20px 0; }

/* ---------- Méthode ---------- */
details { border-top: 1px solid var(--grid); padding: 12px 0; }
details:first-of-type { margin-top: 12px; }
summary { cursor: pointer; font-weight: 600; }
details p { color: var(--ink-2); margin: 10px 0 0; max-width: 820px; }

/* ---------- Actualités ---------- */
.nav a[aria-current="page"] { color: var(--ink); background: var(--surface-2); font-weight: 600; }
.field.grow { flex: 1 1 220px; }
input[type="search"] {
  font: inherit; font-size: 14px; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 7px 10px; min-height: 36px; width: 100%;
}
.news-day + .news-day { margin-top: 20px; }
.news-day h3 {
  font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 0 0 4px;
  padding-bottom: 6px; border-bottom: 1px solid var(--grid);
}
.news { list-style: none; margin: 0; padding: 0; }
.news-item { display: grid; grid-template-columns: 48px 1fr; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--grid); }
.news-item:last-child { border-bottom: 0; }
.news-item time { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; padding-top: 2px; }
.news-title { font-weight: 600; text-decoration: none; line-height: 1.4; }
a.news-title:hover { text-decoration: underline; text-decoration-color: var(--axis); }
a.news-title:visited { color: var(--ink-2); }
.news-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 5px; font-size: 12.5px; color: var(--muted); }
.news-src { font-weight: 600; color: var(--ink-2); margin-right: 4px; }
.tag {
  display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 12px; color: var(--ink-2);
  background: transparent; border: 1px solid var(--border); border-radius: 99px; padding: 1px 8px 1px 6px; cursor: pointer;
}
.tag:hover { background: var(--surface-2); color: var(--ink); }
.tag .dot { width: 8px; height: 8px; }
.sources { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 14px 0 0; }
.sources li { font-size: 13px; border: 1px solid var(--border); border-radius: 99px; padding: 2px 10px; color: var(--ink-2); }
.sources li.down { color: var(--muted); border-style: dashed; }

/* ---------- Pied ---------- */
.foot { padding: 12px 0 40px; font-size: 13px; color: var(--muted); }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px;
  box-shadow: 0 6px 24px rgba(0,0,0,.2);
}
.loading { opacity: .55; transition: opacity .2s; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .nav a:not(.page), .nav a[aria-current="page"], .brand-pre { display: none; }
  .controls:has(.grow) { display: grid; grid-template-columns: 1fr 1fr; }
  .controls .field.grow { grid-column: 1 / -1; }
  .controls select { width: 100%; }
  .news-item { grid-template-columns: 40px 1fr; gap: 10px; }
  .top-inner { justify-content: space-between; }
  .hero { padding-top: 28px; }
  .lede { font-size: 16.5px; }
  .card { padding: 18px 16px; border-radius: 12px; }
  .table-wrap { margin: 0 -16px; padding: 0 16px; }
  .rank-row, .rank-head { grid-template-columns: minmax(104px, 132px) 1fr 52px 56px; gap: 8px; }
  .name small { display: none; }
  .rank-row.qualified .name strong::after { display: none; }
  .value { font-size: 15px; }
  #share-btn { margin-left: 0; }
  .controls { gap: 10px 14px; }
  .scroll-hint { display: block; }
  .duels { gap: 10px; }
  .duel { padding: 12px 14px; }
  .duel-vals { font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .bar-fill, .split > div { transition: none; }
}
@media (forced-colors: active) {
  .bar-fill, .split > div, .dot { forced-color-adjust: none; }
}
