/* === EFERUS Nova — Design System === */
/* Tokens extraits de exvibris.com — couleurs, typo, espacements */
/* WCAG 2.1 AA — contraste minimum 4.5:1 texte normal, 3:1 texte large */

:root {
  --font-body: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-garamond: 'EB Garamond', 'Garamond', 'Cormorant Garamond', Georgia, serif;

  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-6: 1.5rem; --space-8: 2rem;
  --space-12: 3rem; --space-16: 4rem;

  --radius-sm: 0.25rem; --radius-md: 0.5rem; --radius-lg: 0.75rem;
  --transition: 180ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* === Thème Père (christian) — Parchemin, Garamond, chaleureux === */
[data-view="pere"] {
  --bg: #faf6f0;
  --surface: #fefcf8;
  --surface-2: #f5efe4;
  --border: #d4c5a9;
  --text: #2c2416;
  --text-muted: #5c4f3a;
  --text-faint: #9a8d75;
  --accent: #8b4513;
  --accent-dim: rgba(139, 69, 19, 0.1);
  --accent-hover: #7a3b0e;
  --green: #4a6d3a;
  --green-dim: rgba(90, 125, 74, 0.1);
  --red: #b33a30;
  --orange: #a8780a;
  --shadow: 0 2px 12px rgba(44, 36, 22, 0.12);
  --focus-ring: #8b4513;

  --font-display: var(--font-garamond);
  color-scheme: light;
}

/* === Thème Bougie (chandelle) — Veillée à la chandelle, sombre chaleureux === */
[data-view="bougie"] {
  --bg: radial-gradient(ellipse at 50% 30%, #1a0e04 0%, #0a0502 60%, #060301 100%);
  --surface: #1c1208;
  --surface-2: #24180c;
  --border: #8a6a30;
  --text: #e6d4a8;
  --text-muted: #8a7850;
  --text-faint: #5a4e30;
  --accent: #e8b020;
  --accent-dim: rgba(232, 176, 32, 0.12);
  --accent-hover: #f0c840;
  --green: #5a9a4a;
  --green-dim: rgba(90, 154, 74, 0.1);
  --red: #c84a3a;
  --orange: #d4900a;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.6);
  --focus-ring: #e8b020;

  --font-display: var(--font-garamond);
  color-scheme: dark;
}
[data-view="tris"] {
  --bg: #0d0d0f;
  --surface: #131316;
  --surface-2: #18181c;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e2e2e8;
  --text-muted: #8e8e9e;
  --text-faint: #4a4a5a;
  --accent: #6b7af8;
  --accent-dim: rgba(107, 122, 248, 0.12);
  --accent-hover: #8b96fa;
  --green: #3ecf6e;
  --green-dim: rgba(62, 207, 110, 0.1);
  --red: #e55a5a;
  --orange: #f5a524;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  --focus-ring: #6b7af8;

  --font-display: var(--font-body);
  color-scheme: dark;
}

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* === Focus visible (WCAG 2.4.7) === */
:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}
:focus:not(:focus-visible) { outline: none; }

/* === Skip to content (WCAG 2.4.1) === */
.skip-link {
  position: absolute; top: -100%; left: var(--space-4);
  background: var(--accent); color: #fff; padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md); z-index: 1000; font-weight: 600;
}
.skip-link:focus { top: var(--space-4); }

h1, h2, h3, h4 { font-family: var(--font-display); line-height: 1.3; }

h1 { font-size: clamp(1.5rem, 3vw, 2.5rem); }
h2 { font-size: clamp(1.25rem, 2vw, 1.75rem); }
h3 { font-size: 1.125rem; }

a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

/* Layout utils */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-6);
  box-shadow: var(--shadow);
}

/* Button — min 44px touch target (WCAG 2.5.5) */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: 44px; padding: var(--space-3) var(--space-6);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text);
  font-family: var(--font-body); font-size: 0.9375rem; font-weight: 500;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--accent); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); }

/* Input — min 44px height */
.input {
  width: 100%; min-height: 44px; padding: var(--space-3) var(--space-4);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-family: var(--font-body); font-size: 1rem;
  transition: border-color var(--transition);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.input::placeholder { color: var(--text-faint); }

/* Tag / Badge */
.badge {
  display: inline-block; padding: 0.1875rem var(--space-2);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500;
  background: var(--accent-dim); color: var(--accent);
}

/* Theme toggle */
.theme-toggle {
  display: flex; gap: 1px;
  background: var(--surface-2); border-radius: var(--radius-md);
  padding: 2px;
}
.theme-toggle button {
  min-height: 36px; padding: var(--space-2) var(--space-4);
  border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text-muted);
  font-family: var(--font-body); font-size: 0.8125rem; cursor: pointer;
  transition: all var(--transition);
}
.theme-toggle button.active {
  background: var(--surface); color: var(--text);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* Search bar */
.search-bar {
  display: flex; gap: var(--space-3); width: 100%; max-width: 680px;
}
.search-bar input { flex: 1; }
.search-bar .btn { flex-shrink: 0; }

/* Result list */
.result-item {
  display: block; padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border); text-decoration: none; color: inherit;
  transition: background var(--transition);
}
.result-item:hover { background: var(--surface-2); }
.result-item .badge { margin-right: var(--space-2); }
.result-item .snippet { font-size: 0.875rem; color: var(--text-muted); margin-top: var(--space-1); }
.result-item .snippet b { color: var(--accent); }

