/* Isoloir : un seul fichier de styles, clair et sombre. Les pages doivent tenir à 400 px de large.
   L'identité d'une association (couleurs, en-tête, police) se change sans toucher ce fichier : custom/theme.css
   redéfinit les variables « marque » ci-dessous (voir custom.example/theme.css). */

:root {
  color-scheme: light;
  /* La marque : l'en-tête, la couleur principale (accents, boutons), la seconde (danger, direct). */
  --header-bg: linear-gradient(180deg, #232a36, #171c25);
  --header-ink: #ffffff;
  --header-ink-soft: #c9d3e3;
  --brand: #2a78d6;
  --brand-alt: #d0402f;
  --surface-0: #f3f2ef;
  --surface-1: #fcfcfb;
  --border: #dddcd7;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --accent: #1d5fd1;
  --button: #1d5fd1;
  --button-ink: #ffffff;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #6250d6; --s8: #e34948;
  --blank-mark: #c3cad6;
  --neutral-mark: #8a93a3;
  --track: #e6ebf2;
  --good: #0a7a3d;
  --warning: #9a6500;
  --critical: #c0302f;
  --radius: 10px;
  /* Polices du système : rien à télécharger, aucune licence à joindre. */
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-title: var(--font-body);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-0: #111110;
    --surface-1: #1a1a19;
    --border: #33332f;
    --text-primary: #f0efec;
    --text-secondary: #c3c2b7;
    --accent: #6ea6ff;
    --button: #2468e0;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --s5: #d55181; --s6: #008300; --s7: #9085e9; --s8: #e66767;
    --blank-mark: #4a4945;
    --neutral-mark: #8f8e86;
    --track: #2a2a27;
    --good: #4cc27e;
    --warning: #e0a63a;
    --critical: #f07171;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.5 var(--font-body);
  background: var(--surface-0);
  color: var(--text-primary);
}
a { color: var(--accent); }
h1, h2, h3, .brand, button, .button { font-family: var(--font-title); }
h1 { font-size: 1.7rem; font-weight: 800; margin: 0 0 1rem; line-height: 1.25; }
/* Un trait de la couleur de la marque sous les grands titres. */
h1::after { content: ""; display: block; width: 3rem; height: 3px; margin-top: .45rem; border-radius: 2px; background: var(--brand); }
.hero h1::after { margin-inline: auto; }
h2 { font-size: 1.15rem; font-weight: 700; margin: 0 0 .75rem; }

/* L'en-tête : un bandeau sombre, liseré de la couleur de la marque en bas. */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
  padding: .7rem 1.25rem; color: var(--header-ink);
  background: var(--header-bg);
  border-bottom: 2px solid var(--brand);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--header-ink); text-decoration: none; line-height: 1.1; }
