/* ================================================================================== */
/* SECTION 1 : MEGA MENU DESKTOP (Votre code existant)                               */
/* ================================================================================== */

/* 1. Reset et structure de base du Mega Menu */
.ac-desktop-menu,
header ul {
  list-style: none !important;
}
.ac-desktop-menu {
  margin: 0;
  padding: 0;
}
.ac-desktop-menu .ac-menu-ul {
  display: flex;
  /* gap: 3.2vw !important; */
  gap: 0;
  list-style: none;
  margin: 0;
  padding: 0;
}
header a {
  text-underline-offset: 0.25em;
}
header li:hover > a,
header figure:hover a {
  text-decoration: underline;
}
header figure {
  text-indent: 0 !important;
}
/* Base de l'élément parent */
.ac-desktop-menu .ac-menu-ul > li {
  position: static;
  /* padding: 2.5svh 0; */
  padding: 2.5svh calc(3.2vw / 2);
}
.ac-desktop-menu.menu-left .ac-menu-ul > li:first-child {
  padding-left: 0;
}
.ac-desktop-menu.menu-right .ac-menu-ul > li:last-child {
  padding-right: 0;
}
/* 2. GESTION DE L'AFFICHAGE ET DES COLONNES */
/* Masquer TOUS les sous-menus de premier niveau (Mega Menu Panel) par défaut */
.home .ac-desktop-menu .ac-menu-ul > li > .sub-menu,
.archive.category .ac-desktop-menu .ac-menu-ul > li > .sub-menu,
.single-post .ac-desktop-menu .ac-menu-ul > li > .sub-menu {
  min-width: 100svw !important;
}
.ac-desktop-menu .ac-menu-ul > li > .sub-menu {
  /* display: none; */
  position: absolute;
  top: 100%;
  width: calc(100vw - 10svw);
  max-width: calc(100vw - 10svw);
  min-width: calc(100vw - 10svw);
  /*display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));*/
  display: flex;
  flex-wrap: wrap;
  gap: 1rem !important;
  align-items: start;
  justify-content: space-evenly;
  margin: 0;
  list-style: none;
  padding: 2rem 5svw;
  background: var(--cream);
  border-bottom: 0.5px solid var(--brown);
  box-shadow: 0 20px 30px rgba(0, 0, 0, 0.085);
  z-index: 1000;
  /* animation-friendly state */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translate3d(0, 8px, 0) scale(0.995);
  max-height: 80vh;
  overflow: clip;
  backface-visibility: hidden;
  will-change: opacity, transform;
  contain: layout paint;
  transition: opacity 220ms ease, transform 220ms ease,
    visibility 0s linear 220ms; /* cache visuel une fois l’anim terminée */
}
.menu-left .ac-desktop-menu .ac-menu-ul > li > .sub-menu {
  left: -5svw;
}
.menu-right .ac-desktop-menu .ac-menu-ul > li > .sub-menu {
  right: -5svw;
}
/* État ouvert sur le LI parent */
.ac-desktop-menu .ac-menu-ul > li:hover > .sub-menu,
.ac-desktop-menu .ac-menu-ul > li:focus-within > .sub-menu {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
  visibility: visible;
  pointer-events: auto;
  overflow: visible;
  transition: opacity 220ms ease, transform 220ms ease, visibility 0s;
}
/* AFFICHAGE : Déclencheur unique au survol du LI de niveau 1 */
.ac-desktop-menu .ac-menu-ul > li:hover > .sub-menu {
  opacity: 1;
  height: auto;
  overflow: visible;
  visibility: visible;
}
/* Accessibilité: respecte la préférence utilisateur */
@media (prefers-reduced-motion: reduce) {
  .ac-desktop-menu .ac-menu-ul > li > .sub-menu {
    transition: none;
    transform: none;
  }
}

