/*
  navbar / navbar--pill = barre
  navbar-ligne, navbar-logo, navbar-zone, navbar-menu
  navbar-liste, navbar-liste-claire, navbar-item, avec-services
  navbar-lien, navbar-sous, navbar-pastille, navbar-bouton
*/

/* ---------------------------------------------------------------------------
   Toutes largeurs — barre pilule, ligne, logo
   --------------------------------------------------------------------------- */

.navbar--pill {
  position: fixed;
  top: clamp(1rem, 3vw, 1.75rem);
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 200;
  width: auto;
  max-width: min(1180px, calc(100% - 2rem));
  margin: 0;
  padding: 0;
  background: rgba(104, 82, 63, 0.58);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9999px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
  opacity: 1;
  transition:
    transform 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    opacity 0.35s ease;
}

/* Masquée après 3 s d’inactivité ; réaffichée au scroll / toucher
   ou quand la souris est en haut de l’écran (voir main.js) */
.navbar--pill.is-nav-scroll-idle {
  transform: translate(-50%, calc(-100% - 1.25rem));
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .navbar--pill {
    transition-duration: 0.01ms;
  }

  .navbar--pill.is-nav-scroll-idle {
    transform: translate(-50%, 0);
    opacity: 1;
    pointer-events: auto;
  }
}

.navbar-ligne {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: clamp(2.5rem, 8vw, 5.5rem);
  padding: 0.62rem 2.25rem 0.62rem 1.6rem;
  margin: 0;
  box-sizing: border-box;
}

.navbar-ligne .navbar-zone {
  margin-left: auto;
  flex: 0 1 auto;
}

