/*
 * QC Élection Forecast — Plateforme de prévision électorale du Québec 2026
 * Auteur : Simon-Pierre Boucher
 * Contact : contact@spboucher.ai
 * https://www.qc-election.com
 */
/* QC Élection Forecast — thème sombre (défaut) + thème clair
   Palette des partis validée (bande de luminance, chroma, CVD, contraste)
   sur les deux surfaces #14161d et #f6f7f9. */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root, [data-theme="dark"] {
  --bg: #0e1015;
  --surface: #14161d;
  --card: #181b24;
  --card-2: #1d2130;
  --border: #262b3a;
  --ink: #e8eaf0;
  --ink-2: #aab2c2;
  --muted: #7d8698;
  --accent: #8fa3c8;
  --accent-ink: #0c0d11;
  --good: #3fa66a;
  --warn: #c9932a;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 8px 28px -12px rgba(0,0,0,.5);
  --hero-grad: radial-gradient(1200px 420px at 18% -10%, rgba(63,122,214,.14), transparent 60%),
               radial-gradient(900px 380px at 85% -20%, rgba(112,105,214,.10), transparent 60%);
  --header-bg: rgba(14,16,21,.82);
  --radius: 14px;
  --caq: #0097cf; --plq: #e5484d; --pq: #3f7ad6; --qs: #e06c1f; --pcq: #7069d6; --aut: #ad8226;
  font-size: 15px;
}
[data-theme="light"] {
  --bg: #f3f4f7;
  --surface: #f6f7f9;
  --card: #ffffff;
  --card-2: #eef0f5;
  --border: #dfe3ec;
  --ink: #1a1e28;
  --ink-2: #45506a;
  --muted: #6d7891;
  --accent: #3d5f9e;
  --accent-ink: #ffffff;
  --good: #2c7a4e;
  --warn: #9a6d10;
  --danger: #c93540;
  --shadow: 0 1px 2px rgba(23,32,64,.06), 0 10px 30px -14px rgba(23,32,64,.16);
  --hero-grad: radial-gradient(1200px 420px at 18% -10%, rgba(63,122,214,.10), transparent 60%),
               radial-gradient(900px 380px at 85% -20%, rgba(112,105,214,.08), transparent 60%);
  --header-bg: rgba(246,247,249,.85);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--ink);
  font-family: "Inter", -apple-system, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased; }
body { background-image: var(--hero-grad); background-repeat: no-repeat; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1280px; margin: 0 auto; padding: 0 20px 60px; }

/* ---------- header ---------- */
header.site {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg); backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
}
header.site .inner { max-width: 1280px; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; gap: 24px; height: 60px; }
.brand { font-weight: 700; letter-spacing: -.02em; font-size: 1.05rem; white-space: nowrap; }
.brand .fleur { color: var(--accent); margin-right: 8px; }
nav.main { display: flex; gap: 4px; overflow-x: auto; }
nav.main a { color: var(--ink-2); padding: 8px 12px; border-radius: 8px;
  font-size: .92rem; white-space: nowrap; }
nav.main a:hover { color: var(--ink); background: var(--card); text-decoration: none; }
nav.main a.active { color: var(--ink); background: var(--card-2); }
.updated { margin-left: auto; color: var(--muted); font-size: .8rem; white-space: nowrap; }

/* ---------- hero ---------- */
.hero { padding: 40px 0 8px; }
.hero h1 { font-size: 1.9rem; letter-spacing: -.03em; margin: 0 0 6px; }
.hero .sub { color: var(--ink-2); margin: 0; font-size: 1rem; }
.hero .countdown { color: var(--accent); font-variant-numeric: tabular-nums; }
.disclaimer { color: var(--muted); font-size: .82rem; margin-top: 6px; }

