/* Les sites en chiffres (bloc « Sites en chiffres (MapCen) »).
   Une seule couleur de données, le vert de l'association ; le texte reste à l'encre
   du site. Les valeurs se lisent toujours en clair (étiquettes, tableau) : l'infobulle
   ne fait que les reprendre. */
.ana-sites {
  /* Les couleurs du site, en dur : les variables du thème pointent ici sur la
     palette bleue d'origine de Kadence. */
  --vert: #3e9645;
  --vert-fonce: #2f7a36;
  --encre: #1a2b38;
  --encre-2: #5a6e68;
  --attenue: #c3c2b7;
  --fond: #f4f8f4;
  --filet: #e1e0d9;
  --menacee: #c62828;
  margin: 1.25rem 0 2rem;
  color: var(--encre);
}
.ana-sites [hidden] { display: none !important; }
.ana-sites ul, .ana-sites ol { list-style: none; margin: 0; padding: 0; }
.ana-sites li { margin: 0; }
.ana-sites button {
  background: none; border: 0; box-shadow: none; color: inherit; font: inherit;
  letter-spacing: normal; text-transform: none; min-height: 0; padding: 0; cursor: pointer;
}
.ana-sites button:focus-visible, .ana-sites select:focus-visible, .ana-sites summary:focus-visible {
  outline: 2px solid var(--vert-fonce); outline-offset: 2px;
}
.ana-sites .ana-sites-intro { margin: 0 0 1rem; }

/* Chiffres clés */
.ana-sites-chiffres {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); gap: .75rem;
}
.ana-sites-chiffres li {
  display: flex; flex-direction: column; gap: .15rem;
  padding: .9rem 1rem 1rem; background: var(--fond); border-radius: 10px;
}
.ana-sites-valeur { font-size: clamp(1.75rem, 3.2vw, 2.25rem); font-weight: 600; line-height: 1.1; letter-spacing: -.01em; }
.ana-sites-libelle { font-size: .9rem; font-weight: 500; line-height: 1.3; }
.ana-sites-precision { font-size: .78rem; color: var(--encre-2); line-height: 1.3; }

