/* ==========================================================================
   site.css — M5 stage 2, visual direction "field guide" (docs/decisions.md D-50,
   D-50a, D-51, D-56; contracts C4; PRD NFR-4 responsive, NFR-5 WCAG 2.1 AA, NFR-8
   colour + text, FR-12 print).

   Plain CSS, no build step, no framework. **Desktop is the default presentation**
   (D-50a, owner O-6: "do not default the display to mobile"): every rule below
   describes the wide layout — a ≈ 84 rem container, the report as a two-column
   composition (card grid left, sticky map right), the home with the pin map beside
   the "what a report contains" copy — and `@media (max-width: …)` blocks adapt it
   down: ≤ 64 rem one column (cards still two abreast when they fit), ≤ 48 rem the
   phone presentation (one column, DOM order, tighter paddings and type). The
   desktop placement is done with `grid-template-areas` so the DOM keeps the D-52
   reading order (header → cards → limits → map → links) for print, screen readers
   and phones. Content pages keep a reading column (`--measure`) — long prose is
   not "mobile". The **report page** (`/rapport/<id>`) is the reference page for
   the O-6 checkpoint; every other page reuses its components.

   Class hooks used by the templates (do not rename; stage 1 contract):
     .site-header .site-brand .site-nav .site-main .site-footer .footer-line .draft-banner
     .skip-link .visually-hidden .form-error .help .htmx-indicator
     .search .search-form .suggestions .suggestions__list .suggestions__empty
     .suggestion .suggestion__button .suggestion__label .suggestion__type
     .pin .pin-form .pin-form__position .how
     .report-header .precision .report-commune .report-meta .report-note .report-address
     .breadcrumb .cards .card .card--<layer> .card--<state> .card__header .card__title
     .card__subtitle .card__body .card__primary .card__primary-label .card__primary-value
     .card__precision-note .card__footer .card__detail
     .chip .chip--very_low .chip--low .chip--moderate .chip--high .chip--neutral
     .badge .badge--measured .badge--modelled .nature .source .source__name .source__date
     .source__licence .explanation .caveats .metrics .metrics__row .metrics__row--primary
     .not-told .report-map .report-links
     .map .map--small .map__fallback .map__description .map__print-note .map__toggles
     .map__legend .map__toggles-title .map__toggles-list .map__swatch .map__swatch--<key> .map__attribution
     .items .items__list .item .item__label .item__attrs .stats .stats__table
     .dataset .dataset__facts .dataset__caveat .thresholds .soon .page-error
     .signal-form .signal-report .field .field--check .field--error .hp (M6)
   Body classes set by the views: .page-home .page-report .page-detail .page-commune
     .page-content .page-donnees .page-science … .precision-<exact|street|commune>
   Tokens read by static/js/map.js: --marker --layer-antennas --layer-coverage
   --layer-hv-lines --layer-turbines --layer-noise --layer-crops.

   Sections: 1 tokens · 2 fonts · 3 base · 4 chrome (header, footer, banner, main) ·
   5 components (buttons, forms, chips, badges) · 6 report page · 7 map · 8 home ·
   9 detail · 10 commune and content pages · 11 adaptations (≤ 64 rem, ≤ 48 rem) · 12 print.
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  color-scheme: light dark;

  /* ground, ink, accent (D-50) */
  --ground: #f7f4ee;          /* warm off-white page */
  --surface: #fffdf9;         /* cards, inputs */
  --surface-tint: #efebe2;    /* quiet blocks (limits, map placeholder) */
  --ink: #1b1b18;             /* near-black text */
  --ink-muted: #5c5a54;       /* 6.3:1 on --ground */
  --border: #ddd8ce;
  --border-strong: #b8b2a6;
  --accent: #2c5a4a;          /* muted deep green, actions and links: 7.2:1 on --ground */
  --accent-deep: #1f4a3a;
  --accent-ink: #ffffff;      /* text on --accent: 7.9:1 */
  --accent-soft: #e4ede8;     /* tinted background for the "mesuré" badge */
  --focus: #2c5a4a;
  --error: #8a2f2a;           /* form errors: text only, never a rating */
  --marker: #1b1b18;

  /* rating ramp, C4 light column; the ink of each chip is chosen for ≥ 4.5:1 */
  --rating-very_low: #e8eef2;
  --rating-low: #b9cbd6;
  --rating-moderate: #7e9aac;
  --rating-high: #3f5e73;
  --rating-very_low-ink: #1b1b18;   /* 14.8:1 */
  --rating-low-ink: #1b1b18;        /* 10.3:1 */
  --rating-moderate-ink: #1b1b18;   /* 5.8:1 */
  --rating-high-ink: #ffffff;       /* 6.9:1 */

  /* overlay colours (map.js reads these; reports/couches.py carries the fallbacks) */
  --layer-antennas: #7f3b8a;
  --layer-coverage: #2b6cb0;
  --layer-hv-lines: #b7791f;
  --layer-turbines: #2f855a;
  --layer-noise: #c05621;
  --layer-crops: #805ad5;

  /* type */
  --font-display: "Source Serif 4", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --step--1: 0.875rem;   /* 14 px — meta, licences */
  --step-0: 1.0625rem;   /* 17 px — body */
  --step-1: 1.25rem;     /* 20 px — card titles */
  --step-2: 1.5rem;      /* 24 px — h2 */
  --step-3: 1.875rem;    /* 30 px — h1 mobile, primary values */
  --step-4: 2.375rem;    /* 38 px — h1 desktop */
  --leading: 1.55;
  --leading-tight: 1.2;

  /* spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  --radius: 6px;
  --radius-lg: 10px;
  --container: 84rem;    /* desktop content width, 1344 px (D-50a) */
  --gutter: clamp(1rem, 4vw, 3rem);   /* side gutters of header, main and footer */
  --measure: 46rem;      /* reading column of the content pages (long prose) */
  --sticky-top: 1rem;    /* offset of the sticky map beside the cards */
  --touch: 44px;         /* minimum target size */
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #17191b;
    --surface: #1f2225;
    --surface-tint: #24282b;
    --ink: #edeae3;
    --ink-muted: #b0aca3;       /* 7.8:1 on --ground */
    --border: #34383c;
    --border-strong: #5a6066;
    --accent: #8cc1aa;          /* 8.7:1 on --ground */
    --accent-deep: #9bcbb6;
    --accent-ink: #17191b;
    --accent-soft: #24332c;
    --focus: #8cc1aa;
    --error: #e59a94;
    --marker: #edeae3;

    /* C4 dark column; moderate and high take the dark ink (light ink would be 3.4:1) */
    --rating-very_low: #26313a;
    --rating-low: #3d5566;
    --rating-moderate: #5f8299;
    --rating-high: #8fb3cc;
    --rating-very_low-ink: #edeae3;   /* 11.0:1 */
    --rating-low-ink: #edeae3;        /* 6.5:1 */
    --rating-moderate-ink: #0f1113;   /* 4.6:1 */
    --rating-high-ink: #0f1113;       /* 8.6:1 */

    --layer-antennas: #c98bd4;
    --layer-coverage: #7fb0e6;
    --layer-hv-lines: #e0a94a;
    --layer-turbines: #6fc194;
    --layer-noise: #ef8a5a;
    --layer-crops: #b39bea;
  }
}


