/* menu-expanding-pill-panel : styles de l'effet, tous scopés à [data-fx="menu-expanding-pill-panel"].
   Le root est l'en-tête fixe (bouton pastille à droite, logo à gauche) ; il contient le panneau du menu, ancré au
   même coin que la pastille. L'étirement pastille → panneau est un clip-path calculé ici depuis --fx-p (0 → 1),
   écrit par le JS pendant les transitions : aucune mesure, le panneau garde sa taille finale et son contenu ne
   reflue jamais. Thème partagé (contrat v3 §2) : la PAGE fournit les rôles communs, l'effet ne fait que les LIRE,
   avec la valeur d'origine en repli. Le panneau prend la couleur d'accent ; son texte est noir ou blanc selon la
   clarté de cet accent (couleur relative oklch), il contraste donc sous tous les thèmes.
   Ne jamais DÉCLARER un rôle partagé ici (ex. `--fx-bg: #000`) : cela écraserait le thème de la page. */
[data-fx="menu-expanding-pill-panel"] {
  /* couleurs */
  --fx-ink: var(--fx-fg, #111111); /* logo, posé sur la page */
  --fx-panel: var(--fx-accent, #c9fd74); /* pastille, panneau */
  /* texte sur le panneau : noir si l'accent est clair, blanc s'il est sombre (surcharge possible sur le root) */
  --fx-panel-ink: oklch(from var(--fx-panel) clamp(0, (0.62 - l) * 1000, 1) 0 0);
  --fx-outline: var(--fx-focus, currentColor);
  /* polices */
  --fx-family: var(--fx-font, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif);
  --fx-link-weight: var(--fx-weight, 400);
  /* géométrie : le panneau est à --fx-edge des bords de l'écran, la pastille à --fx-gap des bords du panneau */
  --fx-z: 50;
  --fx-edge: clamp(0.75rem, 0.25rem + 1.6vw, 1.5625rem);
  --fx-gap: clamp(0.625rem, 0.25rem + 1.6vw, 1.5625rem);
  --fx-pill-w: 6.25rem;
  --fx-pill-h: 2.5rem;
  --fx-radius: var(--fx-radius-l, 1.5625rem); /* arrondi du panneau ouvert */
  --fx-panel-w: 30rem;
  --fx-panel-h: 40.625rem;
  --fx-panel-pad-x: clamp(1.25rem, 0.75rem + 1.6vw, 2.5rem);
  --fx-link-size: var(--fx-t2, clamp(2rem, min(1.25rem + 5vw, 7svh), 2.875rem));
  --fx-foot-size: 0.875rem;
  /* mouvement (survol du bouton ; la timeline GSAP garde ses options JS) */
  --fx-flip-dur: 0.45s;
  --fx-flip-ease: var(--fx-ease, cubic-bezier(0.76, 0, 0.24, 1));

  position: fixed;
  inset: 0 0 auto;
  z-index: var(--fx-z);
  color: var(--fx-ink);
  font-family: var(--fx-family);
  pointer-events: none; /* la bande de l'en-tête laisse passer les clics (logo, bouton et panneau réactivés) */
}

[data-fx="menu-expanding-pill-panel"] *,
[data-fx="menu-expanding-pill-panel"] *::before,
[data-fx="menu-expanding-pill-panel"] *::after {
  box-sizing: border-box;
}

/* ---- En-tête : logo à gauche, pastille à droite (le bouton précède le logo dans le DOM : premier élément
   interactif). La bande n'ouvre pas de contexte d'empilement : le logo passe SOUS le panneau, le bouton au-dessus. */
[data-fx="menu-expanding-pill-panel"] .fx-bar {
  position: relative;
  display: flex;
  flex-direction: row-reverse;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(var(--fx-edge) + var(--fx-gap));
}

[data-fx="menu-expanding-pill-panel"] .fx-brand {
  position: relative;
  z-index: 0;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  pointer-events: auto;
  color: inherit;
  text-decoration: none;
  font-size: clamp(1.125rem, 1rem + 0.5vw, 1.375rem);
  font-weight: 600;
  letter-spacing: -0.01em;
  -webkit-tap-highlight-color: transparent;
}

/* ---- Bouton pastille : deux libellés empilés (Menu, Fermer) dans une glissière de 200 % de haut */
[data-fx="menu-expanding-pill-panel"] .fx-toggle {
  position: relative;
  z-index: 2;
  flex: none;
  width: var(--fx-pill-w);
  height: var(--fx-pill-h);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: calc(var(--fx-pill-h) / 2);
  overflow: hidden;
  background: var(--fx-panel);
  color: var(--fx-panel-ink);
  font: inherit;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

[data-fx="menu-expanding-pill-panel"] .fx-slider {
  display: block;
  height: 200%;
  pointer-events: none;
}

[data-fx="menu-expanding-pill-panel"] .fx-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50%;
  background: var(--fx-panel);
  color: var(--fx-panel-ink);
}

/* Libellé « Fermer » : surface inversée (texte du panneau en fond, accent en texte) */
[data-fx="menu-expanding-pill-panel"] .fx-slot-close {
  background: var(--fx-panel-ink);
  color: var(--fx-panel);
}

/* Flip 3D au survol : le libellé pivote de 90° sur X ; le premier texte monte et s'efface, le second, couché à
   -90° sous la scène, se redresse face au visiteur (0,45 s, cubic-bezier(0.76, 0, 0.24, 1)) */
[data-fx="menu-expanding-pill-panel"] .fx-label {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform var(--fx-flip-dur) var(--fx-flip-ease);
}

/* Libellé lu dans data-label : deux copies en pseudo-éléments (le nom accessible vient de l’aria-label du bouton) */
[data-fx="menu-expanding-pill-panel"] .fx-label::before,
[data-fx="menu-expanding-pill-panel"] .fx-label::after {
  content: attr(data-label);
  font-size: 0.8125rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  white-space: nowrap;
  transition: transform var(--fx-flip-dur) var(--fx-flip-ease), opacity var(--fx-flip-dur) var(--fx-flip-ease);
}

[data-fx="menu-expanding-pill-panel"] .fx-label::after {
  position: absolute;
  transform-origin: 50% 100%;
  transform: rotateX(-90deg) translateY(0.7em);
  opacity: 0;
}

@media (hover: hover) {
  [data-fx="menu-expanding-pill-panel"] .fx-toggle:hover .fx-label {
    transform: rotateX(90deg);
  }

  [data-fx="menu-expanding-pill-panel"] .fx-toggle:hover .fx-label::before {
    transform: translateY(-100%);
    opacity: 0;
  }

  [data-fx="menu-expanding-pill-panel"] .fx-toggle:hover .fx-label::after {
    opacity: 1;
  }
}

[data-fx="menu-expanding-pill-panel"] .fx-toggle:focus-visible .fx-label {
  transform: rotateX(90deg);
}

[data-fx="menu-expanding-pill-panel"] .fx-toggle:focus-visible .fx-label::before {
  transform: translateY(-100%);
  opacity: 0;
}

[data-fx="menu-expanding-pill-panel"] .fx-toggle:focus-visible .fx-label::after {
  opacity: 1;
}

/* ---- Panneau : taille finale fixe, ancré au coin ; le clip-path le réduit à la pastille tant que --fx-p = 0 */
[data-fx="menu-expanding-pill-panel"] .fx-panel {
  --fx-k: calc(1 - var(--fx-p, 0));
  position: fixed;
  top: var(--fx-edge);
  right: var(--fx-edge);
  z-index: 1;
  width: min(var(--fx-panel-w), 100% - 2 * var(--fx-edge));
  height: min(var(--fx-panel-h), 100% - 2 * var(--fx-edge));
  background: var(--fx-panel);
  color: var(--fx-panel-ink);
  clip-path: inset(
    calc(var(--fx-gap) * var(--fx-k))
    calc(var(--fx-gap) * var(--fx-k))
    calc((100% - var(--fx-gap) - var(--fx-pill-h)) * var(--fx-k))
    calc((100% - var(--fx-gap) - var(--fx-pill-w)) * var(--fx-k))
    round calc(var(--fx-pill-h) / 2 + (var(--fx-radius) - var(--fx-pill-h) / 2) * var(--fx-p, 0))
  );
  visibility: hidden;
  pointer-events: none;
}

[data-fx="menu-expanding-pill-panel"] .fx-panel-body {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: clamp(1rem, 4svh, 2rem);
  height: 100%;
  padding: calc(var(--fx-gap) + var(--fx-pill-h) + clamp(0.75rem, 4svh, 2.1875rem)) var(--fx-panel-pad-x) clamp(1rem, 5svh, 3.125rem);
  overflow-x: hidden;
  overflow-y: auto; /* dernier recours sur écran très bas */
  overscroll-behavior: contain;
}

[data-fx="menu-expanding-pill-panel"] .fx-list {
  display: flex;
  flex-direction: column;
  gap: clamp(0rem, 1.2svh, 0.625rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

/* Masque de chaque lien : il bascule depuis le bas de sa ligne. `clip` (repli `hidden`) : pas de conteneur de
   défilement, un Tab pendant l'entrée ne peut donc pas faire défiler le masque et décaler le lien pour de bon */
[data-fx="menu-expanding-pill-panel"] .fx-item {
  overflow: hidden;
  overflow: clip;
}

[data-fx="menu-expanding-pill-panel"] .fx-link {
  display: flex;
  align-items: center;
  min-height: 40px;
  color: inherit;
  text-decoration: none;
  font-size: var(--fx-link-size);
  font-weight: var(--fx-link-weight);
  line-height: 1.15;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  -webkit-tap-highlight-color: transparent;
}

/* Le masque rognerait un contour extérieur : contour intérieur pour les liens */
[data-fx="menu-expanding-pill-panel"] .fx-link:focus-visible {
  outline-offset: -2px;
  text-decoration: underline;
  text-underline-offset: 0.12em;
  text-decoration-thickness: 0.05em;
}

@media (hover: hover) {
  [data-fx="menu-expanding-pill-panel"] .fx-link:hover {
    text-decoration: underline;
    text-underline-offset: 0.12em;
    text-decoration-thickness: 0.05em;
  }
}

[data-fx="menu-expanding-pill-panel"] .fx-foot {
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: var(--fx-foot-size);
}

[data-fx="menu-expanding-pill-panel"] .fx-foot li {
  width: 50%; /* deux par ligne */
}

[data-fx="menu-expanding-pill-panel"] .fx-foot a {
  display: inline-flex;
  align-items: center;
  min-width: 44px;
  min-height: 40px;
  color: inherit;
  text-decoration: none;
}

@media (hover: hover) {
  [data-fx="menu-expanding-pill-panel"] .fx-foot a:hover {
    text-decoration: underline;
    text-underline-offset: 0.2em;
  }
}

/* ---- Menu ouvert (data-fx-open, posé par le JS) ; en mouvement réduit (aucun style inline GSAP), le CSS pose
   l'état final : panneau déployé, libellé « Fermer » */
[data-fx="menu-expanding-pill-panel"][data-fx-open] .fx-panel {
  --fx-p: 1;
  visibility: visible;
  pointer-events: auto;
}

[data-fx="menu-expanding-pill-panel"][data-fx-open] .fx-slider {
  transform: translateY(-50%);
}

/* Transition en cours (ouverture ou fermeture) : panneau visible ; à la fermeture, plus cliquable */
[data-fx="menu-expanding-pill-panel"][data-fx-state="playing"] .fx-panel {
  visibility: visible;
}

/* will-change uniquement pendant une transition */
[data-fx="menu-expanding-pill-panel"][data-fx-state="playing"] .fx-link,
[data-fx="menu-expanding-pill-panel"][data-fx-state="playing"] .fx-slider {
  will-change: transform;
}

/* Pause hors écran / onglet caché (posé par l'IO de init), sans !important */
[data-fx="menu-expanding-pill-panel"][data-fx-idle] * {
  animation-play-state: paused;
}

[data-fx="menu-expanding-pill-panel"] :focus-visible {
  outline: 2px solid var(--fx-outline);
  outline-offset: 3px;
}

/* ---- Sans JS (aucun data-fx-motion : le boot inline ne l'a pas posé) : pas de bouton inopérant, les liens
   restent visibles et utilisables dans l'en-tête */
[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 1.5rem;
  padding: var(--fx-edge) calc(var(--fx-edge) + var(--fx-gap));
}

[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) .fx-bar {
  padding: 0;
}

[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) .fx-toggle {
  display: none;
}

[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) .fx-panel {
  position: static;
  width: auto;
  height: auto;
  background: none;
  color: inherit;
  clip-path: none;
  visibility: visible;
  pointer-events: auto;
}

[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) .fx-panel-body {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 1.25rem;
  height: auto;
  padding: 0;
  overflow: visible;
}

[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) .fx-list {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0 1.25rem;
}

[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) .fx-link {
  font-size: 1rem;
}

[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) .fx-foot {
  gap: 0 0.75rem;
  opacity: 0.75;
}

[data-fx="menu-expanding-pill-panel"]:not([data-fx-motion]) .fx-foot li {
  width: auto;
}

/* Navigateur sans couleur relative : texte du panneau noir (accent clair par défaut), surchargeable sur le root */
@supports not (color: oklch(from red l c h)) {
  [data-fx="menu-expanding-pill-panel"] {
    --fx-panel-ink: #111111;
  }
}

/* Écran bas (mobile paysage) : liens secondaires sur une seule ligne */
@media (max-height: 480px) {
  [data-fx="menu-expanding-pill-panel"] .fx-foot {
    gap: 0 1.25rem;
  }

  [data-fx="menu-expanding-pill-panel"] .fx-foot li {
    width: auto;
  }
}

@media (max-width: 767px) {
  /* Reset mobile : même spécificité (0,3,0) que les règles « playing » ci-dessus et placé après → gagne */
  [data-fx="menu-expanding-pill-panel"][data-fx-motion][data-fx-state="playing"] * {
    will-change: auto;
  }
}

/* Mouvement réduit : ouverture / fermeture instantanées (le JS ne tweene rien), aucun flip au survol */
@media (prefers-reduced-motion: reduce) {
  [data-fx="menu-expanding-pill-panel"] .fx-label,
  [data-fx="menu-expanding-pill-panel"] .fx-label::before,
  [data-fx="menu-expanding-pill-panel"] .fx-label::after {
    transition: none;
  }
}