/* Les deux parties : milieux, galerie */
.ana-sites-bloc { position: relative; margin-top: 2rem; }
.ana-sites-entete { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.ana-sites .ana-sites-entete h3 { margin: 0; }
.ana-sites .ana-sites-sous-titre { margin: 1.5rem 0 0; font-size: .9rem; font-weight: 600; }
.ana-sites-especes .ana-sites-chiffres { margin-top: .75rem; }
.ana-sites-barres li[tabindex]:focus-visible { outline: 2px solid var(--vert-fonce); outline-offset: 2px; border-radius: 6px; }
.ana-sites-barres li[tabindex]:hover .ana-sites-barre { background: var(--fond); }
.ana-sites .ana-sites-aide { margin: .35rem 0 .75rem; font-size: .82rem; color: var(--encre-2); }

.ana-sites-bascule { display: inline-flex; padding: 2px; border: 1px solid var(--filet); border-radius: 999px; }
.ana-sites-bascule button { padding: .3rem .85rem; border-radius: 999px; font-size: .82rem; color: var(--encre-2); }
.ana-sites-bascule button[aria-pressed="true"] { background: var(--vert-fonce); color: #fff; }

/* Barres : une rangée par milieu, rangées replacées en douceur quand l'ordre change */
.ana-sites-barres { --h: 2.15rem; position: relative; height: calc(var(--nb) * var(--h)); margin-top: .75rem; }
.ana-sites-barres li { position: absolute; left: 0; right: 0; top: calc(var(--rang) * var(--h)); height: var(--h); transition: top .45s ease; }
.ana-sites-barre {
  display: grid; grid-template-columns: minmax(9rem, 38%) 1fr; align-items: center; gap: .75rem;
  width: 100%; height: 100%; padding: 0 .35rem !important; border-radius: 6px; text-align: left;
}
.ana-sites-barre:disabled { cursor: default; }
.ana-sites-barre:not(:disabled):hover, .ana-sites-barre:focus-visible { background: var(--fond); }
.ana-sites-barre-nom { font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ana-sites-barre-piste { display: flex; align-items: center; min-width: 0; }
.ana-sites-barre-trait {
  display: block; flex: none; height: 14px; min-width: 2px;
  width: calc((100% - 4.5rem) * var(--part)); background: var(--vert); border-radius: 0 4px 4px 0;
  transition: width .45s ease, background-color .2s ease;
}
.ana-sites-barre-valeur { margin-left: .4rem; font-size: .82rem; color: var(--encre-2); white-space: nowrap; }
.ana-sites-barre:not(:disabled):hover .ana-sites-barre-trait { background: #5aa960; }
/* Un milieu choisi : lui seul en couleur, les autres en retrait */
.ana-sites-barres.a-un-choix .ana-sites-barre-trait { background: var(--attenue); }
.ana-sites-barres .est-choisi .ana-sites-barre-trait { background: var(--vert-fonce); }
.ana-sites-barres .est-choisi .ana-sites-barre-nom { font-weight: 600; }

.ana-sites-infobulle {
  position: absolute; z-index: 3; pointer-events: none; max-width: 15rem;
  padding: .5rem .7rem; background: #fff; border: 1px solid var(--filet); border-radius: 8px;
  box-shadow: 0 6px 18px rgba(26, 43, 56, .1); font-size: .8rem; line-height: 1.35; color: var(--encre-2);
}
.ana-sites-infobulle strong { display: block; font-size: 1rem; font-weight: 600; color: var(--encre); }

.ana-sites-tableau { margin-top: .75rem; font-size: .85rem; }
.ana-sites-tableau summary { cursor: pointer; color: var(--vert-fonce); width: fit-content; }
.ana-sites-defilement { overflow-x: auto; }
.ana-sites .ana-sites-tableau table { width: 100%; margin-top: .5rem; border-collapse: collapse; }
.ana-sites-tableau th, .ana-sites-tableau td { padding: .35rem .5rem; border-bottom: 1px solid var(--filet); text-align: right; font-variant-numeric: tabular-nums; }
.ana-sites-tableau th[scope="row"], .ana-sites-tableau thead th:first-child { text-align: left; font-weight: 400; }
.ana-sites-tableau thead th { font-weight: 600; color: var(--encre-2); font-size: .78rem; }
.ana-sites-tableau tfoot th, .ana-sites-tableau tfoot td { font-weight: 600; border-bottom: 0; }

/* Galerie */
.ana-sites-filtres { display: flex; flex-wrap: wrap; align-items: center; gap: .5rem 1.25rem; margin: .75rem 0 1rem; }
.ana-sites .ana-sites-filtres label { display: inline-flex; align-items: center; gap: .45rem; margin: 0; font-size: .85rem; color: var(--encre-2); }
.ana-sites .ana-sites-filtres select {
  width: auto; min-height: 0; margin: 0; padding: .35rem 1.8rem .35rem .55rem; font-size: .88rem; color: var(--encre);
  border: 1px solid var(--filet); border-radius: 6px; background-color: #fff;
}
.ana-sites-compte { margin-left: auto; font-size: .85rem; color: var(--encre-2); }

.ana-sites-cartes { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5rem, 1fr)); gap: 1rem; }
.ana-sites-carte { display: flex; flex-direction: column; gap: .35rem; padding: .7rem .7rem .8rem; border: 1px solid var(--filet); border-radius: 10px; background: #fff; }
.ana-sites-contour { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; margin-bottom: .2rem; background: var(--fond); border-radius: 6px; }
.ana-sites-contour path { fill-rule: evenodd; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
/* Aplats opaques, liserés de la même teinte : les limites entre parcelles voisines
   disparaissent, et une toute petite parcelle reste visible. */
.ana-sites-contour .site { fill: #87bd8b; stroke: #87bd8b; stroke-width: 1.6; }
.ana-sites-contour .echelle line { stroke: var(--encre-2); stroke-width: 1; vector-effect: non-scaling-stroke; }
.ana-sites-contour .echelle text { fill: var(--encre-2); font-size: 9px; dominant-baseline: middle; }
.ana-sites .ana-sites-nom { margin: 0; font-size: 1rem; line-height: 1.25; }
.ana-sites .ana-sites-meta { margin: 0; font-size: .8rem; line-height: 1.35; color: var(--encre-2); }
.ana-sites .ana-sites-mesures { margin: 0; font-size: .8rem; line-height: 1.4; color: var(--encre-2); }
.ana-sites .ana-sites-mesures strong { color: var(--encre); font-weight: 600; }
.ana-sites .ana-sites-carte details { margin: auto 0 0; padding-top: .2rem; font-size: .8rem; }
.ana-sites .ana-sites-carte summary { cursor: pointer; color: var(--vert-fonce); width: fit-content; }
.ana-sites .ana-sites-carte details p { margin: .35rem 0 0; font-size: .85rem; line-height: 1.45; color: var(--encre); }

.ana-sites-plus {
  display: block; margin: 1.25rem auto 0; padding: .5rem 1.2rem !important;
  border: 1px solid var(--vert) !important; border-radius: 999px; color: var(--vert-fonce) !important; font-size: .9rem !important;
}
.ana-sites-plus:hover { background: var(--fond) !important; }
.ana-sites .ana-sites-source { margin: 1.5rem 0 0; font-size: .78rem; line-height: 1.45; color: var(--encre-2); }

@media (max-width: 520px) {
  .ana-sites-chiffres { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .ana-sites-chiffres li { padding: .75rem .75rem .85rem; }
  .ana-sites-barres { --h: 3.1rem; }
  .ana-sites-barre { grid-template-columns: 1fr; gap: .2rem; align-content: center; }
  .ana-sites-tableau th, .ana-sites-tableau td { padding: .3rem .3rem; font-size: .8rem; }
  .ana-sites .ana-sites-filtres label { width: 100%; }
  .ana-sites .ana-sites-filtres select { flex: 1; min-width: 0; }
  .ana-sites-compte { margin-left: 0; width: 100%; }
  .ana-sites-cartes { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .5rem; }
  .ana-sites-carte { padding: .5rem .5rem .65rem; }
  .ana-sites .ana-sites-nom { font-size: .92rem; }
}
@media (prefers-reduced-motion: reduce) {
  .ana-sites-barres li, .ana-sites-barre-trait { transition: none; }
}

/* Espèces par groupe, en cercles comme dans le Dashboard ANA (core/cercles.py) : le
   total au centre, un cercle par groupe autour, les sous-groupes en satellites. Les
   positions et les tailles sont des pourcentages du carré ; les textes suivent sa
   largeur (unités cqw). */
.ana-sites-cercles { container: ana-cercles / inline-size; margin-top: .5rem; }
.ana-sites-cercles-figure {
  container: ana-figure / inline-size;
  position: relative; width: min(100%, 44rem); aspect-ratio: 1; margin: 0 auto;
}
.ana-sites-cercles-traits { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ana-sites-cercles-traits line { stroke: #90a4ae; stroke-width: 3; vector-effect: non-scaling-stroke; }
.ana-sites-cercles-centre,
.ana-sites .ana-sites-cercle {
  position: absolute; left: calc(var(--x) * 1%); top: calc(var(--y) * 1%); width: calc(var(--t) * 1%);
  aspect-ratio: 1; transform: translate(-50%, -50%); border-radius: 50%;
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
}
.ana-sites-cercles-centre {
  z-index: 1; background: #f0f0f0; box-shadow: 0 0 15px rgba(0, 0, 0, .1);
  color: #555; font-weight: 600; font-size: max(11px, 1.8cqw); line-height: 1.2;
}
.ana-sites-cercles-total { font-size: max(22px, 5.2cqw); font-weight: 700; color: var(--encre); }
.ana-sites .ana-sites-cercle {
  z-index: 10; padding: 0; border: 0; background: var(--c); color: var(--encre);
  box-shadow: 0 4px 8px rgba(0, 0, 0, .2); line-height: 1.05;
  font-size: max(9px, 1.4cqw); font-weight: 600; transition: transform .2s, box-shadow .2s;
}
.ana-sites .ana-sites-cercle--clair { color: #fff; }
/* Une boîte fixe pour l'icône : les hautes (mille-pattes) ne débordent pas. */
.ana-sites .ana-sites-cercle img { width: 36%; height: 30%; object-fit: contain; margin-bottom: 2%; }
.ana-sites .ana-sites-cercle--clair img, .ana-sites-dialogue-icone.ana-sites-cercle--clair img { filter: invert(1); }
.ana-sites-cercle-valeur { font-size: max(12px, 2.1cqw); font-weight: 700; }
.ana-sites-cercle-nom { max-width: 90%; hyphens: auto; }
.ana-sites .ana-sites-cercle--parent { z-index: 5; border: 4px solid rgba(255, 255, 255, .8); font-size: max(10px, 1.5cqw); }
.ana-sites .ana-sites-cercle--satellite { z-index: 20; font-size: max(7.5px, 1.05cqw); }
.ana-sites .ana-sites-cercle--satellite img { width: 32%; height: 26%; }
.ana-sites .ana-sites-cercle--satellite .ana-sites-cercle-valeur { font-size: max(11px, 1.7cqw); }
.ana-sites button.ana-sites-cercle { cursor: pointer; }
.ana-sites button.ana-sites-cercle:hover,
.ana-sites button.ana-sites-cercle:focus-visible {
  z-index: 100; transform: translate(-50%, -50%) scale(1.1); box-shadow: 0 6px 14px rgba(0, 0, 0, .28);
}
.ana-sites button.ana-sites-cercle:focus-visible { outline: 3px solid var(--encre); outline-offset: 3px; }
.ana-sites-cercles .ana-sites-aide { text-align: center; }
@media (prefers-reduced-motion: reduce) { .ana-sites .ana-sites-cercle { transition: none; } }

/* Étroit (téléphone) : le total en bandeau, puis les groupes en rangées de cercles —
   les regroupements s'effacent derrière leurs sous-groupes. */
@container ana-cercles (max-width: 520px) {
  .ana-sites-cercles-figure { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; aspect-ratio: auto; }
  .ana-sites-cercles-traits, .ana-sites .ana-sites-cercle--parent { display: none; }
  .ana-sites-cercles-centre, .ana-sites .ana-sites-cercle { position: static; transform: none; }
  .ana-sites-cercles-centre { width: 100%; aspect-ratio: auto; flex-direction: row; gap: .5rem; padding: .6rem; border-radius: 10px; font-size: .9rem; }
  .ana-sites-cercles-total { font-size: 1.5rem; }
  .ana-sites .ana-sites-cercle, .ana-sites .ana-sites-cercle--satellite { width: 5rem; font-size: .6rem; }
  .ana-sites .ana-sites-cercle .ana-sites-cercle-valeur { font-size: .9rem; }
  .ana-sites button.ana-sites-cercle:hover, .ana-sites button.ana-sites-cercle:focus-visible { transform: scale(1.06); }
}

/* La liste des espèces d'un groupe, dans une fenêtre : une colonne, qui défile dans l'ordre. */
.ana-sites-dialogue {
  width: min(34rem, calc(100vw - 2rem)); max-height: min(85vh, 44rem); padding: 0; overflow: auto;
  border: 0; border-radius: 12px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); color: var(--encre); background: #fff;
}
.ana-sites-dialogue::backdrop { background: rgba(26, 43, 56, .5); }
.ana-sites-dialogue-entete {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: .75rem;
  padding: .85rem 1rem; background: #fff; border-bottom: 1px solid var(--filet);
}
.ana-sites-dialogue-icone { flex: none; display: grid; place-items: center; width: 2.6rem; height: 2.6rem; border-radius: 50%; background: var(--c); }
.ana-sites-dialogue-icone img { width: 60%; height: auto; }
.ana-sites .ana-sites-dialogue h4 { flex: 1; margin: 0; font-size: 1.05rem; }
.ana-sites .ana-sites-dialogue-fermer { flex: none; width: 2rem; height: 2rem; border-radius: 50%; font-size: 1rem; color: var(--encre-2); }
.ana-sites .ana-sites-dialogue-fermer:hover { background: var(--fond); color: var(--encre); }
.ana-sites ul.ana-sites-dialogue-liste { margin: 0; padding: .9rem 1.25rem 1.25rem; font-size: .9rem; }
.ana-sites ul.ana-sites-dialogue-liste li { margin: 0 0 .3rem; line-height: 1.35; }
.ana-sites-dialogue-liste i { color: var(--encre-2); }

/* Chaque espèce de la fenêtre : un lien vers sa fiche (Biodiv'Occitanie). */
.ana-sites .ana-sites-dialogue-note { margin: 0; padding: .7rem 1.25rem 0; font-size: .8rem; color: var(--encre-2); }
.ana-sites .ana-sites-dialogue-note a { color: inherit; }
/* Une espèce menacée : un astérisque rouge ; son sens, en toutes lettres, pour les lecteurs d'écran. */
.ana-sites .ana-menacee { color: var(--menacee); font-weight: 700; margin-left: .15em; cursor: help; }
.ana-sites .ana-menacee-texte { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.ana-sites .ana-sites-dialogue-legende { margin: 0; padding: 0 1.25rem 1.25rem; font-size: .8rem; color: var(--encre-2); }
.ana-sites .ana-sites-dialogue-legende .ana-menacee { margin: 0; }
/* Des liens qui se voient, au doigt comme à la souris : vert du site, soulignés. */
.ana-sites .ana-sites-dialogue-liste a {
  color: var(--vert-fonce); text-decoration: underline; text-decoration-color: rgba(47, 122, 54, .35);
  text-underline-offset: 2px;
}
.ana-sites .ana-sites-dialogue-liste a:hover, .ana-sites .ana-sites-dialogue-liste a:focus-visible { text-decoration-color: currentColor; }

/* Les milieux en cercles (avec la carte) : la surface au centre, un cercle par type ;
   pas d'icône, la surface en grand, le nombre de sites dessous. */
.ana-sites-cercles-detail { font-size: max(10px, 1.6cqw); font-weight: 500; }
/* Dix cercles sans satellites : un dessin plus serré, ramené à la taille des cercles de
   la biodiversité. */
.ana-sites-cercles--milieux .ana-sites-cercles-figure { width: min(100%, 30rem); }
.ana-sites-cercles--milieux .ana-sites-cercle-valeur { font-size: max(12px, 2cqw); }
.ana-sites-cercle-detail { margin-top: 3%; font-size: .85em; font-weight: 500; opacity: .9; }
.ana-sites .ana-sites-dialogue-site {
  display: inline; padding: 0; border: 0; background: none; font: inherit; text-align: left; cursor: pointer;
  color: var(--vert-fonce); text-decoration: underline; text-decoration-color: rgba(47, 122, 54, .35); text-underline-offset: 2px;
}
.ana-sites .ana-sites-dialogue-site:hover, .ana-sites .ana-sites-dialogue-site:focus-visible { text-decoration-color: currentColor; }
.ana-sites .ana-sites-dialogue-sites li { margin-bottom: .45rem; }
.ana-sites .ana-sites-dialogue-sites small { display: block; font-size: .78rem; color: var(--encre-2); }
@container ana-cercles (max-width: 520px) {
  .ana-sites-cercles-detail { font-size: .85rem; }
}

/* La fiche d'un milieu, en tête de sa fenêtre : photo, texte, sources. */
.ana-sites .ana-sites-dialogue-fiche { padding: .9rem 1.25rem 0; }
.ana-sites .ana-sites-fiche-photo { margin: 0 0 .75rem; }
.ana-sites .ana-sites-fiche-photo img { display: block; width: 100%; height: auto; border-radius: 8px; }
.ana-sites .ana-sites-fiche-photo figcaption { margin-top: .25rem; font-size: .72rem; color: var(--encre-2); text-align: right; }
.ana-sites .ana-sites-fiche-texte { font-size: .92rem; line-height: 1.55; }
.ana-sites .ana-sites-fiche-texte p { margin: 0 0 .6rem; }
.ana-sites .ana-sites-fiche-sources { margin: 0 0 .4rem; font-size: .78rem; color: var(--encre-2); }
.ana-sites .ana-sites-fiche-sources a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.ana-sites .ana-sites-dialogue-fiche + .ana-sites-dialogue-note { margin-top: .5rem; padding-top: .7rem; border-top: 1px solid var(--filet); }
