:root {
  --paper: #f6f1e6;
  --paper-2: #fbf8f0;
  --ink: #15213b;
  --ink-soft: #50596d;
  --ink-faint: #8a8f9a;
  --bleu: #1f3a7a;
  --bleu-bright: #2b54b0;
  --rouge: #b01219;
  --line: rgba(21, 33, 59, 0.14);
  --line-strong: rgba(21, 33, 59, 0.28);
  --shadow: 0 1px 0 rgba(21,33,59,.05), 0 18px 40px -28px rgba(21,33,59,.45);
  --radius: 4px;
  --serif: "Spectral", Georgia, "Times New Roman", serif;
  --display: "Fraunces", Georgia, serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(43,84,176,.06), transparent 60%),
    radial-gradient(900px 500px at -10% 10%, rgba(176,18,25,.05), transparent 55%),
    var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.tricolore {
  height: 4px;
  background: linear-gradient(90deg,
    var(--bleu) 0 33.33%, var(--paper-2) 33.33% 66.66%, var(--rouge) 66.66% 100%);
  position: sticky; top: 0; z-index: 50;
}

/* ---------- masthead ---------- */
.masthead {
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(180deg, var(--paper-2), transparent);
}
.masthead-inner {
  max-width: 1080px; margin: 0 auto; padding: 38px 24px 30px;
  display: flex; justify-content: space-between; align-items: flex-end; gap: 32px;
  flex-wrap: wrap;
}
.kicker {
  margin: 0 0 10px; font-family: var(--mono);
  font-size: 11px; letter-spacing: .22em; text-transform: uppercase;
  color: var(--bleu);
}
.masthead h1 {
  margin: 0; font-family: var(--display);
  font-weight: 900; font-size: clamp(34px, 6vw, 58px); line-height: .98;
  letter-spacing: -.02em;
}
.masthead h1 em { font-style: italic; font-weight: 400; color: var(--rouge); }
.lede { margin: 14px 0 0; max-width: 46ch; color: var(--ink-soft); font-size: 17px; }

.masthead-meta {
  font-family: var(--mono); font-size: 12px; color: var(--ink-soft);
  text-align: right; line-height: 1.9; border-left: 1px solid var(--line); padding-left: 20px;
}
.masthead-meta b { color: var(--ink); font-weight: 500; }
.masthead-meta .big {
  display: block; font-family: var(--display); font-size: 30px; font-weight: 600;
  color: var(--ink); letter-spacing: -.01em;
}

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky; top: 4px; z-index: 40;
  background: rgba(246,241,230,.86); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.toolbar-inner {
  max-width: 1080px; margin: 0 auto; padding: 12px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.breadcrumb {
  list-style: none; margin: 0; padding: 0; display: flex; gap: 8px; align-items: center;
  font-size: 14px; flex-wrap: wrap;
}
.breadcrumb li { display: flex; align-items: center; gap: 8px; }
.breadcrumb li::after { content: "/"; color: var(--ink-faint); }
.breadcrumb li:last-child::after { content: ""; }
.breadcrumb button {
  background: none; border: none; padding: 0; cursor: pointer;
  font-family: var(--serif); font-size: 14px; color: var(--bleu);
  border-bottom: 1px solid transparent;
}
.breadcrumb button:hover { border-bottom-color: var(--bleu); }
.breadcrumb .here { color: var(--ink); font-weight: 600; }

.search { position: relative; display: flex; flex-direction: column; }
.search input {
  width: min(420px, 60vw); padding: 9px 14px; font-family: var(--serif); font-size: 15px;
  color: var(--ink); background: var(--paper-2);
  border: 1px solid var(--line-strong); border-radius: var(--radius); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--bleu); box-shadow: 0 0 0 3px rgba(43,84,176,.14); }
.search input::placeholder { color: var(--ink-faint); }
.search-hint {
  position: absolute; right: 4px; top: -18px; font-family: var(--mono);
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint);
}

/* ---------- view ---------- */
.view { max-width: 1080px; margin: 0 auto; padding: 34px 24px 60px; }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; margin-bottom: 22px; }
.section-head h2 {
  margin: 0; font-family: var(--display); font-weight: 600;
  font-size: clamp(24px, 4vw, 34px); letter-spacing: -.01em;
}
.section-head .count { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); white-space: nowrap; }