.brand img { height: 32px; width: auto; }
.brand strong { display: block; font-size: 1.25rem; font-weight: 800; letter-spacing: .01em; }
.brand small { display: block; font-size: .7rem; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--header-ink-soft); }
/* Les boutons de l'en-tête : translucides sur le bandeau, la page en cours de la couleur de la marque. */
.account { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }
.top-button {
  display: inline-flex; align-items: center; gap: .45rem; height: 2.25rem; padding: 0 .85rem;
  font: 600 .88rem/1 var(--font-title); color: var(--header-ink-soft); text-decoration: none; cursor: pointer;
  background: rgba(255, 255, 255, .06); border: 1px solid color-mix(in srgb, var(--header-ink-soft) 30%, transparent); border-radius: 999px;
  transition: background .15s, border-color .15s;
}
.top-button:hover { background: color-mix(in srgb, var(--brand) 22%, transparent); border-color: var(--brand); color: var(--header-ink); }
.top-button:focus-visible { outline: 2px solid var(--header-ink); outline-offset: 2px; }
.top-button.active { background: color-mix(in srgb, var(--brand) 28%, transparent); border-color: var(--brand); color: var(--header-ink); }
.top-button.icon-only { width: 2.25rem; padding: 0; justify-content: center; }
.top-button.icon-only:hover { background: color-mix(in srgb, var(--brand-alt) 25%, transparent); border-color: var(--brand-alt); }
.user-chip {
  display: inline-flex; align-items: center; gap: .5rem; height: 2.25rem; padding: 0 .85rem 0 .25rem;
  color: var(--header-ink); font-weight: 600; background: rgba(0, 0, 0, .25); border-radius: 999px; max-width: 14rem;
}
.user-chip img, .avatar-initial { width: 28px; height: 28px; border-radius: 50%; flex: none; box-shadow: 0 0 0 2px var(--brand); }
.avatar-initial { display: grid; place-items: center; background: var(--brand); font: 800 .85rem var(--font-title); }
.user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 480px) {
  .user-name, .top-button:not(.icon-only) span { display: none; }
  .user-chip { padding-right: .25rem; }
  .top-button:not(.icon-only) { width: 2.25rem; padding: 0; justify-content: center; }
}
.dev { margin: 0; padding: .4rem 1rem; background: var(--warning); color: #fff; font-size: .85rem; text-align: center; }

main { max-width: 720px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }
main.wide { max-width: 1100px; }

.card {
  background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; margin: 0 0 1rem;
}
.hero { text-align: center; padding: 0 0 2.25rem; overflow: hidden; }
.hero:not(:has(.banner)) { padding-top: 2.25rem; }
.hero .banner { display: block; width: 100%; height: 110px; object-fit: cover; margin-bottom: 1.75rem; }
.hero > :not(.banner) { margin-inline: 1.25rem; }
footer.bottom { text-align: center; font-size: .8rem; color: var(--text-secondary); padding: 0 1rem 2rem; }
footer.bottom a { color: inherit; }

.muted { color: var(--text-secondary); }
.small { font-size: .85rem; }
.ok { color: var(--good); }
.warn { color: var(--warning); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.flash { padding: .75rem 1rem; border-radius: var(--radius); border: 1px solid; font-weight: 600; }
.flash.ok { color: var(--good); background: color-mix(in srgb, var(--good) 10%, var(--surface-1)); }
.flash.error { color: var(--critical); background: color-mix(in srgb, var(--critical) 10%, var(--surface-1)); }

.status {
  display: inline-block; padding: .15rem .65rem; border-radius: 999px; font-size: .85rem; font-weight: 600;
  border: 1px solid currentColor; margin: 0 0 1rem;
}
.status.draft { color: var(--text-secondary); }
.status.open { color: var(--good); }
.status.closed { color: var(--text-secondary); }
/* Un point « en direct » qui clignote. */
.status.open::before {
  content: ""; display: inline-block; width: .55rem; height: .55rem; margin-right: .4rem; border-radius: 50%;
  background: var(--brand-alt); vertical-align: 1px; animation: live 1.6s ease-in-out infinite;
}
@keyframes live { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .status.open::before { animation: none; } }

/* Boutons et formulaires */
button, .button {
  display: inline-block; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center;
  padding: .55rem 1rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-1); color: var(--text-primary);
}
button:hover, .button:hover { border-color: var(--accent); }
.primary { background: var(--button); border-color: var(--button); color: var(--button-ink); }
.primary:hover { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 30%, transparent); }
.danger { color: var(--critical); }
button.danger:not(.link) { background: var(--brand-alt); border-color: var(--brand-alt); color: #fff; }
.big { padding: .8rem 1.4rem; font-size: 1.05rem; }
.link { background: none; border: none; padding: 0; color: var(--accent); font-weight: 400; text-decoration: underline; }
.link.danger { color: var(--critical); }
form.inline { display: inline; }
input:not([type=radio]):not([type=checkbox]), textarea {
  font: inherit; padding: .5rem .65rem; border-radius: 8px; border: 1px solid var(--border);
  background: var(--surface-0); color: var(--text-primary); min-width: 0;
}
textarea { width: 100%; font-family: ui-monospace, monospace; font-size: .85rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
.row input { flex: 1 1 12rem; }
.row.spread { justify-content: space-between; }
.row.spread h2, .row.spread .status { margin: 0; }
.stack { display: flex; flex-direction: column; gap: .75rem; }
.stack label, .grid-form label { display: flex; flex-direction: column; gap: .25rem; font-weight: 600; }
label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 400; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: .75rem; align-items: end; margin-top: 1rem; }

/* Bulletins */
.voices { padding-left: 1.2rem; }
.ballot fieldset { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 1rem; padding: .75rem 1rem; }
.ballot legend { font-weight: 700; padding: 0 .35rem; }
.choice {
  display: flex; align-items: center; gap: .6rem; padding: .55rem .5rem; border-radius: 6px; cursor: pointer;
}
.choice:hover { background: var(--surface-0); }
.choice input { width: 1.2rem; height: 1.2rem; accent-color: var(--button); }
.choice:has(input:checked) { background: color-mix(in srgb, var(--accent) 12%, var(--surface-1)); font-weight: 600; }
.choice.blank { color: var(--text-secondary); }

/* Administration */
/* Un poste = un bloc encadré ; ses candidats sont dedans, en retrait. */
.positions, .candidates { list-style: none; padding: 0; margin: 0; }
.position { border: 1px solid var(--border); border-radius: 8px; margin: 0 0 .9rem; overflow: hidden; }
.position-head {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .7rem 1rem; background: color-mix(in srgb, var(--brand) 10%, var(--surface-1));
  border-bottom: 1px solid var(--border);
}
.position-head h3 { margin: 0; font-size: 1.15rem; }
.position-body { padding: .75rem 1rem .5rem; }
.eyebrow { display: block; font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-secondary); }
.candidates { margin: .35rem 0 .5rem; }
.candidates li {
  display: flex; align-items: center; gap: .5rem; padding: .4rem .6rem; margin: 0 0 .3rem;
  background: var(--surface-0); border-radius: 6px;
}
.candidates li form { margin-left: auto; }
.candidates li.empty { background: none; padding-left: 0; font-style: italic; }
.person { opacity: .7; }
.link.small { font-size: .85rem; }
.card.new-position { border-style: dashed; }
.quorum { margin: .75rem 0; }
.present-form label { font-weight: 600; flex-basis: 100%; }
.present-form input { flex: 0 1 8rem; }
.quorum-label { font-weight: 700; margin: 0 0 .25rem; }
.quorum.reached .quorum-label { color: var(--good); }
.quorum.missing .quorum-label { color: var(--warning); }
.quorum-meter { display: block; overflow: visible; }
.quorum-meter .track { fill: var(--track); }
.quorum-meter .fill { fill: var(--s1); }
.quorum.reached .quorum-meter .fill { fill: var(--good); }
.quorum-meter .majority, .distribution .majority { stroke: var(--text-primary); stroke-width: 2px; stroke-dasharray: 3 2; }
.quorum-settings summary, .about summary { cursor: pointer; }
select { font: inherit; padding: .5rem .65rem; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-0); color: var(--text-primary); }
.about[open] summary { margin-bottom: .5rem; }
.rich > :first-child { margin-top: 0; }
.rich > :last-child { margin-bottom: 0; }
.rich ul { padding-left: 1.2rem; }
.description-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.description-form textarea { font-family: inherit; font-size: .95rem; }
.card.danger-zone { border-color: color-mix(in srgb, var(--brand-alt) 55%, var(--border)); }
.card.danger-zone h2 { color: var(--brand-alt); }
.kpi { font-size: 1.1rem; }
.kpi strong { font-size: 1.6rem; }
.columns { columns: 12rem; padding-left: 1.2rem; }
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.list th, table.list td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }

