/*
 * Pages annuaire des mairies : /mairies, /mairies/regions, /mairies/region/<region>,
 * /mairies/departement/<departement> (inc/mairies_helper.php).
 * Complete assets/css/pages/acceuil.css (hero clair, sf-section, sf-city-grid, sf-city-card, sf-btn),
 * charge juste avant : seuls les blocs propres a l'annuaire sont definis ici.
 */

body.sf-mairies-page { background: #fff; }

.sf-mairies-page a:focus-visible,
.sf-mairies-page button:focus-visible,
.sf-mairies-page summary:focus-visible {
  outline: 2px solid var(--brand-ink);
  outline-offset: 2px;
}

/* ---------- Hero ---------- */
.sf-mairies-hero { position: relative; overflow: hidden; color: var(--brand-ink); }
.sf-mairies-hero-inner { position: relative; padding-top: 7rem; padding-bottom: 3rem; }
@media (min-width: 1024px) {
  .sf-mairies-hero-inner { padding-top: 8rem; padding-bottom: 3.25rem; }
}

/* La section qui suit le hero ouvre sinon sur 7rem, qui s'ajoutent a la marge basse du hero :
   pres de 11rem de blanc entre la photo et le premier titre. */
.sf-mairies-hero + .sf-section { padding-top: 3.25rem; }
@media (min-width: 640px) { .sf-mairies-hero + .sf-section { padding-top: 4rem; } }

.sf-mairies-hero-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
  user-select: none;
}
/* Renfort blanc sur la zone du titre : la photo est bien plus chargee que le ciel pale de l'accueil
   (carrosserie blanche, rue passante). Le voile vertical seul ne suffisait pas : on ajoute un voile
   horizontal qui rend la colonne de texte a gauche presque opaque, tandis que le camion reste net a
   droite. */
.sf-mairies-hero-veil {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(to right, rgb(255 255 255 / 0.92) 0%, rgb(255 255 255 / 0.82) 38%, rgb(255 255 255 / 0.35) 68%, transparent 100%),
    linear-gradient(to bottom, rgb(255 255 255 / 0.55) 0%, rgb(255 255 255 / 0.32) 55%, rgb(255 255 255 / 0.58) 100%);
}
@media (max-width: 767px) {
  /* En colonne etroite le texte occupe toute la largeur : le degrade horizontal ne protege plus rien. */
  .sf-mairies-hero-veil {
    background-image: linear-gradient(to bottom, rgb(255 255 255 / 0.9) 0%, rgb(255 255 255 / 0.82) 60%, rgb(255 255 255 / 0.88) 100%);
  }
}

.sf-mairies-breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
  font-size: 0.75rem;
  color: var(--brand-muted);
}
.sf-mairies-breadcrumb a { color: inherit; text-decoration: none; }
.sf-mairies-breadcrumb a:hover { color: var(--brand-ink); }
.sf-mairies-breadcrumb .is-current { font-weight: 500; color: var(--brand-ink); }

.sf-mairies-title {
  margin: 1.25rem 0 0;
  max-width: 46rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.875rem;
  line-height: 1.15;
  letter-spacing: -0.01em;
  color: var(--brand-ink);
  text-wrap: balance;
}
@media (min-width: 640px) { .sf-mairies-title { font-size: 2.5rem; } }
/* Le jaune de la charte sur fond clair plafonne a ~1,4:1 de contraste : illisible des que la phrase
   surlignee depasse un mot. Le mot-cle garde donc l'encre, et le jaune devient un surligneur —
   la couleur reste au premier plan, le texte redevient lisible sur n'importe quelle photo. */
.sf-mairies-title span {
  color: var(--brand-ink);
  background-image: linear-gradient(to bottom, transparent 58%, rgba(var(--brand-yellow-rgb), 0.9) 58%);
  padding: 0 0.12em 0.04em;
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
}

/* Sur photo, le gris de --brand-muted disparait : encre a 82 %, plus dense. */
.sf-mairies-sub {
  margin: 1rem 0 0;
  max-width: 42rem;
  font-size: 0.9375rem;
  line-height: 1.65;
  font-weight: 500;
  color: rgba(var(--brand-ink-rgb), 0.82);
}
@media (min-width: 640px) { .sf-mairies-sub { font-size: 1rem; } }

.sf-mairies-stats {
  margin: 1.75rem 0 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.5rem;
}
.sf-mairies-stats .value {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  color: var(--brand-ink);
}
.sf-mairies-stats .label { display: block; font-size: 0.8125rem; font-weight: 500; color: rgba(var(--brand-ink-rgb), 0.72); }

