/* Panneau de choix du département (statique/js/departements.js) : champ bouton, panneau sous le champ en bureau,
   feuille du bas sur mobile. S'appuie sur les variables du thème. */

.dep { position: relative; }
.dep [hidden] { display: none !important; }

.dep-champ {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 0;
  border-radius: 14px;
  background: var(--fond);
  color: var(--texte);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px var(--bordure-forte);
}
.dep-champ:hover { box-shadow: inset 0 0 0 2px var(--lien); }
.dep-champ:focus-visible { outline: 3px solid var(--lien); outline-offset: 2px; }
.dep-champ[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--lien); }
.dep-champ[aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--cta); }
.dep-champ-vide .dep-valeur { color: var(--texte-secondaire); }
.dep-champ .ico { flex: none; width: 22px; height: 22px; color: var(--titre); }
.dep-valeur { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.dep-panneau {
  position: absolute;
  z-index: 60;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  max-height: min(420px, 70vh);
  padding: 12px;
  border-radius: 16px;
  background: var(--carte-fond);
  color: var(--texte);
  box-shadow: 0 0 0 1px var(--bordure), 0 24px 48px -16px rgba(12, 26, 19, 0.45);
}
.dep-fond { display: none; }

.dep-tete { display: none; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.dep-titre { margin: 0; font-weight: 800; font-size: 19px; color: var(--titre); }
.dep-fermer {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--titre);
  cursor: pointer;
}
.dep-fermer:focus-visible { outline: 3px solid var(--lien); outline-offset: 2px; }
.dep-fermer .ico { width: 22px; height: 22px; }

.dep-recherche { position: relative; flex: none; }
.dep-recherche .ico { position: absolute; left: 14px; top: 50%; width: 20px; height: 20px; transform: translateY(-50%); color: var(--texte-secondaire); pointer-events: none; }
.dep-recherche input::-webkit-search-cancel-button { display: none; }
.dep-recherche input {
  width: 100%;
  min-height: 50px;
  padding: 10px 14px 10px 44px;
  border: 0;
  border-radius: 12px;
  background: var(--fond);
  color: var(--texte);
  font: inherit;
  font-size: 17px;
  box-shadow: inset 0 0 0 2px var(--bordure-forte);
}
.dep-recherche input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--lien); }
.dep-recherche input:focus-visible { outline: 3px solid var(--lien); outline-offset: 2px; }

/* .dep devant : prend le pas sur les listes de .prose (retrait, marge entre puces, mesure) */
.dep .dep-liste { flex: 1 1 auto; min-height: 0; margin: 10px 0 0; padding: 0; overflow-y: auto; overscroll-behavior: contain; list-style: none; }
.dep .dep-option {
  display: flex;
  max-width: none;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  margin: 0;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}
.dep-code {
  flex: none;
  min-width: 2.6em;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--titre);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.dep-nom { color: var(--titre); }
.dep-option.dep-actif { background: var(--surface); box-shadow: inset 0 0 0 2px var(--lien); }
.dep-option[aria-selected="true"] { background: var(--lime); }
.dep-option[aria-selected="true"] .dep-nom { font-weight: 800; }
.dep-option[aria-selected="true"] .dep-code { background: var(--accent); color: var(--accent-texte); }

.dep-statut { margin: 8px 4px 0; font-size: 15.5px; color: var(--texte-secondaire); }
.dep-statut:empty { display: none; }
.dep-statut-vide { color: var(--texte); font-weight: 700; }

/* Mobile : feuille du bas sur presque toute la hauteur, page figée derrière */
@media (max-width: 39.99em) {
  html.dep-ouvert, html.dep-ouvert body { overflow: hidden; }
  .dep-fond { display: block; position: fixed; inset: 0; z-index: 1000; background: rgba(12, 26, 19, 0.55); }
  .dep-panneau {
    position: fixed;
    z-index: 1001;
    top: 6vh;
    top: 6dvh;
    bottom: 0;
    left: 0;
    right: 0;
    max-height: none;
    padding: 16px 16px calc(16px + env(safe-area-inset-bottom));
    border-radius: 20px 20px 0 0;
  }
  .dep-tete { display: flex; }
  .dep-option { min-height: 52px; }
}
