/* ==========================================================================
   Header mobile Alternatives (≤ 980px)
   Burger + tiroir latéral à droite, version claire / sombre
   JS : js/alt_header_mobile.js — PHP : inc/alt_header_mobile.php
   ========================================================================== */

:root {
  --al-hd-z: 100000;
  --al-hd-speed: 0.6s; /* garder en phase avec SPEED dans le JS */
  --al-hd-ease: cubic-bezier(0.65, 0, 0.15, 1);

  /* Tiroir */
  --al-hd-drawer-w: min(82vw, 400px);
  --al-hd-backdrop: rgba(6, 0, 13, 0.45);

  /* Hauteur du header + largeur du logo */
  --al-hd-h-tablet: 110px;
  --al-hd-h-phone: 84px;
  --al-hd-logo-tablet: 130px;
  --al-hd-logo-phone: 100px;
}

/* Tout ça n'existe qu'en dessous de 980px */
.al-hd-burger,
.al-hd-backdrop,
.al-hd-drawer {
  display: none;
}

@media only screen and (max-width: 980px) {

  /* ---------- Header : hauteur + logo ---------- */
  .et-l--header .et_pb_row:has(.module_menu_alternatives) {
    height: var(--al-hd-h-tablet) !important;
  }

  .et-l--header .et_pb_row:has(.module_menu_alternatives) .et_pb_image {
    flex: 0 0 auto;
    width: var(--al-hd-logo-tablet) !important;
    max-width: var(--al-hd-logo-tablet) !important;
  }

  /* On masque le burger Divi seulement si notre JS a pris le relais */
  html.al-hd-ready .module_menu_alternatives .et_mobile_nav_menu {
    display: none !important;
  }

  /* ---------- Boutons burger / croix ---------- */
  .al-hd-burger,
  .al-hd-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  .al-hd-burger {
    position: relative;
    margin: 0 -10px 0 0; /* aligne les traits sur le bord de la row */
    color: var(--alt-dark, #400047);
  }

  .al-hd-burger[data-theme="dark"] {
    color: var(--alt-light, #fcf7ed);
  }

  .al-hd-burger:focus,
  .al-hd-close:focus {
    outline: none;
  }

  .al-hd-burger:focus-visible,
  .al-hd-close:focus-visible {
    outline: 1px solid currentColor;
    outline-offset: 2px;
  }

  .al-hd-icon {
    position: relative;
    display: block;
    width: 28px;
    height: 12px;
  }

  .al-hd-icon__line {
    position: absolute;
    right: 0;
    width: 100%;
    height: 1.5px;
    border-radius: 2px;
    background: currentColor;
    transition: width 0.3s var(--al-hd-ease);
  }

  .al-hd-icon__line:nth-child(1) {
    top: 0;
  }

  .al-hd-icon__line:nth-child(2) {
    top: calc(100% - 1.5px);
    width: 65%;
  }

  .al-hd-burger:hover .al-hd-icon__line:nth-child(2) {
    width: 100%;
  }

  /* Croix */
  .al-hd-close .al-hd-icon {
    width: 24px;
    height: 24px;
    transition: transform 0.4s var(--al-hd-ease);
  }

  .al-hd-close .al-hd-icon__line {
    top: calc(50% - 0.75px);
    width: 100%;
  }

  .al-hd-close .al-hd-icon__line:nth-child(1) {
    transform: rotate(45deg);
  }

  .al-hd-close .al-hd-icon__line:nth-child(2) {
    transform: rotate(-45deg);
  }

  .al-hd-close:hover .al-hd-icon {
    transform: rotate(90deg);
  }

  /* ---------- Bloque le scroll de la page ---------- */
  html.al-hd-active,
  html.al-hd-active body {
    overflow: hidden !important;
  }

  html.al-hd-active {
    scrollbar-gutter: stable;
  }

  /* ---------- Fond assombri ---------- */
  .al-hd-backdrop {
    position: fixed;
    inset: 0;
    z-index: var(--al-hd-z);
    display: block;
    background: var(--al-hd-backdrop);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    cursor: pointer;
    transition:
      opacity var(--al-hd-speed) ease,
      visibility 0s linear var(--al-hd-speed);
  }

  html.al-hd-open .al-hd-backdrop {
    opacity: 1;
    visibility: visible;
    transition:
      opacity var(--al-hd-speed) ease,
      visibility 0s linear 0s;
  }

  /* ---------- Tiroir ---------- */
  .al-hd-drawer {
    --al-hd-bg: var(--alt-light, #fcf7ed);
    --al-hd-fg: var(--alt-dark, #400047);
    --al-hd-accent: var(--alt-dark, #400047);

    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: calc(var(--al-hd-z) + 1);
    display: flex;
    flex-direction: column;
    width: var(--al-hd-drawer-w);
    box-sizing: border-box;
    padding: 0 var(--al-hd-pad-r, 24px) calc(28px + env(safe-area-inset-bottom, 0px)) 32px;
    background: var(--al-hd-bg);
    color: var(--al-hd-fg);
    box-shadow: -20px 0 60px rgba(6, 0, 13, 0.18);
    overflow-y: auto;
    overscroll-behavior: contain;
    visibility: hidden;
    transform: translateX(100%);
    transition:
      transform var(--al-hd-speed) var(--al-hd-ease),
      visibility 0s linear var(--al-hd-speed);
  }

  .al-hd-drawer[data-theme="dark"] {
    --al-hd-bg: linear-gradient(160deg, var(--alt-dark, #400047) 20%, #06000d 100%);
    --al-hd-fg: var(--alt-light, #fcf7ed);
    --al-hd-accent: var(--alt-yellow, #fcff00);
    box-shadow: -20px 0 60px rgba(0, 0, 0, 0.35);
  }

  html.al-hd-open .al-hd-drawer {
    visibility: visible;
    transform: translateX(0);
    transition:
      transform var(--al-hd-speed) var(--al-hd-ease),
      visibility 0s linear 0s;
  }

  /* Haut du tiroir : même hauteur que le header, avec sa ligne */
  .al-hd-drawer__head {
    flex: 0 0 auto;
    height: var(--al-hd-top, 110px);
    border-bottom: 1px solid currentColor;
    border-bottom-color: color-mix(in srgb, currentColor 25%, transparent);
  }

  /* La croix se place exactement là où était le burger */
  .al-hd-close {
    position: absolute;
    top: var(--al-hd-btn-top, 30px);
    right: var(--al-hd-btn-right, 14px);
    color: var(--al-hd-fg);
  }

  /* ---------- Liens ---------- */
  .al-hd-drawer .al-hd-drawer__nav {
    flex: 1 0 auto;
    padding-top: clamp(28px, 6vh, 56px);
  }

  .al-hd-drawer .al-hd-drawer__list {
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: right;
  }

  .al-hd-drawer .al-hd-drawer__item {
    margin: 0;
    padding: 0;
    list-style: none;
  }

  .al-hd-drawer .al-hd-drawer__link {
    position: relative;
    display: inline-block;
    padding: 6px 0;
    font-family: "chapman", sans-serif;
    font-size: clamp(26px, 7vw, 32px);
    font-style: italic;
    font-weight: 700;
    line-height: 1.3;
    color: var(--al-hd-fg);
    text-decoration: none;
    opacity: 0;
    transform: translateX(24px);
    transition:
      opacity 0.3s ease,
      transform 0.3s var(--al-hd-ease);
  }

  html.al-hd-open .al-hd-drawer__link {
    opacity: 1;
    transform: translateX(0);
    transition:
      opacity 0.5s ease calc(0.2s + var(--i, 0) * 0.06s),
      transform 0.7s var(--al-hd-ease) calc(0.2s + var(--i, 0) * 0.06s);
  }

  /* Soulignement fin : au survol + page en cours */
  .al-hd-drawer__link::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 6px;
    width: 100%;
    height: 1px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: right center;
    transition: transform 0.4s var(--al-hd-ease);
  }

  /* Page en cours : petit point à gauche, pas de soulignement */
  .al-hd-drawer__item.is-current .al-hd-drawer__link::before {
    content: "";
    position: absolute;
    top: 50%;
    right: calc(100% + 0.4em);
    width: 6px;
    height: 6px;
    margin-top: -1px;
    border-radius: 50%;
    background: var(--al-hd-accent);
  }

  @media (hover: hover) {
    .al-hd-drawer__item:not(.is-current) .al-hd-drawer__link:hover::after {
      transform: scaleX(1);
    }
  }

  .al-hd-drawer__link:focus {
    outline: none;
  }

  .al-hd-drawer__link:focus-visible::after {
    transform: scaleX(1);
  }

  /* ---------- Baseline ---------- */
  .al-hd-drawer .al-hd-drawer__baseline {
    flex: 0 0 auto;
    max-width: 220px;
    margin: 40px 0 0 auto;
    font-family: "mundial-narrow-variable", sans-serif;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    text-align: right;
    opacity: 0;
    transition: opacity 0.3s ease;
  }

  html.al-hd-open .al-hd-drawer__baseline {
    opacity: 0.7;
    transition: opacity 0.6s ease calc(0.3s + var(--i, 0) * 0.06s);
  }
}

/* ---------- Mobile ---------- */
@media only screen and (max-width: 767px) {
  .et-l--header .et_pb_row:has(.module_menu_alternatives) {
    height: var(--al-hd-h-phone) !important;
  }

  .et-l--header .et_pb_row:has(.module_menu_alternatives) .et_pb_image {
    width: var(--al-hd-logo-phone) !important;
    max-width: var(--al-hd-logo-phone) !important;
  }
}

/* ---------- Mouvements réduits ---------- */
@media (prefers-reduced-motion: reduce) {
  .al-hd-backdrop,
  .al-hd-drawer,
  .al-hd-drawer__link,
  .al-hd-drawer__baseline {
    transition-duration: 0.01s !important;
    transition-delay: 0s !important;
  }
}