/* --------------------------------------------------------------------------
   2. Fonts (self-hosted, static/fonts/README.md)
   -------------------------------------------------------------------------- */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/Inter-Regular-latin.677f86e49a6a.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/Inter-Regular-latin-ext.a2fb86941782.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/Inter-SemiBold-latin.881e63f7093d.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/Inter-SemiBold-latin-ext.14c0ef31730e.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/SourceSerif4-Regular-latin.4f9c6bd97bfa.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/SourceSerif4-Regular-latin-ext.16b212459069.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/SourceSerif4-Semibold-latin.8d1194b1a7e2.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "Source Serif 4";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/SourceSerif4-Semibold-latin-ext.74e879899d29.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}



/* --------------------------------------------------------------------------
   3. Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: var(--leading);
  font-feature-settings: "tnum" 1;   /* tabular figures: distances and counts line up */
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3);
  text-wrap: balance;
}
h1 { font-size: var(--step-4); margin-bottom: var(--space-4); }
h2 { font-size: var(--step-2); margin-top: var(--space-7); }
h3 { font-size: var(--step-1); }

p, ul, ol, dl, table { margin: 0 0 var(--space-4); }
ul, ol { padding-left: 1.25rem; }
li + li { margin-top: var(--space-1); }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}
a:hover { text-decoration-thickness: 2px; }

strong { font-weight: 600; }
small { font-size: var(--step--1); }
time { white-space: nowrap; }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-weight: 600; }
th, td { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--border); vertical-align: top; }
caption { text-align: left; font-weight: 600; padding-bottom: var(--space-2); font-family: var(--font-display); font-size: var(--step-1); }

