/* ==========================================================================
   Stratide — Feuille de style du site
   Design : Sombre & premium · noir profond + ivoire + or vieilli
   ========================================================================== */

:root {
  /* Fonds */
  --bg-page: #14110F;
  --bg-block: #1C1916;
  --bg-accent: #221E1A;
  --bg-deep: #0E0C0A;

  /* Texte */
  --text-primary: #F5EFDF;
  --text-secondary: #BFB6A2;
  --text-muted: #8A8170;

  /* Or vieilli */
  --gold: #C9A961;
  --gold-bright: #E1C181;
  --gold-deep: #9A7E3D;

  /* Compatibilité avec les noms de variables existants utilisés dans le HTML/SVG inline */
  --terracotta: #C9A961;
  --ocre: #B8965A;
  --olive: #D4B978;

  /* Bordures */
  --border-soft: rgba(201, 169, 97, 0.12);
  --border-strong: rgba(201, 169, 97, 0.28);
  --border-gold: rgba(201, 169, 97, 0.55);

  /* Échelles */
  --max-text-width: 52rem;
  --max-page-width: 76rem;

  /* Typographie — inchangée */
  --font-body: 'EB Garamond', 'Garamond', 'Georgia', 'Times New Roman', serif;
  --font-display: 'EB Garamond', 'Georgia', serif;
  --font-mono: 'JetBrains Mono', 'Consolas', 'Courier New', monospace;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
}

/* Variante claire (toggle ☀) — ivoire/or pour les lecteurs qui la préfèrent */
[data-theme="light"] {
  --bg-page: #FBFAF6;
  --bg-block: #F4F1E8;
  --bg-accent: #ECE6D6;
  --bg-deep: #F7F3EA;
  --text-primary: #1F1A12;
  --text-secondary: #4A3F2D;
  --text-muted: #7A6B50;
  --gold: #8B6914;
  --gold-bright: #6B4F0E;
  --gold-deep: #B8965A;
  --terracotta: #8B6914;
  --ocre: #6B4F0E;
  --olive: #A0782B;
  --border-soft: rgba(139, 105, 20, 0.15);
  --border-strong: rgba(139, 105, 20, 0.35);
  --border-gold: rgba(139, 105, 20, 0.6);
}

/* Reset minimal */
*, *::before, *::after { box-sizing: border-box; }

html {
  font-size: 17px;
  scroll-behavior: smooth;
  background: var(--bg-page);
}

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.75;
  font-weight: 400;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ==========================================================================
   En-tête du site — bandeau noir, filet d'or en bas
   ========================================================================== */

.site-header {
  background: var(--bg-page);
  padding: 1.1rem 2rem;
  border-bottom: 1px solid var(--border-strong);
  position: relative;
}

.site-header::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold) 20%,
    var(--gold-bright) 50%,
    var(--gold) 80%,
    transparent 100%);
  opacity: 0.5;
}

.site-header-content {
  max-width: var(--max-page-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: inherit;
}

.site-logo svg { width: 42px; height: 42px; flex-shrink: 0; }

.site-logo-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
}

.site-nav {
  display: flex;
  gap: 2.4rem;
  font-family: var(--font-ui);
  font-size: 0.72rem;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-weight: 500;
  position: relative;
  padding-bottom: 4px;
  transition: color 0.25s;
}

.site-nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: var(--gold);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.3s ease;
}

.site-nav a:hover,
.site-nav a.active {
  color: var(--gold-bright);
}

.site-nav a:hover::after,
.site-nav a.active::after {
  transform: scaleX(1);
}

/* ==========================================================================
   Article — page éditoriale
   ========================================================================== */

.article {
  max-width: var(--max-text-width);
  margin: 0 auto;
  padding: 3.5rem 1.5rem 6rem 1.5rem;
  counter-reset: chapter-counter;
}

.article-meta {
  text-align: center;
  margin-bottom: 3.5rem;
  padding-bottom: 2.5rem;
  border-bottom: 1px solid var(--border-strong);
  position: relative;
}