/* 3. STRUCTURE INTERNE DU MEGA MENU (Colonnes) */
ul.sub-menu.mega_grille li.menu--cta {
  flex: 0 0 100% !important;
  order: -1;
  width: 100%;
  flex-direction: row !important;
  gap: 1rem !important;
  align-items: baseline;
  justify-content: flex-start;
}
li.menu--cta a {
  text-wrap-mode: nowrap;
  color: white;
  background-color: var(--brown);
  border-radius: 50px;
  width: fit-content;
  text-decoration: none !important;
}
.ac-desktop-menu li.menu--cta a {
  font-size: clamp(0.8rem, 1.55vmin, 2vmax) !important;
}
li.menu--cta a:hover {
  background-color: var(--black);
}
/* Chaque LI de niveau 2 (dans le Mega Menu Panel) devient la colonne */
.ac-desktop-menu .ac-menu-ul > li > .sub-menu > li {
  display: flex;
  flex-direction: column;
  gap: 0.5em;
  flex: 1 1 10%;
  min-width: 1px;
  text-indent: 5px;
}
/* Assurer que les sous-menus imbriqués (niveau 3, 4, etc.) sont TOUJOURS VISIBLES dans la colonne */
.ac-desktop-menu .sub-menu .sub-menu {
  position: static;
  display: block !important;
  width: auto;
  background-color: transparent;
  box-shadow: none;
}
/* Styles pour les titres de colonne (liens de niveau 2) */
.ac-desktop-menu .sub-menu.mega_grille > li > a {
  font-weight: 600;
  text-transform: uppercase;
  display: block;
}
.ac-desktop-menu .sub-menu .sub-menu li a {
  font-weight: 400;
  text-transform: capitalize !important;
}
.ac-desktop-menu .sub-menu .sub-menu li a:before,
.ac-mobile-menu-ul .sub-menu .sub-menu a:before {
  content: "\2192";
  margin-right: 6px;
  transform: scale(0.9);
}
/* Styles pour les liens sous les titres de colonne (liens de niveau 3+) */
.ac-desktop-menu .sub-menu .sub-menu li a {
  font-weight: normal;
  padding: 3px 0;
  display: block;
}
/* Images */
header .ac-desktop-menu li.wide_thumbnail {
  flex: 1 1 27% !important;
}
header .ac-desktop-menu li.wide_thumbnail figure img {
  aspect-ratio: 2 / 0.96 !important;
  object-fit: cover;
}

/* ================================================================================== */
/* SECTION 2 : MEDIA QUERIES (Transition Desktop <-> Tablet et Mobile)                */
/* ================================================================================== */
/* NAV Breakpoint Desktop */
@media (min-width: 1000px) {
  nav ul .menu--button a {
    border: 1px solid var(--black);
    border-radius: var(--xl-radius);
    padding: 0.5em 1.2em;
  }
  /* Cache les éléments mobiles sur Desktop */
  #ac-mobile-menu-toggle,
  #ac-mobile-menu-drawer,
  .menu_grille .menu-left > p:has(#ac-mobile-menu-toggle) {
    display: none !important;
  }
}
/* only iPad in portrait and landscape */
@media only screen and (min-device-width: 600px) and (max-device-width: 1050px) and (orientation: portrait),
  only screen and (min-device-width: 600px) and (max-device-width: 1366px) and (orientation: landscape) {
  /* Nav breakpoint */
  .wp-block-navigation__responsive-container:not(.hidden-by-default):not(
      .is-menu-open
    ) {
    display: none !important;
  }
  .wp-block-navigation__responsive-container-open {
    display: flex !important;
  }
  #ac-mobile-menu-toggle {
    transform: scale(1.5);
    margin-left: 1rem;
  }
  svg#letstravel__logo,
  .wp-block-site-logo.is-default-size img {
    width: 9rem !important;
  }
  figure.wp-block-image.size-full.letscontact.large_hide.nomargin {
    margin-right: 1.2rem;
    transform: scale(1.5);
  }
}
/* NAV Breakpoint Drawer */
@media only screen and (max-width: 999px),
  only screen and (min-device-width: 600px) and (max-device-width: 1050px) and (orientation: portrait),
  only screen and (min-device-width: 600px) and (max-device-width: 1366px) and (orientation: landscape) {
  /* 1. Masque les menus DESKTOP (pour ne garder que la grille et le logo) */
  .menu_grille .ac-desktop-menu {
    display: none !important;
  }
  /* 2. Affiche le conteneur du bouton burger (inclus dans un <p>) */
  figure.wp-block-image.size-full.letscontact.large_hide.nomargin {
    display: block !important;
  }
  .menu_grille .menu-left > p:has(#ac-mobile-menu-toggle) {
    /* Enlève les marges du <p> pour une bonne intégration dans la grille */
    margin: 0;
    padding: 0;
    display: flex !important;
    justify-content: flex-start; /* Aligne le burger à gauche de la zone */
    align-items: center;
  }
  /* 3. Affiche le bouton burger lui-même */
  #ac-mobile-menu-toggle {
    display: flex !important;
    align-self: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
  }
  figure.wp-block-image.size-full.letscontact.large_hide.nomargin {
    margin-right: 0.5rem;
    transform: scale(1.1);
  }
  /* Autres */
  svg#letstravel__logo,
  .wp-block-site-logo.is-default-size img {
    margin-top: 1.5svh;
    margin-bottom: 1.5svh;
    margin-left: 0;
  }
  li.menu--cta {
    margin-left: 1rem;
    margin-bottom: 1em;
  }
  .ac-drawer-back-link svg {
    transform: rotate(90deg);
  }
  span.ac-drawer-back-text {
    text-transform: uppercase;
    font-weight: 500;
  }
  .ac-mobile-menu-ul .sub-menu li.menu-item-has-children > a:first-child,
  li.menu--cta a {
    font-weight: 600 !important;
  }
  /* .current-menu-ancestor,
  nav.ac-mobile-menu-nav > ul > li.current-menu-item {
    background-color: var(--brown);
    color: white !important;
  }
  .current-menu-ancestor {
    background-color: var(--brown);
  }
  .current-menu-ancestor > a,
  nav.ac-mobile-menu-nav > ul > li.current-menu-item > a {
    color: white;
  }
  .current-menu-ancestor a:after {
    filter: invert(1);
  } */
  .ac-mobile-menu-ul .sub-menu li.menu-item-has-children ul.sub-menu {
    margin-bottom: 0.95em;
  }
}

