/* Styles propres à l'écran « Carte » (section 3.4 de docs/design-v3.md), classes préfixées .carte-.
   Les composants partagés (.map-view, .map-wrap, .map-ctl, .map-chip, .map-selection, .map-scale, .card,
   .card-footer, .legend-grid, .expander, .list, .list-row, .sheet, .skeleton, .empty) viennent de style.css.
   Aucune couleur politique ici : les remplissages de la carte et les pastilles sont posés en ligne par le
   module depuis INDEX.blocs. Aucun rayon supérieur à 16 px, aucun dégradé (l'échelle continue est posée en
   ligne par le module, une teinte vers --surface). */

/* ---------------------------------------------------------------- mise en page : une colonne, puis deux à 1080 px */
.carte-layout { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }
.carte-map-col, .carte-side { display: flex; flex-direction: column; gap: var(--s4); min-width: 0; }

/* carte bord à bord (le débord négatif vient de .map-view) ; la hauteur est celle de .map-wrap (62 dvh, 520 px à 720) */
.carte-view { margin-bottom: calc(-1 * var(--s4)); }
.carte-map { position: relative; min-width: 0; }
.carte-view .map-chip { max-width: calc(100% - 64px); }

/* squelette pendant le chargement des contours ou des distributions : même hauteur que la carte, pas de saut */
.carte-loading { position: relative; height: 62dvh; min-height: 320px; padding: var(--s2); display: flex; flex-direction: column; }
.carte-loading .skeleton { flex: 1; min-height: 0; border-radius: var(--r-8); }
.carte-loading-text { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; font-size: var(--fs-13); color: var(--muted); pointer-events: none; }
.carte-error { min-height: 200px; justify-content: center; }

/* barre de sélection : bord à bord sous la carte, texte tronqué proprement, aide en 12 px */
.carte-selection { margin: 0 calc(-1 * var(--s4)); }
.carte-selection > span:first-child { min-width: 0; }
.carte-selection b { overflow-wrap: anywhere; }
.carte-selection small { overflow-wrap: anywhere; }
.carte-selection .carte-help { font-size: var(--fs-12); color: var(--muted); margin-top: 2px; }
.carte-selection.is-fresh { animation: carte-rise 300ms var(--ease); }
@keyframes carte-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