/* focus: one visible ring everywhere (WCAG 2.4.7); keyboard only where supported */
:focus { outline: 3px solid var(--focus); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

/* reduced motion */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* utilities */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-4);
  top: -100px;
  z-index: 10;
  padding: var(--space-3) var(--space-4);
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: none;
  font-weight: 600;
}
.skip-link:focus { top: 0; }


/* --------------------------------------------------------------------------
   4. Chrome: header, footer, draft banner, main container
   Header and footer are full-width bands whose content aligns with the main
   container: the horizontal padding is the gutter or the centring remainder,
   whichever is larger.
   -------------------------------------------------------------------------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-6);
  padding: var(--space-4) max(var(--gutter), calc((100% - var(--container)) / 2));
  border-bottom: 1px solid var(--border);
  background: var(--ground);
}
.site-brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.site-brand a { color: var(--ink); text-decoration: none; display: inline-block; padding: var(--space-2) 0; }
.site-brand a:hover { color: var(--accent); }
.site-nav { margin-left: auto; }
.site-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-5);
}
.site-nav li + li { margin-top: 0; }
.site-nav a {
  display: inline-block;
  padding: var(--space-3) 0;
  min-height: var(--touch);
  color: var(--ink);
  text-decoration: none;
  font-size: 1rem;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { border-bottom-color: var(--accent); color: var(--accent); }

.draft-banner {
  margin: 0;
  padding: var(--space-2) var(--gutter);
  background: var(--surface-tint);
  border-bottom: 1px solid var(--border);
  font-size: var(--step--1);
  color: var(--ink-muted);
  text-align: center;
}
.draft-banner p { margin: 0; }

.site-main {
  flex: 1;
  width: 100%;
  max-width: calc(var(--container) + 2 * var(--gutter));
  margin: 0 auto;
  padding: var(--space-6) var(--gutter) var(--space-8);
}
.site-main > h1:first-child { margin-top: 0; }
.site-main > h1 + p { font-size: var(--step-1); line-height: 1.45; color: var(--ink-muted); }

/* content pages (science, mesure-anfr, legal…): a reading column, centred */
.page-content .site-main { max-width: calc(var(--measure) + 2 * var(--gutter)); }
.page-donnees .site-main { max-width: calc(var(--container) + 2 * var(--gutter)); }

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3) var(--space-7);
  border-top: 1px solid var(--border);
  padding: var(--space-5) max(var(--gutter), calc((100% - var(--container)) / 2)) var(--space-6);
  font-size: var(--step--1);
  color: var(--ink-muted);
}
.footer-line { margin: 0; flex: 1 1 24rem; max-width: 64ch; }
.site-footer nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-5);
}
.site-footer nav li + li { margin-top: 0; }
.site-footer nav a { display: inline-block; padding: var(--space-3) 0; color: var(--ink-muted); }
.site-footer nav a:hover { color: var(--accent); }


/* --------------------------------------------------------------------------
   5. Components: buttons, forms, chips, badges
   -------------------------------------------------------------------------- */
button, .button {
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch);
  padding: var(--space-2) var(--space-5);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--accent-deep); border-color: var(--accent-deep); }
button[type="button"] {
  background: transparent;
  color: var(--accent);
}
button[type="button"]:hover { background: var(--accent-soft); color: var(--accent-deep); }
button:disabled, button:disabled:hover {
  background: var(--surface-tint);
  border-color: var(--border);
  color: var(--ink-muted);
  cursor: not-allowed;
}

label { display: block; font-weight: 600; margin-bottom: var(--space-2); }
input[type="search"], input[type="text"], input[type="email"], textarea, select {
  font: inherit;
  width: 100%;
  min-height: 3rem;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
}
input::placeholder { color: var(--ink-muted); opacity: 1; }
input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; }
input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1.25rem;
  height: 1.25rem;
  margin: 0;
  flex: none;
}
.help { font-size: var(--step--1); color: var(--ink-muted); margin: var(--space-2) 0 0; }
.form-error {
  color: var(--error);
  font-weight: 600;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--error);
  border-radius: var(--radius);
  background: var(--surface);
}
.htmx-indicator { color: var(--ink-muted); }