.article-meta::after {
  content: "✦";
  position: absolute;
  bottom: -0.7rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--gold);
  background: var(--bg-page);
  padding: 0 1rem;
  font-size: 0.9rem;
  letter-spacing: 0.5em;
}

.article-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  color: var(--gold);
  margin-bottom: 1.2rem;
  text-align: center;
}

.article-title {
  font-family: var(--font-display);
  font-size: 3.6rem;
  font-weight: 400;
  line-height: 1.05;
  color: var(--text-primary);
  margin: 0 0 1rem 0;
  letter-spacing: -0.01em;
  text-align: center;
}

.article .article-subtitle {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.4rem;
  color: var(--gold);
  font-weight: 400;
  margin: 0 0 0.6rem 0;
  text-align: center;
  letter-spacing: 0.01em;
}

.article .article-tagline {
  font-style: italic;
  font-size: 1.05rem;
  color: var(--text-muted);
  font-weight: 400;
  margin: 0;
  text-align: center;
}

/* ==========================================================================
   Hiérarchie des titres dans l'article — h2 numérotés façon livre relié
   ========================================================================== */

.article h2 {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 400;
  line-height: 1.2;
  color: var(--text-primary);
  margin: 2.2rem 0 0.8rem 0;
  padding-top: 1.2rem;
  border-top: none;
  letter-spacing: -0.01em;
  text-align: center;
  position: relative;
  counter-increment: chapter-counter;
}

.article h2::before {
  content: "— " counter(chapter-counter, upper-roman) " —";
  display: block;
  font-family: var(--font-ui);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.45em;
  color: var(--gold);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.article h2:first-of-type {
  padding-top: 1rem;
  margin-top: 1rem;
}

.article h2.toc-title {
  text-align: left;
  padding: 0;
  margin: 0 0 1rem 0;
  counter-increment: none;
}

.article h2.toc-title::before { content: none; }

.article h3 {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 500;
  font-style: italic;
  line-height: 1.3;
  color: var(--gold);
  margin: 2rem 0 0.9rem 0;
  letter-spacing: 0.005em;
}

.article h4 {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--gold-bright);
  margin: 2rem 0 0.7rem 0;
}

/* ==========================================================================
   Paragraphes et texte
   ========================================================================== */

.article p {
  margin: 0 0 1.1rem 0;
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-justify: inter-word;
  color: var(--text-primary);
}

.article p:first-of-type {
  font-size: 1.1rem;
  line-height: 1.7;
}

.article strong {
  font-weight: 600;
  color: var(--gold-bright);
}

.article em {
  font-style: italic;
  color: var(--text-primary);
}

/* Notation mathématique / code inline */
.article p code,
.article li code {
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 500;
  background: var(--bg-accent);
  padding: 0.05em 0.4em;
  border-radius: 2px;
  font-size: 0.95em;
  color: var(--gold-bright);
  border: 1px solid var(--border-soft);
}

/* ==========================================================================
   Listes
   ========================================================================== */

.article ul,
.article ol {
  margin: 0 0 1.5rem 0;
  padding-left: 1.8rem;
}

.article li {
  margin: 0.5rem 0;
  line-height: 1.75;
}

.article ul li::marker { color: var(--gold); }
.article ol li::marker { color: var(--gold); font-weight: 600; }

/* ==========================================================================
   Tableaux
   ========================================================================== */

.article table {
  border-collapse: collapse;
  width: 100%;
  margin: 2.5rem 0;
  font-size: 0.95rem;
  font-family: var(--font-body);
  background: var(--bg-block);
  border: 1px solid var(--border-strong);
}

.article table th,
.article table td {
  text-align: left;
  padding: 0.85rem 1rem;
  vertical-align: top;
  border: 1px solid var(--border-soft);
}

.article table th {
  background: var(--bg-accent);
  font-weight: 600;
  color: var(--gold);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  border-bottom: 1px solid var(--border-gold);
}

.article table tbody tr:nth-child(even) {
  background: rgba(201, 169, 97, 0.025);
}

/* ==========================================================================
   Diagrammes
   ========================================================================== */

.figure {
  margin: 3.5rem -2rem;
  text-align: center;
  padding: 2rem 0;
  background: var(--bg-block);
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
}

