/*
 * Barre utilitaire, barre d'alerte, header, navigation et drawer mobile.
 *
 * Reprise fidèle de la maquette, classes conservées telles quelles.
 * Six écarts, tous volontaires :
 *
 * 1. État transparent conditionné à body.has-hero. Dans la maquette, le header
 *    est transparent tant que la page n'a pas défilé, parce qu'il flotte sur le
 *    hero. Une page interne sans hero afficherait du texte blanc sur fond clair :
 *    l'état transparent est donc réservé aux pages dont le premier bloc est un
 *    hero (classe posée sur <body> par le thème). Voir CLAUDE.md, piège n° 1.
 *
 * 2. Étiquette « Alerte » : texte --ink au lieu de blanc sur --gold.
 *    2.56:1 → 6.34:1. Le gold est conservé.
 *
 * 3. Sous-menus ouverts aussi au clavier (:focus-within), pas seulement au
 *    survol. Sans cela ils sont inatteignables sans souris (RGAA 10.7 / 12.x).
 *
 * 4. Zone cliquable portée à 44 px sur les boutons plus petits que cela
 *    (fermeture de l'alerte, bouton de recherche) par un pseudo-élément
 *    transparent : la taille visuelle de la maquette est intacte, la cible
 *    tactile est conforme.
 *
 * 5. Recherche : le bouton ouvre un champ dans le header, sur toutes les pages.
 *    Dans la maquette il faisait défiler jusqu'au champ du hero, qui n'existe
 *    pas ailleurs. Un seul comportement, prévisible et utilisable au clavier
 *    (RGAA 12.2, cohérence de la navigation). Voir CLAUDE.md, piège n° 7.
 *
 * 6. Bascule vers le tiroir à 1300 px au lieu de 980 : en dessous, la
 *    navigation ne tient pas sur une ligne (voir plus bas).
 *
 * 7. Navigation agrandie à la demande du client (7 octobre 2026) : 16 px au
 *    lieu de 14. Pour que l'ensemble tienne encore dans le conteneur de
 *    1280 px, les entrées passent de 14 à 11 px de marge latérale et les
 *    groupes du header de 32 à 24 px d'écart.
 *
 * Tailles de police : ce fichier est le SEUL du thème qui reste en px (les
 * autres sont en rem). Le réglage « Taille du texte » du panneau
 * d'accessibilité agrandit la racine ; si la navigation suivait, ses cinq
 * entrées déborderaient du header à 1280 px dès « A+ ». Le header reste donc
 * stable, le contenu grandit — le zoom du navigateur, lui, agrandit tout.
 */

/* ==========================================================================
   Barre utilitaire
   ========================================================================== */

.utility {
  background: var(--navy);
  color: #d8d4cb;
  font-size: 13px;
}

.utility .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: var(--h-utility);
  /* Écart vertical réduit : quand le bandeau passe sur deux lignes (tablette),
     les 24 px d'écart horizontal les écartaient trop. */
  gap: 4px 24px;
  padding-top: 6px;
  padding-bottom: 6px;
  flex-wrap: wrap;
}

.utility-left { display: flex; gap: 20px; align-items: center; }

.utility-left .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 6px rgba(74, 222, 128, 0.5);
  display: inline-block;
  margin-right: 8px;
}

/* Mairie fermée : la pastille passe au neutre. L'information reste portée par
   le texte, jamais par la seule couleur (RGAA 3.1). */
.utility-left .dot.is-closed {
  background: rgba(255, 255, 255, 0.45);
  box-shadow: none;
}

/*
 * L'état d'ouverture mène aux horaires (schwob_hours_url()). Souligné en
 * permanence, discrètement : sans lui, rien ne dit que la phrase se clique.
 */
.utility-status {
  display: inline-flex;
  align-items: center;
  color: inherit;
  text-decoration: underline;
  text-decoration-color: rgba(255, 255, 255, 0.35);
  text-underline-offset: 3px;
  transition: color .2s, text-decoration-color .2s;
}

