/* ============================================================
   ALYRIAZ · Le thème de chaque article (voir js/theme-article.js)
   ------------------------------------------------------------
   Rien ici ne s'applique sans fiche : toutes les règles dépendent de
   `body.th-actif`, posée par le script seulement si l'article a un
   thème valide. Les couleurs arrivent en variables --th-*.

   Le thème habille l'ARTICLE, pas le site : le menu, le pied de page et
   la navigation restent ceux d'Alyriaz. Un lecteur doit sentir qu'il
   change de sujet, pas qu'il change de site.
   ============================================================ */

body.th-actif {
  --th-fond: #F5F1E8;
  --th-surface: #FCFAF5;
  --th-encre: #1E1D1C;
  --th-accent: #BC5A38;
  --th-accent2: var(--th-accent);
  --th-discret: #7A7369;
  --th-trait: #D8D0C2;
}

/* ── La page de l'article devient une feuille à ses couleurs ─── */
body.th-actif .article-layout {
  /* LES VARIABLES DU SITE, REDÉFINIES DANS L'ARTICLE.
     L'agent rédacteur écrit ses tableaux et encadrés avec des styles en
     ligne qui utilisent les variables du site (`background:
     var(--surface)`, `border: 1px solid var(--border)`). Mesuré le
     24/09/2026 : sur fond crème, ces tableaux restaient noirs, avec un
     texte devenu sombre — illisibles. Plutôt que de retoucher chaque
     article, on redéfinit ces variables ici : tout le contenu existant
     prend les couleurs du thème de lui-même. */
  --surface: var(--th-surface);
  --surface2: var(--th-fond);
  --border: var(--th-trait);
  --text: var(--th-encre);
  --muted: var(--th-discret);
  --accent: var(--th-accent);
  --accent2: var(--th-accent2);
  background: var(--th-fond);
  color: var(--th-encre);
  border-radius: 28px;
  margin-top: 40px;
  padding-top: 44px;
  max-width: 920px;
}
body.th-actif .article-content {
  color: color-mix(in srgb, var(--th-encre) 86%, transparent);
  font-family: var(--th-police-texte, Inter), Inter, system-ui, sans-serif;
}
body.th-actif .article-content h2,
body.th-actif .article-content h3,
body.th-actif .article-content strong {
  color: var(--th-encre);
}
body.th-actif .article-content h2,
body.th-actif .article-content h3 {
  font-family: var(--th-police-titre, inherit), system-ui, sans-serif;
}
body.th-actif .article-content h2::before { background: var(--th-accent); }
body.th-actif .article-content em { color: var(--th-accent); }
body.th-actif .article-content a { color: var(--th-accent); text-decoration-color: color-mix(in srgb, var(--th-accent) 40%, transparent); }
body.th-actif .article-content blockquote { border-left-color: var(--th-accent); color: var(--th-encre); }
/* Les tableaux déjà présents dans le texte de l'article prennent aussi
   les couleurs du thème, sinon ils resteraient blancs sur crème. */
body.th-actif .article-content table { border-color: var(--th-trait); }
body.th-actif .article-content th,
body.th-actif .article-content td { border-color: var(--th-trait); color: var(--th-encre); }
body.th-actif .article-content thead th { background: var(--th-surface); }
body.th-actif .article-content .article-callout {
  background: var(--th-surface);
  border-color: var(--th-trait);
  color: var(--th-encre);
}

/* Le vignettage du site (body::after, css/premium.css) assombrit les
   bords de l'écran jusqu'à 55 % de noir : beau sur fond sombre, il
   salissait la feuille crème (vu le 24/09/2026 sur mobile). */
body.th-actif.th-clair::after { opacity: .3; }