/* ---------- cards ---------- */
.grid { display: grid; gap: 14px; margin: 22px 0; }
.grid.parties { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.three { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 900px) { .grid.two, .grid.three { grid-template-columns: 1fr; } }

.card { background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.card h3 { margin: 0 0 4px; font-size: .82rem; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; }
.card .note { color: var(--muted); font-size: .78rem; margin-top: 8px; line-height: 1.45; }

.party-card { position: relative; overflow: hidden; }
.party-card .bar { position: absolute; top: 0; left: 0; right: 0; height: 3px; }
.party-card .pname { font-weight: 650; font-size: .95rem; margin-bottom: 2px; }
.party-card .leader { color: var(--muted); font-size: .78rem; margin-bottom: 12px; }
.bignum { font-size: 2.1rem; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums; line-height: 1.1; }
.bignum small { font-size: 1rem; color: var(--ink-2); font-weight: 500; }
.kv { display: flex; justify-content: space-between; font-size: .85rem;
  color: var(--ink-2); padding: 3px 0; font-variant-numeric: tabular-nums; }
.kv b { color: var(--ink); font-weight: 600; }

/* ---------- charts ---------- */
.chart { width: 100%; height: 360px; }
.chart.tall { height: 430px; }
.chart.short { height: 240px; }
.chart-note { color: var(--muted); font-size: .78rem; margin-top: 4px; }

/* ---------- majority meter ---------- */
.meter { display: flex; height: 30px; border-radius: 8px; overflow: hidden; gap: 2px;
  background: var(--surface); }
.meter div { display: flex; align-items: center; justify-content: center;
  font-size: .75rem; font-weight: 600; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.45);
  min-width: 0; overflow: hidden; }
.meter-axis { position: relative; height: 16px; color: var(--muted); font-size: .72rem; }
.meter-axis .maj { position: absolute; left: 50%; transform: translateX(-50%); }

/* ---------- tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .87rem;
  font-variant-numeric: tabular-nums; }
table.data th { text-align: left; color: var(--muted); font-weight: 600;
  font-size: .76rem; text-transform: uppercase; letter-spacing: .05em;
  padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
table.data tr:hover td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.chip { display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 600; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%;
  margin-right: 6px; vertical-align: baseline; }

/* ---------- filtres ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 14px 0; }
.filters label { color: var(--muted); font-size: .8rem; }
select, input[type="text"], input[type="date"], input[type="number"], input[type="password"], textarea {
  background: var(--card-2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 10px; font-size: .88rem; font-family: inherit; }
select:focus, input:focus, textarea:focus { outline: 1px solid var(--accent); }
button, .btn { background: var(--card-2); color: var(--ink); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 14px; font-size: .88rem; cursor: pointer;
  font-family: inherit; font-weight: 550; }
button:hover, .btn:hover { border-color: var(--accent); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }

/* ---------- sliders (simulateur) ---------- */
.slider-row { display: grid; grid-template-columns: 130px 1fr 64px; gap: 12px;
  align-items: center; padding: 7px 0; }
.slider-row .val { text-align: right; font-variant-numeric: tabular-nums;
  font-weight: 600; font-size: .9rem; }
input[type="range"] { width: 100%; accent-color: var(--accent); }

/* ---------- carte / cartogramme ---------- */
.carto { display: flex; flex-wrap: wrap; gap: 18px; }
.carto .region { min-width: 150px; }
.carto .region h4 { margin: 0 0 6px; font-size: .78rem; color: var(--muted);
  font-weight: 600; }
.carto .cells { display: grid; grid-template-columns: repeat(4, 26px); gap: 3px; }
.cell { width: 26px; height: 26px; border-radius: 5px; cursor: pointer;
  border: 1px solid transparent; transition: transform .06s; }
.cell:hover { transform: scale(1.18); border-color: var(--ink); z-index: 2; position: relative; }
.cell.tossup { border: 1px dashed color-mix(in srgb, var(--ink) 55%, transparent); }
.side-panel { position: sticky; top: 76px; max-height: calc(100vh - 100px); overflow: auto; }
.legend-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: center;
  color: var(--ink-2); font-size: .8rem; margin: 10px 0; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px;
  vertical-align: -2px; margin-right: 5px; }