.utility-status:hover { color: #fff; text-decoration-color: currentColor; }

.utility-right {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 18px;
  align-items: center;
}

/*
 * Ces liens vivent dans une barre de 38 px : la cible ne peut pas atteindre
 * 44 px sans casser la maquette. Ce sont des liens en ligne dans un bloc de
 * texte, cas explicitement exclu du critère de taille de cible (WCAG 2.5.8).
 */
.utility-right a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0.85;
  transition: opacity .2s;
}

.utility-right a:hover { opacity: 1; }
.utility-right a::after { content: none; } /* pas de repère ↗ dans la barre */
.utility-right .sep { opacity: 0.3; }
.utility-right svg { width: 12px; height: 12px; --icon-boost: 8px; }

/*
 * Sous 620 px : icônes seules, intitulés réservés aux lecteurs d'écran (même
 * technique que .sr-only). Chaque lien garde une cible de 32 × 32 px, au-dessus
 * des 24 px du critère WCAG 2.5.8 ; les mêmes actions existent en grand dans le
 * menu et le pied de page.
 */
@media (max-width: 620px) {
  .utility .container { gap: 2px 16px; padding-top: 4px; padding-bottom: 4px; }
  .utility-right { gap: 4px; margin-left: -8px; }
  .utility-right .sep { display: none; }

  .utility-right a {
    justify-content: center;
    min-width: 32px;
    min-height: 32px;
  }

  .utility-right svg { width: 16px; height: 16px; --icon-boost: 4px; }

  .utility-label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }
}

/* ==========================================================================
   Barre d'alerte
   ========================================================================== */

.alert-bar {
  background: var(--alert-bg);
  border-bottom: 1px solid var(--alert-line);
  color: var(--alert-ink);
}

.alert-bar .container {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-top: 13px;
  padding-bottom: 13px;
}

.alert-ico {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
}

.alert-ico svg {
  width: 22px;
  height: 22px;
  color: var(--alert-ico);
}

.alert-bar p { flex: 1; font-size: 15px; line-height: 1.45; }
.alert-bar p strong { font-weight: 700; }

/* Écart n° 2 : --ink sur --gold, 6.34:1. */
.alert-bar .alert-label {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: var(--ls-eyebrow);
  text-transform: uppercase;
  background: var(--gold);
  color: var(--ink);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  margin-right: 10px;
  vertical-align: middle;
  white-space: nowrap;
}

.alert-bar a {
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.alert-close {
  position: relative;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--alert-ink);
  transition: background .2s;
}

/* Écart n° 4 : cible de 44 px sans changer la taille visible. */
.alert-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--touch);
  height: var(--touch);
  transform: translate(-50%, -50%);
}

.alert-close:hover { background: rgba(91, 68, 8, 0.1); }
.alert-close svg { width: 16px; height: 16px; --icon-boost: 4px; }

/* ==========================================================================
   Header
   ========================================================================== */

.header {
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
  transition: background .35s ease, border-color .35s ease, box-shadow .35s ease;
}

.header.scrolled { box-shadow: 0 8px 28px rgba(20, 32, 57, 0.10); }

.header .container {
  display: flex;
  align-items: center;
  height: var(--h-header);
  /* 24 px et non la gouttière de 32 : la place est rendue à la navigation
     agrandie (écart n° 7). */
  gap: 24px;
}

/* --------------------------------------------------------------------------
   Écart n° 1 — état transparent, uniquement quand le header flotte sur un hero
   -------------------------------------------------------------------------- */

.has-hero .header:not(.scrolled) {
  background: transparent;
  border-bottom-color: transparent;
  backdrop-filter: none;
}