/* Pagination */
.pagination {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap;
  gap: var(--space-2); padding: var(--space-6) 0;
}
.pagination .page-link {
  min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid transparent; text-decoration: none;
  transition: all var(--transition);
}
.pagination .page-link:hover { border-color: var(--border); }
.pagination .page-link.active {
  background: var(--accent-dim); border-color: var(--accent);
  color: var(--accent); font-weight: 600;
}
.pagination .page-link.disabled {
  color: var(--text-faint); pointer-events: none;
}

/* Document detail */
.doc-header { margin-bottom: var(--space-8); }
.doc-meta { display: flex; flex-wrap: wrap; gap: var(--space-3); margin-top: var(--space-4); }
.doc-body { max-width: 80ch; }

/* Header */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-8);
}
.site-header .logo { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; color: var(--text); text-decoration: none; }
.site-header .logo span { color: var(--accent); }

/* === Responsive breakpoints === */

/* Mobile: <= 640px */
@media (max-width: 640px) {
  .container { padding: 0 var(--space-3); }

  .site-header { flex-direction: column; gap: var(--space-3); padding: var(--space-3) 0; }
  .site-header .logo { font-size: 1.1rem; }

  .search-bar { flex-direction: column; }
  .search-bar .btn { width: 100%; }

  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.15rem; }

  .card { padding: var(--space-4); }

  .result-item { padding: var(--space-3) var(--space-4); }

  .doc-meta { gap: var(--space-2); }

  .pagination { gap: var(--space-1); }
  .pagination .page-link { min-width: 36px; min-height: 36px; font-size: 0.8125rem; }

  .cdo-grid { grid-template-columns: 1fr !important; }
}