/* card grid (regions / departements) */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  position: relative; text-align: left; cursor: pointer;
  background: var(--paper-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 18px 16px;
  box-shadow: var(--shadow); transition: transform .18s ease, border-color .18s, box-shadow .18s;
  display: flex; flex-direction: column; gap: 12px;
  animation: rise .5s cubic-bezier(.2,.7,.2,1) both;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); }
.card:focus-visible { outline: 2px solid var(--bleu); outline-offset: 2px; }
.card .chip {
  align-self: flex-start; font-family: var(--mono); font-size: 11px; letter-spacing: .1em;
  color: var(--bleu); background: rgba(43,84,176,.08);
  border: 1px solid rgba(43,84,176,.2); border-radius: 100px; padding: 2px 9px;
}
.card h3 {
  margin: 0; font-family: var(--display); font-weight: 600; font-size: 21px; line-height: 1.1;
  letter-spacing: -.01em;
}
.card .meta { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); display: flex; gap: 14px; }
.card .arrow { position: absolute; top: 16px; right: 16px; color: var(--ink-faint); transition: transform .18s, color .18s; }
.card:hover .arrow { transform: translateX(3px); color: var(--bleu); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* table (communes / resultats) */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--paper-2); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
thead th {
  text-align: left; font-family: var(--mono); font-weight: 500; font-size: 11px;
  letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft);
  padding: 12px 16px; border-bottom: 1px solid var(--line-strong); background: rgba(21,33,59,.03);
}
tbody td { padding: 11px 16px; border-bottom: 1px solid var(--line); vertical-align: baseline; }
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(43,84,176,.05); }
.col-cp { font-family: var(--mono); font-size: 13px; color: var(--ink-soft); white-space: nowrap; }
.col-cp .more { color: var(--ink-faint); }
.col-commune { font-weight: 500; }
.col-commune .insee { font-family: var(--mono); font-size: 11px; color: var(--ink-faint); margin-left: 8px; }
.col-maire .prenom { color: var(--ink-soft); }
.col-maire .nom { font-variant-caps: small-caps; letter-spacing: .02em; font-weight: 500; }
.col-loc { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }
.col-kit { white-space: nowrap; }
.col-kit .dl {
  font-family: var(--mono); font-size: 12px; text-decoration: none;
  color: var(--bleu); border: 1px solid rgba(43,84,176,.32);
  background: rgba(43,84,176,.06); border-radius: 100px; padding: 3px 10px;
  transition: background .12s, color .12s, border-color .12s; white-space: nowrap;
}
.col-kit .dl:hover { background: var(--bleu); color: #fff; border-color: var(--bleu); }

.badge-sexe {
  font-family: var(--mono); font-size: 11px; font-weight: 500; letter-spacing: .05em;
  padding: 2px 8px; border-radius: 100px; border: 1px solid;
}
.badge-sexe.F { color: var(--rouge); border-color: rgba(176,18,25,.35); background: rgba(176,18,25,.07); }
.badge-sexe.M { color: var(--bleu); border-color: rgba(43,84,176,.32); background: rgba(43,84,176,.07); }

/* pagination */
.pager { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 22px; font-family: var(--mono); font-size: 13px; }
.pager button {
  font-family: var(--mono); font-size: 13px; color: var(--ink);
  background: var(--paper-2); border: 1px solid var(--line-strong); border-radius: var(--radius);
  padding: 6px 12px; cursor: pointer; transition: background .12s, color .12s, border-color .12s;
}
.pager button:hover:not(:disabled) { background: var(--bleu); color: #fff; border-color: var(--bleu); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager .status { color: var(--ink-soft); padding: 0 8px; }

.empty { text-align: center; padding: 60px 20px; color: var(--ink-soft); font-family: var(--serif); font-size: 18px; }
.empty b { color: var(--ink); }

/* colophon */
.colophon {
  max-width: 1080px; margin: 0 auto; padding: 26px 24px 50px;
  border-top: 1px solid var(--line); color: var(--ink-soft); font-size: 13px;
}
.colophon code { font-family: var(--mono); font-size: 12px; color: var(--ink); }
.colophon-sub { color: var(--ink-faint); margin-top: 4px; }

@media (max-width: 620px) {
  .masthead-meta { text-align: left; border-left: none; padding-left: 0; }
  thead th { top: 70px; }
  .col-loc, .col-cp .more { display: none; }
}

.badge-nuance {
  font-family: var(--mono); font-size: 11px; padding: 2px 8px; border-radius: 100px;
  border: 1px solid var(--line-strong); color: var(--ink-soft);
}