.has-hero .header:not(.scrolled) .brand-name { color: #fff; }
.has-hero .header:not(.scrolled) .brand-sub { color: rgba(255, 255, 255, 0.72); }
.has-hero .header:not(.scrolled) .nav-item > a { color: rgba(255, 255, 255, 0.92); }

.has-hero .header:not(.scrolled) .nav-item > a:hover,
.has-hero .header:not(.scrolled) .nav-item:hover > a,
.has-hero .header:not(.scrolled) .nav-item:focus-within > a,
.has-hero .header:not(.scrolled) .nav-item.active > a {
  color: #fff;
  background: rgba(255, 255, 255, 0.15);
}

/*
 * Fond sombre et non plus blanc translucide : le blanc à 14 % éclaircissait la
 * photo sous un texte blanc, 1,63:1 (audit du 16 novembre 2026, RGAA 3.2).
 */
.has-hero .header:not(.scrolled) .cta-btn {
  background: rgba(15, 22, 40, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.55);
}

.has-hero .header:not(.scrolled) .cta-btn:hover {
  background: #fff;
  color: var(--navy);
  border-color: #fff;
}

.has-hero .header:not(.scrolled) .menu-toggle,
.has-hero .header:not(.scrolled) .search-toggle { color: #fff; }

.has-hero .header:not(.scrolled) .menu-toggle:hover,
.has-hero .header:not(.scrolled) .search-toggle:hover { background: rgba(255, 255, 255, 0.15); }

/* --------------------------------------------------------------------------
   Identité
   -------------------------------------------------------------------------- */

.brand { display: flex; align-items: center; gap: 14px; }

/* L'identité est un lien : ses sous-parties sont des <span> passés en bloc,
   plutôt que des <div> imbriqués dans un <a>. */
.crest {
  display: block;
  width: 46px;
  height: 52px;
  flex-shrink: 0;
}

.crest img { width: 100%; height: 100%; object-fit: contain; }

.brand-text { display: block; line-height: 1.1; }

.brand-name {
  display: block;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.brand-sub {
  display: block;
  font-family: var(--mono);
  font-size: 10.5px; /* fixe */
  text-transform: uppercase;
  letter-spacing: var(--ls-eyebrow);
  color: var(--ink-3);
  margin-top: 4px;
}

/* --------------------------------------------------------------------------
   Navigation principale
   -------------------------------------------------------------------------- */

.nav {
  display: flex;
  margin-left: auto;
  height: 100%;
  align-items: stretch;
}

/* La liste des entrées (role="list", RGAA 9.3) porte la rangée du menu. */
.nav-list {
  display: flex;
  gap: 2px;
  height: 100%;
  align-items: stretch;
}

.nav-item { position: relative; display: flex; align-items: center; }

.nav-item > a {
  padding: 10px 11px;
  font-size: 16px;   /* fixe : voir l'en-tête du fichier (écart n° 7) */
  font-weight: 500;
  color: var(--ink-2);
  border-radius: var(--r-field);
  transition: color .2s, background .2s;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.nav-item > a:hover,
.nav-item.active > a,
.nav-item:hover > a,
.nav-item:focus-within > a { color: var(--ink); background: var(--bg-alt); }

.nav-item .caret { width: 10px; height: 10px; opacity: 0.5; transition: transform .2s; --icon-boost: 8px; }

.nav-item:hover .caret,
.nav-item:focus-within .caret { transform: rotate(180deg); }

.dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.08);
  min-width: 280px;
  padding: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
  z-index: 60;
}

/* Écart n° 3 : ouverture au survol ET au clavier. */
.nav-item:hover .dropdown,
.nav-item:focus-within .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Refermé par Échap (header.js, RGAA 10.13) jusqu'à la sortie du pointeur ou du focus. */
.nav-item.is-dismissed .dropdown {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
}

.nav-item.is-dismissed .caret { transform: none; }

/* Le dernier élément de menu ouvre son sous-menu vers la gauche pour ne pas
   déborder du conteneur. */
.nav-item:last-child .dropdown { left: auto; right: 0; }

.dropdown a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 14px;
  border-radius: 4px;
  font-size: 14px;   /* fixe : voir l'en-tête du fichier */
  color: var(--ink-2);
  transition: color .15s, background .15s;
}

.dropdown a:hover { background: var(--bg-alt); color: var(--ink); }

.dropdown a .num {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--ink-3);
  letter-spacing: 0.1em;
}

.dropdown-head {
  padding: 6px 14px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--line-soft);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   Bouton « Nous contacter »
   -------------------------------------------------------------------------- */

.cta-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  min-height: var(--touch);
  background: var(--navy);
  color: #fff;
  border: 1px solid transparent;
  border-radius: var(--r-pill);
  font-size: 14px;   /* fixe : voir l'en-tête du fichier */
  font-weight: 500;
  white-space: nowrap;
  transition: transform .2s, background .2s;
}

