/* ==========================================================================
   Sélecteur de langue
   Injecté par le build i18n dans les trois gabarits de navigation du site,
   juste après le bouton d'appel à l'action : coin supérieur droit sur
   grand écran, juste avant le menu burger sur mobile.
   Sans JavaScript : <details> natif dans le header, liens à plat dans le
   menu mobile. La CSP du site interdit tout script inline.
   ========================================================================== */

/* --- Header : bouton compact mais visible -------------------------------- */

details.lang-switch {
  position: relative;
  margin-left: 10px;
  flex: none;
}

details.lang-switch > summary {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  border: 1px solid rgba(56, 72, 114, 0.22);
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #384872;
  background: #fff;
  cursor: pointer;
  list-style: none;
  user-select: none;
  white-space: nowrap;
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

details.lang-switch > summary::-webkit-details-marker { display: none; }
details.lang-switch > summary::marker { content: ""; }

/* Chevron */
details.lang-switch > summary::after {
  content: "";
  width: 0;
  height: 0;
  margin-left: 1px;
  border-left: 3.5px solid transparent;
  border-right: 3.5px solid transparent;
  border-top: 4px solid currentColor;
  opacity: 0.65;
  transition: transform 0.15s ease;
}

details.lang-switch[open] > summary::after { transform: rotate(180deg); }

details.lang-switch > summary:hover,
details.lang-switch > summary:focus-visible {
  border-color: #05b936;
  background: rgba(5, 185, 54, 0.06);
}

details.lang-switch > summary:focus-visible {
  outline: 2px solid #05b936;
  outline-offset: 2px;
}

.lang-globe { flex: none; opacity: 0.85; }
.lang-flag { font-size: 14px; line-height: 1; }

/* Le sélecteur prend une place que la nav n'avait pas prévue : celle-ci
   tenait tout juste sur une ligne. S'y ajoute l'allongement des traductions
   — l'espagnol fait 85 caractères de libellés contre 80 en français, et en
   allemand « Loslegen » venait chevaucher « Preise ».

   L'espacement des liens est donc élastique plutôt que fixe : il se resserre
   quand la fenêtre ou la langue l'exigent. Le conteneur reçoit un gap propre
   et la nav le droit de rétrécir (min-width: 0), sans quoi les éléments se
   recouvrent au lieu de se serrer. */
.header-inner { gap: 12px; }
.header-inner .nav-links {
  gap: clamp(11px, 1.3vw, 19px);
  min-width: 0;
  flex-wrap: nowrap;
}
.header-inner .nav-links a { white-space: nowrap; }
.header-inner .header-cta { flex: none; }
.header-inner .header-cta .btn { padding: 10px 16px; }

/* L'allemand est la langue la plus longue : « Unsere Simulatoren »,
   « Kundenstimmen », « Unsere Coaches »… Sa barre réclame 788 px pour 742
   disponibles, mesure faite en production. Comme le conteneur est plafonné
   à 1 200 px, aucune largeur d'écran ne suffit : il faut resserrer la
   typographie de la nav pour cette langue. On répartit l'effort entre
   l'espacement et le corps de texte plutôt que de tout demander à l'un des
   deux. */
html[lang="de"] .header-inner .nav-links { gap: clamp(9px, 0.95vw, 14px); }
html[lang="de"] .header-inner .nav-links a { font-size: 0.89rem; }

.nav-in { gap: 12px; }
.nav-in .nav-links {
  gap: clamp(10px, 1.2vw, 20px);
  min-width: 0;
  flex-wrap: nowrap;
}
.nav-in .nav-links a { white-space: nowrap; }

/* --- Menu déroulant ------------------------------------------------------ */

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1002;
  display: flex;
  flex-direction: column;
  min-width: 170px;
  padding: 6px;
  background: #fff;
  border: 1px solid rgba(56, 72, 114, 0.14);
  border-radius: 10px;
  box-shadow: 0 12px 32px -10px rgba(56, 72, 114, 0.35);
}

.lang-menu a {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  border-radius: 6px;
  font-size: 13.5px;
  font-weight: 500;
  line-height: 1.2;
  color: #00262d;
  text-decoration: none;
  white-space: nowrap;
}

.lang-menu a:hover,
.lang-menu a:focus-visible {
  background: rgba(56, 72, 114, 0.07);
}