/* ── L'en-tête : la police et l'accent du sujet ─────────────── */
body.th-actif .article-page-title { font-family: var(--th-police-titre, inherit), system-ui, sans-serif; }
body.th-actif .article-hero .category-badge { background: var(--th-accent); color: #fff; border-color: transparent; }

/* ── Les briques ────────────────────────────────────────────── */
.th-brique {
  margin: 36px 0;
  padding: 26px 26px 22px;
  background: var(--th-surface);
  border: 1px solid var(--th-trait);
  border-radius: 20px;
  color: var(--th-encre);
}
.th-titre {
  font-family: var(--th-police-titre, inherit), system-ui, sans-serif;
  font-weight: 800;
  font-size: clamp(1.15rem, 2.2vw, 1.45rem);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin-bottom: 18px;
}
/* Le style des articles met les <em> en italique, avec une priorité
   supérieure à une simple classe : on précise donc le chemin. */
body.th-actif .th-brique .th-accent,
.th-accent { color: var(--th-accent); font-style: normal; }
.th-note { margin: 16px 0 0; font-size: .95rem; color: var(--th-discret); line-height: 1.6; }
.th-mono { font-family: var(--th-police-chiffres, 'JetBrains Mono'), ui-monospace, monospace; }

/* Chiffres */
.th-chiffres { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 18px; }
.th-valeur {
  font-family: var(--th-police-titre, inherit), system-ui, sans-serif;
  font-weight: 800; font-size: clamp(1.8rem, 4vw, 2.4rem); line-height: 1; color: var(--th-accent);
}
.th-libelle { margin-top: 8px; font-size: .92rem; line-height: 1.45; color: var(--th-discret); }

/* Barres */
.th-barres { display: grid; gap: 18px; }
.th-barre-tete { display: flex; justify-content: space-between; gap: 12px; font-size: .95rem; margin-bottom: 8px; }
.th-barre-tete .th-mono { color: var(--th-accent); font-weight: 600; }
.th-piste { height: 14px; border-radius: 999px; background: var(--th-trait); overflow: hidden; }
.th-remplissage { height: 100%; border-radius: 999px; background: var(--th-accent); }

/* Tableau */
.th-tableau-cadre { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.th-tableau { width: 100%; border-collapse: collapse; font-size: .95rem; }
.th-tableau th, .th-tableau td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--th-trait); white-space: nowrap; }
.th-tableau th { font-family: var(--th-police-chiffres, 'JetBrains Mono'), ui-monospace, monospace; font-size: .78rem; font-weight: 600; color: var(--th-discret); }
.th-tableau td + td { font-family: var(--th-police-chiffres, 'JetBrains Mono'), ui-monospace, monospace; }
.th-tableau .th-surligne { color: var(--th-accent); font-weight: 700; }

/* Étapes */
.th-etapes { margin: 0; padding-left: 1.4em; display: grid; gap: 10px; }
.th-etapes li { line-height: 1.55; }
.th-etapes li::marker { color: var(--th-accent); font-weight: 800; }
.th-coche { list-style: none; padding-left: 0; }
.th-coche li { padding-left: 30px; position: relative; }
.th-coche li::before { content: '✓'; position: absolute; left: 4px; color: var(--th-accent); font-weight: 800; }

/* Terminal */
.th-terminal {
  background: #262523; color: #EDE6DA; border-radius: 14px; padding: 16px 18px 18px;
  font-family: var(--th-police-chiffres, 'JetBrains Mono'), ui-monospace, monospace; font-size: .92rem;
}
.th-terminal-points { display: flex; gap: 7px; margin-bottom: 12px; }
.th-terminal-points i { width: 10px; height: 10px; border-radius: 50%; background: #E0564B; }
.th-terminal-points i:nth-child(2) { background: #E8B04A; }
.th-terminal-points i:nth-child(3) { background: #6FB35A; }
.th-terminal-ligne { padding: 3px 0; }
.th-terminal-ligne.th-discret { opacity: .6; padding-left: 16px; }
.th-invite { color: var(--th-accent2); }

/* Citation */
.th-citation { margin: 0; border: 0; padding: 0; }
.th-citation p {
  font-family: var(--th-police-titre, inherit), system-ui, sans-serif;
  font-size: clamp(1.2rem, 2.6vw, 1.6rem); font-weight: 700; line-height: 1.3; margin: 0;
}
.th-citation cite { display: block; margin-top: 12px; font-style: normal; font-size: .9rem; color: var(--th-discret); }

/* Visuel */
.th-visuel { margin: 0; }
.th-brique.th-type-visuel { padding: 0; overflow: hidden; }
.th-visuel img { display: block; width: 100%; height: auto; }
.th-visuel figcaption { padding: 12px 18px 14px; font-size: .9rem; color: var(--th-discret); }

/* ── Mobile ─────────────────────────────────────────────────── */
/* Les barres de défilement des tableaux larges, aux couleurs du thème
   (celles du site sont noires, et tranchaient sur le fond clair). */
body.th-actif .article-content ::-webkit-scrollbar-track { background: var(--th-trait); }
body.th-actif .article-content ::-webkit-scrollbar-thumb { background: var(--th-accent); }

@media (max-width: 640px) {
  body.th-actif .article-layout { border-radius: 20px; margin: 24px 8px 0; padding-top: 28px; }
  .th-brique { padding: 20px 18px 18px; margin: 28px 0; border-radius: 16px; }
  body.th-actif .article-content h2::before { left: -12px; }
}