.figure svg,
.figure img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 0 auto;
}

.figure-caption {
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-muted);
  margin-top: 1.2rem;
  letter-spacing: 0.05em;
}

/* ==========================================================================
   Citations — guillemets ornementaux dorés
   ========================================================================== */

.article blockquote {
  border-left: none;
  margin: 2.5rem 1rem;
  padding: 1.8rem 2rem 1.8rem 4rem;
  font-style: italic;
  color: var(--text-secondary);
  background: var(--bg-block);
  position: relative;
  border-top: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  font-size: 1.08rem;
  line-height: 1.7;
}

.article blockquote::before {
  content: "\201C";
  position: absolute;
  top: 0.5rem;
  left: 1rem;
  font-family: var(--font-display);
  font-size: 4.5rem;
  color: var(--gold);
  font-style: normal;
  line-height: 1;
}

/* ==========================================================================
   Notation formelle (D1, D2, etc.) — bloc tactile or
   ========================================================================== */

.def {
  background: var(--bg-block);
  border: 1px solid var(--border-soft);
  border-left: 3px solid var(--gold);
  padding: 1.2rem 1.5rem;
  margin: 1.8rem 0;
  border-radius: 0 2px 2px 0;
  position: relative;
}

.def-label {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  color: var(--gold);
  margin-bottom: 0.6rem;
  display: block;
}

/* ==========================================================================
   Liens
   ========================================================================== */

.article a,
.home-content a {
  color: var(--gold-bright);
  text-decoration: underline;
  text-decoration-color: var(--border-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  transition: color 0.25s, text-decoration-color 0.25s;
}

.article a:hover,
.home-content a:hover {
  color: var(--gold);
  text-decoration-color: var(--gold);
}

.article a.home-card,
.article a.home-card:hover,
.home-content a.home-card,
.home-content a.home-card:hover {
  color: inherit;
  text-decoration: none;
}

.article a.home-card .home-card-title,
.article a.home-card .home-card-description,
.article a.home-card .home-card-eyebrow,
.home-content a.home-card .home-card-title,
.home-content a.home-card .home-card-description,
.home-content a.home-card .home-card-eyebrow {
  text-decoration: none;
}

/* ==========================================================================
   Table des matières — encadré or
   ========================================================================== */

.toc {
  margin: 2.5rem 0 2rem 0;
  padding: 2rem 2.2rem;
  background: var(--bg-block);
  border: 1px solid var(--border-soft);
  border-top: 2px solid var(--gold);
  border-radius: 0;
  position: relative;
}

h2.toc-title,
.toc-title {
  font-family: var(--font-ui);
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.35em;
  color: var(--gold);
  margin: 0 0 1.4rem 0;
  padding: 0;
  border: none;
  line-height: 1.2;
  text-align: left;
}

.toc ol {
  list-style: none;
  padding: 0;
  margin: 0;
  counter-reset: toc-counter;
}

.toc li {
  counter-increment: toc-counter;
  margin: 0.55rem 0;
  position: relative;
  padding-left: 2.6rem;
  line-height: 1.5;
}

.toc li::before {
  content: counter(toc-counter, upper-roman);
  position: absolute;
  left: 0;
  top: 0;
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 500;
  font-style: italic;
  color: var(--gold);
  letter-spacing: 0.05em;
  padding-top: 0.05rem;
  min-width: 2rem;
  text-align: left;
}

.toc a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 1rem;
  transition: color 0.2s;
}

.toc a:hover { color: var(--gold-bright); }

/* ==========================================================================
   Skip-link
   ========================================================================== */

.skip-link {
  position: absolute;
  top: -100%;
  left: 1rem;
  background: var(--gold);
  color: var(--bg-page);
  padding: 0.6rem 1.2rem;
  border-radius: 0;
  font-family: var(--font-ui);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-decoration: none;
  z-index: 1000;
  transition: top 0.2s;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--gold-bright);
  outline-offset: 2px;
}

/* ==========================================================================
   Fil d'Ariane
   ========================================================================== */