/* ================================================================================== */
/* SECTION 3 : DRAWER MOBILE (Structure et animation) - CORRIGÉE POUR MEGA MENU ET ISOLATION */
/* ================================================================================== */
/* Conteneur principal du tiroir (Initialement caché) */
#ac-mobile-menu-drawer {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  margin: 0;
  height: 100%;
  z-index: 900;
  background-color: var(--cream);
  /* Animation de glissement */
  transform: translateX(-100%);
  transition: transform 0.3s ease-out;
  /* Structure de la hauteur pour le scroll */
  display: flex;
  flex-direction: column;
}
/* État affiché du tiroir */
#ac-mobile-menu-drawer.is-open {
  transform: translateX(0);
}
/* En-tête du tiroir (Bouton Fermer/Retour) */
.ac-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.15rem 1.5rem 0 1.5rem;
  flex-shrink: 0;
}
.ac-drawer-close {
  color: black;
  font-size: 2.5rem;
  font-family: var(--wp--preset--font-family--sangbleu-sunrise);
  background: none;
  border: none;
  cursor: pointer;
  font-weight: 200;
  padding: 0;
  line-height: unset;
}
/* Bouton Retour (initialement masqué) */
#ac-drawer-back-button {
  cursor: pointer;
  font-weight: 400;
  line-height: 125%;
}
.ac-drawer-back-link {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: #333;
}
/* Wrapper du contenu (RENDU SCROLLABLE ET CONTEXTE DE POSITIONNEMENT) */
.ac-drawer-content-wrapper {
  overflow-y: auto; /* ESSENTIEL : Permet le scroll sur le contenu principal (Level 1) */
  overflow-x: hidden;
  flex-grow: 1;
  position: relative;
  /* Calcule la hauteur restante du tiroir (hauteur totale - hauteur du header) */
  height: calc(100% - 50px);
  max-height: calc(100% - 50px); /* Ajout de max-height pour la robustesse */
  -webkit-overflow-scrolling: touch; /* Pour un défilement fluide sur iOS */
}
/* Conteneur de navigation principal (doit prendre 100% de la hauteur du wrapper si on veut défiler, mais overflow-y: auto sur le wrapper est suffisant s'il y a plusieurs UL) */
.ac-mobile-menu-nav {
  display: block;
  position: relative;
  width: 100%;
  padding-top: 2em;
}
/* Listes de menus principales */
#ac-mobile-menu-drawer a {
  text-decoration: none;
}
.ac-mobile-menu-ul {
  list-style: none;
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  padding-left: 0;
  padding-right: 0;
}
/* liens */
/* Liens de niveau 2 */
.ac-mobile-menu-ul > li > .sub-menu > li > a,
li.menu--cta a {
  font-weight: 600;
  font-size: 0.95rem !important;
}
/* Liens de niveau 3/ enfants d'enfants */
.ac-mobile-menu-ul .sub-menu .sub-menu a {
  font-weight: 400;
}
nav.ac-mobile-menu-nav > ul > li a {
  display: block;
  text-transform: uppercase;
  font-weight: 400;
  font-size: 1.05rem;
  padding: 1em 2rem;
  line-height: 1em;
}
/* Symbole pour les parents (Level 1 uniquement) */
.ac-mobile-menu-ul > li.menu-item-has-children > a {
  position: relative;
  display: flex !important;
  flex-direction: row;
  align-items: center;
}
.ac-mobile-menu-ul > li.menu-item-has-children > a::after {
  position: absolute;
  right: 1em;
  content: "";
  display: block !important;
  background: center / contain no-repeat
    url("/wp-content/themes/twentytwentyfive-letstravel/assets/lets_fleche.svg");
  width: 1.55em;
  height: 1.55em;
  transform: rotate(-90deg);
  text-decoration: none;
}

