/* Firefox */
html {
  scrollbar-width: none; /* cache la barre */
}

/* Chrome/Edge/Safari (WebKit/Blink) */
html::-webkit-scrollbar {
  width: 0;
  height: 0;
}

/* Hauteur verrouillée du nav */
:root {
  --nav-h: 40px;
}

.header {
  /* tu gardes ton padding 14px */
  padding-block: 14px;
}

.nav {
  display: flex;
  align-items: center; /* centre verticalement les liens */
}

/* Chaque bouton = pile la même hauteur, sans dépendre de la ligne de base */
.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--nav-h); /* au lieu de min-height */
  line-height: 1; /* coupe l’influence de la baseline */
  padding: 0 12px; /* pas de padding vertical, on fixe la hauteur */
  position: relative;
}

/* Le ring n'influe pas le flux et ne crée pas de “gap” */
.nav-ring {
  position: absolute;
  inset: calc(var(--ring-w) / -2);
  width: calc(100% + var(--ring-w));
  height: calc(100% + var(--ring-w));
  pointer-events: none;
  border-radius: inherit;
  display: block; /* IMPORTANT: évite le 1px dû à la baseline */
}

/* Par sécurité : tous les SVG du header hors baseline */
.header svg {
  display: block;
} /* évite le “gap” d’élément inline */

/* ========= Bulle + Drawer Mobile ========= */
:root {
  --fab-bg: #2b2540;
  --fab-ring: #8b5cf6;
}

/* Bulle cachée par défaut (montrée en mobile) */
.nav-fab {
  display: none;
}

/* Panneau déroulant */
.mobile-drawer {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: var(--surface, #151823);
  border-bottom: 1px solid var(--line);
  border-radius: 0 0 18px 18px;
  padding: 14px;
  transform: translateY(-100%);
  transition: transform 0.25s ease;
  z-index: 1001;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}
.mobile-drawer[data-open="true"] {
  transform: translateY(0);
}

.mobile-nav {
  display: grid;
  gap: 10px;
}

.mobile-link {
  display: block;
  padding: 12px 14px;
  border-radius: 12px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-weight: 600;
}
.mobile-link:hover {
  background: rgba(255, 255, 255, 0.08);
}

/* état actif */
.mobile-link[data-active="1"] {
  background: rgba(142, 124, 248, 0.15);
  border-color: rgba(142, 124, 248, 0.4);
  color: #fff;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 1000;
}
.mobile-backdrop[data-open="true"] {
  opacity: 1;
}

/* ===== Header mobile : bouton centré et collé en haut ===== */
@media (max-width: 520px) {
  :root {
    --mbar-h: 56px; /* hauteur de la barre */
    --safe-top: env(safe-area-inset-top, 0); /* encoche iOS */
  }

  /* 1) Cache le header classique */
  .header {
    display: none !important;
  }

  /* 2) Réserve la place sous la barre */
  body {
    padding-top: calc(var(--mbar-h) + var(--safe-top));
  }

  /* 3) Barre mobile fixe qui imite un header */
  .mobile-topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: calc(var(--mbar-h) + var(--safe-top));
    padding-top: var(--safe-top);
    display: flex;
    justify-content: center; /* <-- centre H */
    align-items: center; /* <-- centre V */
    z-index: 1002;
    backdrop-filter: blur(8px);
  }

  /* 4) Bouton : pas de position fixed ici, centré par la barre */
  .mobile-topbar .nav-fab {
    display: inline-grid !important;
    place-items: center;
    width: 46px;
    height: 46px;
    border-radius: 999px;
    border: 2px solid var(--fab-ring, #8b5cf6);
    background: var(--fab-bg, #2b2540);
    color: #fff;
    font-size: 20px;
    box-shadow: 0 0 0 2px rgba(69, 69, 75, 0.35),
      inset 0 0 0 1px rgba(255, 255, 255, 0.06);
    cursor: pointer;
    transition: transform 0.08s ease, box-shadow 0.2s ease,
      background 0.15s ease;
    /* sécurité : neutralise d'anciens "fixed top/right" */
    position: static !important;
    margin: 0 auto; /* renfort centrage si contenu change */
  }
  .mobile-topbar .nav-fab:hover {
    background: #372e58;
    box-shadow: 0 0 0 5px rgba(139, 92, 246, 0.45),
      inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  }
  .mobile-topbar .nav-fab[aria-expanded="true"] {
    box-shadow: 0 0 0 6px rgba(139, 92, 246, 0.5),
      inset 0 0 0 1px rgba(255, 255, 255, 0.1);
  }

  /* 5) Le drawer s'ouvre juste sous la barre */
  .mobile-drawer {
    top: calc(var(--mbar-h) + var(--safe-top)) !important;
  }
}

/* ===== Hamburger → X animé ===== */
.mobile-topbar .nav-fab {
  /* garde tes styles existants (taille, bordure, etc.) */
  /* on force un contexte pour la position absolue des barres */
  position: static !important;
}

.mobile-topbar .nav-fab .hamb {
  position: relative;
  width: 22px; /* largeur de l'icône */
  height: 16px; /* hauteur totale (3 barres + espacements) */
  display: inline-block;
}

.mobile-topbar .nav-fab .bar {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: currentColor; /* hérite de la couleur du bouton */
  transform-origin: 50% 50%;
  transition: transform 180ms cubic-bezier(0.4, 0, 0.2, 1), opacity 140ms linear,
    width 140ms ease; /* petit confort pour la barre du milieu */
}

/* positions initiales des 3 barres */
.mobile-topbar .nav-fab .bar1 {
  top: 0;
}
.mobile-topbar .nav-fab .bar2 {
  top: 7px;
  width: 100%;
}
.mobile-topbar .nav-fab .bar3 {
  top: 14px;
}

/* État OUVERT (aria-expanded="true") -> croix */
.mobile-topbar .nav-fab[aria-expanded="true"] .bar1 {
  transform: translateY(7px) rotate(45deg);
}
.mobile-topbar .nav-fab[aria-expanded="true"] .bar2 {
  opacity: 0;
  transform: scaleX(0.2); /* se contracte avant de disparaître */
}
.mobile-topbar .nav-fab[aria-expanded="true"] .bar3 {
  transform: translateY(-7px) rotate(-45deg);
}

/* Motion-safe */
@media (prefers-reduced-motion: reduce) {
  .mobile-topbar .nav-fab .bar {
    transition: none !important;
  }
}