.cta-btn:hover { background: var(--terra); transform: translateY(-1px); }
.cta-btn svg { width: 14px; height: 14px; --icon-boost: 6px; }

/* --------------------------------------------------------------------------
   Recherche du header (écart n° 5)
   -------------------------------------------------------------------------- */

/*
 * La zone de recherche est un <details> : elle s'ouvre et se ferme sans une
 * ligne de JavaScript, au clic comme au clavier, et le navigateur gère seul
 * l'état exposé aux technologies d'assistance. Le script du header n'ajoute que
 * le confort (fermeture par Échap, focus porté sur le champ).
 */
.header-search { position: relative; display: flex; align-items: center; }

.search-toggle {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--ink);
  cursor: pointer;
  list-style: none;
  transition: background .2s;
}

/* Masque le triangle par défaut du <summary>. */
.search-toggle::marker,
.search-toggle::-webkit-details-marker { display: none; content: ""; }

.search-toggle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--touch);
  height: var(--touch);
  transform: translate(-50%, -50%);
}

.search-toggle:hover { background: var(--bg-alt); }
.search-toggle svg { width: 18px; height: 18px; }

.header-search-form {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  /* 420 px : à 380, « Rechercher une page, une actualité… » était coupé. */
  width: min(92vw, 420px);
  padding: 4px 4px 4px 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  box-shadow: 0 16px 40px rgba(10, 18, 40, 0.16);
}

.header-search-form .search-ico {
  width: 18px;
  height: 18px;
  color: var(--ink-3);
}

/*
 * Le champ efface son contour : c'est le formulaire entier qui montre le focus.
 * Le formulaire flotte souvent sur la photo sombre de l'en-tête, où le terra ne
 * fait que 2.4:1 : un filet blanc comble l'écart entre le formulaire et le
 * liseré, qui se détache ainsi sur du blanc (5.3:1) quel que soit le fond.
 */
.header-search-form:focus-within {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--paper), 0 16px 40px rgba(10, 18, 40, 0.16);
}

.header-search-form input[type="search"] {
  flex: 1;
  min-width: 0;
  height: var(--touch);
  border: none;
  outline: none;
  background: none;
  font-size: 15px;
  color: var(--ink);
}

.header-search-form input[type="search"]::placeholder { color: var(--ink-3); }

.header-search-form button[type="submit"] {
  flex-shrink: 0;
  height: var(--touch);
  padding: 0 18px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--r-pill);
  font-size: 13.5px;
  font-weight: 600;
  transition: background .2s;
}

.header-search-form button[type="submit"]:hover { background: var(--terra); }

/* --------------------------------------------------------------------------
   Bascule du drawer — masquée au-dessus de 1300 px
   -------------------------------------------------------------------------- */

.menu-toggle {
  display: none;
  width: var(--touch);
  height: var(--touch);
  place-items: center;
  border-radius: 10px;
  color: var(--ink);
}

.menu-toggle svg { width: 24px; height: 24px; }
.menu-toggle:hover { background: var(--bg-alt); }

.mobile-nav { display: none; }
.mobile-overlay { display: none; }

/* ==========================================================================
   Sous 1300 px — la navigation devient un drawer
   ==========================================================================

   Écart n° 6, ajouté après revue : la maquette basculait à 980 px. Mesuré, ses
   cinq entrées, la recherche et « Nous contacter » ne tenaient sur une ligne
   qu'à partir de 1240 px. Entre 981 et 1080 px le bouton sortait de l'écran
   (défilement horizontal, RGAA 10.11), et jusqu'à 1239 px « Activités &
   tourisme » passait sur trois lignes. Une tablette en paysage et un portable
   zoomé ont donc le tiroir.

   Depuis la navigation en 16 px (écart n° 7), la bascule est à 1300 px.
   Calculé sur les métriques des polices, crénage compris : la ligne demande
   1206 px de contenu, soit 1270 px de fenêtre, 1287 px avec une barre de
   défilement Windows. 1300 laisse une marge, et le conteneur plafonné à
   1216 px de contenu garde 10 px d'aisance. À vérifier à l'écran. */

