/* ==========================================================
   NAVBAR — Líonra
   Pilule flottante en verre dépoli, menu mobile plein écran.
   Thème : classe .dark / .light sur <html> (comme le reste du site).
   Aucune modification du JS nécessaire (#navLinks, #hamburger,
   #themeToggle et la classe .active sont conservés).
========================================================== */

:root {
  --nav-brand: var(--brand, #2f7a52);
  --nav-brand-dark: var(--brand-dark, #123524);
  --nav-glow: rgba(47, 122, 82, 0.28);

  --nav-bg: rgba(255, 255, 255, 0.62);
  --nav-border: rgba(0, 0, 0, 0.07);
  --nav-shadow:
    0 8px 30px rgba(0, 0, 0, 0.08), 0 1px 0 rgba(255, 255, 255, 0.7) inset;
  --nav-chip: rgba(0, 0, 0, 0.04);
  --nav-hover: rgba(47, 122, 82, 0.12);
  --nav-text: #111;
  --nav-muted: rgba(17, 17, 17, 0.68);

  /* menu mobile */
  --nav-menu-1: rgba(47, 122, 82, 0.16);
  --nav-menu-2: rgba(255, 255, 255, 0.97);
  --nav-menu-3: rgba(245, 250, 247, 0.99);
  --nav-menu-border: rgba(0, 0, 0, 0.08);
  --nav-menu-footer: rgba(0, 0, 0, 0.35);
  --nav-menu-blob: 0.18;
}

html.dark {
  --nav-bg: rgba(16, 19, 16, 0.6);
  --nav-border: rgba(255, 255, 255, 0.09);
  --nav-shadow:
    0 8px 30px rgba(0, 0, 0, 0.4), 0 1px 0 rgba(255, 255, 255, 0.05) inset;
  --nav-chip: rgba(255, 255, 255, 0.06);
  --nav-hover: rgba(47, 122, 82, 0.28);
  --nav-text: #f7f7f7;
  --nav-muted: rgba(247, 247, 247, 0.72);

  --nav-menu-1: rgba(47, 122, 82, 0.28);
  --nav-menu-2: rgba(10, 12, 10, 0.98);
  --nav-menu-3: rgba(2, 3, 2, 1);
  --nav-menu-border: rgba(255, 255, 255, 0.08);
  --nav-menu-footer: rgba(255, 255, 255, 0.35);
  --nav-menu-blob: 0.25;
}

/* ----------------------------------------------------------
   BARRE
---------------------------------------------------------- */

.navbar {
  position: fixed;
  top: 0.75rem;
  inset-inline: 0;
  z-index: 50;
  padding-inline: 0.75rem;
  pointer-events: none; /* les marges autour de la pilule restent cliquables */
}

.nav-inner {
  position: relative;
  pointer-events: auto;
  max-width: 1100px;
  margin-inline: auto;
  padding: 0.5rem 0.6rem 0.5rem 1.15rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-radius: 999px;
}

/* Le verre dépoli est sur un pseudo-élément : un backdrop-filter sur
   .navbar elle-même "piégerait" le menu plein écran (position: fixed)
   à l'intérieur de la barre. */
.nav-inner::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border-radius: inherit;
  background: var(--nav-bg);
  border: 1px solid var(--nav-border);
  box-shadow: var(--nav-shadow);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  backdrop-filter: blur(16px) saturate(160%);
  transition:
    background 0.3s,
    border-color 0.3s,
    opacity 0.3s;
}

/* Menu ouvert : la pilule s'efface, seuls logo + boutons restent visibles */
.navbar:has(.nav-links.active) .nav-inner::before {
  opacity: 0;
}

/* ----------------------------------------------------------
   LOGO
---------------------------------------------------------- */

.logo {
  position: relative;
  z-index: 90;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--nav-brand);
}