.breadcrumb {
  max-width: var(--max-page-width);
  margin: 0 auto;
  padding: 1.2rem 1.5rem 0 1.5rem;
  font-family: var(--font-ui);
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.2s;
}

.breadcrumb a:hover { color: var(--gold); }

.breadcrumb .breadcrumb-sep {
  color: var(--gold-deep);
  margin: 0 0.6rem;
}

/* ==========================================================================
   Retour en haut
   ========================================================================== */

.back-to-top {
  display: block;
  text-align: center;
  margin: 4rem 0 1rem 0;
  font-family: var(--font-ui);
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
}

.back-to-top a {
  color: var(--gold);
  text-decoration: none;
  border: 1px solid var(--border-strong);
  padding: 0.7rem 1.8rem;
  border-radius: 0;
  transition: border-color 0.25s, color 0.25s, background 0.25s;
  letter-spacing: 0.25em;
}

.back-to-top a:hover {
  color: var(--bg-page);
  background: var(--gold);
  border-color: var(--gold);
}

/* ==========================================================================
   Tableau wrapper
   ========================================================================== */

.table-wrapper {
  overflow-x: auto;
  margin: 2.5rem 0;
  -webkit-overflow-scrolling: touch;
}

.table-wrapper table {
  margin: 0;
  min-width: 100%;
}

/* ==========================================================================
   Pied de page
   ========================================================================== */

.site-footer {
  background: var(--bg-deep);
  border-top: 1px solid var(--border-strong);
  padding: 4rem 2rem 2.5rem 2rem;
  margin-top: 5rem;
  position: relative;
}

.site-footer::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--gold) 20%,
    var(--gold-bright) 50%,
    var(--gold) 80%,
    transparent 100%);
  opacity: 0.5;
}

.site-footer-content {
  max-width: var(--max-page-width);
  margin: 0 auto;
  text-align: center;
  font-family: var(--font-ui);
  color: var(--text-muted);
  font-size: 0.85rem;
  line-height: 1.6;
}

.site-footer p { margin: 0.5rem 0; }

.site-copyright {
  margin-top: 1.5rem !important;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-soft);
  font-size: 0.72rem;
  color: var(--text-muted);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.site-footer-logo {
  width: 40px;
  height: 40px;
  margin: 0 auto 1.2rem auto;
  display: block;
  opacity: 0.85;
}

/* ==========================================================================
   Page d'accueil — hero façon page de garde
   ========================================================================== */

.home-hero {
  max-width: var(--max-text-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 2.5rem 1.5rem;
  text-align: center;
  position: relative;
}

.home-hero::before,
.home-hero::after {
  content: "";
  display: block;
  width: 90px;
  height: 1px;
  background: var(--gold);
  margin: 0 auto;
  opacity: 0.6;
}

.home-hero::before { margin-bottom: 1.5rem; }
.home-hero::after { margin-top: 1.5rem; }

.home-hero-logo {
  width: 110px;
  height: 110px;
  margin: 0 auto 1.4rem auto;
  display: block;
  filter: drop-shadow(0 0 30px rgba(201, 169, 97, 0.15));
}

.home-title {
  font-family: var(--font-display);
  font-size: 3.4rem;
  font-weight: 400;
  letter-spacing: 0.3em;
  color: var(--gold);
  margin: 0 0 1rem 0;
  text-transform: uppercase;
  text-indent: 0.3em;
}

.home-tagline {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 1.35rem;
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

.home-content {
  max-width: var(--max-text-width);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem 1.5rem;
}

.home-content p {
  text-align: justify;
  hyphens: auto;
  -webkit-hyphens: auto;
  text-justify: inter-word;
}

.home-content > p:first-of-type {
  font-size: 1.18rem;
  line-height: 1.75;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
}

.home-content h2 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 400;
  margin: 4rem 0 1.8rem 0;
  color: var(--text-primary);
  text-align: center;
  letter-spacing: 0.02em;
  position: relative;
  padding-bottom: 1.2rem;
}

.home-content h2::after {
  content: "✦";
  display: block;
  position: absolute;
  bottom: -0.2rem;
  left: 50%;
  transform: translateX(-50%);
  color: var(--gold);
  font-size: 0.85rem;
  letter-spacing: 0.5em;
}

/* Cards — façon "tomes" tactiles */
.home-card {
  display: block;
  padding: 2.2rem 2.4rem;
  margin: 1.5rem 0;
  background: var(--bg-block);
  border: 1px solid var(--border-soft);
  border-left: 2px solid var(--gold);
  border-radius: 0;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.3s, transform 0.3s, background 0.3s;
  text-align: left;
  position: relative;
}

.home-card::after {
  content: "→";
  position: absolute;
  right: 2.4rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gold);
  font-size: 1.3rem;
  opacity: 0.4;
  transition: opacity 0.3s, transform 0.3s, color 0.3s;
}