@media (max-width: 1300px) {
  .header .container { gap: 14px; }

  .nav { display: none; }
  .menu-toggle { display: grid; }

  .mobile-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(10, 18, 40, 0.5);
    z-index: 190;
    opacity: 0;
    visibility: hidden;
    transition: opacity .3s, visibility .3s;
  }

  .mobile-overlay.open { opacity: 1; visibility: visible; }

  /*
   * Fermé, le tiroir est hors écran ET masqué (visibility) : sans cela ses liens
   * restaient atteignables au clavier — 24 tabulations dans le vide à 390 px —
   * et un lecteur d'écran y voyait une seconde navigation (RGAA 10.8, 12.8).
   * La visibilité ne se retire qu'à la fin du glissement, pour qu'il reste
   * visible pendant qu'il se referme ; elle revient immédiatement à l'ouverture.
   */
  .mobile-nav {
    display: block;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(86vw, 360px);
    background: var(--paper);
    z-index: 200;
    transform: translateX(calc(100% + 48px));
    visibility: hidden;
    transition: transform .3s ease, visibility 0s linear .3s;
    box-shadow: -12px 0 44px rgba(10, 18, 40, 0.25);
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 22px 22px 32px;
  }

  .mobile-nav.open {
    transform: none;
    visibility: visible;
    transition: transform .3s ease, visibility 0s;
  }

  .mobile-nav-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
  }

  .mobile-nav-head .t {
    font-family: var(--mono);
    font-size: 10.5px; /* fixe */
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--ink-3);
  }

  .mobile-nav-close {
    width: var(--touch);
    height: var(--touch);
    display: grid;
    place-items: center;
    border-radius: 10px;
    color: var(--ink);
  }

  .mobile-nav-close:hover { background: var(--bg-alt); }
  .mobile-nav-close svg { width: 22px; height: 22px; }

  .mobile-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 500;
    color: var(--ink);
    border-bottom: 1px solid var(--line-soft);
  }

  /*
   * Pas de filet sous le dernier lien de la liste (« Nous contacter ») ni sous le
   * dernier lien de chaque sous-menu. Écrit d'après la liste (RGAA 9.3) : un
   * simple a:last-child viserait aussi chaque entrée sans sous-menu, seule dans
   * son élément de liste.
   */
  .mobile-nav-list > [role="listitem"]:last-child > a:last-child,
  .mobile-sub > [role="listitem"]:last-child > a { border-bottom: none; }
  .mobile-nav a:hover { background: var(--bg-alt); }
  .mobile-nav a svg { width: 20px; height: 20px; color: var(--navy); }

  /* Sous-niveaux du menu principal, en retrait dans le drawer. */
  .mobile-nav .mobile-sub a {
    min-height: 48px;
    padding-left: 44px;
    font-size: 15px;
    font-weight: 400;
    color: var(--ink-2);
  }

  /*
   * La navigation, qui poussait les commandes à droite (margin-left: auto), est
   * masquée : la recherche prend le relais. Sans cela, entre 621 et 1300 px,
   * recherche, menu et « Nous contacter » se tassaient contre le nom du village.
   */
  .header-search { margin-left: auto; }

  /*
   * Le champ s'accroche au header et non plus à la loupe : calé sur le bord
   * droit du bouton, il débordait de l'écran à gauche (34 px à 390 px de large).
   * Pleine largeur moins les gouttières, plafonné à 480 px et aligné à droite.
   */
  .header .container { position: relative; }
  .header-search { position: static; }

  .header-search-form {
    left: var(--gutter);
    right: var(--gutter);
    width: auto;
    max-width: 480px;
    margin-left: auto;
  }
}

/*
 * Sous 620 px, le bouton « Nous contacter » sort du header : identité, recherche
 * et bascule de menu occupent déjà toute la largeur. Le même lien figure en tête
 * du drawer et dans le pied de page, il ne disparaît donc pas du parcours.
 */
@media (max-width: 620px) {
  .header .cta-btn { display: none; }
  .crest { width: 38px; height: 44px; }
  .brand-name { font-size: 19px; }
}
