/* ══════════════════════════════════════════════════════════════
   QUATRE V2 — NAVIGATION
   Transparente, posée sur le fond. Noir sur rouge, blanc sur noir
   (classe .nav--on-dark togglée par shared.js selon le scroll).
   ═════════════════════════════════════════════════════════════ */

.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--nav-h);
}

.nav-inner {
  height: 100%;
  padding-inline: clamp(16px, 1.6vw, 28px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* ── Logo : « 4 » au repos → QU4TRE au survol.
   Les lettres Q U T R E sont VU DE PROFIL (rotateY 89°, pivot sur leur
   bord gauche comme une porte) et pivotent sur Y pour passer de face,
   en cascade. La largeur s'ouvre VITE, la rotation est LENTE : c'est
   la bascule profil → face qu'on doit voir, pas un glissement. ── */
.nav-logo {
  display: flex;
  align-items: center;
  height: 28px;
  /* perspective serrée = raccourci de profil bien marqué */
  perspective: 340px;
}

.lg {
  display: block;
}

.lg svg {
  display: block;
  height: 25px;
  width: auto;
}

.lg-letter {
  width: 0;
  margin-right: 0;
  opacity: 0;
  transform: rotateY(89deg);
  transform-origin: 0 50%;
  backface-visibility: hidden;
  /* SORTIE : rotation face → profil d'abord (pure, lente), la lettre
     s'éteint en fin de bascule, puis la largeur se replie tout en
     douceur une fois la lettre invisible */
  transition:
    transform 0.65s var(--ease-out) calc(var(--i) * 45ms),
    opacity 0.24s ease calc(var(--i) * 45ms + 420ms),
    width 0.5s var(--ease-out) calc(var(--i) * 45ms + 520ms),
    margin-right 0.5s var(--ease-out) calc(var(--i) * 45ms + 520ms);
}

.nav-logo:hover .lg-letter,
.nav-logo:focus-visible .lg-letter {
  opacity: 1;
  transform: rotateY(0deg);
  margin-right: 2.4px;
  /* ENTRÉE : la place s'ouvre vite, la lettre pivote lentement */
  transition:
    width 0.3s var(--ease-out) calc(var(--i) * 70ms),
    margin-right 0.3s var(--ease-out) calc(var(--i) * 70ms),
    opacity 0.12s linear calc(var(--i) * 70ms + 30ms),
    transform 0.7s var(--ease-out) calc(var(--i) * 70ms + 40ms);
}

.nav-logo:hover .lg-q,
.nav-logo:focus-visible .lg-q {
  width: 25px;
}

.nav-logo:hover .lg-u,
.nav-logo:hover .lg-t,
.nav-logo:hover .lg-r,
.nav-logo:hover .lg-e,
.nav-logo:focus-visible .lg-u,
.nav-logo:focus-visible .lg-t,
.nav-logo:focus-visible .lg-r,
.nav-logo:focus-visible .lg-e {
  width: 18.5px;
}

/* Le 4 : version carrée au repos, version wordmark au survol */
.lg-4 {
  position: relative;
  width: 23.6px;
  height: 28px;
  /* sortie : la largeur ne bouge qu'une fois les glyphes repassés de profil */
  transition: width 0.5s var(--ease-out) 560ms, margin-right 0.5s var(--ease-out) 560ms;
}

.lg-4 svg {
  position: absolute;
  left: 0;
  top: 50%;
  transform-origin: 0 50%;
  backface-visibility: hidden;
  /* sortie : bascule wordmark → carré, pure et lente */
  transition: transform 0.65s var(--ease-out) 90ms, opacity 0.24s ease 460ms;
}

.nav-logo:hover .lg-4,
.nav-logo:focus-visible .lg-4 {
  transition: width 0.3s var(--ease-out) 70ms, margin-right 0.3s var(--ease-out) 70ms;
}

.nav-logo:hover .lg-4 svg,
.nav-logo:focus-visible .lg-4 svg {
  transition: transform 0.65s var(--ease-out) 70ms, opacity 0.12s linear 100ms;
}

.lg-4-mini {
  height: 28px !important;
  transform: translateY(-50%);
}

.lg-4-word {
  opacity: 0;
  transform: translateY(-50%) rotateY(89deg);
}

.nav-logo:hover .lg-4,
.nav-logo:focus-visible .lg-4 {
  width: 19.5px;
  margin-right: 2.4px;
}

.nav-logo:hover .lg-4-mini,
.nav-logo:focus-visible .lg-4-mini {
  opacity: 0;
  transform: translateY(-50%) rotateY(-89deg);
}

.nav-logo:hover .lg-4-word,
.nav-logo:focus-visible .lg-4-word {
  opacity: 1;
  transform: translateY(-50%) rotateY(0deg);
}

@media (prefers-reduced-motion: reduce) {
  .lg-letter,
  .lg-4,
  .lg-4 svg {
    transition: none;
  }
}

/* ── Barre + nom de page (sous-pages, maquette 35:14011) ── */
.nav-sep {
  width: 2px;
  height: 26px;
  background-color: currentColor;
  opacity: 0.9;
}

.nav-left {
  color: var(--black);
}

.nav--on-dark .nav-left,
.nav--mega-open .nav-left {
  color: var(--white);
}

.nav-page-name {
  font-size: 14px;
  font-weight: 600;
  line-height: 16px;
  white-space: nowrap;
}

/* ── Bouton retour : réservé au mode galerie (body.lb-open) ── */
.nav-back {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 9999px;
  background-color: var(--night);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  line-height: 16px;
  transition: transform 0.35s var(--ease-out), background-color 0.4s ease, color 0.4s ease;
}

.nav-back:hover {
  transform: scale(1.05);
}

body.lb-open .nav-back {
  display: inline-flex;
}

body.lb-open .nav-sep,
body.lb-open .nav-page-name {
  display: none;
}

.nav--on-dark .nav-back {
  background-color: var(--white);
  color: var(--black);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: clamp(16px, 2vw, 32px);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 14px;
  line-height: 16px;
}

/* Liens du header : comme le bouton Contact mais fond transparent,
   noir translucide au survol (maquette 35:13439 : items b/base) */
.nav-links a,
.nav-links .nav-disabled {
  display: inline-flex;
  align-items: center;
  padding: 12px 22px;
  border-radius: 9999px;
  font-weight: 600;
  color: var(--black);
  background-color: transparent;
  transition: color 0.4s ease, background-color 0.3s ease;
}

.nav-links a:hover {
  background-color: rgba(0, 0, 0, 0.35);
}

.nav-disabled {
  opacity: 0.55;
  cursor: default;
}

/* ── Rich menu Expertises (maquette 35:13273) : panneau pleine
   largeur sous la nav, 4 cards orbes → pages expertise ── */
.nav-exp-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-chev {
  transition: transform 0.3s var(--ease-out);
}

.nav-exp-link.is-open .nav-chev {
  transform: rotate(180deg);
}

.nav-mega {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: -1; /* sous la barre de nav (liens/logo restent cliquables) */
  padding-top: var(--nav-h);
  background-color: var(--night);
  border-radius: 0 0 20px 20px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(-10px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.45s var(--ease-out);
}

.nav-mega.is-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.nav-mega-inner {
  width: min(var(--wide-w), calc(100% - 2 * var(--pad-x)));
  margin-inline: auto;
  padding: clamp(28px, 3.5vh, 64px) 0 clamp(28px, 3.5vh, 48px);
  display: flex;
  flex-direction: column;
  gap: clamp(20px, 2.5vh, 32px);
}

/* En-tête du panneau : titre + bouton vers la landing */
.nav-mega-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--gutter);
}

/* deux CTA côte à côte (toutes les expertises + insights) */
.nav-mega-ctas {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.nav-mega-title {
  font-size: clamp(24px, 2vw, 40px);
  line-height: 1.15;
  color: var(--white);
}

.nav-mega-cta {
  flex: none;
  background-color: transparent;
  border: 1px solid rgba(255, 255, 255, 0.55);
  color: var(--white);
}

.nav-mega-cta:hover,
.nav-mega-cta:focus-visible {
  background-color: var(--white);
  border-color: var(--white);
  color: var(--black);
}

.nav-mega-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gutter);
}