.home-card:hover {
  border-color: var(--border-strong);
  border-left-color: var(--gold-bright);
  background: var(--bg-accent);
}

.home-card:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(6px);
  color: var(--gold-bright);
}

.home-card-eyebrow {
  font-family: var(--font-ui);
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.32em;
  color: var(--gold);
  margin-bottom: 0.7rem;
  text-align: left;
}

.home-card-title {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 400;
  margin: 0 0 0.7rem 0;
  color: var(--text-primary);
  text-align: left;
  letter-spacing: 0.005em;
}

.home-card .home-card-description {
  margin: 0;
  color: var(--text-secondary);
  line-height: 1.65;
  text-align: left;
  font-size: 0.97rem;
  padding-right: 2rem;
}

/* ==========================================================================
   Barre de progression de lecture
   ========================================================================== */

.progress-bar {
  position: fixed;
  top: 0; left: 0;
  height: 2px;
  background: var(--gold);
  z-index: 1001;
  width: 0%;
  transition: width 0.1s linear;
  pointer-events: none;
  box-shadow: 0 0 8px rgba(201, 169, 97, 0.5);
}

/* ==========================================================================
   Bouton mode sombre
   ========================================================================== */

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--gold);
  transition: border-color 0.25s, color 0.25s, background 0.25s;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
}

.theme-toggle:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(201, 169, 97, 0.08);
}

/* ==========================================================================
   Bouton retour en haut flottant
   ========================================================================== */

.back-to-top-float {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-block);
  border: 1px solid var(--border-strong);
  color: var(--gold);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, border-color 0.25s, color 0.25s, background 0.25s;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.back-to-top-float:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: var(--bg-accent);
}

@media print {
  .back-to-top-float { display: none !important; }
}

/* ==========================================================================
   Séparateurs ornementaux
   ========================================================================== */

.article hr {
  border: none;
  text-align: center;
  margin: 2.5rem 0;
  overflow: visible;
  height: 0;
}

.article hr::after {
  content: "✦   ✦   ✦";
  letter-spacing: 1.4em;
  color: var(--gold);
  font-size: 0.6rem;
  position: relative;
  top: -0.5rem;
  opacity: 0.7;
}

/* ==========================================================================
   Lettrines
   ========================================================================== */

.article h2 + p:first-of-type::first-letter,
.article h3 + p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 4rem;
  float: left;
  line-height: 0.8;
  color: var(--gold);
  margin-right: 0.4rem;
  margin-top: 0.05rem;
  padding-top: 0.15rem;
  font-weight: 500;
  font-style: italic;
}

/* ==========================================================================
   Sidebar TOC (écrans larges)
   ========================================================================== */