/* Sous-menus (Niveaux 2 : le VOLET QUI GLISSE et COUVRE TOUT) */
.ac-mobile-menu-ul .sub-menu {
  position: absolute; /* Positionné par rapport au .ac-drawer-content-wrapper */
  top: 0;
  left: 0;
  width: 100%;
  height: 100svh;
  background-color: #f7f7f7;
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  z-index: 2;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: block;

  /* Glissement */
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.3s ease-out, visibility 0.3s;
}

/* ================================================================================== */
/* SECTION 4 : États d'affichage du Sous-Menu Mobile (Mega Menu Indenté)              */
/* ================================================================================== */

/* État affiché du sous-menu (il glisse en place) */
.ac-mobile-menu-ul .sub-menu.is-active {
  transform: translateX(0);
  visibility: visible;
  padding: 15px 0; /* Padding pour le contenu après le glissement */
}

/* S'assurer que les sous-menus de Niveau 3 (et suivants) sont TOUJOURS VISIBLES et INDENTÉS */
.ac-mobile-menu-ul .sub-menu .sub-menu {
  position: static !important;
  transform: none !important;
  visibility: visible !important;
  height: auto;
  width: auto;
  background-color: transparent;
  border: none;
  padding: 0;
  z-index: auto;
}

/* Retirer le symbole "›" des liens à partir du Niveau 2 */
.ac-mobile-menu-ul .sub-menu li.menu-item-has-children > a::after {
  content: none;
}

/* Style et Indentation des liens de niveau 2 (dans le volet glissant) */
.ac-mobile-menu-ul .sub-menu li a {
  padding-left: 2rem;
  padding-top: 0.7em;
  padding-bottom: 0.7em;
}
/* Style et Indentation des liens de niveau 3 et suivants (affichés "à plat") */
.ac-mobile-menu-ul .sub-menu .sub-menu li a {
  font-size: 0.95rem;
  text-transform: capitalize;
  padding-top: 0.8em !important;
  padding-bottom: 0.8em !important;
}

/* ================================================================================== */
/* SECTION 5 : Améliorations de Compatibilité Mobile/iOS                              */
/* ================================================================================== */
/* Empêche le défilement du contenu principal lorsque le drawer est ouvert */
body.drawer-open {
  overflow: hidden;
  position: fixed;
  width: 100%;
}
/* Fixe le défilement pour les systèmes mobiles */
#ac-mobile-menu-drawer {
  height: 100%;
  max-height: 100vh;
  -webkit-overflow-scrolling: touch;
}
/* S'assurer que le wrapper prend bien la hauteur restante */
/* (Déplacé dans .ac-drawer-content-wrapper pour être près de position: relative) */
.ac-drawer-content-wrapper {
  height: calc(
    100% - 50px
  ); /* Ajustez si la hauteur de .ac-drawer-header est différente de 50px */
}