/* Résultats : une barre horizontale par réponse, une seule teinte, le gris pour « Contre ». */
.results-head { margin-bottom: 1rem; }
.kpis { display: flex; gap: 1.5rem; flex-wrap: wrap; color: var(--text-secondary); margin: 0; }
.kpis strong { font-size: 1.8rem; color: var(--text-primary); font-variant-numeric: tabular-nums; }
.results-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 460px), 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.results-grid .card { margin: 0; }
.verdict { font-size: 1.05rem; margin: 0 0 .75rem; }
.verdict.elected { color: var(--good); }
.verdict.tie { color: var(--warning); }
.verdict.rejected { color: var(--critical); }
table.bars { width: 100%; border-collapse: collapse; }
table.bars thead th { font-size: .8rem; font-weight: 500; color: var(--text-secondary); text-align: left; padding: 0 .4rem .3rem; }
table.bars tbody th { text-align: left; font-weight: 500; padding: .45rem .4rem; white-space: nowrap; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; }
table.bars td { padding: .45rem .4rem; }
table.bars .bar-cell { width: 100%; min-width: 6rem; }
table.bars .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.bars .pct { color: var(--text-secondary); }
tr.is-winner th { font-weight: 700; }
.bar { display: block; }
.bar .track { fill: var(--track); }
/* Une teinte par candidat (ordre fixe), la même dans la barre de répartition, les barres et la pastille. */
.s1 { --c: var(--s1); } .s2 { --c: var(--s2); } .s3 { --c: var(--s3); } .s4 { --c: var(--s4); }
.s5 { --c: var(--s5); } .s6 { --c: var(--s6); } .s7 { --c: var(--s7); } .s8 { --c: var(--s8); }
.other { --c: var(--neutral-mark); } .blank { --c: var(--blank-mark); }
.bar .fill, .distribution .seg { fill: var(--c); }
/* 2 px de surface entre deux segments voisins. */
.distribution .seg { stroke: var(--surface-1); stroke-width: 2px; }
.distribution { margin: 0 0 .9rem; }
.distribution svg { display: block; overflow: visible; }
.distribution figcaption { margin-top: .2rem; }
.distribution .majority { stroke: var(--text-primary); stroke-width: 2px; stroke-dasharray: 3 2; }
.majority-key { display: inline-block; width: 0; height: .9em; border-left: 2px dashed var(--text-primary); vertical-align: -2px; margin: 0 .2rem 0 .1rem; }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; background: var(--c); margin-right: .45rem; vertical-align: 0; }
tr.blank-row th, tr.blank-row td { color: var(--text-secondary); }
.badge {
  display: inline-block; margin-left: .3rem; padding: 0 .45rem; border-radius: 999px; font-size: .72rem; font-weight: 700;
  color: var(--good); border: 1px solid currentColor; vertical-align: 1px;
}

@media (max-width: 480px) {
  table.bars tbody th { max-width: 8rem; }
  .kpis { gap: 1rem; }
}
@media print {
  .top, .no-print, .dev { display: none; }
  body { background: #fff; }
}

/* Les bulletins et les résultats portent le liseré bleu du bandeau. */
.card.ballot, .card.result { border-top: 3px solid var(--brand); }
.kpis strong, .kpi strong { font-family: var(--font-title); font-weight: 800; }
.card.rich li + li { margin-top: .35rem; }