/* Card : scène d'orbe + titre + bouton (maquette 337×366) */
.mega-card {
  position: relative;
  display: block;
  aspect-ratio: 337 / 366;
  max-height: 52vh;
  border-radius: 12px;
  overflow: hidden;
  background-color: #0c0b0b;
  transform: translateZ(0);
  isolation: isolate;
  transition: transform 0.5s var(--ease-out);
}

.mega-card:hover {
  transform: scale(1.02) translateZ(0);
}

.mega-card canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  filter: saturate(1.04);
}

.mega-card-content {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding: 24px;
  text-align: center;
  color: var(--white);
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.35) 100%);
}

.mega-card-title {
  font-family: var(--font-serif);
  font-size: clamp(18px, 1.5vw, 26px);
  line-height: 1.2;
}

.mega-card .pill-btn {
  pointer-events: none;
  padding: 12px 22px;
  font-size: 14px;
}

/* Menu ouvert : la barre passe en blanc sur le panneau sombre,
   quel que soit le thème de la page derrière */
.nav--mega-open .nav-links a,
.nav--mega-open .nav-links .nav-disabled {
  color: var(--white);
}

.nav--mega-open .nav-logo {
  color: var(--white);
}

.nav--mega-open .nav-contact-btn,
.nav--mega-open .nav-back {
  background-color: var(--white);
  color: var(--black);
}