/* Tablet: 641px – 960px */
@media (min-width: 641px) and (max-width: 960px) {
  .cdo-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* Large: 1200px+ */
@media (min-width: 1200px) {
  .container { padding: 0; }
}

/* === Reduced motion (WCAG 2.3.3) === */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* === Print styles === */
@media print {
  .theme-toggle, .btn, .pagination, .search-bar { display: none; }
  body { background: #fff; color: #000; }
  a { color: #000; }
}

/* ===========================================================================
   Code couleur par rubrique — repris du site de Christian (04/09/2026)
   Source : ~/exvibris-analyse/DESIGN-exvibris.md

   Sur exvibris.com chaque résultat porte la couleur de sa rubrique. C'est le
   repère de lecture du site, et la correspondance avec nova2 est directe :
       NAV     rouge  #c0392b   navigation, 173 documents portent ce code
       RCH     or     #b8860b   Fil d'Ariane = les signets
       RNG     bleu   #2e6da4   Corpus = les pages d'ouvrages
       GRV     brun   #8b5a2b   Gravures (hors périmètre, réservé)
   =========================================================================== */

:root {
  --col-nav: #c0392b; --col-nav-lt: rgba(192,57,43,.10);  --col-nav-bd: rgba(192,57,43,.40);
  --col-rch: #b8860b; --col-rch-lt: rgba(184,134,11,.10); --col-rch-bd: rgba(184,134,11,.40);
  --col-rng: #2e6da4; --col-rng-lt: rgba(46,109,164,.10); --col-rng-bd: rgba(46,109,164,.40);
  --col-grv: #8b5a2b; --col-grv-lt: rgba(139,90,43,.10);  --col-grv-bd: rgba(139,90,43,.40);
}

/* En vue sombre, les mêmes teintes éclaircies pour rester lisibles sur fond
   d'encre : le site de Christian fait la même chose en mode nuit. */
[data-view="bougie"], [data-view="tris"] {
  --col-nav: #e0685a; --col-nav-lt: rgba(224,104,90,.14);  --col-nav-bd: rgba(224,104,90,.45);
  --col-rch: #e8b020; --col-rch-lt: rgba(232,176,32,.14);  --col-rch-bd: rgba(232,176,32,.45);
  --col-rng: #6fa8dc; --col-rng-lt: rgba(111,168,220,.14); --col-rng-bd: rgba(111,168,220,.45);
  --col-grv: #c08a5a; --col-grv-lt: rgba(192,138,90,.14);  --col-grv-bd: rgba(192,138,90,.45);
}

.badge.type-signet   { background: var(--col-rch-lt); color: var(--col-rch); box-shadow: inset 0 0 0 1px var(--col-rch-bd); }
.badge.type-page     { background: var(--col-rng-lt); color: var(--col-rng); box-shadow: inset 0 0 0 1px var(--col-rng-bd); }
.badge.type-metadata { background: var(--col-grv-lt); color: var(--col-grv); box-shadow: inset 0 0 0 1px var(--col-grv-bd); }
.badge.cdo-nav       { background: var(--col-nav-lt); color: var(--col-nav); box-shadow: inset 0 0 0 1px var(--col-nav-bd); }

/* Ornements. Motifs relevés sur exvibris.com :
     ouverture de page   ✦   ✦   ✦
     séparation de bloc  ❧   ❧   ❧          */
.fleuron, .etoiles {
  text-align: center; color: var(--col-rch);
  letter-spacing: .6em; line-height: 1; user-select: none;
  margin: var(--space-8) 0;
}
.fleuron::before { content: "❧   ❧   ❧"; }
.etoiles::before { content: "✦   ✦   ✦"; }

/* ===========================================================================
   Texture parchemin — vue Père uniquement (04/09/2026)

   Reprise de exvibris.com, qui l'applique en `background-attachment: fixed;
   background-size: cover`. Les vues bougie et tris gardent leur propre fond.

   Les surfaces passent en semi-opaque pour que la texture transparaisse sans
   nuire à la lisibilité du texte.
   =========================================================================== */

[data-view="pere"] body {
  background-image: url("/img/papier_ancien.webp");
  background-attachment: fixed;
  background-size: cover;
  background-position: center;
}

[data-view="pere"] .card,
[data-view="pere"] .result-item,
[data-view="pere"] .facet-panel,
[data-view="pere"] header {
  background-color: rgba(254, 252, 248, 0.88);
  backdrop-filter: blur(2px);
}

[data-view="pere"] .result-item:hover {
  background-color: rgba(245, 239, 228, 0.94);
}

/* Ajustements du 04/09 apres verification en ligne :
   - les ornements etaient trop discrets a la taille du texte courant
   - le fond ne couvrait pas toute la hauteur quand la page est courte */
.fleuron, .etoiles { font-size: 1.15rem; margin: var(--space-6) 0; }

[data-view="pere"] html { background: var(--bg); }
[data-view="pere"] body { min-height: 100vh; }

/* ===========================================================================
   Page de livre — vue Père (04/09/2026)

   Repris de la mise en scène d'exvibris.com, sans sa contrainte : son `.book`
   est une scène 3D plein écran en `overflow: hidden`, ce qui convient à un
   accueil mais empêche une page de résultats de défiler.

   On en garde le vocabulaire — feuille de parchemin posée, ombre portée,
   bord de tranche, fond sombre autour — et on laisse le contenu défiler.
   Ses valeurs d'origine : largeur min(1400px, 98vw), ombre
   drop-shadow(0 28px 56px rgba(0,0,0,.9)), fond #f2e8d0.
   =========================================================================== */

[data-view="pere"] body {
  /* Le pourtour s'assombrit : la page se détache, comme sur son site. */
  background-color: #2c1808;
}

[data-view="pere"] main.container {
  max-width: min(1400px, 96vw);
  margin: var(--space-6) auto var(--space-16);
  padding: var(--space-12) var(--space-8);
  background-color: rgba(242, 232, 208, 0.97);
  background-image: url("/img/papier_ancien.webp");
  background-size: cover;
  background-position: center;
  background-blend-mode: multiply;
  border: 1px solid var(--parchment-edg, #c8b47a);
  box-shadow: 0 28px 56px rgba(0, 0, 0, 0.55);
  position: relative;
}

/* Tranche : le liseré or qui borde ses pages. */
[data-view="pere"] main.container::before {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(139, 105, 20, 0.28);
}

/* Sur petit écran la mise en scène n'a plus de sens : on rend la page pleine
   largeur pour ne pas gaspiller l'espace de lecture. */
@media (max-width: 720px) {
  [data-view="pere"] main.container {
    max-width: 100%;
    margin: 0;
    padding: var(--space-6) var(--space-4);
    border: none;
    box-shadow: none;
  }
}

/* L'en-tête reste solidaire du fond sombre, comme sa barre d'outils. */
[data-view="pere"] header {
  background-color: rgba(242, 232, 208, 0.94);
  border-bottom: 1.5px solid rgba(139, 105, 20, 0.45);
}

/* Correctif du 04/09 : la texture restait appliquée au pourtour, ce qui
   annulait l'effet de feuille posée. Elle n'appartient qu'à la page. */
[data-view="pere"] body {
  background-image: none;
  background-color: #2c1808;
}

/* Retouches apres verification en ligne (04/09) :
   - le panneau de facettes tranchait en blanc sur le parchemin
   - une bande sombre apparaissait entre l'en-tete et le contenu sur mobile */
[data-view="pere"] .facet-panel,
[data-view="pere"] aside {
  background-color: rgba(248, 242, 228, 0.92);
  border: 1px solid rgba(139, 105, 20, 0.22);
}

@media (max-width: 720px) {
  [data-view="pere"] body { background-color: var(--bg); }
}

/* Bouton d'extension de la table des matieres, pour les documents qui comptent
   des dizaines de milliers de signets. */
.toc-more {
  display: block; width: calc(100% - 1rem); margin: var(--space-3) var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: 0.82rem; cursor: pointer;
  transition: all var(--transition);
}
.toc-more:hover { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
/* ============================================================================
   P1 ADOPTION — lecteur lisible (t_fc5745b2)
   Bloc à AJOUTER À LA FIN de /var/www/frontend/.../styles/global.css en PROD.

   Pourquoi un ajout et pas un remplacement : le global.css de prod contient
   145 lignes de correctifs absents du dépôt (couleurs de rubrique NAV/RCH/RNG/
   GRV, fleurons, badges .type-signet/.type-page…). On ne remplace donc rien :
   ces règles, plus bas dans la feuille, écrasent les anciennes à spécificité
   égale. Sur le dépôt (dev), les mêmes valeurs sont écrites « en place ».
   ========================================================================= */

/* --- Texte posé sur un fond --accent (WCAG AA) ---------------------------- */
[data-view="pere"]   { --on-accent: #ffffff; }  /* blanc sur #8b4513 = 7,10:1 */
[data-view="tris"]   { --on-accent: #0d0d0f; }  /* encre sur #6b7af8 = 5,33:1 */
[data-view="bougie"] { --on-accent: #1c150e; }  /* encre sur #e8b020 = 9,17:1 */

/* --- Contraste du texte discret en thème Bougie --------------------------- */
[data-view="bougie"] {
  --text-muted: #a58f63;  /* était #8a7850 = 4,41:1 → 6,05:1 sur le haut du dégradé */
  --text-faint: #96805a;  /* était #5a4e30 = 2,32:1 → 4,99:1 */
}

/* --- CTA principal : plus jamais de texte blanc sur or -------------------- */
.btn-primary { color: var(--on-accent); }
.btn-primary:hover { color: var(--on-accent); }
.skip-link { color: var(--on-accent); }

/* --- Sélecteur de thème de l'en-tête : cibles ≥ 44 px, 15 px --------------- */
.theme-toggle button {
  min-height: 44px;
  padding: 0 var(--space-4);
  font-size: 0.9375rem;
}

/* --- Liens de navigation : 16 px, cible ≥ 44 px, contraste AA -------------- */
.site-nav-link,
.site-nav-btn {
  display: inline-flex; align-items: center;
  min-height: 44px; padding: 0 var(--space-3);
  font-family: var(--font-body); font-size: 1rem;
  color: var(--text-muted); text-decoration: none;
  background: transparent; border: 0; border-radius: var(--radius-sm);
  cursor: pointer; line-height: 1.2;
}
.site-nav-link:hover,
.site-nav-btn:hover { color: var(--text); background: var(--surface-2); }
.site-nav-btn { border: 1px solid var(--border); }
.site-nav-link:focus-visible,
.site-nav-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }

/* --- Compatibilité : HTML déjà déployé (styles inline 14 px / 22 px) ------
   Les pages prod portent encore style="font-size:0.875rem;color:…" sur ces
   liens. Sans réécrire tous les HTML, on neutralise ces styles inline : le
   rendu devient identique à celui de la classe .site-nav-link.               */
.site-header nav > a,
.site-header nav #nav-user > a,
.site-header nav #nav-user > button {
  display: inline-flex !important;
  align-items: center !important;
  min-height: 44px !important;
  padding: 0 var(--space-3) !important;
  font-size: 1rem !important;
  line-height: 1.2 !important;
  text-decoration: none !important;
}

/* === Fiches de collection (carte t_2450c60e) ==========================
   Badge discret sur les cartes de document (catalogue / résultats de
   recherche) quand l'API signale content_status ≠ 'ok' : la notice décrit
   une collection, mais son texte n'est pas lisible.
   Bloc additif : aucun style existant n'est modifié. */
.badge-fiche {
  font-family: var(--font-garamond);
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  padding: 0.0625rem 0.4rem;
  margin-left: var(--space-2);
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  white-space: nowrap;
  vertical-align: middle;
}