/* correction form (M6, /signaler): stacked fields, inline checkbox, CSS-hidden honeypot */
.signal-form { display: grid; gap: var(--space-5); max-width: 40rem; }
.signal-form .field { display: grid; gap: var(--space-2); }
.signal-form .field label { margin: 0; }
.signal-form .field .help { margin: 0; }
.signal-form .field .form-error { padding: var(--space-2) var(--space-3); }
.signal-form .field--check { grid-template-columns: auto 1fr; align-items: start; column-gap: var(--space-3); }
.signal-form .field--check input { margin-top: 0.2em; }
.signal-form .field--check label { font-weight: 500; }
.signal-form .field--check .form-error { grid-column: 1 / -1; }
.signal-form .field--error label { color: var(--error); }
.signal-form button { justify-self: start; }
.signal-form .hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.signal-report { color: var(--ink-muted); }

/* rating chip (C4, D-51, NFR-8): colour AND the text "Présence : <label>" */
.chip {
  display: inline-block;
  margin: 0;
  padding: var(--space-1) var(--space-3);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.35;
  white-space: nowrap;
  background: var(--surface-tint);
  color: var(--ink);
}
.chip--very_low { background: var(--rating-very_low); color: var(--rating-very_low-ink); }
.chip--low { background: var(--rating-low); color: var(--rating-low-ink); }
.chip--moderate { background: var(--rating-moderate); color: var(--rating-moderate-ink); }
.chip--high { background: var(--rating-high); color: var(--rating-high-ink); }
.chip--neutral { background: transparent; border-color: var(--border-strong); color: var(--ink-muted); }

/* measured / modelled badge and the "nature" word */
.badge {
  display: inline-block;
  padding: 0.1rem var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-size: var(--step--1);
  font-weight: 600;
  line-height: 1.4;
}
.badge--measured { background: var(--accent-soft); color: var(--accent-deep); }
.badge--modelled { border-color: var(--border-strong); color: var(--ink-muted); }
.nature { font-size: var(--step--1); color: var(--ink-muted); }


/* --------------------------------------------------------------------------
   6. Report page (O-6 reference) and commune page — desktop composition (D-50a)

   .site-main is a two-column grid: the report header spans both columns; the six
   cards (two abreast) sit in the left column (62 %); the map section sits in the
   right column (38 %), sticky, so the visitor reads cards and map together; "Ce que
   ce rapport ne dit pas" and "Pour aller plus loin" span the full width below. The
   DOM order stays D-52 (header → cards → limits → map → links): only the areas move.
   -------------------------------------------------------------------------- */
.page-report .site-main,
.page-commune .site-main {
  display: grid;
  grid-template-columns: minmax(0, 62fr) minmax(0, 38fr);
  grid-template-areas:
    "header header"
    "cards  map"
    "limits limits"
    "links  links";
  column-gap: var(--space-6);
  align-items: start;
}
.report-header { grid-area: header; }
.cards { grid-area: cards; }
.not-told { grid-area: limits; }
.report-map { grid-area: map; }
.report-links { grid-area: links; }

.report-header { margin-bottom: var(--space-6); }
.report-header h1 { margin-bottom: var(--space-2); }
.report-header p { margin-bottom: var(--space-1); }
.precision {
  display: inline-block;
  font-weight: 600;
  color: var(--accent-deep);
}
.precision::before {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-right: var(--space-2);
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 0.05em;
}
.report-commune, .report-meta, .report-address { color: var(--ink-muted); font-size: var(--step--1); }
.report-note {
  max-width: 78ch;
  margin-top: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-left: 3px solid var(--border-strong);
  background: var(--surface-tint);
  border-radius: 0 var(--radius) var(--radius) 0;
}

/* card grid: as many 20 rem columns as fit (two in the report column on a desktop,
   one on a phone); equal-height panels, the footer pushed to the bottom */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr));
  gap: var(--space-5);
  align-items: stretch;
}
.cards > h2 { grid-column: 1 / -1; margin-top: 0; margin-bottom: 0; }

.card {
  display: flex;
  flex-direction: column;
  container-type: inline-size;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: 0 1px 0 rgba(27, 27, 24, 0.04);
}
.card__body { flex: 1 1 auto; }
.card__header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2) var(--space-4);
  margin-bottom: var(--space-4);
}
.card__title { margin: 0; flex: 1 1 10rem; }
.card__subtitle {
  flex-basis: 100%;
  order: 3;
  margin: 0;
  font-size: var(--step--1);
  color: var(--ink-muted);
}
.card__header .chip { order: 2; }