/* ---------- Recherche ----------
   Carte focale : la recherche est l'action principale de la page, elle doit primer sur le texte
   voisin. Meme traitement que le bloc assistant de l'accueil (lisere jaune + halo). */
.sf-mairies-search {
  position: relative;
  width: 100%;
  max-width: 40rem;
  border-radius: 1.5rem;
  background: #fff;
  padding: 1.25rem;
  box-shadow:
    inset 0 1px 0 rgb(255 255 255 / 0.95),
    0 0 0 1.5px rgba(var(--brand-yellow-rgb), 0.7),
    0 0 0 7px rgba(var(--brand-yellow-rgb), 0.14),
    0 2px 4px rgba(var(--brand-ink-rgb), 0.05),
    0 20px 40px -22px rgba(var(--brand-ink-rgb), 0.22);
}
.sf-mairies-search::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -2rem -1rem;
  pointer-events: none;
  background-image: radial-gradient(closest-side, rgba(var(--brand-yellow-rgb), 0.22), transparent 100%);
}

.sf-mairies-search-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand-ink);
}
.sf-mairies-search-field { position: relative; }
.sf-mairies-search-field > svg {
  position: absolute;
  left: 1.15rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--brand-muted);
  pointer-events: none;
}
.sf-mairies-search-field input {
  width: 100%;
  height: 3.75rem;
  border: 1.5px solid var(--brand-border);
  border-radius: 0.9rem;
  background: var(--brand-surface);
  padding: 0 3.25rem 0 3.25rem;
  font-family: var(--font-sans);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--brand-ink);
  transition: border-color 180ms ease, box-shadow 180ms ease, background-color 180ms ease;
}
.sf-mairies-search-field input::placeholder { color: var(--brand-muted); font-weight: 400; }
.sf-mairies-search-field input:hover { background: #fff; }
.sf-mairies-search-field input:focus {
  outline: none;
  background: #fff;
  border-color: var(--brand-yellow);
  box-shadow: 0 0 0 3px rgba(var(--brand-yellow-rgb), 0.35);
}
/* La croix native de <input type="search"> ferait doublon avec notre bouton. */
.sf-mairies-search-field input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.sf-mairies-search-clear {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--brand-muted);
  cursor: pointer;
  transition: background-color 160ms ease, color 160ms ease;
}
.sf-mairies-search-clear:hover { background: var(--brand-surface); color: var(--brand-ink); }
.sf-mairies-search-clear[hidden] { display: none; }

.sf-mairies-search-count {
  margin: 0.6rem 0 0;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand-muted);
}
.sf-mairies-search-count[hidden] { display: none; }

.sf-mairies-toolbar {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  justify-content: space-between;
}
.sf-mairies-toolbar > * { min-width: 0; }
/* Sans repartition explicite, la colonne de recherche se reduit au contenu du titre voisin. */
@media (min-width: 768px) {
  .sf-mairies-toolbar { flex-direction: row; align-items: flex-end; gap: 2.5rem; }
  .sf-mairies-toolbar > .sf-section-header { flex: 1 1 22rem; }
  .sf-mairies-toolbar-search { flex: 1 1 40rem; }
  .sf-mairies-toolbar > .sf-mairies-search { flex: 1 1 40rem; }
}

.sf-mairies-region-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  border-radius: 999px;
  background: rgba(var(--brand-yellow-rgb), 0.14);
  padding: 0.7rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--brand-ink);
  text-decoration: none;
  transition: background-color 180ms ease;
}
.sf-mairies-region-link:hover { background: rgba(var(--brand-yellow-rgb), 0.24); color: var(--brand-ink); }

.sf-mairies-empty {
  margin: 2rem 0 0;
  border-radius: 1rem;
  background: #fff;
  padding: 2rem 1.5rem;
  text-align: center;
  font-size: 0.9375rem;
  color: var(--brand-muted);
  box-shadow: inset 0 0 0 1px rgba(var(--brand-ink-rgb), 0.07);
}

/* Masquage pendant une recherche (le script bascule cette classe). */
.sf-mairies-hidden { display: none !important; }

/* ---------- Liste par departement ---------- */
.sf-mairies-departments { margin-top: 2.5rem; display: flex; flex-direction: column; gap: 0.75rem; }

