/* ============================================
   NAVBAR INTERACTIVE STICKY - VERSION CORRIGÉE
   ============================================ */

/* Variables pour la navbar */
:root {
  --navbar-height: 80px;
  --navbar-scroll-height: 70px;
  --navbar-scroll-max-width: 1120px;
  --navbar-scroll-gutter: 2rem;
  --navbar-transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================
   HEADER / NAVBAR
   ============================================ */

.header {
  position: fixed;
  top: 0;
  /* left + right (plutôt que width:100%) → permet d'animer les marges latérales
     quand la barre se détache en capsule flottante au scroll.
     margin auto + max-width : centre la capsule rétrécie au scroll. Le max-width
     est posé en base (100%) pour qu'il s'anime vers sa valeur réduite sans saut. */
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  max-width: 100%;
  height: var(--navbar-height);
  padding: 0 8%;
  background: rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 1000;
  /* Transition explicite SANS backdrop-filter : animer la valeur du flou
     (blur 10→22) recalcule le flou d'arrière-plan à chaque frame = très coûteux
     et saccadé. Le flou change donc instantanément ; seule la géométrie + les
     couleurs/ombres s'animent (propriétés peu coûteuses). */
  transition:
    top 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    max-width 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    border-radius 0.4s cubic-bezier(0.4, 0, 0.2, 1),
    background-color 0.4s ease,
    border-color 0.4s ease,
    box-shadow 0.4s ease;
  /* Bord complet transparent (et non border-bottom seul) : la largeur 1px est
     déjà posée → au scroll seule la couleur s'anime, et le radius de la capsule
     peut s'appliquer proprement. border-box global → pas de décalage. */
  border: 1px solid rgba(255, 255, 255, 0);
}

/* Reflet « liquid glass » : pseudo placé DERRIÈRE le contenu (z-index:-1, dans
   le contexte d'empilement du header) et DEVANT le background de base.
   Invisible sur le hero, il s'allume en fondu au scroll → la transition verre
   se fait via l'opacité (les gradients ne sont pas animables en CSS). */
.header::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0) 32%),
    radial-gradient(140% 200% at 0% 0%, rgba(124, 58, 237, 0.22), transparent 55%),
    radial-gradient(120% 200% at 100% 0%, rgba(44, 183, 255, 0.14), transparent 55%);
  opacity: 0;
  transition: opacity 0.45s ease;
}

.header.scrolled::before {
  opacity: 1;
}

/* Header au scroll - MATÉRIAU LIQUID GLASS */
.header.scrolled {
  height: var(--navbar-scroll-height);
  background: rgba(22, 18, 38, 0.45);
  -webkit-backdrop-filter: blur(22px) saturate(185%);
  backdrop-filter: blur(22px) saturate(185%);
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow:
    0 8px 32px rgba(10, 5, 25, 0.45),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 0 rgba(255, 255, 255, 0.04);
}

/* DESKTOP : la barre se DÉTACHE en capsule flottante arrondie au scroll
   (style « liquid glass » Apple). Scopé ≥1025px : sur mobile la barre reste
   pleine largeur car le tiroir burger est ancré sous le header. */
@media(min-width: 1025px) {
  /* La nav prend l'espace libre (flex:1) et centre ses liens → il ne reste AUCUN
     espace libre au niveau du header, donc space-between n'a plus rien à étaler :
     logo collé à gauche, actions à droite, liens centrés au milieu, à toute
     largeur. C'est ce qui supprime le bug de répartition quand la pilule rétrécit.
     Les liens gardent une transition de couleur/transform pour le hover, mais PAS
     de padding → le compactage est instantané (aucun reflow animé). */
  .navbar {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: center;
  }

  .navbar a {
    transition: color 0.3s ease, transform 0.3s ease;
  }

  .logo {
    margin-right: 1.2rem;
  }

  .header.scrolled {
    top: 1.1rem;
    /* Capsule rétrécie + centrée (left:0/right:0 + margin auto de la base).
       max-width chiffré (et non fit-content) → la largeur s'ANIME dans les deux
       sens. Le min() garde une marge latérale sur les viewports proches du
       breakpoint desktop tout en laissant assez de place au bouton formation. */
    left: 0;
    right: 0;
    max-width: min(var(--navbar-scroll-max-width), calc(100% - var(--navbar-scroll-gutter)));
    padding: 0 2.2rem;
    border-radius: 100px;
    box-shadow:
      0 14px 40px rgba(10, 5, 25, 0.5),
      0 2px 8px rgba(10, 5, 25, 0.3),
      inset 0 1px 0 0 rgba(255, 255, 255, 0.25),
      inset 0 -1px 0 0 rgba(255, 255, 255, 0.05);
  }

  /* Liens un peu resserrés dans la pilule (snap instantané, cf. transition nav a) */
  .header.scrolled .navbar a {
    padding: 1rem 1.6rem;
  }
}
/* Logo - ANIMATION FIXÉE */
.logo {
  text-decoration: none;
  font-size: 2.3rem;
  color: var(--text-color);
  font-weight: 800;
  cursor: pointer;
  transition: var(--navbar-transition);
  z-index: 1001;
  user-select: none;
  white-space: nowrap;
  flex: 0 0 auto;
}