.card__primary {
  display: grid;
  gap: var(--space-1);
  margin-bottom: var(--space-4);
}
.card__primary-label { font-size: var(--step--1); color: var(--ink-muted); }
.card__primary-value {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--step-3);
  line-height: var(--leading-tight);
  letter-spacing: -0.01em;
}
.card__primary-value--none { font-size: var(--step-1); font-weight: 600; color: var(--ink-muted); }
.card__precision-note { font-size: var(--step--1); color: var(--ink-muted); }

.explanation { margin-bottom: var(--space-4); }

.caveats {
  list-style: none;
  padding: 0 0 0 var(--space-4);
  margin: 0 0 var(--space-4);
  border-left: 3px solid var(--border);
  font-size: var(--step--1);
  color: var(--ink-muted);
}
.caveats li + li { margin-top: var(--space-2); }

/* metrics: two columns inside the card; one when the card's content box is narrower
   than 20 rem (container query on .card; browsers without it keep two columns) */
.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-2) var(--space-5);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) 0 0;
  border-top: 1px dashed var(--border);
}
@container (max-width: 19.99rem) {
  .metrics { grid-template-columns: 1fr; }
}
.metrics__row { display: grid; gap: 0; }
.metrics__row dt { font-size: var(--step--1); color: var(--ink-muted); }
.metrics__row dd { margin: 0; }
.metrics__row--primary dd { font-weight: 600; }

.card__footer {
  border-top: 1px solid var(--border);
  padding-top: var(--space-3);
  font-size: var(--step--1);
  color: var(--ink-muted);
}
.card__footer p { margin: 0; }
.source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}
.source__licence { flex-basis: 100%; }
.card__detail { margin-top: var(--space-3) !important; }
.card__detail a {
  display: inline-block;
  padding: var(--space-2) 0;
  font-weight: 600;
  font-size: 1rem;
}
.card__detail a::after { content: " →"; }

/* state variants: nothing alarming, just a quieter title for missing data */
.card--no_data .card__title, .card--not_mapped .card__title { color: var(--ink-muted); }

/* limits block, full width: title on the left, the paragraph in two text columns */
.not-told {
  display: grid;
  grid-template-columns: minmax(12rem, 18rem) minmax(0, 1fr);
  gap: var(--space-4) var(--space-7);
  align-items: start;
  margin-top: var(--space-7);
  padding: var(--space-6);
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.not-told h2 { margin: 0; font-size: var(--step-2); }
.not-told p { margin: 0; columns: 2; column-gap: var(--space-6); }
.not-told p:last-child { margin-bottom: 0; }

/* map section beside the cards: sticky while the cards scroll */
.report-map {
  position: sticky;
  top: var(--sticky-top);
  margin-top: 0;
}
.report-map h2 { margin-top: 0; }
.report-map > p { color: var(--ink-muted); }
.report-map .map { height: min(60vh, 36rem); aspect-ratio: auto; }

/* "Pour aller plus loin": the links spread over the width, one rule per row */
.report-links { margin-top: var(--space-7); }
.report-links ul {
  list-style: none;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(18rem, 100%), 1fr));
  gap: 0 var(--space-6);
  border-bottom: 1px solid var(--border);
}
.report-links li + li { margin-top: 0; }
.report-links li { border-top: 1px solid var(--border); }
.report-links li a { display: block; padding: var(--space-3) 0; text-decoration: none; font-weight: 600; }
.report-links li a:hover { text-decoration: underline; }
.report-links li a::after { content: " →"; }
p.report-links a { display: inline-block; padding: var(--space-3) 0; }


/* --------------------------------------------------------------------------
   7. Map (MapLibre container, legend, fallbacks)
   -------------------------------------------------------------------------- */
.map {
  position: relative;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  max-height: 75vh;
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.map--small { aspect-ratio: 2 / 1; }
.map__fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: var(--space-5);
  text-align: center;
  color: var(--ink-muted);
}
.map__description { font-size: var(--step--1); color: var(--ink-muted); margin-bottom: var(--space-2); }
.map__print-note { display: none; }