@media (min-width: 1200px) {
  .article {
    --toc-width: 16rem;
    --content-max: 50rem;
    --gap: 2.5rem;
    max-width: none;
    display: grid;
    grid-template-columns: minmax(1rem, 2.5rem) var(--toc-width) minmax(0, var(--content-max)) 1fr;
    gap: 0 var(--gap);
    padding: 4.5rem 2rem 6rem 2rem;
  }

  .article > .article-meta { grid-column: 1 / -1; }

  .article > .toc {
    grid-column: 2;
    grid-row: 2 / span 9999;
    position: sticky;
    top: 2rem;
    align-self: start;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    margin: 0;
    padding: 1.6rem 1.5rem;
    font-size: 0.88rem;
    border: 1px solid var(--border-soft);
    border-top: 2px solid var(--gold);
    border-radius: 0;
    background: var(--bg-block);
    z-index: 10;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-deep) transparent;
  }

  .article > .toc .toc-title {
    font-size: 0.65rem;
    margin-bottom: 1rem;
  }

  .article > .toc li {
    padding-left: 2rem;
    margin: 0.35rem 0;
  }

  .article > .toc li::before { font-size: 0.78rem; }

  .article > .toc a {
    font-size: 0.92rem;
    line-height: 1.4;
  }

  .article > :not(.article-meta):not(.toc) { grid-column: 3; }

  .article .figure {
    margin-left: 0;
    margin-right: 0;
  }

  .article blockquote.pull,
  .article .def.pull {
    float: none;
    margin-left: 0;
    margin-right: 0;
    width: auto;
    padding: 1.5rem 1.8rem 1.5rem 4rem;
    font-size: 0.95rem;
    background: var(--bg-block);
  }

  .article .def.pull {
    border-left: 3px solid var(--gold);
    font-style: normal;
  }
}

@media (min-width: 1024px) and (max-width: 1199px) {
  .toc {
    position: sticky;
    top: 2rem;
    max-height: calc(100vh - 4rem);
    overflow-y: auto;
    z-index: 10;
    scrollbar-width: thin;
    scrollbar-color: var(--gold-deep) transparent;
  }
}

.toc a.toc-active {
  color: var(--gold-bright);
  font-weight: 500;
}

/* ==========================================================================
   Pied de page élargi (grille 3 colonnes)
   ========================================================================== */

.site-footer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 2.5rem;
  text-align: left;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border-soft);
}

.site-footer-brand { text-align: left; }

.site-footer-brand .site-footer-logo { margin: 0 0 1rem 0; }

.site-footer-brand p {
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 0.95rem;
  line-height: 1.6;
}

.site-footer-brand strong {
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 500;
}

.site-footer-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.site-footer-nav-title {
  font-weight: 600;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.68rem;
  margin-bottom: 0.6rem;
}

.site-footer-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.2s;
  font-size: 0.85rem;
  letter-spacing: 0.02em;
}

.site-footer-nav a:hover { color: var(--gold-bright); }

.site-footer-quote {
  font-style: italic;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-family: var(--font-display);
  line-height: 1.65;
  position: relative;
  padding-left: 1rem;
  border-left: 1px solid var(--border-strong);
}

.site-footer-quote p { margin: 0 0 0.5rem 0; }

.site-footer-quote-src {
  font-style: normal !important;
  font-family: var(--font-ui) !important;
  font-size: 0.7rem !important;
  color: var(--gold) !important;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

@media (max-width: 640px) {
  .site-footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
    text-align: center;
  }

  .site-footer-brand { text-align: center; }
  .site-footer-brand .site-footer-logo { margin: 0 auto 1rem auto; }
  .site-footer-nav { align-items: center; }
  .site-footer-quote {
    padding-left: 0;
    border-left: none;
    border-top: 1px solid var(--border-strong);
    padding-top: 1rem;
  }
}

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

@media (max-width: 720px) {
  html { font-size: 16px; }

  .site-header { padding: 0.7rem 1rem; }

  .site-header-content {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.8rem;
  }

  .site-nav {
    gap: 1.5rem;
    font-size: 0.65rem;
  }

  .article { padding: 2.5rem 1.2rem 4rem 1.2rem; }

  .article-title { font-size: 2.4rem; }
  .article-subtitle { font-size: 1.15rem; }

  .article h2 {
    font-size: 1.85rem;
    margin: 2.5rem 0 1rem 0;
    padding-top: 1.8rem;
  }

  .article h2.toc-title {
    font-size: 0.7rem;
    margin: 0 0 1rem 0;
    padding-top: 0;
  }

  .article h3 { font-size: 1.35rem; margin: 1.4rem 0 0.7rem 0; }

  .figure { margin: 2.5rem -1rem; padding: 1.5rem 0; }

  .toc { padding: 1.5rem 1.6rem; }

  .article table { font-size: 0.85rem; }
  .article table th,
  .article table td { padding: 0.6rem 0.7rem; }

  .home-title { font-size: 2.8rem; letter-spacing: 0.22em; }
  .home-tagline { font-size: 1.15rem; }
  .home-hero { padding: 4rem 1.2rem 3rem 1.2rem; }
  .home-card { padding: 1.6rem 1.8rem; }
  .home-card::after { right: 1.5rem; }
  .home-card .home-card-description { padding-right: 1.5rem; }
  .home-card-title { font-size: 1.45rem; }
}

