/* ================================================================
   STYLES COMMUNS — Mairie de Navacelles
   Chargé par toutes les pages publiques (accueil, article, école,
   gestion des déchets). Contient les styles de l'en-tête, du pied de
   page, des boutons, de la fenêtre d'accessibilité et du bouton
   « retour en haut », alignés sur la page d'accueil.
   Les styles propres à une page restent dans le <style> de la page.
================================================================ */

/* ── Variables (palette République — RGAA AA) ──────────────────── */
:root {
  --rep-50:  #EEF4FB;
  --rep-100: #D5E4F4;
  --rep-200: #A9C8EA;
  --rep-300: #73A7DA;
  --rep-400: #3D85C8;
  --rep-500: #1A63A8;
  --rep-600: #144F8A;
  --rep-700: #0E3C6D;
  --rep-800: #082B50;
  --rep-900: #041A33;
  --gold-500: #B8891A;
  --focus-ring: 0 0 0 2px #fff, 0 0 0 4px #1A63A8;
}

/* ── Base ──────────────────────────────────────────────────────── */
html { scroll-padding-top: 76px; }
body { font-family: 'Noto Sans', sans-serif; background: #fff; color: #1a2535; }
h1, h2, h3, h4, h5 { font-family: 'Spectral', Georgia, serif; }

/* ── Accessibilité — RGAA AA ───────────────────────────────────── */
/* Lien d'évitement (skip-nav) */
.skip-nav {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--rep-800);
  color: #fff;
  padding: .75rem 1.5rem;
  font-weight: 700;
  z-index: 9999;
  border-radius: 0 0 8px 0;
  text-decoration: none;
  transition: top .2s;
}
.skip-nav:focus { top: 0; }

/* Focus visible universel — RGAA 10.7 */
*:focus-visible {
  outline: none !important;
  box-shadow: var(--focus-ring) !important;
  border-radius: 4px;
}
a, button, input, select, textarea { outline-offset: 2px; }

/* ── Navigation ────────────────────────────────────────────────── */
.nav-underline { position: relative; }
.nav-underline::after {
  content: '';
  position: absolute;
  bottom: -3px; left: 0;
  width: 0; height: 2px;
  background: var(--gold-500);
  transition: width .25s ease;
}
.nav-underline:hover::after,
.nav-underline[aria-current="page"]::after { width: 100%; }
.nav-underline[aria-current="page"] { color: var(--rep-600); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }

/* Menu mobile */
#mobile-nav { display: none; }
#mobile-nav.open { display: block; max-height: calc(100vh - 64px); max-height: calc(100dvh - 64px); overflow-y: auto;
                   overscroll-behavior: contain; box-shadow: 0 14px 24px -12px rgba(4,26,51,.45); }