.logo:hover {
  transform: scale(1.05);
  filter: drop-shadow(0 0 10px rgba(75, 0, 130, 0.4));
}

.header.scrolled .logo {
  font-size: 2.1rem;
}

.logo span {
  background: linear-gradient(200deg,
      #6366F1, #2CB7FF);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* Menu icon (burger) - ANIMATION FIXÉE */
#menu-icon {
  font-size: 3.5rem;
  color: var(--main-color);
  display: none;
  cursor: pointer;
  z-index: 1001;
  transition: var(--navbar-transition);
  user-select: none;
}

#menu-icon:hover {
  transform: scale(1.1);
  color: #6366F1;
}

#menu-icon:active {
  transform: scale(0.95);
}

/* Burger ↔ X — l'icône SVG est swap dans le DOM via JS */
#menu-icon.is-open {
  color: var(--main-color);
}

/* ============================================
   NAVIGATION
   ============================================ */

.navbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  transition: var(--navbar-transition);
}

.navbar a {
  position: relative;
  text-decoration: none;
  font-size: 1.6rem;
  color: var(--text-color);
  font-weight: 500;
  padding: 1rem 2rem;
  transition: var(--navbar-transition);
  white-space: nowrap;
  display: inline-block;
}

/* Effet hover - FIXÉ */
.navbar a:hover {
  color: var(--main-color);
  transform: translateY(-2px);
}

/* Indicateur de lien actif - ANIMATION AMÉLIORÉE */
.navbar a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 0;
  height: 3px;
  background: linear-gradient(135deg,
      rgba(127, 90, 240, 0),
      rgba(127, 90, 240, 1),
      rgba(127, 90, 240, 1),
      rgba(127, 90, 240, 0));
  border-radius: 10px;
  transform: translateX(-50%);
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 10px rgba(28, 191, 212, 0);
}

/* Lien actif - FIXÉ */
.navbar a.active {
  color: var(--main-color);
}

/* Desktop : catégorie sélectionnée → on garde la couleur de texte normale
   (le soulignement lumineux suffit à marquer l'état actif), pas de texte violet.
   Scopé ≥1025px pour ne pas affecter le tiroir mobile. */
@media(min-width: 1025px) {
  .navbar a.active,
  .navbar a.active:hover {
    color: var(--text-color);
  }
}

.navbar a.active::after {
  width: 80%;
  box-shadow: 0 0 15px rgba(127, 90, 240, 1);
}

/* Animation au hover sur le lien actif */
.navbar a.active:hover::after {
  width: 100%;
  box-shadow: 0 0 20px rgba(127, 90, 240, 1);
}

.header-actions {
  flex: 0 0 auto;
}

/* ============================================
   BOUTON GRADIENT
   ============================================ */

.gradient-btn {
  text-decoration: none;
  font-size: 1.6rem;
  padding: 1rem 2.5rem;
  border-radius: 3rem;
  background: linear-gradient(135deg,
      #6366F1 100%,
      #2CB7FF 100%);
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: var(--navbar-transition);
  color: white;
  border: 2px solid transparent;
  text-wrap: nowrap;
  font-weight: 600;
  box-shadow: 0 4px 15px rgba(103, 2, 174, 0.4);
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
}

.gradient-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg,
      rgba(255, 255, 255, 0.1) 0%,
      rgba(255, 255, 255, 0) 100%);
  transition: left 0.5s ease;
}

.gradient-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 25px rgba(127, 90, 240, 0.6);
  border-color: rgba(127, 90, 240, 1);
}

.gradient-btn:hover::before {
  left: 100%;
}

