/* ══════════════════════════════════════════════════════════
   shared.css — Styles communs à tous les outils Partithèque
   Partithèque AGSE · Bleu marine + lavande
══════════════════════════════════════════════════════════ */
/* Les polices sont chargées via <link> dans le <head> de chaque page (voir
   charte graphique § Polices), PAS via @import ici : un @import en tête de
   feuille de style force le navigateur à attendre d'avoir téléchargé ET
   analysé shared.css avant de découvrir qu'il faut aussi aller chercher les
   polices sur un autre domaine — deux allers-retours réseau strictement en
   série avant le premier texte lisible. Avec un <link rel="preconnect"> puis
   <link rel="stylesheet"> dans le <head>, les deux requêtes partent en
   parallèle dès l'analyse du HTML, sans attendre shared.css.
   NE PAS remettre cet @import : il annulerait ce gain sur toutes les pages. */

:root {
  --navy:        #1e2d5a;
  --navy-light:  #2c4278;
  --navy-pale:   #e8ecf5;
  --lavender:    #e8e7f4;
  --lavender2:   #d4d2eb;
  --lavender3:   #b8b5de;
  --white:       #ffffff;
  --surface:     #eeecf8;
  --border:      #dddaf0;
  --text:        #1a1a2e;
  --text-2:      #4a5070;
  --text-3:      #8085a0;
  --green:       #1a6b3a;
  --green-bg:    #e3f5eb;
  --green-border: rgba(26,107,58,0.30);
  --blue:        #1a5fa0;
  --blue-bg:     #e3eef8;
  --gold:        #7a5200;
  --gold-bg:     #fdf3dc;
  --gold-border: #e8c866;   /* bordure du badge "non numéroté" */
  --red:         #b02020;
  --red-bg:      #fce8e8;
  --neutral-bg:  #f5f5f5;   /* fond du badge sans fichier */
  --neutral:     #999999;   /* texte du badge sans fichier */
  --neutral-border: #e0e0e0;/* bordure du badge sans fichier */
  --accent:      #5b4fcf;
  --accent-pale: #eeecfb;
  --c-voix:    #5b4fcf;  --c-voix-bg:    rgba(91,79,207,0.07);  --c-voix-border:    rgba(91,79,207,0.30);
  --c-etiq:    #b86000;  --c-etiq-bg:    rgba(184,96,0,0.07);   --c-etiq-border:    rgba(184,96,0,0.30);
  --c-themes:  #7a5200;  --c-themes-bg:  rgba(122,82,0,0.07);   --c-themes-border:  rgba(122,82,0,0.28);
  --c-dispo:   #1a6b3a;  --c-dispo-bg:   rgba(26,107,58,0.07);  --c-dispo-border:   rgba(26,107,58,0.28);
  --c-recueil: #b02020;  --c-recueil-bg: rgba(176,32,32,0.07);  --c-recueil-border: rgba(176,32,32,0.28);
  --c-langue:  #008078;  --c-langue-bg:  rgba(0,128,120,0.07);  --c-langue-border:  rgba(0,128,120,0.30);
  --c-audio:   #a13670;  --c-audio-bg:   rgba(161,54,112,0.07); --c-audio-border:   rgba(161,54,112,0.30);
  --c-audio-dark: #822a5a;  /* hover audio sélectionné */
  --radius:    8px;
  /* Dropdown hover thématique — chaque groupe colore son propre hover.
     Les couleurs sont celles définies par --c-<groupe> ci-dessus.
     Règle générale : hover = var(--c-<groupe>-bg), texte = var(--c-<groupe>).
     Défini dans style.css (catalogue) et saisie.css (saisie) via .filter-group.grp-* */
  --shadow:    0 2px 12px rgba(30,45,90,0.10);
  --shadow-lg: 0 8px 32px rgba(30,45,90,0.16);
  --font-sans: 'DM Sans', system-ui, sans-serif;
  --font-serif:'Source Serif 4', Georgia, serif;
  --font-mono: 'JetBrains Mono', monospace;
  /* Typographic scale */
  --fs-xs:   0.68rem;   /* labels, numéros, section-titles uppercase */
  --fs-sm:   0.75rem;   /* badges, meta, footer */
  --fs-base: 0.82rem;   /* corps principal, boutons, détail */
  --fs-md:   0.88rem;   /* autocomplete, inputs */
  --fs-lg:   0.95rem;   /* titres de morceaux, search input */
  /* Radius tokens */
  --radius-sm:   6px;   /* inputs, dropdowns, accordions */
  --radius-pill: 20px;  /* boutons, chips, badges pill */
  /* Additional colors */
  --surface-soft:  #f0eef9;  /* séparateurs subtils, zebra */
  --color-mark:    #ffe082;  /* surbrillance recherche */
  --c-voix-dark:   #4a3fb8;  /* hover voix selected */
  --c-recueil-dark:#8b1a1a;  /* hover recueil selected */
  --c-dispo-dark:  #145530;  /* hover dispo selected */
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Ne pas ajouter overflow/scrollbar-gutter sur <html> — voir DECISIONS.md §1. */

/* Défilement animé vers une section au clic sur un lien d'ancrage (doc-nav,
   liens internes #section, bouton retour en haut…) plutôt qu'un saut instantané.
   Désactivé pour les personnes préférant réduire les animations. Indépendant du
   correctif scrollbar ci-dessus/ci-dessous : n'a aucun lien avec le bug sticky. */
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}