.logo::before {
  content: "";
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--nav-brand), #92c9b1);
  box-shadow:
    0 0 0 4px var(--nav-hover),
    0 0 14px var(--nav-glow);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.logo:hover::before {
  transform: scale(1.25);
}

/* ----------------------------------------------------------
   LIENS — MOBILE : menu plein écran
---------------------------------------------------------- */

.nav-links {
  display: none;
  flex-direction: column;
  justify-content: center;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100dvh;
  padding: 7rem 2rem 4rem;
  background:
    radial-gradient(circle at 85% 12%, var(--nav-menu-1), transparent 55%),
    linear-gradient(160deg, var(--nav-menu-2), var(--nav-menu-3));
  -webkit-backdrop-filter: blur(22px);
  backdrop-filter: blur(22px);
  z-index: 75;
  overflow: hidden;
  counter-reset: navcount;
}

.nav-links::before {
  content: "";
  position: absolute;
  top: -80px;
  right: -100px;
  width: 340px;
  height: 340px;
  border-radius: 50%;
  background: var(--nav-brand);
  filter: blur(100px);
  opacity: var(--nav-menu-blob);
  pointer-events: none;
}

.nav-links::after {
  content: "Líonra — Créer · Connecter · Inspirer";
  position: absolute;
  left: 2rem;
  right: 2rem;
  bottom: 1.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--nav-menu-footer);
  opacity: 0;
  pointer-events: none;
}

.nav-links.active {
  display: flex;
  animation: navPanelIn 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-links.active::after {
  animation: navFadeIn 0.5s ease forwards 0.5s;
}

.nav-links a {
  position: relative;
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding: 1.1rem 0;
  overflow: hidden;
  font-size: clamp(1.7rem, 7vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--nav-text);
  border-bottom: 1px solid var(--nav-menu-border);
  opacity: 0;
  transform: translateY(28px);
  counter-increment: navcount;
  transition:
    color 0.3s ease,
    padding-left 0.3s ease,
    gap 0.3s ease;
}

.nav-links a::before {
  content: counter(navcount, decimal-leading-zero);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--nav-brand);
  opacity: 0.85;
}

.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 0;
  height: 2px;
  background: var(--nav-brand);
  transition: width 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-links a[aria-current="page"] {
  color: var(--nav-brand);
}

.nav-links a[aria-current="page"]::after {
  width: 100%;
}

