/* ==========================================================================
   header.css — en-tête, navigation, menu compact (tiroir) & contrôles d'apparence.
   Mobile-first. Sans JS : le menu complet est visible (pas de bouton).
   Avec JS (.js) : bouton « Menu » + tiroir sous 900px. Uniquement des variables.
   ========================================================================== */

.site-header { background: var(--surface); border-bottom: var(--bw) solid var(--border); }

.site-header__bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-5);
  padding-block: var(--space-3);
}
@media (min-width: 900px) { .site-header__bar { flex-wrap: nowrap; } }

/* Identité */
.site-brand { display: flex; flex-direction: column; line-height: 1.2; flex: 0 0 auto; text-decoration: none; }
.site-brand__name { font-size: 1.0625rem; font-weight: 700; color: var(--text); white-space: nowrap; }
.site-brand__role { font-family: var(--font-mono); font-size: 0.75rem; color: var(--faint); }

/* Bouton de menu : caché par défaut (sans JS, tout le menu reste visible) */
.nav-toggle {
  display: none;
  margin-left: auto;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  padding: 0.5rem 0.9rem;
  border: var(--bw-strong) solid var(--border-strong);
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
}
.nav-toggle__icon { font-size: 1.1em; line-height: 1; }

/* Zone menu : nav + outils (langue, apparence) */
.site-menu {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  width: 100%;
  padding-block: var(--space-2) var(--space-4);
}
.site-menu__head { display: none; }

/* Navigation */
.site-nav ul {
  list-style: none;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.site-nav a {
  display: flex;
  align-items: center;
  min-height: 44px;
  padding: var(--space-1) var(--space-2);
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
}
.site-nav a:hover { color: var(--text); }
/* Page active : repère de forme (barre) + gras, jamais la couleur seule */
.site-nav a[aria-current="page"] {
  color: var(--primary);
  box-shadow: inset 3px 0 var(--primary);
  padding-left: calc(var(--space-2) + 3px);
}

/* Outils : langue + apparence */
.header-tools { display: flex; flex-direction: column; gap: var(--space-4); }

/* Sélecteur de langue (vrais liens, fonctionne sans JS) */
.lang-switch { display: inline-flex; align-items: center; flex: 0 0 auto; border: var(--bw) solid var(--border-strong); border-radius: var(--radius); overflow: hidden; width: max-content; }
.lang-switch a, .lang-switch span { padding: 0.5rem 0.85rem; font-family: var(--font-mono); font-size: 0.8125rem; text-decoration: none; }
.lang-switch a { color: var(--muted); }
.lang-switch a:hover { color: var(--text); background: var(--accent); }
.lang-switch .is-current { background: var(--primary); color: var(--on-primary); font-weight: 600; }
.lang-switch .sep { padding: 0; width: var(--bw); background: var(--border-strong); align-self: stretch; }

/* Contrôles d'apparence (préparés — logique au lot 8) */
.appearance { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.control-group { display: flex; flex-direction: column; gap: var(--space-2); }
.control-group__label { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.04em; color: var(--faint); }
.segmented { display: inline-flex; flex: 0 0 auto; border: var(--bw) solid var(--border-strong); border-radius: var(--radius); overflow: hidden; width: max-content; max-width: 100%; }
.segmented button {
  min-height: 40px;
  padding: 0.4rem 0.8rem;
  border: 0;
  border-left: var(--bw) solid var(--border-strong);
  background: transparent;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}
.segmented button:first-child { border-left: 0; }
.segmented button:hover { background: var(--accent); color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* --- Amélioration progressive JS : bouton + tiroir sous 900px ------------ */
@media (max-width: 899.98px) {
  .js .nav-toggle { display: inline-flex; }
  /* Tiroir toujours présent (JS) mais glissé hors champ et masqué quand fermé,
     pour permettre une transition d'ouverture/fermeture. */
  .js .site-menu {
    display: flex;
    position: fixed;
    inset: 0 0 0 auto;
    width: min(88vw, 22rem);
    max-width: 100%;
    background: var(--surface);
    border-left: var(--bw) solid var(--border);
    padding: var(--space-5);
    overflow-y: auto;
    z-index: 60;
    box-shadow: var(--shadow);
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.4s ease, visibility 0s linear 0.4s;
  }
  .js .site-menu.is-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.4s ease, visibility 0s linear 0s;
  }
  .js .site-menu .site-menu__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-2);
  }
  .site-menu__head span { font-weight: 700; }
  .nav-close {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 44px;
    padding: 0.4rem 0.8rem;
    border: var(--bw) solid var(--border-strong);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
  }
}

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 18, 0.5);
  z-index: 55;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.nav-backdrop.is-shown { opacity: 1; }

/* Réduction de mouvement : ouverture/fermeture instantanées. */
@media (prefers-reduced-motion: reduce) {
  .js .site-menu,
  .js .site-menu.is-open { transition: none; }
  .nav-backdrop { transition: none; }
}

/* --- Disposition bureau (≥ 900px) : barre horizontale sobre -------------- */
@media (min-width: 900px) {
  .site-menu {
    flex-direction: row;
    align-items: center;
    flex-wrap: nowrap;
    gap: var(--space-3) var(--space-4);
    width: auto;
    flex: 1 1 auto;
    padding-block: 0;
  }
  .site-nav { margin-inline: auto; }
  .site-nav ul { flex-direction: row; flex-wrap: nowrap; gap: var(--space-2) var(--space-4); }
  .site-nav a { min-height: 0; padding-block: var(--space-1); white-space: nowrap; }
  .site-nav a[aria-current="page"] {
    box-shadow: inset 0 -2px var(--primary);
    padding-left: var(--space-2);
  }
  .header-tools { flex-direction: row; flex-wrap: nowrap; align-items: center; gap: var(--space-3); flex: 0 0 auto; }
  .nav-close { display: none; }
}