.gradient-btn:active {
  transform: translateY(0);
}

/* ============================================
   RESPONSIVE - TABLETTE & MOBILE (burger menu)
   ============================================ */

@media(max-width: 1024px) {
  :root {
    --navbar-height: 70px;
    --navbar-scroll-height: 65px;
  }

  .header {
    padding: 0 5%;
  }

  #menu-icon {
    display: block;
  }

  .navbar {
    position: fixed;
    top: var(--navbar-height);
    right: -100%;
    width: 300px;
    max-width: 85vw;
    height: calc(100vh - var(--navbar-height));
    padding: 3rem 0;
    /* Tiroir liquid glass : fond translucide (alpha bas → le blur du contenu
       derrière transparaît), blur saturé, liseré clair + reflet spéculaire
       interne sur l'arête gauche. */
    background: rgba(15, 12, 28, 0.6);
    -webkit-backdrop-filter: blur(26px) saturate(180%);
    backdrop-filter: blur(26px) saturate(180%);
    border-left: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 22px 0 0 22px;
    box-shadow:
      -8px 0 40px rgba(0, 0, 0, 0.5),
      inset 1px 0 0 0 rgba(255, 255, 255, 0.18);
    flex-direction: column;
    gap: 0;
    align-items: flex-start;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    z-index: 999;
  }

  .navbar.active {
    right: 0;
  }

  /* Liens du tiroir en px (et non rem) : le html{font-size} diffère entre index
     (55%/50%) et mentions (60%), donc des rem rendraient les liens plus gros sur
     mentions. Valeurs calées sur le rendu d'index → menu identique sur les 2 pages. */
  .navbar a {
    display: block;
    width: 100%;
    font-size: 16px;
    padding: 18px 26px;
    margin: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.12);
    transform: translateX(0);
    transition: all 0.3s ease;
  }

  .navbar a::after {
    display: none !important;
  }

  .navbar a.active {
    background: rgba(99, 102, 241, 0.28);
    color: var(--text-color);
    border-left: 4px solid var(--main-color);
    padding-left: calc(26px - 4px);
  }

  .navbar a:hover {
    background: rgba(99, 102, 241, 0.28);
    color: var(--text-color);
    padding-left: 30px;
    transform: translateX(0);
  }

  .navbar a.active:hover {
    background: rgba(99, 102, 241, 0.28);
    color: var(--text-color);
  }

  .gradient-btn {
    display: none;
  }

  /* Logo + burger + header-actions en px : la navbar rend identique sur index
     et mentions, indépendamment du html{font-size} de chaque page (index descend
     à 55/50%, mentions reste à 60%). Valeurs calées sur le rendu d'index
     (racine 55% dans cette tranche), pour que mentions adopte la navbar d'index. */
  .logo {
    font-size: 19px;
  }

  #menu-icon {
    font-size: 36px;
  }

  .header-actions {
    gap: 11px;
  }

  .theme-switch {
    width: 56px;
    height: 28px;
    border-radius: 28px;
    padding: 0 4px;
  }

  .switch-thumb {
    width: 21px;
    height: 21px;
  }

  .switch-thumb i,
  .switch-thumb .icon {
    font-size: 12px;
  }

  body.light-mode .switch-thumb {
    transform: translateX(25px);
  }

  .lang-current {
    height: 28px;
    padding: 0 10px;
    border-radius: 28px;
    gap: 5px;
    font-size: 11px;
  }

  .lang-current .lang-globe {
    font-size: 16px;
  }

  .lang-current .lang-caret {
    font-size: 12px;
  }

  .header.scrolled {
    height: var(--navbar-scroll-height);
  }

  /* Empêche la règle desktop .header.scrolled .logo (2.4rem) de regrossir
     le logo au scroll sur mobile et de pousser les header-actions à droite. */
  .header.scrolled .logo {
    font-size: 18px;
  }

  .header.scrolled .navbar {
    top: var(--navbar-scroll-height);
    height: calc(100vh - var(--navbar-scroll-height));
  }
}

@media(max-width: 768px) {
  :root {
    --navbar-height: 65px;
    --navbar-scroll-height: 60px;
  }
}

/* ============================================
   RESPONSIVE - PETIT MOBILE
   ============================================ */