.nav-links.active a {
  animation: navLinkIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.nav-links.active a:nth-child(1) {
  animation-delay: 0.08s;
}
.nav-links.active a:nth-child(2) {
  animation-delay: 0.15s;
}
.nav-links.active a:nth-child(3) {
  animation-delay: 0.22s;
}
.nav-links.active a:nth-child(4) {
  animation-delay: 0.29s;
}
.nav-links.active a:nth-child(5) {
  animation-delay: 0.36s;
}
.nav-links.active a:nth-child(6) {
  animation-delay: 0.43s;
}

.nav-links a:active {
  color: var(--nav-brand);
}

@media (hover: hover) {
  .nav-links a:hover {
    color: var(--nav-brand);
    padding-left: 0.4rem;
    gap: 1.3rem;
  }

  .nav-links a:hover::after {
    width: 100%;
  }
}

/* Pas de scroll de la page derrière le menu ouvert */
@media (max-width: 767.98px) {
  html:has(.nav-links.active) {
    overflow: hidden;
  }
}

/* ----------------------------------------------------------
   CONTRÔLES (thème + burger)
---------------------------------------------------------- */

.right-controls {
  position: relative;
  z-index: 90;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

/* ---- Burger ---- */
.hamburger {
  position: relative;
  flex: none;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--nav-border);
  background: var(--nav-chip);
  color: var(--nav-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    background 0.3s,
    border-color 0.3s,
    color 0.3s;
}

.hamburger span {
  position: absolute;
  left: 12px;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition:
    transform 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.2s,
    background 0.3s;
}

.hamburger span:nth-child(1) {
  top: 14px;
}
.hamburger span:nth-child(2) {
  top: 20px;
}
.hamburger span:nth-child(3) {
  top: 26px;
}

.hamburger.active {
  background: var(--nav-hover);
  border-color: var(--nav-brand);
  color: var(--nav-brand);
}

.hamburger.active span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}
.hamburger.active span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.hamburger.active span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

/* ---- Switch thème ---- */
.ln-switch {
  display: inline-flex;
  padding: 0;
  border: none;
  background: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.ln-track {
  position: relative;
  width: 58px;
  height: 32px;
  border-radius: 999px;
  background: var(--nav-chip);
  border: 1px solid var(--nav-border);
  transition:
    background 0.35s ease,
    border-color 0.35s ease;
}

.ln-switch:hover .ln-track {
  border-color: var(--nav-brand);
}

.ln-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--nav-brand);
  color: #fff;
  box-shadow: 0 2px 8px var(--nav-glow);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ln-thumb svg {
  position: absolute;
  width: 16px;
  height: 16px;
  opacity: 0;
  transform: scale(0.5) rotate(-40deg);
  transition:
    opacity 0.25s,
    transform 0.3s;
}

html:not(.dark) .ln-thumb .icon-light,
html.dark .ln-thumb .icon-dark {
  opacity: 1;
  transform: scale(1) rotate(0);
}

html.dark .ln-thumb {
  transform: translateX(26px);
}

/* ---- Accessibilité ---- */
.logo:focus-visible,
.nav-links a:focus-visible,
.hamburger:focus-visible,
.ln-switch:focus-visible .ln-track {
  outline: 2px solid var(--nav-brand);
  outline-offset: 3px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ----------------------------------------------------------
   ANIMATIONS
---------------------------------------------------------- */

@keyframes navPanelIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes navFadeIn {
  to {
    opacity: 1;
  }
}
@keyframes navLinkIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .nav-links.active,
  .nav-links.active a,
  .nav-links.active::after {
    animation-duration: 0.01ms;
    animation-delay: 0s;
  }

  .hamburger span,
  .ln-thumb,
  .ln-thumb svg,
  .logo::before {
    transition: none;
  }
}

/* ----------------------------------------------------------
   DESKTOP & TABLETTE (≥ 768px)
   Logo | liens centrés dans une capsule | contrôles
---------------------------------------------------------- */

@media (min-width: 768px) {
  .nav-inner {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    padding: 0.5rem 0.6rem 0.5rem 1.35rem;
  }

  .right-controls {
    justify-self: end;
  }

  .hamburger {
    display: none;
  }

  .nav-links,
  .nav-links.active {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    padding: 4px;
    gap: 2px;
    overflow: visible;
    counter-reset: none;
    animation: none;
    z-index: auto;
    background: var(--nav-chip);
    border: 1px solid var(--nav-border);
    border-radius: 999px;
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }

  .nav-links::before,
  .nav-links::after,
  .nav-links.active::after {
    content: none;
    animation: none;
  }

  .nav-links a,
  .nav-links.active a {
    display: inline-flex;
    gap: 0;
    padding: 0.5rem 1rem;
    overflow: visible;
    font-size: 0.92rem;
    font-weight: 600;
    letter-spacing: 0;
    color: var(--nav-muted);
    border: none;
    border-radius: 999px;
    opacity: 1;
    transform: none;
    animation: none;
    transition:
      background 0.25s,
      color 0.25s,
      box-shadow 0.25s;
  }

  .nav-links a::before,
  .nav-links a::after {
    content: none;
    display: none;
  }

  .nav-links a:hover,
  .nav-links a:active {
    padding-left: 1rem;
    gap: 0;
    color: var(--nav-brand);
    background: var(--nav-hover);
  }

  .nav-links a[aria-current="page"],
  .nav-links a[aria-current="page"]:hover {
    color: #fff;
    background: var(--nav-brand);
    box-shadow: 0 4px 14px var(--nav-glow);
  }
}