body {
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  background: var(--surface);
  min-height: 100dvh;   /* dvh : évite un footer mal positionné quand la barre d'URL mobile se rétracte */
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

/* ── TOPBAR ── */
.topbar {
  background: var(--navy);
  color: white;
  padding: 0 2rem;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 300;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  width: 100%;   /* indispensable ici — piège récurrent, voir DECISIONS.md §9 */
  min-width: 0;
}
.topbar-title {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: white;
  line-height: 1.2;
  flex-shrink: 0;
}
.topbar-title span {
  display: block;
  font-weight: 300;
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  opacity: 0.7;
}
.topbar-label {
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.50);
  text-transform: uppercase;
  flex-shrink: 0;
}
.topbar-sep { flex: 1; }
.topbar-meta {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.40);
  font-family: var(--font-mono);
  flex-shrink: 0;
}
/* Bouton de déconnexion — ajouté en JS par js/auth.js, toujours en bout de topbar */
.topbar-logout {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,0.25);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}
.topbar-logout:hover {
  color: white;
  border-color: rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.08);
}
@media (max-width: 640px) {
  .topbar-logout { font-size: 0.65rem; padding: 0.3rem 0.6rem; }
}
/* Mobile : la topbar déborderait (titre + label + méta). On resserre les marges
   et on masque la méta décorative (présente uniquement sur accueil / charte /
   stats ; le catalogue et la saisie utilisent d'autres éléments, non affectés).
   Le sous-titre est aussi légèrement réduit pour dégager de la place (ex. la
   barre de recherche du catalogue, positionnée indépendamment du titre). */
@media (max-width: 640px) {
  .topbar { padding: 0 1rem; gap: 0.85rem; }
  .topbar-meta { display: none; }
  .topbar-title span { font-size: 0.62rem; }
}
/* Écrans très étroits (ex. 320px) : marge encore plus juste pour la barre de
   recherche du catalogue (positionnée indépendamment, voir style.css) — le
   sous-titre est resserré un peu plus. */
@media (max-width: 400px) {
  .topbar-title span { font-size: 0.56rem; letter-spacing: 0.08em; }
}

/* ── HERO ── */
.hero {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-light) 60%, #3a3080 100%);
  padding: 3rem 2rem 2.5rem;
  text-align: center;
}
.hero-eyebrow {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--lavender3);
  margin-bottom: 0.8rem;
}
.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(1.5rem, 3vw, 2.2rem);
  font-weight: 600;
  color: white;
  line-height: 1.2;
  margin-bottom: 0.5rem;
}
.hero-sub {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.65);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ── DOC NAV (barre de navigation secondaire) ── */
.doc-nav {
  background: white;
  border-bottom: 2px solid var(--border);
  position: sticky;
  top: 60px;
  z-index: 200;
  min-height: 44px;
}
.doc-nav-inner {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  min-height: 44px;
  align-items: stretch;
  padding: 0;
  cursor: grab;
  user-select: none;
}
.doc-nav-inner:active { cursor: grabbing; }
.doc-nav-inner::-webkit-scrollbar { display: none; }
.doc-nav-inner::before,
.doc-nav-inner::after {
  content: '';
  flex: 1;
  min-width: 1rem;
}
.doc-nav a {
  display: flex;
  align-items: center;
  padding: 0 0.85rem;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-3);
  text-decoration: none;
  letter-spacing: 0.03em;
  box-shadow: inset 0 -2px 0 transparent;
  white-space: nowrap;
  transition: color 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
/* @media (hover:hover) : le survol lavande ne s'applique qu'aux appareils à
   pointeur précis (souris/trackpad). Sans ça, sur tactile, :hover reste
   "collé" sur le dernier lien touché jusqu'au tap suivant ailleurs sur la
   page — un simple scroll ne le retire pas, laissant un lien en bleu clair
   même après que le scroll-spy a déplacé .active ailleurs. */
@media (hover: hover) {
  .doc-nav a:hover { color: var(--navy); box-shadow: inset 0 -2px 0 var(--lavender3); }
}
.doc-nav a.active { color: var(--navy); font-weight: 600; box-shadow: inset 0 -2px 0 var(--navy); }