@media(max-width: 480px) {
  :root {
    --navbar-height: 60px;
    --navbar-scroll-height: 55px;
  }

  .header {
    padding: 0 4%;
  }

  /* Valeurs calées sur le rendu d'index en racine 50% (1rem=8px). */
  .logo {
    font-size: 16px;
  }

  .header.scrolled .logo {
    font-size: 14px;
  }

  #menu-icon {
    font-size: 32px;
  }

  .header-actions {
    gap: 6px;
  }

  .theme-switch {
    width: 51px;
    height: 26px;
    border-radius: 26px;
  }

  .switch-thumb {
    width: 19px;
    height: 19px;
  }

  .switch-thumb i,
  .switch-thumb .icon {
    font-size: 11px;
  }

  body.light-mode .switch-thumb {
    transform: translateX(22px);
  }

  .lang-current {
    height: 26px;
    padding: 0 9px;
    border-radius: 26px;
    gap: 5px;
    font-size: 10px;
  }

  .lang-current .lang-globe {
    font-size: 14px;
  }

  .lang-current .lang-caret {
    font-size: 11px;
  }

  .navbar {
    width: 100%;
    border-left: none;
    border-top: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 0;
    box-shadow:
      0 -8px 40px rgba(0, 0, 0, 0.5),
      inset 0 1px 0 0 rgba(255, 255, 255, 0.18);
    right: -100%;
  }

  .navbar.active {
    right: 0;
  }

  .navbar a {
    font-size: 13px;
    padding: 14px 20px;
  }

  .navbar a.active {
    padding-left: calc(20px - 4px);
  }

  .navbar a:hover {
    padding-left: 24px;
  }
}

/* ============================================
   OVERLAY MENU MOBILE - CORRIGÉ
   ============================================ */

.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(5, 5, 15, 0.55);
  -webkit-backdrop-filter: blur(8px) saturate(140%);
  backdrop-filter: blur(8px) saturate(140%);
  z-index: 998;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

@media(min-width: 1025px) {
  .menu-overlay {
    display: none;
  }
}

/* ============================================
   ANIMATIONS SUPPLÉMENTAIRES
   ============================================ */

/* Animation de pulse pour le lien actif */
@keyframes pulse-glow {

  0%,
  100% {
    box-shadow: 0 0 10px rgba(127, 90, 240, 1);
  }

  50% {
    box-shadow: 0 0 20px rgba(127, 90, 240, 0);
  }
}

.navbar a.active::after {
  animation: pulse-glow 2s ease-in-out infinite;
}

/* Désactiver animation au hover */
.navbar a.active:hover::after {
  animation: none;
}

/* Offset pour le scroll */
section {
  scroll-margin-top: calc(var(--navbar-scroll-height) + 2rem);
}

/* ============================================
   ACCESSIBILITÉ
   ============================================ */

/* Focus visible */
.navbar a:focus-visible,
.gradient-btn:focus-visible,
#menu-icon:focus-visible {
  outline: 2px solid var(--main-color);
  outline-offset: 4px;
  border-radius: 4px;
}

/* Indicateur de focus clavier global : ne s'affiche qu'au clavier
   (:focus-visible), jamais au clic souris. Bat les `outline:none` posés
   sur .btn / .lang-current grâce à la spécificité élément + pseudo-classe. */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid var(--main-color);
  outline-offset: 3px;
  border-radius: 4px;
}

/* Cible programmatique du lien d'évitement : pas d'anneau autour de tout <main> */
#main:focus {
  outline: none;
}

/* Lien d'évitement : caché hors écran, glisse à l'écran au focus clavier */
.skip-link {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 10001;
  margin: 0.6rem;
  padding: 0.8rem 1.4rem;
  background: var(--main-color);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 600;
  border-radius: 8px;
  transform: translateY(-150%);
  transition: transform 0.2s ease;
}

.skip-link:focus {
  transform: translateY(0);
  outline: 2px solid #fff;
  outline-offset: 2px;
}

/* Réduire les animations si demandé */
@media (prefers-reduced-motion: reduce) {

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  html {
    scroll-behavior: auto;
  }
}

/* ============================================
   CORRECTIONS POUR SAFARI
   ============================================ */

@supports (-webkit-touch-callout: none) {
  .navbar {
    /* Fix pour iOS */
    -webkit-overflow-scrolling: touch;
  }

  .header {
    /* Fix backdrop-filter sur iOS */
    backdrop-filter: blur(10px);
  }
}

/* Smooth transitions globales */
* {
  -webkit-tap-highlight-color: transparent;
}
