:root {
--marine: #132232;
--marine-2: #1e3a5f;
--rouge: #b30000;
--papier: #ffffff;
--texte: #1c2733;
--texte-doux: #4f5d6b;
--filet: #d6dde4;
--alerte-fond: #fff3cd;
--alerte-texte: #6b4f00;
color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
color: var(--texte);
}
#carte { position: absolute; inset: 0; }

/* Sélecteur de vues : flex-wrap + max-width évitent que les 5 boutons (Ensemble, Douillac,
Pierrepinet, Fayat, Les Farges) ne débordent hors de l'écran sur un étroit viewport — ils
passent alors sur une seconde ligne plutôt que de s'étendre au-delà. */
.vues {
position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 3;
display: flex; flex-wrap: wrap; justify-content: center; max-width: 94vw;
padding: 3px; gap: 2px;
background: var(--marine); border-radius: 999px;
box-shadow: 0 2px 8px rgba(19, 34, 50, 0.35);
}
.vues button {
border: 0; background: transparent; color: #dce6f0;
font: 600 13px/1 inherit; font-family: inherit;
padding: 8px 16px; border-radius: 999px; cursor: pointer;
}
.vues button[aria-pressed="true"] { background: var(--rouge); color: #fff; }
/* « Les Farges » n'est pas un PER mais un site ponctuel (voir carte-commune.js / donnees.js) :
filet + teinte orangée (même famille que le point « Ancien site minier », #ef6c00) pour qu'il ne
soit plus confondu avec les 3 boutons de PER qui le précèdent. */
.vues .vue-site {
margin-left: 6px;
padding-left: 15px;
border-left: 1px solid rgba(255, 255, 255, 0.3);
color: #ffcc94;
}
.vues .vue-site[aria-pressed="true"] { background: #ef6c00; color: #fff; }
.vues button:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* Barre d'échelle : centrée en bas de la carte plutôt que calée à gauche (comportement MapLibre
par défaut). Un décalage vers le haut (bottom) et un z-index supérieur évitent qu'elle soit
recouverte par la bande d'attribution, qui s'étend sur presque toute la largeur du bas de la
carte dès que le texte des crédits est un peu long. */
.maplibregl-ctrl-bottom-left {
left: 50%;
right: auto;
bottom: 28px;
z-index: 3;
transform: translateX(-50%);
}

/* Flèche de nord : placée juste au-dessus des boutons de zoom (coin haut-droit).
C'est aussi un bouton : un clic réoriente la carte plein nord (voir activerRotationMolette /
ajouterFlecheNord dans carte-commune.js). */
.fleche-nord {
position: absolute; top: 12px; right: 12px; z-index: 3;
width: 34px; height: 34px; border-radius: 50%; border: 0; padding: 0;
background: var(--papier); box-shadow: 0 2px 8px rgba(19, 34, 50, 0.3);
display: flex; align-items: center; justify-content: center;
cursor: pointer; transition: transform 0.15s linear, background 0.15s;
}
.fleche-nord:hover { background: #eef2f6; }
.fleche-nord:focus-visible { outline: 2px solid var(--rouge); outline-offset: 1px; }

/* Laisse la place à la flèche de nord juste au-dessus, sans qu'elle chevauche les boutons +/-. */
#carte .maplibregl-ctrl-top-right { padding-top: 54px; }

/* Panneau */
#panneau {
position: absolute; left: 12px; bottom: 32px; z-index: 2;
width: 363px; max-width: calc(100vw - 40px); max-height: calc(100% - 80px); overflow-y: auto;
background: var(--papier); border-radius: 8px; padding: 12px 14px;
border-top: 3px solid var(--rouge);
box-shadow: 0 2px 12px rgba(19, 34, 50, 0.28);
font-size: 12.5px; line-height: 1.45;
}
#panneau h2 { margin: 0 0 8px; font-size: 15px; color: var(--marine); }
.intro p { margin: 0 0 8px; }
.legende div { display: flex; align-items: center; margin: 3px 0; }
/* Bouton « Légende » d'une couche (ex. géologie BRGM, groupes de cultures RPG) : ouvre une
pop-up plutôt que d'encombrer le panneau en permanence (la légende complète d'un service WMS,
ou la table des ~24 groupes de cultures du RPG, ne tient jamais dans 300px). */
.btn-legende {
display: inline-flex; align-items: center; gap: 5px; margin: 0 0 8px;
border: 1px solid var(--marine-2); background: #fff; color: var(--marine-2);
font: 600 12px/1 inherit; font-family: inherit; padding: 6px 10px; border-radius: 5px; cursor: pointer;
}
.btn-legende:hover { background: var(--marine-2); color: #fff; }
.btn-legende:focus-visible { outline: 2px solid var(--rouge); outline-offset: 1px; }
.legende-popup-fond {
position: fixed; inset: 0; z-index: 10; background: rgba(19, 34, 50, 0.55);
display: flex; align-items: center; justify-content: center; padding: 20px;
}
.legende-popup-fond[hidden] { display: none; }
.legende-popup {
position: relative; background: var(--papier); border-radius: 8px; width: 100%; max-width: 420px;
max-height: 90vh; overflow-y: auto; padding: 20px 22px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
font-size: 12.5px; line-height: 1.5;
}
.legende-popup h3 { margin: 0 0 10px; color: var(--marine); font-size: 15px; padding-right: 22px; }
.legende-popup img { display: block; max-width: 100%; height: auto; border: 1px solid var(--filet); border-radius: 4px; margin-bottom: 10px; background: #fff; }
.legende-popup p { margin: 0 0 12px; color: var(--texte-doux); }
.legende-popup-lien {
display: inline-block; background: var(--rouge); color: #fff; text-decoration: none;
font-weight: 600; font-size: 12.5px; padding: 8px 14px; border-radius: 5px;
}
.legende-popup-lien:hover { opacity: 0.9; }
.legende-popup-fermer {
position: absolute; top: 10px; right: 10px; border: 0; background: transparent;
font-size: 16px; line-height: 1; cursor: pointer; color: var(--texte-doux); padding: 4px;
}
.legende-popup-fermer:hover { color: var(--rouge); }
.pastille { width: 11px; height: 11px; border-radius: 50%; margin-right: 7px; flex: none; }
.pastille.creuse { background: #fff; border: 2px solid var(--texte-doux); }
.cadre { width: 16px; height: 11px; border: 2px solid; margin-right: 7px; flex: none; }
.cube { width: 14px; height: 14px; margin-right: 7px; flex: none; background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Cpolygon points='50,6 90,28 50,50 10,28' fill='%23ffffff' stroke='%233c4852' stroke-width='4' stroke-linejoin='round'/%3E%3Cpolygon points='10,28 50,50 50,94 10,72' fill='%23dde2e6' stroke='%233c4852' stroke-width='4' stroke-linejoin='round'/%3E%3Cpolygon points='90,28 50,50 50,94 90,72' fill='%23c3cad0' stroke='%233c4852' stroke-width='4' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain; }
/* Losange rouge/vert (couche Hub'Eau) : une FORME différente des ronds pleins (.pastille,
ci-dessus) utilisés par les « Relevés et repères » (couche manuelle), pour que les deux
couches restent visuellement distinctes même si elles partagent la même convention de
couleur (seuil eau potable 10 µg/L). Même principe de base qu'un .pastille carré, tourné à
45°, avec un liseré blanc assorti à l'icône losange dessinée sur la carte (voir
assurerIconesHubEau() dans carte-commune.js) pour que la légende ressemble au symbole réel. */
.losange {
width: 10px; height: 10px; margin: 0 9px 0 2px; flex: none;
transform: rotate(45deg); border: 1.5px solid #ffffff;
box-shadow: 0 0 0 1px rgba(19, 34, 50, 0.3);
}
.couches { border: 0; border-top: 1px solid var(--filet); margin: 10px 0 0; padding: 8px 0 0; }
.couches legend { font-weight: 700; padding: 0; color: var(--marine); }
.couches label { display: flex; gap: 6px; align-items: flex-start; margin: 3px 0; cursor: pointer; }
.outils { border-top: 1px solid var(--filet); margin-top: 10px; padding-top: 8px; }
.ligne-boutons { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0; }
.outils button {
flex: 1 1 auto; border: 1px solid var(--marine-2); background: #fff; color: var(--marine-2);
font: 600 12px/1 inherit; font-family: inherit; padding: 7px 8px; border-radius: 5px; cursor: pointer;
}
.outils button[aria-pressed="true"], .outils button.principal { background: var(--marine-2); color: #fff; }
.outils button.imprimer { width: 100%; margin-top: 4px; }
.outils button:focus-visible, .couches input:focus-visible { outline: 2px solid var(--rouge); outline-offset: 1px; }
.aide { margin: 4px 0; color: var(--texte-doux); min-height: 0; }
.aide:empty { display: none; }
.sources { border-top: 1px solid var(--filet); margin-top: 10px; padding-top: 6px; font-size: 11px; color: var(--texte-doux); }
.sources summary { cursor: pointer; font-weight: 700; color: var(--marine); }
.sources p { margin: 5px 0; }

#statut {
position: absolute; top: 58px; left: 50%; transform: translateX(-50%); z-index: 3;
max-width: min(420px, 90vw); max-height: min(40vh, 260px); overflow-y: auto;
background: var(--alerte-fond); color: var(--alerte-texte);
border: 1px solid #e6d38a; border-radius: 6px; padding: 8px 30px 8px 10px; font-size: 12px;
}
#statut[hidden] { display: none; }
.statut-fermer {
position: absolute; top: 3px; right: 5px; border: 0; background: transparent;
color: inherit; font: 700 19px/1 system-ui, sans-serif; padding: 2px 5px; cursor: pointer;
}
.statut-fermer:focus-visible { outline: 2px solid var(--rouge); outline-offset: 1px; }
.statut-messages > div + div { margin-top: 5px; }
.erreur-bloquante { margin: 80px auto; max-width: 420px; padding: 16px; background: var(--alerte-fond); color: var(--alerte-texte); border-radius: 6px; }

/* Popups */
.pop { font-size: 12.5px; line-height: 1.45; }
.pop p { margin: 4px 0; }
.pop .type { font-weight: 600; }
.pop .src { font-size: 11.5px; color: var(--texte-doux); }
.pop .src.manquante { color: #8a5a00; }
.pop a { color: var(--marine-2); }
.pop .supprimer { margin-top: 6px; border: 1px solid var(--rouge); background: #fff; color: var(--rouge); border-radius: 4px; padding: 4px 8px; cursor: pointer; font: inherit; }

@media (max-width: 640px) {
#panneau { left: 8px; right: 8px; width: auto; bottom: 28px; max-height: 42%; }
.vues button { padding: 7px 12px; }
}
#credits-impression { display: none; }
@media print {
#panneau .outils, #panneau .couches, #panneau .sources, .vues, #statut,
.maplibregl-ctrl-top-right, .maplibregl-ctrl-attrib { display: none !important; }
#panneau { box-shadow: none; border: 1px solid #999; bottom: 92px; }
.maplibregl-ctrl-bottom-left { bottom: 80px; }
#credits-impression {
display: block; position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
background: #fff; border-top: 1px solid #999; padding: 6px 12px;
font-size: 9pt; line-height: 1.35; color: #000;
}
#credits-impression p { margin: 0; }
}

/* Fiches d'attributs (cavités, parcelles) */
.pop .attributs { display: grid; grid-template-columns: auto 1fr; gap: 2px 8px; margin: 6px 0; font-size: 11.5px; }
.pop .attributs dt { color: var(--texte-doux); }
.pop .attributs dd { margin: 0; word-break: break-word; }
.pop .ajouter { margin-top: 6px; border: 0; background: #2e7d32; color: #fff; border-radius: 4px; padding: 6px 8px; cursor: pointer; font: inherit; font-weight: 600; }

/* Onglets des résultats d'interrogation : une fiche indépendante par couche superposée. */
.pop-onglets {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 9px;
  padding: 0 0 7px; border-bottom: 1px solid var(--filet);
}
.pop-onglet {
  flex: 0 0 auto; max-width: 100%; border: 1px solid var(--filet);
  border-radius: 5px; padding: 6px 9px; background: #f3f6f8;
  color: var(--marine); font: 600 11.5px/1.3 inherit; font-family: inherit;
  cursor: pointer; overflow-wrap: anywhere;
}
.pop-onglet[aria-selected="true"] {
  background: var(--marine-2); border-color: var(--marine-2); color: #fff;
}
.pop-onglet:focus-visible { outline: 2px solid var(--rouge); outline-offset: 2px; }
.pop-onglet-contenu[hidden] { display: none; }
.pop-onglet-contenu { min-width: 0; }