/* legend built by map.js: fieldset > legend + list of checkbox labels with swatches */
.map__toggles { margin-top: var(--space-3); }
.map__legend { border: 0; margin: 0; padding: 0; min-width: 0; }
.map__toggles-title {
  padding: 0;
  margin: 0 0 var(--space-1);
  font-size: var(--step--1);
  font-weight: 600;
  color: var(--ink-muted);
}
.map__toggles-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0 var(--space-4);
}
.map__toggles-list li + li { margin-top: 0; }
.map__toggles-list label {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: var(--touch);
  margin: 0;
  font-weight: 400;
  font-size: 1rem;
  cursor: pointer;
}
.map__toggles-list input:disabled + .map__swatch { opacity: 0.4; }
.map__toggles-list label:has(input:disabled) { color: var(--ink-muted); cursor: default; }
.map__swatch {
  display: inline-block;
  width: 0.875rem;
  height: 0.875rem;
  border-radius: 2px;
  border: 1px solid rgba(27, 27, 24, 0.25);
  flex: none;
}

.map__attribution { margin: var(--space-2) 0 0; font-size: var(--step--1); color: var(--ink-muted); }

/* MapLibre chrome: readable attribution, controls that fit the palette */
.maplibregl-ctrl-attrib { font-size: 0.75rem; line-height: 1.4; }
.maplibregl-ctrl-attrib a { color: #1b1b18; }
.maplibregl-ctrl-group button:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }
.maplibregl-canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }


/* --------------------------------------------------------------------------
   8. Home: search, suggestions, pin map, "what a report contains"
   Desktop: title, intro and the search band span the width; below them the pin
   map (3/5) with the "what a report contains" copy alongside (2/5).
   -------------------------------------------------------------------------- */
.page-home .site-main {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  grid-template-areas:
    "title  title"
    "intro  intro"
    "error  error"
    "search search"
    "pin    how";
  column-gap: var(--space-8);
  align-items: start;
}
.page-home .site-main > h1 { grid-area: title; max-width: 30ch; }
.page-home .site-main > p { grid-area: intro; max-width: 64ch; }
.page-home .site-main > .form-error { grid-area: error; max-width: none; }
.search { grid-area: search; }
.pin { grid-area: pin; }
.how { grid-area: how; }

.page-home h2 { margin-top: var(--space-6); }
.search {
  margin-top: var(--space-5);
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.search h2 { margin-top: 0; font-size: var(--step-1); }
.search-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: var(--space-2) var(--space-3);
}
.search-form label { grid-column: 1 / -1; margin: 0; }
.search-form input[type="search"] { grid-column: 1; grid-row: 2; min-height: 3.5rem; font-size: var(--step-1); }
.search-form button[type="submit"] { grid-column: 2; grid-row: 2; min-height: 3.5rem; padding-inline: var(--space-6); }
.search-form .help { grid-column: 1 / -1; grid-row: 3; }
.search-form .htmx-indicator { grid-column: 1 / -1; font-size: var(--step--1); }
.suggestions { margin-top: var(--space-3); }
.suggestions p:last-child { margin-bottom: 0; }
.suggestions__list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--space-1); }
.suggestions__list li + li { margin-top: 0; }
.suggestion { margin: 0; }
.suggestion__button {
  width: 100%;
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-3);
  text-align: left;
  font-weight: 400;
  background: var(--ground);
  color: var(--ink);
  border-color: var(--border);
}
.suggestion__button:hover { background: var(--accent-soft); border-color: var(--accent); color: var(--ink); }
.suggestion__label { flex: 1 1 12rem; }
.suggestion__type { font-size: var(--step--1); color: var(--ink-muted); }
.suggestions__empty { color: var(--ink-muted); }

.pin .map { height: clamp(30rem, 56vh, 38rem); aspect-ratio: auto; max-height: none; }
.pin-form { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-3); }
.pin-form__position { flex-basis: 100%; margin: 0; font-size: var(--step--1); color: var(--ink-muted); }

.how { padding-left: var(--space-6); border-left: 1px solid var(--border); }
.how ul { padding-left: 1.1rem; }
.how li + li { margin-top: var(--space-2); }


/* --------------------------------------------------------------------------
   9. Layer detail: breadcrumb, card + statistics/items left, focused map right
   -------------------------------------------------------------------------- */
.page-detail .site-main {
  display: grid;
  grid-template-columns: minmax(0, 62fr) minmax(0, 38fr);
  grid-template-areas:
    "crumb  crumb"
    "header header"
    "cards  map"
    "list   map"
    "links  links";
  column-gap: var(--space-6);
  align-items: start;
}
.page-detail .breadcrumb { grid-area: crumb; }
.page-detail .items, .page-detail .stats { grid-area: list; }
.page-detail .cards { grid-template-columns: minmax(0, 1fr); }
.page-detail p.report-links { grid-area: links; }