.nav--mega-open .menu-toggle {
  color: var(--white);
}

/* Sous-liens mobiles (le rich menu est desktop uniquement) */
.nav-mobile-sub {
  display: none;
}

.nav-contact-btn {
  display: inline-flex;
  align-items: center;
  padding: 12px 22px;
  border-radius: 9999px;
  background-color: var(--night);
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
  line-height: 16px;
  transition: transform 0.35s var(--ease-out), background-color 0.4s ease, color 0.4s ease;
}

.nav-contact-btn:hover {
  transform: scale(1.05);
}

/* Logo : les SVG héritent via currentColor */
.nav-logo {
  color: var(--black);
}

/* ── Variante sur fond noir ── */
.nav--on-dark .nav-links a,
.nav--on-dark .nav-links .nav-disabled {
  color: var(--white);
}

.nav--on-dark .nav-logo {
  color: var(--white);
}

.nav--on-dark .nav-contact-btn {
  background-color: var(--white);
  color: var(--black);
}

/* ── Mobile ── */
.menu-toggle {
  display: none;
  font-size: 28px;
  line-height: 1;
  color: var(--black);
  transition: color 0.4s ease, transform 0.3s var(--ease-out);
}

.nav--on-dark .menu-toggle {
  color: var(--white);
}

@media (max-width: 860px) {
  .menu-toggle {
    display: block;
  }

  .menu-toggle.is-open {
    transform: rotate(45deg);
  }

  .nav-links {
    position: fixed;
    inset: var(--nav-h) 0 auto 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 20px;
    padding: 24px var(--pad-x) 32px;
    background-color: var(--night);
    font-size: 20px;
    transform: translateY(-12px);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s var(--ease-out);
  }

  .nav-links a,
  .nav-links .nav-disabled {
    color: var(--white);
    padding: 0;
    background-color: transparent;
  }

  .nav-links a:hover {
    background-color: transparent;
  }

  .nav-links.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  /* Mobile : pas de rich menu — sous-liens simples indentés */
  .nav-mega {
    display: none;
  }

  .nav-exp-link .nav-chev {
    display: none;
  }

  .nav-mobile-sub {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-left: 16px;
  }

  .nav-mobile-sub a {
    font-size: 16px;
  }
}