/* ==========================================================================
   Navigation mobile (hamburger)
   ========================================================================== */

.mobile-nav-checkbox { display: none; }

.mobile-nav-label {
  display: none;
  cursor: pointer;
  flex-direction: column;
  gap: 5px;
  padding: 8px 4px;
  z-index: 100;
  order: 1;
}

.mobile-nav-label span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--gold);
  border-radius: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

@media (max-width: 540px) {
  .mobile-nav-label { display: flex; }

  .site-nav {
    display: none;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-page);
    border-bottom: 1px solid var(--border-strong);
    padding: 1.5rem;
    gap: 1.2rem;
    box-shadow: 0 8px 20px rgba(0,0,0,0.4);
    z-index: 99;
  }

  .mobile-nav-checkbox:checked ~ .site-nav { display: flex; }

  .site-header-content {
    position: relative;
    flex-wrap: wrap;
  }

  .mobile-nav-checkbox:checked ~ .mobile-nav-label span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }
  .mobile-nav-checkbox:checked ~ .mobile-nav-label span:nth-child(2) { opacity: 0; }
  .mobile-nav-checkbox:checked ~ .mobile-nav-label span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }
}

/* ==========================================================================
   Animation du logo hero
   ========================================================================== */

@keyframes draw-ring {
  to { stroke-dashoffset: 0; }
}

.home-hero-logo circle {
  stroke-dashoffset: 350;
  animation: draw-ring 1.4s ease-out forwards;
}

.home-hero-logo circle:nth-child(1) { animation-delay: 0s; }
.home-hero-logo circle:nth-child(2) { animation-delay: 0.3s; }
.home-hero-logo circle:nth-child(3) { animation-delay: 0.6s; }

/* ==========================================================================
   Sélection de texte
   ========================================================================== */

::selection {
  background: var(--gold);
  color: var(--bg-page);
}

/* ==========================================================================
   Scrollbar
   ========================================================================== */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-page);
}

::-webkit-scrollbar-thumb {
  background: var(--gold-deep);
  border: 2px solid var(--bg-page);
  border-radius: 0;
}

::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ==========================================================================
   Styles d'impression
   ========================================================================== */

@media print {
  .site-header,
  .site-footer,
  .skip-link,
  .back-to-top,
  .back-to-top-float,
  .progress-bar,
  .theme-toggle,
  .toc {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
    line-height: 1.5;
  }

  .article {
    max-width: 100%;
    padding: 0;
    margin: 0;
  }

  .article h2 {
    border-top: 1pt solid #000;
    page-break-after: avoid;
    color: #000;
  }

  .article h2::before { color: #555; }
  .article h3 { color: #555; page-break-after: avoid; }

  .article a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    font-style: italic;
  }

  .article a[href^="/"]::after,
  .article a[href^="#"]::after,
  .article a[href^="./"]::after { content: none; }

  .article p { orphans: 3; widows: 3; }

  .article table { border: 1pt solid #000; font-size: 9pt; }
  .article table th { background: #eee; color: #000; }

  .figure {
    page-break-inside: avoid;
    margin: 1.5rem 0;
    background: none;
    border: none;
  }

  .figure svg,
  .figure img { max-width: 100%; height: auto; }

  .article p code,
  .article li code {
    background: none;
    border: 1pt solid #ddd;
    color: #000;
  }

  .article blockquote {
    border-left: 2pt solid #000;
    background: none;
  }

  .def {
    border-left: 2pt solid #000;
    background: none;
  }

  @page { margin: 2cm; }
}