.breadcrumb { font-size: var(--step--1); margin-bottom: var(--space-4); }
.breadcrumb a { display: inline-block; padding: var(--space-2) 0; }
.breadcrumb a::before { content: "← "; }

.items h2, .stats h2 { font-size: var(--step-1); }
.items__list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(20rem, 100%), 1fr));
  gap: var(--space-3);
  counter-reset: item;
}
.items__list li + li { margin-top: 0; }
.item {
  position: relative;
  padding: var(--space-3) var(--space-4) var(--space-3) 2.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  counter-increment: item;
}
.item::before {
  content: counter(item);
  position: absolute;
  left: var(--space-4);
  top: var(--space-3);
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink-muted);
}
.item__label { margin: 0; }
.item__attrs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: var(--space-1) var(--space-4);
  margin: var(--space-2) 0 0;
  font-size: var(--step--1);
}
.item__attrs dt { color: var(--ink-muted); }
.item__attrs dd { margin: 0; }

.stats__table { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.stats__table th { width: 55%; color: var(--ink-muted); font-weight: 400; }
.stats__table tr:last-child th, .stats__table tr:last-child td { border-bottom: 0; }


/* --------------------------------------------------------------------------
   10. Commune page, content pages, /donnees, error pages, /signaler
   -------------------------------------------------------------------------- */
.page-commune .report-header h1::after {
  content: "";
  display: block;
  width: 3rem;
  height: 3px;
  margin-top: var(--space-3);
  background: var(--accent);
}

.page-content section { margin-top: var(--space-6); }
.page-content h2 { font-size: var(--step-2); }
.page-content h3 { margin-top: var(--space-5); }
.page-content .site-main ul li + li, .page-content .site-main ol li + li { margin-top: var(--space-2); }

.thresholds, .dataset__facts {
  display: grid;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
}
.thresholds > div, .dataset__facts > div {
  display: grid;
  gap: var(--space-1);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}
.thresholds dt, .dataset__facts dt { font-weight: 600; }
.thresholds dd, .dataset__facts dd { margin: 0; color: var(--ink-muted); }
.dataset__facts > div { grid-template-columns: 11rem 1fr; gap: var(--space-4); }
.dataset {
  padding: var(--space-5);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}
.dataset h3 { margin-top: 0; }
.dataset__facts { margin-bottom: 0; }
.dataset__facts > div:last-child { border-bottom: 0; padding-bottom: 0; }
.dataset__caveat {
  margin: var(--space-4) 0 0;
  padding-left: var(--space-4);
  border-left: 3px solid var(--border);
  font-size: var(--step--1);
  color: var(--ink-muted);
}

/* /donnees uses the whole width: thresholds two abreast, dataset panels in a grid */
.page-donnees .site-main > p, .page-donnees section > p { max-width: 78ch; }
.page-donnees .thresholds {
  grid-template-columns: repeat(auto-fill, minmax(min(24rem, 100%), 1fr));
  gap: var(--space-4) var(--space-7);
}
.page-donnees section:has(> .dataset) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(26rem, 100%), 1fr));
  gap: var(--space-5);
}
.page-donnees section:has(> .dataset) > h2 { grid-column: 1 / -1; margin-bottom: 0; }
.page-donnees .dataset { margin-bottom: 0; }