/* légende et échelle */
.carte-card { min-width: 0; }
.carte-legend-na .sw { border: 1px solid var(--line-2); }
.carte-scale { flex-wrap: wrap; row-gap: var(--s1); }
.carte-scale .num { font-size: var(--fs-13); color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.carte-scale-bound small { font-size: var(--fs-12); color: var(--muted); font-weight: 500; }
.carte-scale i { min-width: 80px; }
.carte-scale .meta { flex-basis: 100%; }

/* mode « Évolution » : échelle divergente (barre, puis bornes signées et zéro dessous), pastille hachurée des
   unités non comparables (même trame que .sw-na de style.css, trait --ref lisible en clair comme en sombre) */
.carte-div { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.carte-div-bar { display: block; height: 10px; border-radius: 5px; }
.carte-div-ticks { display: grid; grid-template-columns: 1fr auto 1fr; gap: var(--s2); font-size: var(--fs-13); color: var(--ink-2); font-weight: 500; white-space: nowrap; }
.carte-div-ticks span:last-child { text-align: right; }
.carte-div .meta { font-size: var(--fs-12); color: var(--muted); }
.carte-sw-hatch { background: repeating-linear-gradient(45deg, var(--ref) 0 1.5px, var(--na-2) 1.5px 4px); border: 1px solid var(--line-2); }
.carte-ref-title { font-size: var(--fs-13); font-weight: 600; color: var(--muted); padding: var(--s1) var(--s1) 0; }

/* ---------------------------------------------------------------- feuille « Réglages de la carte » */
.carte-settings { display: flex; flex-direction: column; gap: var(--s5); }
.carte-years { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: var(--s2); }
.carte-year { padding: 11px var(--s2); line-height: 1.45; border: 1px solid transparent; border-radius: var(--r-8); background: var(--fill); color: var(--ink); font-size: var(--fs-15); font-weight: 500; font-variant-numeric: tabular-nums; transition: background-color var(--d-fast), border-color var(--d-fast), color var(--d-fast); }
.carte-year:active { background: var(--fill-2); transform: scale(.96); }
.carte-year[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.carte-sw-neutral { background: var(--surface-3); border: 1px solid var(--line-2); }
.carte-sw-accent { background: var(--accent); }
.carte-settings .list-row-subtitle { overflow-wrap: anywhere; }

/* interrupteur (role="switch") : ligne de liste avec une piste 44 x 26 px à rayon 8, sans pilule */
.carte-switch { display: flex; align-items: center; gap: var(--s3); width: 100%; padding: 14px var(--s4); border: 0; border-radius: 18px; background: var(--surface-2); color: var(--ink); text-align: left; transition: background-color var(--d-fast); }
.carte-switch:active { background: var(--fill-2); }
.carte-switch-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.carte-switch-label { font-size: var(--fs-15); font-weight: 500; line-height: 1.3; }
.carte-switch-sub { font-size: var(--fs-13); color: var(--muted); line-height: 1.35; }
.carte-switch-knob { flex: none; position: relative; width: 51px; height: 31px; border-radius: 16px; background: var(--fill-2); border: 0; transition: background-color var(--d-base) var(--ease); }
.carte-switch-knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .22); transition: transform 320ms var(--ease-spring); }
.carte-switch[aria-checked="true"] .carte-switch-knob { background: var(--ok); }
.carte-switch[aria-checked="true"] .carte-switch-knob::after { transform: translateX(20px); }

/* ---------------------------------------------------------------- carte plein écran (feuille .is-fullscreen) */
.carte-full { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.carte-full-map { position: relative; flex: 1; min-height: 0; background: var(--surface); }
.carte-full-map .carte-map, .carte-full-map .map-wrap { height: 100%; min-height: 0; }
.carte-full .carte-selection { margin: 0; flex: none; border-bottom: 0; }

/* ---------------------------------------------------------------- bureaux de vote */
.carte-bureaux { border-radius: var(--r-8); }
.carte-bureau .list-row-subtitle { display: flex; flex-direction: column; gap: 1px; }
.carte-bureau-line { display: block; overflow-wrap: anywhere; }
.carte-bureaux .list-row-value { font-size: var(--fs-13); color: var(--accent); }
.carte-bureaux .list-row-value small { color: var(--muted); }
.carte-bureaux a.list-row .list-row-value span:first-child { text-decoration: underline; text-underline-offset: 2px; }
.carte-about { font-size: var(--fs-13); color: var(--ink-2); line-height: 1.45; }

/* ---------------------------------------------------------------- carte par bureau de vote (web/js/bureaux-carte.js) */
.carte-bv-map { background: var(--surface); border-radius: 18px; overflow: hidden; }
.carte-bv-svg { display: block; width: 100%; height: auto; }
.carte-bv-area { stroke: var(--surface); stroke-width: 1; stroke-linejoin: round; outline: none; }
.carte-bv-area.nodata { fill: var(--na-2); }
.carte-bv-area:focus-visible { stroke: var(--focus); stroke-width: 2.5; }
.carte-bv-sel { min-height: 64px; grid-template-columns: minmax(0, 1fr); }
.carte-bv-sel small.meta { color: var(--muted); }
.carte-bv-legend:empty { display: none; }

/* ---------------------------------------------------------------- 720 px et plus */
@media (min-width: 720px) {
  .carte-selection { margin: 0 calc(-1 * var(--s5)); }
  .carte-loading { height: 520px; }
  .carte-scale .meta { flex-basis: auto; }
}

/* ---------------------------------------------------------------- 1080 px et plus : carte à gauche (60 %), le reste à droite */
@media (min-width: 1080px) {
  /* la colonne de contenu fait 1120 px à partir de 1080 px (style.css) : la carte tient à gauche, la légende à droite */
  .carte-layout { width: auto; margin-left: 0; display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: var(--s5); align-items: start; }
  .carte-view { margin: 0; border-radius: var(--r-12); overflow: hidden; border: 0; box-shadow: var(--shadow-1); }
  .carte-view .map-wrap { height: min(70dvh, 720px); min-height: 520px; }
  .carte-loading { height: min(70dvh, 720px); min-height: 520px; }
  .carte-selection { margin: 0; border: 0; border-radius: var(--r-12); box-shadow: var(--shadow-1); }
  .carte-side .legend-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ---------------------------------------------------------------- mouvement réduit et impression */
@media (prefers-reduced-motion: reduce) {
  .carte-selection.is-fresh { animation: none; }
  .carte-switch-knob, .carte-switch-knob::after, .carte-year { transition: none; }
}
@media print {
  .carte-layout { display: flex; width: auto; margin: 0; }
  .carte-selection { border: 1px solid #bbb; margin: 0; }
  .carte-help { display: none; }
}