.lang-menu a.is-current {
  color: #05b936;
  font-weight: 600;
  background: rgba(5, 185, 54, 0.08);
}

/* Les trois gabarits ont une barre de navigation claire — celle des
   articles est un blanc translucide, pas un fond sombre. Le style clair
   ci-dessus vaut donc partout. */

/* --- Menu mobile : les langues à plat ------------------------------------ */

.lang-switch-mobile {
  display: flex;
  justify-content: center;
  gap: 4px;
  margin: 10px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(56, 72, 114, 0.12);
}

.lang-switch-mobile a {
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #5a6880;
  text-decoration: none;
}

.lang-switch-mobile a:hover,
.lang-switch-mobile a:focus-visible {
  background: rgba(56, 72, 114, 0.08);
  color: #384872;
}

.lang-switch-mobile a.is-current {
  color: #05b936;
  background: rgba(5, 185, 54, 0.1);
}

/* Bascule anticipée pour les langues longues.
   Le site passe au menu burger à 768 px. En allemand et en espagnol, les
   libellés sont assez longs pour que la barre déborde bien avant : à
   1 120 px, « Loslegen » sortait du cadre. Pour ces deux langues, on passe
   au burger dès 1 200 px. Le mécanisme est celui du site ; seul le seuil
   change — mais les styles du burger n'étant déclarés que dans la requête
   768 px, il faut les redéclarer ici. */
@media (max-width: 1200px) {
  html[lang="de"] .header-inner > .nav-links,
  html[lang="es"] .header-inner > .nav-links,
  html[lang="de"] .header-inner > .header-cta,
  html[lang="es"] .header-inner > .header-cta {
    display: none;
  }

  html[lang="de"] .mobile-burger,
  html[lang="es"] .mobile-burger {
    display: flex;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    z-index: 1001;
  }

  html[lang="de"] .mobile-burger span,
  html[lang="es"] .mobile-burger span {
    display: block;
    width: 24px;
    height: 2.5px;
    background: #00262d;
    border-radius: 2px;
    transition: all 0.3s ease;
  }

  html[lang="de"] .mobile-burger.open span:nth-child(1),
  html[lang="es"] .mobile-burger.open span:nth-child(1) { transform: rotate(45deg) translate(5px, 5px); }
  html[lang="de"] .mobile-burger.open span:nth-child(2),
  html[lang="es"] .mobile-burger.open span:nth-child(2) { opacity: 0; }
  html[lang="de"] .mobile-burger.open span:nth-child(3),
  html[lang="es"] .mobile-burger.open span:nth-child(3) { transform: rotate(-45deg) translate(5px, -5px); }

  html[lang="de"] .mobile-nav,
  html[lang="es"] .mobile-nav {
    display: none;
    flex-direction: column;
    gap: 0;
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid #eee;
  }

  html[lang="de"] .mobile-nav.open,
  html[lang="es"] .mobile-nav.open { display: flex; }

  html[lang="de"] .mobile-nav a,
  html[lang="es"] .mobile-nav a {
    padding: 12px 0;
    font-size: 1rem;
    font-weight: 500;
    color: #00262d;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
  }

  html[lang="de"] .mobile-nav a:last-child,
  html[lang="es"] .mobile-nav a:last-child { border-bottom: none; }
  html[lang="de"] .mobile-nav a:hover,
  html[lang="es"] .mobile-nav a:hover { color: #05b936; }

  /* Le sélecteur reste dans la barre : c'est le premier recours de qui
     arrive dans la mauvaise langue. */
  html[lang="de"] .header-inner > details.lang-switch,
  html[lang="es"] .header-inner > details.lang-switch { margin-left: auto; }
}

/* Le bouton du header reste visible sur mobile : c'est là que se joue le
   changement de langue pour qui arrive sur la mauvaise version. Il se
   resserre simplement pour laisser la place au burger. */
@media (max-width: 768px) {
  details.lang-switch { margin-left: auto; margin-right: 6px; }
  details.lang-switch > summary { padding: 6px 8px; font-size: 12px; }
  .lang-menu { min-width: 150px; }
}

@media (prefers-reduced-motion: reduce) {
  details.lang-switch > summary,
  details.lang-switch > summary::after { transition: none; }
}