/* Menu ouvert : la page s'assombrit derrière (un toucher sur le voile referme le menu) et ne défile plus */
@media (max-width: 1023.98px) {
  html.menu-ouvert { overflow: hidden; }
  html.menu-ouvert body::after { content: ''; position: fixed; inset: 64px 0 0 0; z-index: 40; background: rgba(4,26,51,.55); }
}
@media (min-width: 1024px) { #mobile-nav.open { display: none; } }

/* ── Sous-menus (ordinateur) ─────────────────────────────────────
   S'ouvrent au clic et au clavier (classe « ouvert » posée par scripts.php,
   qui pose aussi « nav-js » sur <html>). Sans JavaScript : au survol et au focus. */
.nav-item { position: relative; }
.nav-parent { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; background: none; border: 0;
              font: inherit; color: inherit; cursor: pointer; }
.nav-parent.is-actif { color: var(--rep-600); font-weight: 700; }
.nav-parent.is-actif::after { width: 100%; }
.nav-chevron { font-size: .65em; transition: transform .2s ease; }
.nav-item.ouvert .nav-chevron { transform: rotate(180deg); }
.nav-sous-menu { display: none; position: absolute; top: calc(100% + 10px); left: 0; z-index: 60; min-width: 250px;
                 margin: 0; padding: 6px; list-style: none; background: #fff; border: 1px solid var(--rep-100);
                 border-radius: 10px; box-shadow: 0 12px 28px -10px rgba(8,43,80,.35); }
.nav-sous-menu::before { content: ''; position: absolute; left: 0; right: 0; top: -12px; height: 12px; }  /* pont pour la souris */
.nav-item:last-child .nav-sous-menu { left: auto; right: 0; }
html:not(.nav-js) .nav-item:hover .nav-sous-menu,
html:not(.nav-js) .nav-item:focus-within .nav-sous-menu,
.nav-item.ouvert .nav-sous-menu { display: block; }
.nav-sous-menu a { display: block; padding: 10px 14px; border-radius: 6px; color: #1a2535; font-weight: 500; white-space: nowrap; text-decoration: none; }
.nav-sous-menu a:hover { background: var(--rep-50); color: var(--rep-700); }
.nav-sous-menu a[aria-current="page"] { color: var(--rep-600); font-weight: 700; background: var(--rep-50); }

/* ── Sous-menus (menu mobile) : rubriques qui se déplient ────────
   Sans JavaScript, tout est déplié. */
.mnav-parent { width: 100%; min-height: 48px; background: none; border: 0; font: inherit; text-align: left; cursor: pointer; }
.mnav-parent.is-actif { color: var(--rep-600); font-weight: 700; }
.mnav-libelle { display: flex; flex-direction: column; line-height: 1.25; }
.mnav-courant { font-size: .8rem; font-weight: 500; color: #4b5563; }
.mnav-groupe.ouvert .mnav-courant, html:not(.nav-js) .mnav-courant { display: none; }
.mnav-chevron { margin-left: auto; font-size: .8em; color: var(--rep-600); transition: transform .2s ease; }
.mnav-groupe.ouvert .mnav-chevron { transform: rotate(180deg); }
.mnav-sous { margin: 0 0 8px; padding: 0 0 0 28px; list-style: none; }
html.nav-js .mnav-groupe:not(.ouvert) .mnav-sous { display: none; }
.mnav-sous a { display: flex; align-items: center; min-height: 44px; padding: 0 10px; border-left: 2px solid var(--rep-100);
               color: #374151; text-decoration: none; }
.mnav-sous a:hover { color: var(--rep-700); background: var(--rep-50); }
.mnav-sous a[aria-current="page"] { color: var(--rep-600); font-weight: 700; border-left-color: var(--gold-500); }
@media (prefers-reduced-motion: reduce) { .nav-chevron, .mnav-chevron { transition: none; } }

/* ── Boutons ───────────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex; align-items: center; gap: .5rem;
  background: var(--rep-600);
  color: #fff;
  font-weight: 600; font-size: .9rem;
  padding: .75rem 1.5rem;
  border-radius: 6px;
  border: 2px solid var(--rep-600);
  text-decoration: none;
  transition: background .2s, box-shadow .2s, transform .15s;
  cursor: pointer;
}
.btn-primary:hover { background: var(--rep-700); border-color: var(--rep-700); transform: translateY(-1px); box-shadow: 0 6px 20px rgba(8,43,80,.2); }

.btn-outline {
  display: inline-flex; align-items: center; gap: .5rem;
  background: transparent;
  color: var(--rep-600);
  font-weight: 600; font-size: .9rem;
  padding: .73rem 1.5rem;
  border-radius: 6px;
  border: 2px solid var(--rep-400);
  text-decoration: none;
  transition: background .2s, border-color .2s;
}
.btn-outline:hover { background: #EEF4FB; border-color: var(--rep-600); }

.btn-ghost {
  display: inline-flex; align-items: center; gap: .4rem;
  color: var(--rep-600);
  font-weight: 600; font-size: .85rem;
  padding: .4rem .1rem;
  border: none; background: none;
  text-decoration: none;
  cursor: pointer;
  transition: color .2s, gap .2s;
}
.btn-ghost:hover { color: var(--rep-800); gap: .65rem; }
.btn-ghost i { font-size: .75rem; transition: transform .2s; }
.btn-ghost:hover i { transform: translateX(3px); }

/* ── Bouton « retour en haut » ─────────────────────────────────── */
#back-top {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  width: 48px; height: 48px;
  background: var(--rep-700);
  color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 16px rgba(8,43,80,.3);
  opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s;
  z-index: 100;
  border: none; cursor: pointer;
}
#back-top.visible { opacity: 1; pointer-events: auto; }
#back-top:hover { transform: translateY(-3px); }

/* ── Déclaration d'accessibilité — bandeau et fenêtre ──────────── */
.a11y-notice {
  background: #EEF4FB;
  border-left: 4px solid var(--rep-500);
  padding: .75rem 1.25rem;
  font-size: .85rem;
  color: var(--rep-700);
}

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(4,26,51,.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
  background: #fff;
  border-radius: 14px;
  width: 100%; max-width: 680px;
  max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(4,26,51,.25);
  transform: scale(.97); opacity: 0;
  transition: transform .25s, opacity .25s;
}
.modal-overlay.open .modal-box { transform: scale(1); opacity: 1; }
.modal-body { overflow-y: auto; flex: 1; padding: 1.5rem 2rem; }
.modal-body h3 { font-size: 1rem; font-weight: 700; color: var(--rep-800); margin-bottom: .5rem; }
.modal-body p, .modal-body li { font-size: .875rem; color: #374151; line-height: 1.65; }
.modal-body ul { list-style: disc; padding-left: 1.25rem; margin-top: .35rem; }

/* ── Impression ────────────────────────────────────────────────── */
@media print {
  nav, footer, #back-top, .no-print { display: none !important; }
}

/* ── Menu principal : 5 entrées sur une seule ligne ──────────────
   Entre 1024 et 1279 px (petits portables, tablettes à l'horizontale),
   liens resserrés et bouton raccourci en « Contact ». Au-delà : inchangé.
   Sélecteurs avec #id pour passer devant les classes Tailwind (px-3…). */
#main-nav-links .nav-underline { white-space: nowrap; }
.contact-short { display: none; }
@media (min-width: 1024px) and (max-width: 1279.98px) {
  #main-nav-links { gap: 0; }
  #main-nav-links .nav-underline { padding-left: .5rem; padding-right: .5rem; font-size: .84rem; }
  .contact-long  { display: none; }
  .contact-short { display: inline; }
}

/* Exposants (1er, 2e adjoint…) jamais sous 10 px : lisibilité */
body sup { font-size: max(.75em, 10px); }  /* « body » : passe devant la base Tailwind chargée après */

/* ── Confort mobile ─────────────────────────────────────────────── */
@media (max-width: 1023px) {
  /* Bouton du menu : zone de toucher de 44 × 44 px */
  #burger-btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; }
}
@media (max-width: 767px) {
  /* Numéros de téléphone : plus faciles à toucher */
  a[href^="tel:"]:not(.urg):not(td a) { display: inline-flex; align-items: center; min-height: 44px; }
  a.tel-appel { gap: 8px; padding: 0 16px; border-radius: 999px; background: #EEF4FB; border: 1px solid #A9C8EA;
                color: #0E3C6D; font-weight: 700; text-decoration: none !important; }
  a.tel-appel::after { content: 'Appeler'; font-size: .78rem; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: #144F8A; color: #fff; }
}

/* ── Pied de page : « Application Navacelles » (ajout à l'écran d'accueil) ── */
#app-install[hidden], #app-ios[hidden] { display: none !important; }
.app-btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; width: 100%;
           min-height: 44px; padding: .625rem 1rem; border-radius: .375rem; border: 1px solid rgba(255,255,255,.35);
           background: transparent; color: #fff; font-size: .875rem; font-weight: 600; white-space: nowrap;
           transition: background-color .15s, border-color .15s; }
.app-btn:hover, .app-btn:focus-visible { background: rgba(255,255,255,.08); border-color: #D4A520; }
.app-btn:focus-visible { outline: 2px solid #D4A520; outline-offset: 2px; }
.app-ios { margin-top: .75rem; padding: .75rem 1rem; border-radius: .375rem; background: rgba(255,255,255,.06);
           color: #D1D5DB; font-size: .8125rem; line-height: 1.5; }
.app-ios ol { list-style: decimal; padding-left: 1.25rem; margin-top: .25rem; }
.app-ios li + li { margin-top: .25rem; }
.app-ios strong { color: #fff; }
.app-ios i { color: #D4A520; }
@media (min-width: 768px) { .app-btn { width: auto; } .app-ios { width: 380px; } }

/* ── Pied de page : « Alertes sur votre téléphone » (notifications) ── */
#alertes[hidden], #alertes-btn[hidden] { display: none !important; }
.app-btn:disabled { opacity: .6; cursor: wait; }