.navbar-logo {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.navbar-logo img {
  display: block;
  height: clamp(22px, 4vw, 27px);
  width: auto;
}

/* ---------------------------------------------------------------------------
   Grand écran uniquement — min-width 901px (barre fixe 922×48, pont Services…)
   --------------------------------------------------------------------------- */

@media (min-width: 901px) {
  .navbar--pill {
    width: 922px;
    max-width: min(922px, calc(100% - 2rem));
    height: 48px;
  }

  .navbar-ligne {
    height: 100%;
    padding: 0 2.25rem 0 1.6rem;
    gap: clamp(2.5rem, 8vw, 5.5rem);
  }

  .navbar-logo img {
    height: auto;
    max-height: 28px;
    width: auto;
  }

  .navbar-item.avec-services::after {
    content: "";
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 100%;
    width: 220px;
    height: 30px;
    z-index: 255;
  }
}

/* ---------------------------------------------------------------------------
   Toutes largeurs — zone liens, menu, liste, sous-menu (survol type desktop)
   --------------------------------------------------------------------------- */

.navbar-zone {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: clamp(0.75rem, 2vw, 1.5rem);
  min-width: 0;
}

.navbar-menu {
  display: flex;
  align-items: center;
}

.navbar-liste {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: clamp(4rem, 2.2vw, 4rem);
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: var(--track-sans);
  font-size: 1rem;
}

.navbar-liste-claire .navbar-lien {
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  padding: 0.35rem 0.15rem 0.35rem;
  border-bottom: 1px solid transparent;
  transition:
    color 0.2s,
    border-color 0.2s;
}

.navbar-item {
  position: relative;
}

.navbar-liste-claire .navbar-lien:hover {
  color: #fff;
  text-decoration: none;
  border-bottom-color: transparent;
}

.navbar-liste-claire .navbar-lien.actif {
  color: #fff;
  border-bottom-color: rgba(255, 255, 255, 0.95);
}

/* Sous-menu Services : pastilles centrées sous le mot, texte à gauche dans chaque pastille */
.navbar-sous {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(0.35rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
  /* Desktop : espace sous « Services » (réglage ici, pas margin-top du bloc mobile) */
  padding: 1rem 0 0;
  margin: 0;
  list-style: none;
  background: transparent;
  border: none;
  box-shadow: none;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.2s,
    transform 0.2s,
    visibility 0.2s;
  z-index: 260;
}

.navbar-sous > li {
  margin: 0;
  display: flex;
  justify-content: flex-start;
  width: 200px;
}

.navbar-pastille {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 200px;
  height: 24px;
  box-sizing: border-box;
  padding: 0 10px;
  color: #fff;
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: 20px;
  line-height: 1;
  letter-spacing: var(--track-sans);
  text-transform: lowercase;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-radius: 9999px;
  background: rgba(104, 82, 63, 0.58);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  transition:
    background 0.2s,
    border-color 0.2s,
    color 0.2s;
}

.navbar-pastille:hover,
.navbar-pastille:focus-visible {
  color: #fff;
  background: rgba(104, 82, 63, 0.78);
  border-color: rgba(255, 255, 255, 0.22);
  text-decoration: none;
}

.navbar-pastille.actif {
  color: #fff;
  background: rgba(104, 82, 63, 0.85);
  border-color: rgba(255, 255, 255, 0.28);
  text-decoration: none;
}

.navbar-item.avec-services:hover .navbar-sous,
.navbar-item.avec-services:focus-within .navbar-sous {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

/* ---------------------------------------------------------------------------
   Mobile & tablette — max-width 900px (menu plein écran, liste verticale…)
   --------------------------------------------------------------------------- */

@media (max-width: 900px) {
  /* Plus proche du bord haut que clamp(1rem, …) — évite l’impression de barre « trop basse » sur le hero */
  /* La pilule elle-même s'agrandit vers le bas : le menu vit dedans (continuité de la barre).
     Largeur inchangée (auto, comme avant) — seule la hauteur grandit à l'ouverture. */
  .navbar--pill {
    top: max(env(safe-area-inset-top), 0.4rem);
    border-radius: 1.65rem;
    overflow: hidden;
  }

  .navbar-bouton {
    display: block;
  }

  /* Grille : logo + MENU sur la 1re ligne fixent la largeur (comme avant),
     le menu occupe une 2e ligne pleine largeur sans élargir la pilule */
  .navbar-ligne {
    display: grid;
    grid-template-columns: auto auto;
    align-items: center;
    justify-content: space-between;
    column-gap: clamp(2.5rem, 8vw, 5.5rem);
    row-gap: 0;
    /* Padding horizontal symétrique → noms de pages exactement centrés */
    padding: 0.62rem 1.6rem;
  }

  .navbar-logo {
    grid-column: 1;
    grid-row: 1;
  }

  .navbar-bouton {
    grid-column: 2;
    grid-row: 1;
  }

  /* Zone menu : 2e ligne pleine largeur, dans la même pilule, hauteur animée */
  .navbar--pill .navbar-zone {
    grid-column: 1 / -1;
    grid-row: 2;
    width: auto;
    max-width: none;
    margin-left: 0;
    background: transparent;
    padding: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 0fr;
    justify-content: stretch;
    justify-items: stretch;
    align-items: stretch;
    opacity: 0;
    pointer-events: none;
    transition:
      grid-template-rows 0.3s ease,
      opacity 0.25s ease;
  }

  .navbar-zone.ouvert {
    grid-template-rows: 1fr;
    opacity: 1;
    pointer-events: auto;
  }

  .navbar-menu {
    width: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .navbar-liste-claire {
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
    text-align: center;
    padding: 0.35rem 0 0.55rem;
  }

  .navbar-liste-claire .navbar-lien {
    display: block;
    width: 100%;
    color: #fff;
    font-size: 0.95rem;
    padding: 0.62rem 0.5rem;
    border-bottom: none;
  }

  .navbar-liste-claire .navbar-lien.actif {
    background: transparent;
    border-bottom-color: transparent;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.3em;
    text-decoration-color: rgba(255, 255, 255, 0.95);
  }

  /* Menu compact : le sous-menu Services reste accessible via la page Services */
  .navbar-item.avec-services {
    display: block;
  }

  .navbar-sous {
    display: none;
  }
}