.soon {
  padding: var(--space-4);
  background: var(--surface-tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.page-error .site-main { text-align: center; padding-top: var(--space-8); }
.page-error .site-main a { display: inline-block; padding: var(--space-3) 0; font-weight: 600; }


/* --------------------------------------------------------------------------
   11. Adaptations below the desktop (D-50a: the phone is the adaptation)
   ≤ 64 rem (1024 px): one column, DOM order — the map after the cards; the card
   grid still puts two cards abreast when they fit (tablets).
   ≤ 48 rem (768 px): phone — tighter paddings, smaller h1, map back to a ratio.
   -------------------------------------------------------------------------- */
@media (max-width: 64rem) {
  .page-report .site-main,
  .page-commune .site-main,
  .page-detail .site-main,
  .page-home .site-main { display: block; }
  .report-map { position: static; margin-top: var(--space-7); }
  .report-map .map { height: auto; aspect-ratio: 16 / 10; }
  .not-told { grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
  .not-told h2 { font-size: var(--step-1); }
  .not-told p { columns: auto; }
  .how { padding-left: 0; border-left: 0; }
  .pin .map { height: auto; aspect-ratio: 2 / 1; min-height: 20rem; }
  .page-home .site-main > h1, .page-home .site-main > p { max-width: none; }
}

@media (max-width: 48rem) {
  h1 { font-size: var(--step-3); }
  .site-header { padding: var(--space-3) var(--space-4); gap: var(--space-2) var(--space-5); }
  .site-nav { margin-left: 0; }
  .site-nav ul { gap: 0 var(--space-4); }
  .site-main { padding: var(--space-5) var(--space-4) var(--space-7); }
  .site-footer { display: block; padding-left: var(--space-4); padding-right: var(--space-4); }
  .footer-line { margin-bottom: var(--space-3); max-width: none; }
  .card { padding: var(--space-5) var(--space-4); }
  .not-told { padding: var(--space-5) var(--space-4); }
  .report-map .map { aspect-ratio: 4 / 3; }
  .pin .map { aspect-ratio: 3 / 2; min-height: 0; }
  .search { padding: var(--space-5) var(--space-4); }
  .dataset { padding: var(--space-5) var(--space-4); }
}

@media (max-width: 40rem) {
  .search-form { grid-template-columns: minmax(0, 1fr); }
  .search-form input[type="search"] { grid-column: 1; grid-row: auto; min-height: 3rem; font-size: inherit; }
  .search-form button[type="submit"] { grid-column: 1; grid-row: auto; min-height: 3rem; }
  .search-form .help { grid-row: auto; }
  .metrics { grid-template-columns: 1fr; }
  .dataset__facts > div { grid-template-columns: 1fr; gap: var(--space-1); }
}


/* --------------------------------------------------------------------------
   12. Print (FR-12): text only, the map is not printed, ratings stay readable;
   every grid collapses to one column in DOM order
   -------------------------------------------------------------------------- */
@media print {
  @page { margin: 15mm; }
  :root {
    --ground: #ffffff;
    --surface: #ffffff;
    --surface-tint: #ffffff;
    --ink: #000000;
    --ink-muted: #333333;
    --border: #999999;
    --border-strong: #666666;
    --accent: #000000;
    --accent-deep: #000000;
    --accent-soft: #ffffff;
  }
  html { scroll-behavior: auto; }
  body { font-size: 11pt; line-height: 1.4; display: block; background: #fff; color: #000; }
  .site-header, .site-nav, .site-footer nav, .draft-banner, .skip-link,
  .map, .map__toggles, .map__description, .breadcrumb,
  button, .search, .pin, .htmx-indicator,
  .card__detail, .report-links li a[href="/"] { display: none !important; }
  .site-main { display: block !important; max-width: none; padding: 0; }
  .site-footer { display: block; border-top: 1px solid #999; padding: 8pt 0 0; margin-top: 12pt; font-size: 9pt; }
  a { color: #000; text-decoration: underline; }
  h1 { font-size: 20pt; }
  h2 { font-size: 14pt; margin-top: 16pt; break-after: avoid; }
  h3 { font-size: 12pt; break-after: avoid; }
  .card, .item, .not-told, .dataset { break-inside: avoid; box-shadow: none; border: 1px solid #999; }
  .cards { grid-template-columns: 1fr; gap: 8pt; }
  .card { display: block; padding: 10pt 12pt; }
  .card__primary-value { font-size: 16pt; }
  .chip, .badge { border: 1px solid #000 !important; background: none !important; color: #000 !important; }
  .chip--high { font-weight: 700; }
  .caveats { border-left-color: #999; }
  .not-told { display: block; padding: 10pt 12pt; }
  .not-told h2 { font-size: 12pt; margin-bottom: 6pt; }
  .not-told p { columns: auto; }
  .report-map { position: static; margin-top: 12pt; }
  .map__print-note {
    display: block;
    margin: 0;
    padding: 8pt 10pt;
    border: 1px dashed #666;
    font-size: 10pt;
  }
  .report-links ul { display: block; list-style: none; padding: 0; border: 0; }
  .report-links li, .report-links li:last-child { border: 0; }
  .report-links li a::after { content: " — " var(--site-url, "") attr(href); font-weight: 400; }
  .card .source__name a::after { content: " (" attr(href) ")"; word-break: break-all; }
  .page-donnees section:has(> .dataset) { display: block; }
  .page-donnees .dataset { margin-bottom: 8pt; }
}