/* ---------- timeline événements ---------- */
.events { display: flex; flex-direction: column; gap: 8px; }
.event { display: flex; gap: 12px; font-size: .85rem; }
.event .d { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* ---------- divers ---------- */
h2.section { font-size: 1.15rem; letter-spacing: -.02em; margin: 34px 0 4px; }
p.section-sub { color: var(--muted); font-size: .85rem; margin: 0 0 12px; }
.prose { max-width: 860px; line-height: 1.65; color: var(--ink-2); }
.prose h2 { color: var(--ink); font-size: 1.2rem; margin-top: 34px; letter-spacing: -.02em; }
.prose h3 { color: var(--ink); font-size: 1rem; margin-top: 24px; }
.prose code { background: var(--card-2); padding: 1px 6px; border-radius: 5px; font-size: .85em; }
.prose table.data { margin: 12px 0; }
.badge-aux { background: rgba(201,147,42,.15); color: var(--warn); }
.ask-box { display: flex; gap: 10px; }
.ask-box input { flex: 1; }
.answer { background: var(--card-2); border-radius: 10px; padding: 14px 16px;
  line-height: 1.6; font-size: .92rem; margin-top: 12px; display: none; }
footer.site { margin-top: 60px; padding: 24px 0; border-top: 1px solid var(--border);
  color: var(--muted); font-size: .8rem; line-height: 1.6; }
.loading { color: var(--muted); padding: 30px; text-align: center; }

/* ---------- bascule de thème ---------- */
.theme-toggle { background: var(--card-2); border: 1px solid var(--border);
  border-radius: 999px; width: 34px; height: 34px; display: flex; align-items: center;
  justify-content: center; cursor: pointer; font-size: 15px; padding: 0; flex: none; }
.theme-toggle:hover { border-color: var(--accent); }

/* ---------- carte géographique ---------- */
.geo-map { width: 100%; height: 560px; }
@media (max-width: 900px) { .geo-map { height: 420px; } }
.map-tabs { display: flex; gap: 6px; margin: 0 0 12px; }
.map-tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* ---------- avatars & logos ---------- */
.avatar { border-radius: 50%; object-fit: cover; border: 2px solid var(--border);
  vertical-align: middle; background: var(--card-2); }
.avatar-init { display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; border: 2px solid; border-radius: 50%; }
.party-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.party-head .who { min-width: 0; }
.plogo { height: 22px; max-width: 92px; object-fit: contain; display: block;
  margin-top: 6px; opacity: .92; }
[data-theme="dark"] .plogo { filter: drop-shadow(0 0 1px rgba(255,255,255,.25));
  background: rgba(255,255,255,.88); border-radius: 5px; padding: 2px 6px; }
.avatars-stack { display: flex; }
.avatars-stack .avatar + .avatar { margin-left: -12px; }
.credits { color: var(--muted); font-size: .72rem; }

/* ---------- responsive mobile ---------- */
@media (max-width: 900px) {
  .grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
  .side-panel { position: static; max-height: none; }
}
@media (max-width: 640px) {
  :root { font-size: 14px; }
  header.site .inner { height: auto; flex-wrap: wrap; padding: 8px 12px; gap: 8px; }
  .brand { font-size: .98rem; }
  nav.main { order: 3; width: 100%; gap: 2px; -webkit-overflow-scrolling: touch;
    scrollbar-width: none; margin: 0 -12px; padding: 0 12px 6px; }
  nav.main::-webkit-scrollbar { display: none; }
  nav.main a { padding: 7px 10px; font-size: .86rem; }
  .updated { display: none; }
  .theme-toggle { margin-left: auto; }
  .hero { padding: 22px 0 4px; }
  .hero h1 { font-size: 1.42rem; }
  .hero .sub { font-size: .9rem; }
  .wrap { padding: 0 12px 40px; }
  .grid.parties { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .card { padding: 14px 14px; }
  .bignum { font-size: 1.7rem; }
  .chart { height: 300px; }
  .chart.tall { height: 340px; }
  .geo-map { height: 380px; }
  .meter { height: 24px; }
  .meter div { font-size: .68rem; }
  .slider-row { grid-template-columns: 92px 1fr 52px; gap: 8px; }
  table.data { font-size: .8rem; }
  table.data th, table.data td { padding: 6px 6px; }
  .carto .cells { grid-template-columns: repeat(6, 24px); }
  .cell { width: 24px; height: 24px; }
  .ask-box { flex-direction: column; }
  .filters { gap: 8px; }
  .filters select, .filters input { max-width: 100%; }
  h2.section { margin: 24px 0 4px; }
  .party-card .leader { margin-bottom: 8px; }
  .avatars-stack .avatar { width: 34px !important; height: 34px !important; }
}
@media (max-width: 400px) {
  .grid.parties { grid-template-columns: 1fr; }
}