/* Ombres latérales : indiquent que la barre peut défiler, masquées aux extrémités.
   Activées par les classes .can-left / .can-right posées en JS selon la position de scroll.
   .doc-nav est déjà en position:sticky → sert de bloc conteneur aux pseudo-éléments. */
.doc-nav::before,
.doc-nav::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 2px;                 /* laisse apparaître la bordure inférieure */
  width: 54px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 2;
}
.doc-nav::before { left: 0;  background: linear-gradient(to right, var(--white) 35%, rgba(255,255,255,0)); }
.doc-nav::after  { right: 0; background: linear-gradient(to left,  var(--white) 35%, rgba(255,255,255,0)); }
.doc-nav.can-left::before  { opacity: 1; }
.doc-nav.can-right::after   { opacity: 1; }

/* ── FOOTER ── */
.footer {
  background: var(--navy);
  color: rgba(255,255,255,0.45);
  padding: 1.5rem 2rem;
  font-size: 0.75rem;
  position: relative;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: auto;
  /* Ombre partant du footer vers le haut (sur la barre d'impression),
     même principe que .topbar dont l'ombre part vers le bas sur .search-zone */
  box-shadow: 0 -2px 8px rgba(0,0,0,0.25);
}
/* Sous un certain seuil, la marque et les liens du footer ne tiennent plus
   côte à côte élégamment (espace excessif ou lien collé au bord) : centrés
   verticalement à la place. Le seuil dépend du rôle — role-admin a bien plus
   de liens dans .footer-nav (Youkaïdi, Statistiques, Saisie, Export JSON,
   Charte graphique…) et a donc besoin de plus de place avant de basculer.
   Rôle posé sur <html> par un script inline en tête de <body> sur chaque page
   (role-user/role-admin/role-visiteur, voir charte graphique § Règles d'usage). */
@media (max-width: 650px) {
  html:not(.role-admin) .footer { flex-direction: column; align-items: center; text-align: center; }
  html:not(.role-admin) .footer-nav { justify-content: center; }
}
@media (max-width: 1150px) {
  html.role-admin .footer { flex-direction: column; align-items: center; text-align: center; }
  html.role-admin .footer-nav { justify-content: center; }
}
.footer-brand {
  opacity: 0.6;
}
.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  align-items: center;
}
.footer-nav-label {
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.5;
  margin-right: 0.5rem;
}
/* .footer-nav a ET .footer-nav .current partagent le même gabarit (padding,
   taille, radius) pour un espacement horizontal homogène entre tous les
   outils — l'outil actif n'est PAS un lien (<span class="current">, voir
   catalogue.html etc., volontairement non cliquable) mais doit occuper
   exactement la même "case" visuelle que ses voisins.
   AVANT CE CORRECTIF : cette règle commune ciblait uniquement `.footer-nav a`,
   et la distinction de l'outil actif était portée par `.footer-nav a.current`
   — un sélecteur qui ne correspondait JAMAIS à rien, puisque .current est
   toujours un <span>, jamais un <a>, dans le HTML réel de chaque page. L'outil
   actif n'héritait donc que du style par défaut du footer (texte translucide
   à peine visible) et d'AUCUN padding — d'où un contraste presque
   imperceptible et un espacement resserré par rapport aux autres outils,
   tous deux signalés par Joseph. Voir DECISIONS.md §23. */
.footer-nav a,
.footer-nav .current {
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  border-radius: 20px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.footer-nav a {
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.footer-nav a:hover {
  color: white;
  border-color: rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
}
.footer-nav .current {
  color: var(--navy);
  background: white;
  border-color: white;
  font-weight: 700;
  cursor: default;
}

/* ── BACK TO TOP ── */
#back-to-top {
  position: fixed;
  bottom: 1.8rem;
  right: 1.8rem;
  width: 42px;
  height: 42px;
  background: var(--navy);
  color: white;
  border: none;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(30,45,90,0.30);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s, background 0.15s, bottom 0.25s ease;
  z-index: 500;               /* au-dessus de tout : topbar(300), footer(400), print-toolbar(450) */
  pointer-events: none;
}
#back-to-top.visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
#back-to-top:hover   { background: var(--navy-light); }

/* ── SCROLLBAR ── Défilement général de la page : apparence par défaut du
   navigateur, volontairement — voir DECISIONS.md §2. */
*:not(html):not(body)::-webkit-scrollbar       { width: 6px; height: 6px; }
*:not(html):not(body)::-webkit-scrollbar-track { background: var(--surface); }
*:not(html):not(body)::-webkit-scrollbar-thumb { background: var(--lavender2); border-radius: 3px; }
*:not(html):not(body)::-webkit-scrollbar-thumb:hover { background: var(--lavender3); }