.sf-mairies-dep {
  border: 1px solid var(--brand-border);
  border-radius: 1rem;
  background: #fff;
  overflow: hidden;
}
.sf-mairies-dep > summary {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  color: var(--brand-ink);
}
.sf-mairies-dep > summary::-webkit-details-marker { display: none; }
.sf-mairies-dep > summary .code {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 1.75rem;
  flex-shrink: 0;
  border-radius: 0.5rem;
  background: var(--brand-cream);
  font-size: 0.8125rem;
  font-weight: 700;
}
.sf-mairies-dep > summary .label { flex: 1; min-width: 0; font-size: 0.9375rem; }
.sf-mairies-dep > summary .label small {
  display: block;
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--brand-muted);
}
.sf-mairies-dep > summary .count {
  flex-shrink: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--brand-muted);
}
.sf-mairies-dep > summary .chev { flex-shrink: 0; color: var(--brand-muted); transition: transform 180ms ease; }
.sf-mairies-dep[open] > summary .chev { transform: rotate(180deg); }
.sf-mairies-dep > summary:hover { background: var(--brand-surface); }
.sf-mairies-dep-body { padding: 0 1.25rem 1.25rem; }
.sf-mairies-dep-body .sf-city-grid { margin-top: 0; }

/* ---------- Cartes region / departement ---------- */
.sf-mairies-cards { margin-top: 2.5rem; display: grid; gap: 1rem; }
@media (min-width: 640px) { .sf-mairies-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1024px) { .sf-mairies-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.sf-mairies-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  height: 100%;
  border-radius: 1.25rem;
  background: #fff;
  padding: 1.25rem;
  color: inherit;
  text-decoration: none;
}
.sf-mairies-card .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: 0.875rem;
  background: var(--brand-cream);
  color: var(--brand-ink);
}
.sf-mairies-card .body { display: flex; min-width: 0; flex: 1; flex-direction: column; }
.sf-mairies-card .title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
  color: var(--brand-ink);
}
.sf-mairies-card .badge {
  display: inline-flex;
  align-items: center;
  border-radius: 0.5rem;
  background: rgba(var(--brand-yellow-rgb), 0.22);
  padding: 0.1rem 0.45rem;
  font-size: 0.75rem;
  font-weight: 700;
}
.sf-mairies-card .text { margin-top: 0.25rem; font-size: 0.875rem; color: var(--brand-muted); }
.sf-mairies-card .arrow { flex-shrink: 0; color: var(--brand-muted); transition: transform 180ms ease; }
.sf-mairies-card:hover .arrow { transform: translateX(2px); color: var(--brand-ink); }

/* ---------- Texte SEO et retours ---------- */
.sf-mairies-prose { max-width: 48rem; }
.sf-mairies-prose p { margin: 1rem 0 0; font-size: 0.9375rem; line-height: 1.75; color: var(--brand-muted); }
.sf-mairies-prose h3 {
  margin: 2rem 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.125rem;
  color: var(--brand-ink);
}
.sf-mairies-links { margin-top: 1.75rem; display: flex; flex-wrap: wrap; gap: 0.5rem; }
.sf-mairies-links a {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  border: 1px solid var(--brand-border);
  border-radius: 999px;
  background: #fff;
  padding: 0.45rem 0.9rem;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--brand-ink);
  text-decoration: none;
  transition: background-color 180ms ease, border-color 180ms ease;
}
.sf-mairies-links a:hover { background: rgba(var(--brand-yellow-rgb), 0.14); border-color: rgba(var(--brand-yellow-rgb), 0.5); }

.sf-mairies-back { margin-top: 2.5rem; display: flex; flex-wrap: wrap; gap: 0.75rem; }

/* ---------- CTA sombre ---------- */
.sf-mairies-cta { position: relative; overflow: hidden; color: #fff; }
.sf-mairies-cta-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.5rem;
  padding-top: 3.5rem;
  padding-bottom: 3.5rem;
}
@media (min-width: 768px) {
  .sf-mairies-cta-inner { flex-direction: row; align-items: center; justify-content: space-between; gap: 2.5rem; }
}
.sf-mairies-cta h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.5rem;
  letter-spacing: -0.01em;
  color: #fff;
}
@media (min-width: 640px) { .sf-mairies-cta h2 { font-size: 1.75rem; } }
.sf-mairies-cta p { margin: 0.5rem 0 0; font-size: 0.9375rem; color: rgba(255, 255, 255, 0.7); }
.sf-mairies-cta-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; flex-shrink: 0; }

@media (prefers-reduced-motion: reduce) {
  .sf-mairies-dep > summary .chev,
  .sf-mairies-card .arrow { transition: none; }
}
