/* =====================================================================
   MON EAU DU ROBINET – la feuille de style (l'apparence du site)
   ===================================================================== */

/* ===== 1. La police "Nunito", rangée dans lib/fonts =====
   On la garde sur notre site (au lieu de Google Fonts) :
   ainsi aucune donnée des visiteurs n'est envoyée à Google. */
@font-face {
  font-family: "Nunito";
  src: url("lib/fonts/nunito-latin-wght-normal.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215;
}
@font-face {
  font-family: "Nunito";
  src: url("lib/fonts/nunito-latin-ext-wght-normal.woff2") format("woff2");
  font-weight: 200 1000;
  font-display: swap;
  unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ===== 2. Les couleurs et réglages, à UN SEUL endroit =====
   Ce sont des "variables" : on leur donne un nom (--bleu…),
   puis on écrit var(--bleu) partout ailleurs.
   Changer une couleur ici la change sur tout le site ! */
:root {
  --bleu-fonce: #0b3d63;    /* textes importants */
  --bleu: #0b6aa8;          /* couleur principale */
  --bleu-clair: #5cc3e8;    /* accents */
  --bleu-pale: #e8f4fb;     /* fonds légers */
  --fond: #f4f8fb;          /* fond de la page */
  --blanc: #ffffff;
  --texte: #1c2b36;
  --texte-doux: #5f7280;
  --bordure: #e2eaf0;

  --vert: #2f9e6a;          /* rien à signaler */
  --vert-pale: #e7f6ee;
  --orange: #e0a020;        /* à surveiller */
  --orange-pale: #fdf3dc;
  --rouge: #d64545;         /* problème */
  --rouge-pale: #fdeaea;

  --arrondi: 16px;
  --arrondi-petit: 10px;
  --ombre: 0 1px 2px rgba(11, 61, 99, 0.06), 0 8px 24px rgba(11, 61, 99, 0.08);
  --police: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* ===== 3. Réglages de base ===== */
* {
  box-sizing: border-box; /* les tailles incluent le remplissage : plus simple */
}

body {
  margin: 0;
  font-family: var(--police);
  font-size: 1.05rem;
  background-color: var(--fond);
  color: var(--texte);
  line-height: 1.6;
}

a {
  color: var(--bleu);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--bleu-fonce);
}

/* Un contour bien visible quand on navigue au clavier (accessibilité) */
a:focus-visible,
select:focus-visible {
  outline: 3px solid var(--bleu-clair);
  outline-offset: 2px;
}

h1, h2, h3 {
  line-height: 1.25;
  color: var(--bleu-fonce);
}

/* ===== 4. Le bandeau du haut ===== */
header {
  position: relative;
  background: linear-gradient(160deg, var(--bleu-fonce) 0%, var(--bleu) 60%, #1a8fcf 100%);
  color: var(--blanc);
  padding: 28px 16px 64px; /* de la place en bas pour la vague */
  text-align: center;
}

/* La vague blanche en bas du bandeau (dessinée en SVG dans la page) */
.vague {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 100%;
  height: 40px;
  display: block;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--blanc);
  text-decoration: none;
}

.logo:hover {
  color: var(--blanc);
}

.logo svg {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

header h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 900;
  color: var(--blanc);
  letter-spacing: -0.01em;
}

.sous-titre {
  max-width: 32em;
  margin: 10px auto 0;
  font-size: 1.05rem;
  opacity: 0.92;
}

/* ===== 5. Le menu entre les pages ===== */
.menu-pages {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.menu-pages a {
  color: var(--blanc);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 999px;
  background-color: rgba(255, 255, 255, 0.12);
  font-size: 0.92rem;
  font-weight: 700;
  transition: background-color 0.2s;
}

.menu-pages a:hover {
  background-color: rgba(255, 255, 255, 0.25);
  color: var(--blanc);
}

/* La page où l'on se trouve est mise en évidence */
.menu-pages a[aria-current="page"] {
  background-color: var(--blanc);
  color: var(--bleu);
}

/* ===== 6. La zone principale et les "cartes" ===== */
main {
  max-width: 640px;
  margin: 0 auto;
  padding: 8px 16px 16px;
}

.carte {
  background-color: var(--blanc);
  border-radius: var(--arrondi);
  padding: 22px 20px;
  margin-bottom: 20px;
  box-shadow: var(--ombre);
}

.carte h2 {
  margin: 0 0 12px;
  font-size: 1.3rem;
  font-weight: 800;
}

.carte > p:last-child {
  margin-bottom: 0;
}

.petit {
  font-size: 0.85rem;
  color: var(--texte-doux);
}

/* ===== 7. Page d'accueil : "Comment ça marche ?" en 3 étapes ===== */
.etapes {
  list-style: none;
  counter-reset: etape; /* un compteur pour numéroter 1, 2, 3 */
  padding: 0;
  margin: 0;
}

.etapes li {
  counter-increment: etape;
  position: relative;
  padding: 4px 0 12px 48px;
}

.etapes li::before {
  content: counter(etape);
  position: absolute;
  left: 0;
  top: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-color: var(--bleu-pale);
  color: var(--bleu);
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== 8. Le choix de la commune ===== */
label {
  display: block;
  font-weight: 800;
  margin-bottom: 8px;
}

select {
  width: 100%;
  font-family: inherit;
  font-size: 1.05rem;
  color: var(--texte);
  padding: 14px 44px 14px 14px;
  border: 2px solid var(--bordure);
  border-radius: var(--arrondi-petit);
  background-color: var(--blanc);
  /* une petite flèche dessinée en SVG, à la place de celle du navigateur */
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%230b6aa8' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 18px;
  cursor: pointer;
  transition: border-color 0.2s;
}

select:hover,
select:focus {
  border-color: var(--bleu);
}

.bientot {
  color: var(--texte-doux);
  font-style: italic;
}

/* Le message qui apparaît quand on a choisi une commune */
.choisie {
  color: var(--bleu-fonce);
  font-style: normal;
  background-color: var(--bleu-pale);
  padding: 12px 14px;
  border-radius: var(--arrondi-petit);
}

/* Le bandeau jaune qui prévient que les données sont inventées */
.bandeau-fictif {
  background-color: #fff3c4;
  color: #6b4e00;
  padding: 12px 16px;
  text-align: center;
  font-weight: 800;
}

/* ===== 9. La liste des valeurs ===== */
.valeurs {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
}

.valeurs li {
  border-left-width: 5px;
  border-left-style: solid;
  border-left-color: var(--bordure);
  background-color: var(--fond);
  border-radius: var(--arrondi-petit);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.entete-valeur {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  font-weight: 700;
}

.entete-valeur strong {
  font-weight: 900;
  white-space: nowrap; /* la valeur et son unité restent ensemble */
}

.explication {
  margin: 4px 0 0;
  font-size: 0.95rem;
  color: var(--texte-doux);
}

/* Les 3 couleurs : vert, orange, rouge */
.niveau-ok        { border-left-color: var(--vert); }
.niveau-attention { border-left-color: var(--orange); }
.niveau-alerte    { border-left-color: var(--rouge); }

/* Titre d'un réservoir quand la commune en a plusieurs */
.valeurs .titre-reservoir {
  border: none;
  background: none;
  padding: 14px 0 4px;
  margin: 0;
  font-weight: 900;
  color: var(--bleu);
}

/* La ligne "Source" sous chaque réservoir */
.valeurs .source,
.note-source {
  border: none;
  background: none;
  padding: 0 0 8px;
  font-size: 0.85rem;
  color: var(--texte-doux);
}

/* La petite légende des couleurs */
.legende {
  display: none;
  font-size: 0.85rem;
  color: var(--texte-doux);
  margin: 8px 0 0;
}

.valeurs:not(:empty) + .legende,
.legende-carte {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.pastille {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* un petit rond de couleur devant chaque mot de la légende */
.pastille::before {
  content: "";
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background-color: var(--bordure);
}

.pastille.niveau-ok::before        { background-color: var(--vert); }
.pastille.niveau-attention::before { background-color: var(--orange); }
.pastille.niveau-alerte::before    { background-color: var(--rouge); }

/* ===== 10. Le bloc "Notre conseil" ===== */
.conseil {
  margin: 14px 0 4px;
  padding: 18px;
  border-radius: var(--arrondi);
}

.conseil-ok {
  background-color: var(--vert-pale);
  border: 2px solid var(--vert);
}

.conseil-alerte {
  background-color: var(--rouge-pale);
  border: 2px solid var(--rouge);
}

.conseil h3 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 900;
}

.conseil-ok h3::before    { content: "✅ "; }
.conseil-alerte h3::before { content: "⚠️ "; }

.titre-conseil {
  font-weight: 800;
  margin: 0 0 8px;
}

.conseil ul {
  margin: 0 0 8px;
  padding-left: 20px;
}

.conseil li {
  margin-bottom: 6px;
}

.sous-titre-conseil {
  margin: 10px 0 4px;
  font-weight: 700;
  color: var(--texte-doux);
}

.note-fictif {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: #6b4e00;
}

/* ===== 11. La carte des communes ===== */
.zone-carte {
  height: 380px;
  margin-top: 14px;
  border-radius: var(--arrondi-petit);
  background-color: var(--bleu-pale);
  font-family: var(--police);
}

.aide-carte {
  font-size: 0.85rem;
  color: var(--texte-doux);
  margin: 10px 0 0;
}

/* Pas de cadre noir autour d'une commune après un clic */
.leaflet-interactive:focus {
  outline: none;
}

/* ===== 12. Les pages de texte (À propos, guide, mentions) ===== */
.texte h3 {
  font-size: 1.05rem;
  margin: 18px 0 4px;
}

.texte li {
  margin-bottom: 8px;
}

.encadre-vert {
  background-color: var(--vert-pale);
  border: 2px solid var(--vert);
}

/* Les tableaux (seuils et filtres) */
.tableau-seuils,
.tableau-filtres {
  width: 100%;
  table-layout: fixed; /* colonnes de même largeur, pour tenir sur un téléphone */
  border-collapse: separate;
  border-spacing: 0;
  margin: 8px 0;
  border: 1px solid var(--bordure);
  border-radius: var(--arrondi-petit);
  overflow: hidden;
}

.tableau-seuils {
  font-size: 0.85rem;
}

.tableau-filtres {
  font-size: 0.75rem;
}

.tableau-seuils th,
.tableau-seuils td,
.tableau-filtres th,
.tableau-filtres td {
  border-bottom: 1px solid var(--bordure);
  padding: 8px 5px;
  text-align: left;
  vertical-align: top;
  hyphens: auto; /* coupe les mots longs proprement, avec un tiret */
}

.tableau-seuils thead th,
.tableau-filtres thead th {
  background-color: var(--bleu-pale);
  color: var(--bleu-fonce);
  font-weight: 800;
}

.tableau-seuils tr:last-child td,
.tableau-filtres tr:last-child th,
.tableau-filtres tr:last-child td {
  border-bottom: none;
}

.tableau-filtres td {
  text-align: center;
  vertical-align: middle;
}

.tableau-filtres tbody th {
  padding-left: 8px;
  font-weight: 800;
}

.tableau-filtres .col-filtre {
  width: 27%;
}

/* Les cases colorées : vert = oui, orange = en partie, gris = non */
.tableau-filtres .oui     { background-color: var(--vert-pale); color: #1d6b46; font-weight: 800; }
.tableau-filtres .partiel { background-color: var(--orange-pale); color: #7a5300; }
.tableau-filtres .non     { color: var(--texte-doux); }

/* ===== 13. Le pied de page ===== */
footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--texte-doux);
  padding: 24px 16px 40px;
}

footer p {
  margin: 0;
  line-height: 1.9;
}
