/* ═══════════════════════════════════════════════════════════════════
   themes.css — jeu de thèmes du site (sombre d'origine + 3 clairs)
   Chargé EN DERNIER par includes/head.php (après style/topbar/pages/…) :
   les blocs de tokens sont insensibles à l'ordre, mais les quelques règles
   d'application en fin de fichier (bascule des icônes, halo) doivent gagner
   la cascade face à style.css.

   Activation : <html data-theme="chaud" data-contrast="doux">
     data-theme    : (absent) = thème sombre d'origine | chaud | neutre | gris
     data-contrast : (absent) = AA strict | doux  (retenu pour la prod)

   Le clair « chaud » est le thème par défaut : includes/head.php pose les deux
   attributs dans le markup. Le visiteur qui choisit le sombre les fait retirer
   (localStorage), et retombe alors sur le bloc :root ci-dessous — c'est-à-dire
   exactement le rendu d'avant l'ajout des thèmes.
   ═══════════════════════════════════════════════════════════════════ */

/* ─── Thème sombre d'origine — socle, appliqué sans data-theme ─────── */
:root {
    --page-base: #1d1d20;
    --veil: rgba(200, 205, 215, 0.18);
    --bg-img: url('fond.avif');

    /* Échelle d'encre, du plus fort au plus discret */
    --fg: #ffffff;
    --title: #ededed;
    --strong: #ffffff;
    --text: #cccccc;
    --desc: #bbbbbb;
    --muted: #888888;
    --dim: #555555;

    /* Conteneurs */
    --panel: rgba(18, 18, 18, 0.4);
    --panel-bd: rgba(232, 160, 0, 0.25);
    --card: rgba(18, 18, 18, 0.6);
    --card-strong: rgba(18, 18, 18, 0.7);
    --card-deep: rgba(10, 10, 10, 0.6);

    /* Bordures, du plus clair au plus marqué */
    --bd: #2a2a2a;
    --bd2: #333333;
    --bd3: #444444;

    /* Marque */
    --accent: orange;        /* orange décoratif : filets, bordures */
    --accent-text: orange;   /* orange texte : version lisible sur fond clair */
    --accent2: #e8a000;      /* souligné des titres */
    --red: red;

    --hover: rgba(255, 100, 0, 0.08);
    --thumb-bg: #0a0a0a;

    /* Pastille de date */
    --date-bg1: #181819;
    --date-bg2: #0e0e10;
    --date-fg: #e0e0e0;

    /* Couleur TEXTE / bordure de badge par type (assombrie en clair) */
    --acc-post: #e8a000;
    --acc-rapide: #5ba3ff;
    --acc-partage: #aaaaaa;
    --acc-doc: #9d7bff;
    /* Trait latéral 3px des cartes : décoratif, reste vif */
    --bar-post: #e8a000;
    --bar-rapide: #5ba3ff;
    --bar-partage: #aaaaaa;

    /* Placeholders de vignette par type */
    --ph-post: linear-gradient(135deg, #2a1a05 0%, #6c4408 100%);
    --ph-rapide: linear-gradient(135deg, #0a1f3a 0%, #1e4575 100%);
    --ph-partage: linear-gradient(135deg, #1a1a1a 0%, #3a3a3a 100%);
    --doc-tile: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
    --doc-tile-fg: #ffffff;

    --shadow: none;
    --chip: rgba(255, 255, 255, 0.05);
    --ok: #2ecc71;
    --ko: #e74c3c;

    --halo: none;
    --ico-dark: block;
    --ico-light: none;
    --ico-shadow: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));

    /* ── Extensions hors maquette (la livraison ne couvrait que l'accueil,
       ces rôles sont nécessaires pour /tools, /docs, /quizz, /ip, /ets2) ── */
    --field-bg: #111111;         /* fond des <input> / <select> */
    --field-fg: #eeeeee;
    --tag-bg: rgba(255, 255, 255, 0.02);
    --scrollbar: #333333;
    --overlay: rgba(0, 0, 0, 0.55);
    --selection-bg: #e8a000;
    --selection-fg: #1a1200;
    --btn-grad: linear-gradient(135deg, #c45200, #ff6600);
    --btn-fg: #ffffff;
    --topbar-bg: rgba(18, 18, 20, 0.85);
    --topbar-bd: rgba(232, 160, 0, 0.18);
    --topbar-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    --lvl-debutant: #4caf50;
    --lvl-intermediaire: #ff9800;
    --lvl-avance: #f44336;
    --scrim: rgba(0, 0, 0, 0.7);              /* badge posé sur une vignette */
    --tile-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
    --ip-ok: #35c98a;                          /* pastille IPv4/IPv6 active */
    --status-ok-fg: #cfe6d0;                   /* encarts d'état /legal */
    --status-out-fg: #f0dcb4;
    --status-ko-fg: #f2c9c9;
    --srmap: #d8c04a;                          /* badge « SR map » ETS2 */
    --code-bg: rgba(10, 10, 10, 0.9);          /* fond des blocs de code */
    --th-bg: rgba(255, 100, 0, 0.15);          /* en-tete de tableau */
    --rule-dash: rgba(232, 160, 0, 0.45);      /* filet pointille des titres */
    --chapo-bg: rgba(232, 160, 0, 0.04);
}

/* ─── Clair « chaud » — variante retenue, thème par défaut du site ── */
[data-theme="chaud"] {
    --page-base: #f8f4ec;
    --veil: rgba(255, 252, 245, 0.30);
    --bg-img: url('fond-clair-chaud.avif');

    --fg: #241f17;
    --title: #1d1913;
    --strong: #15120d;
    --text: #3d362b;
    --desc: #4a4235;
    --muted: #6b6154;
    --dim: #655c4f;

    --panel: rgba(255, 255, 255, 0.74);
    --panel-bd: rgba(176, 107, 0, 0.35);
    --card: rgba(255, 255, 255, 0.78);
    --card-strong: rgba(255, 255, 255, 0.88);
    --card-deep: rgba(250, 245, 236, 0.92);

    --bd: #e2d8c6;
    --bd2: #d3c6ae;
    --bd3: #bfae91;

    --accent: #b06b00;
    --accent-text: #8f5200;
    --accent2: #a86200;
    --red: #c02900;

    --hover: rgba(176, 107, 0, 0.10);
    --thumb-bg: #ece3d3;

    --date-bg1: #f0e7d7;
    --date-bg2: #f8f2e7;
    --date-fg: #3d362b;

    --acc-post: #a86200;
    --acc-rapide: #1f62b8;
    --acc-partage: #6f675b;
    --acc-doc: #6d3fd1;
    --bar-post: #e8a000;
    --bar-rapide: #4a90e2;
    --bar-partage: #9a9186;

    --ph-post: linear-gradient(135deg, #f3e3c4 0%, #dfbb72 100%);
    --ph-rapide: linear-gradient(135deg, #dbe7f7 0%, #a9c6ea 100%);
    --ph-partage: linear-gradient(135deg, #ece7dd 0%, #cdc5b6 100%);
    --doc-tile: linear-gradient(135deg, #f2ead9 0%, #e3d7bf 100%);
    --doc-tile-fg: #2a2318;

    --shadow: 0 1px 2px rgba(80, 60, 20, 0.06);
    --chip: rgba(120, 90, 30, 0.07);
    --ok: #1c8a4c;
    --ko: #c0392b;

    --halo: 0 0 5px rgba(255, 252, 245, 0.98), 0 0 11px rgba(255, 252, 245, 0.9), 0 0 20px rgba(255, 252, 245, 0.75);
    --ico-dark: none;
    --ico-light: block;
    --ico-shadow: none;

    --field-bg: #fffdf8;
    --field-fg: #241f17;
    --tag-bg: rgba(120, 90, 30, 0.05);
    --scrollbar: #c7bca6;
    --overlay: rgba(40, 32, 20, 0.45);
    --topbar-bg: rgba(255, 252, 245, 0.92);
    --topbar-bd: rgba(176, 107, 0, 0.28);
    --topbar-shadow: 0 4px 14px rgba(80, 60, 20, 0.12);
    --lvl-debutant: #2e7d32;
    --lvl-intermediaire: #b26a00;
    --lvl-avance: #c62828;
    --scrim: rgba(255, 252, 245, 0.82);
    --tile-shadow: 0 1px 2px rgba(120, 95, 40, 0.28);
    --ip-ok: #1c7a52;
    --status-ok-fg: #1f5c2a;
    --status-out-fg: #7a4e00;
    --status-ko-fg: #8c2020;
    --srmap: #7a6600;
    --code-bg: rgba(246, 241, 231, 0.95);
    --th-bg: rgba(176, 107, 0, 0.14);
    --rule-dash: rgba(176, 107, 0, 0.45);
    --chapo-bg: rgba(176, 107, 0, 0.06);
}

/* ─── Clair « neutre » ────────────────────────────────────────────── */
[data-theme="neutre"] {
    --page-base: #f6f7f9;
    --veil: rgba(250, 251, 253, 0.34);
    --bg-img: url('fond-clair-neutre.avif');

    --fg: #1e2024;
    --title: #16181c;
    --strong: #0f1114;
    --text: #383c43;
    --desc: #454a52;
    --muted: #626873;
    --dim: #5f656f;

    --panel: rgba(255, 255, 255, 0.66);
    --panel-bd: rgba(110, 122, 138, 0.30);
    --card: rgba(255, 255, 255, 0.82);
    --card-strong: rgba(255, 255, 255, 0.90);
    --card-deep: rgba(244, 246, 249, 0.94);

    --bd: #dfe3e8;
    --bd2: #cdd3db;
    --bd3: #b4bcc7;

    --accent: #a85f00;
    --accent-text: #8a4f00;
    --accent2: #9c5800;
    --red: #bb1f0a;

    --hover: rgba(168, 95, 0, 0.09);
    --thumb-bg: #e6eaf0;

    --date-bg1: #eceff4;
    --date-bg2: #f6f8fa;
    --date-fg: #383c43;

    --acc-post: #9c5800;
    --acc-rapide: #1a5fb4;
    --acc-partage: #666d78;
    --acc-doc: #5b32c9;
    --bar-post: #e59a00;
    --bar-rapide: #3d8ae0;
    --bar-partage: #909aa6;

    --ph-post: linear-gradient(135deg, #f4e6cd 0%, #dcbc7e 100%);
    --ph-rapide: linear-gradient(135deg, #dde8f6 0%, #a8c4e6 100%);
    --ph-partage: linear-gradient(135deg, #e9ecf0 0%, #c8ced7 100%);
    --doc-tile: linear-gradient(135deg, #eef1f6 0%, #dbe0e8 100%);
    --doc-tile-fg: #1b1d22;

    --shadow: 0 1px 2px rgba(30, 40, 60, 0.06);
    --chip: rgba(40, 60, 90, 0.06);
    --ok: #1c8a4c;
    --ko: #c0392b;

    --halo: 0 0 5px rgba(250, 251, 253, 0.98), 0 0 11px rgba(250, 251, 253, 0.9), 0 0 20px rgba(250, 251, 253, 0.75);
    --ico-dark: none;
    --ico-light: block;
    --ico-shadow: none;

    --field-bg: #ffffff;
    --field-fg: #1e2024;
    --tag-bg: rgba(40, 60, 90, 0.04);
    --scrollbar: #c2c9d2;
    --overlay: rgba(20, 26, 36, 0.45);
    --topbar-bg: rgba(250, 251, 253, 0.92);
    --topbar-bd: rgba(110, 122, 138, 0.28);
    --topbar-shadow: 0 4px 14px rgba(30, 40, 60, 0.12);
    --lvl-debutant: #2e7d32;
    --lvl-intermediaire: #b26a00;
    --lvl-avance: #c62828;
    --scrim: rgba(250, 251, 253, 0.84);
    --tile-shadow: 0 1px 2px rgba(30, 40, 60, 0.25);
    --ip-ok: #1c7a52;
    --status-ok-fg: #1f5c2a;
    --status-out-fg: #7a4e00;
    --status-ko-fg: #8c2020;
    --srmap: #6d5c00;
    --code-bg: rgba(240, 243, 247, 0.95);
    --th-bg: rgba(168, 95, 0, 0.13);
    --rule-dash: rgba(168, 95, 0, 0.42);
    --chapo-bg: rgba(168, 95, 0, 0.05);
}

/* ─── Clair « gris » ──────────────────────────────────────────────── */
[data-theme="gris"] {
    --page-base: #bfc3ca;
    --veil: rgba(191, 195, 202, 0.34);
    --bg-img: url('fond-clair-gris.avif');

    --fg: #14161a;
    --title: #111316;
    --strong: #0b0d10;
    --text: #2e3238;
    --desc: #3a3f46;
    --muted: #454b54;
    --dim: #4f545d;

    --panel: rgba(198, 202, 209, 0.72);
    --panel-bd: rgba(70, 78, 90, 0.42);
    --card: rgba(212, 216, 222, 0.86);
    --card-strong: rgba(220, 224, 230, 0.92);
    --card-deep: rgba(196, 201, 208, 0.92);

    --bd: #9aa0aa;
    --bd2: #8b919c;
    --bd3: #787f8a;

    --accent: #6b3c00;
    --accent-text: #553000;
    --accent2: #603600;
    --red: #851204;

    --hover: rgba(138, 77, 0, 0.12);
    --thumb-bg: #bcc1c9;

    --date-bg1: #c2c7cf;
    --date-bg2: #d2d6dd;
    --date-fg: #262a30;

    --acc-post: #7a4308;
    --acc-rapide: #154a83;
    --acc-partage: #4e555f;
    --acc-doc: #452399;
    --bar-post: #d98c00;
    --bar-rapide: #2f7bcc;
    --bar-partage: #6f7883;

    --ph-post: linear-gradient(135deg, #d8c4a0 0%, #b98f47 100%);
    --ph-rapide: linear-gradient(135deg, #bccbdf 0%, #7e9cc2 100%);
    --ph-partage: linear-gradient(135deg, #c8ccd3 0%, #a3aab4 100%);
    --doc-tile: linear-gradient(135deg, #ccd0d7 0%, #b3b8c1 100%);
    --doc-tile-fg: #14161a;

    --shadow: 0 1px 3px rgba(20, 25, 35, 0.12);
    --chip: rgba(30, 40, 55, 0.09);
    --ok: #186f3f;
    --ko: #b03427;

    --halo: 0 0 5px rgba(203, 207, 214, 0.98), 0 0 11px rgba(203, 207, 214, 0.9), 0 0 20px rgba(203, 207, 214, 0.75);
    --ico-dark: none;
    --ico-light: block;
    --ico-shadow: none;

    --field-bg: #e8eaee;
    --field-fg: #14161a;
    --tag-bg: rgba(30, 40, 55, 0.05);
    --scrollbar: #9aa0aa;
    --overlay: rgba(15, 20, 28, 0.5);
    --topbar-bg: rgba(203, 207, 214, 0.93);
    --topbar-bd: rgba(70, 78, 90, 0.35);
    --topbar-shadow: 0 4px 14px rgba(20, 25, 35, 0.18);
    --lvl-debutant: #256d29;
    --lvl-intermediaire: #9a5b00;
    --lvl-avance: #ad2020;
    --scrim: rgba(210, 214, 221, 0.86);
    --tile-shadow: 0 1px 2px rgba(20, 25, 35, 0.3);
    --ip-ok: #146346;
    --status-ok-fg: #174a20;
    --status-out-fg: #653f00;
    --status-ko-fg: #78191a;
    --srmap: #5c4d00;
    --code-bg: rgba(190, 195, 203, 0.95);
    --th-bg: rgba(138, 77, 0, 0.16);
    --rule-dash: rgba(107, 60, 0, 0.45);
    --chapo-bg: rgba(138, 77, 0, 0.07);
}

/* ─── Clair « terre » ─────────────────────────────────────────────────
   Fond plus soutenu que les trois autres (crème/sépia, tracés cuivre) :
   son voile est descendu à 0.18 pour ne pas le délaver, et sa zone la
   plus sombre est #e5cfb4 — nettement plus basse que celle de « chaud ».
   Toute l'encre est donc calée sur CETTE zone, pas sur la moyenne du
   fond, sinon les liens et le petit texte décrochent sous 4,5:1. ── */
[data-theme="terre"] {
    --page-base: #f2dfcb;
    --veil: rgba(255, 252, 246, 0.18);
    --bg-img: url('fond-clair-terre.avif');

    --fg: #3d2b22;
    --title: #33231b;
    --strong: #241a13;
    --text: #54413a;
    --desc: #665149;
    --muted: #6d5449;
    --dim: #71574c;

    --panel: rgba(255, 253, 249, 0.70);
    --panel-bd: rgba(145, 74, 19, 0.32);
    --card: rgba(255, 253, 249, 0.76);
    --card-strong: rgba(255, 253, 249, 0.86);
    --card-deep: rgba(250, 243, 233, 0.92);

    --bd: #e0d2bd;
    --bd2: #d0bfa4;
    --bd3: #bba585;

    --accent: #a85a0d;
    --accent-text: #914a13;
    --accent2: #9e5116;
    --red: #b3261e;

    --hover: rgba(145, 74, 19, 0.10);
    --thumb-bg: #ebdfcb;

    --date-bg1: #f0e4d2;
    --date-bg2: #f9f2e6;
    --date-fg: #3d2b22;

    --acc-post: #8c5009;
    --acc-rapide: #2b5f9e;
    --acc-partage: #645047;
    --acc-doc: #5b32c9;
    --bar-post: #e8a000;
    --bar-rapide: #4a90e2;
    --bar-partage: #9a9186;

    --ph-post: linear-gradient(135deg, #f8e8cd 0%, #e3bd80 100%);
    --ph-rapide: linear-gradient(135deg, #dfeaf8 0%, #a6c4e6 100%);
    --ph-partage: linear-gradient(135deg, #f0e9e1 0%, #d0c3b7 100%);
    --doc-tile: linear-gradient(135deg, #f5ecdb 0%, #e6d8c0 100%);
    --doc-tile-fg: #2a1d15;

    --shadow: 0 1px 2px rgba(90, 65, 30, 0.07);
    --chip: rgba(122, 88, 56, 0.08);
    --ok: #15613a;
    --ko: #b3261e;

    --halo: 0 0 5px rgba(255, 252, 246, 0.98), 0 0 11px rgba(255, 252, 246, 0.9), 0 0 20px rgba(255, 252, 246, 0.75);
    --ico-dark: none;
    --ico-light: block;
    --ico-shadow: none;

    --field-bg: #fffdf8;
    --field-fg: #33231b;
    --tag-bg: rgba(122, 88, 56, 0.05);
    --scrollbar: #c6b498;
    --overlay: rgba(38, 26, 20, 0.48);
    --topbar-bg: rgba(255, 252, 246, 0.92);
    --topbar-bd: rgba(145, 74, 19, 0.28);
    --topbar-shadow: 0 4px 14px rgba(90, 65, 30, 0.14);
    --lvl-debutant: #1f6b28;
    --lvl-intermediaire: #8a4f00;
    --lvl-avance: #b02216;
    --scrim: rgba(255, 252, 246, 0.82);
    --tile-shadow: 0 1px 2px rgba(122, 88, 56, 0.3);
    --ip-ok: #15613a;
    --status-ok-fg: #15613a;
    --status-out-fg: #7a4400;
    --status-ko-fg: #8c2020;
    --srmap: #6f570e;
    --code-bg: rgba(248, 242, 233, 0.95);
    --th-bg: rgba(145, 74, 19, 0.14);
    --rule-dash: rgba(145, 74, 19, 0.45);
    --chapo-bg: rgba(145, 74, 19, 0.06);
}

/* ─── Contraste « doux » (retenu) ─────────────────────────────────────
   Rétablit la hiérarchie de gris du site d'origine et une encre neutre
   (le noir teinté chaud lisait « sale »). L'orange redevient franc.
   Sans cet attribut, tout le petit texte passe 4,5:1 (AA strict). ── */
[data-theme="chaud"][data-contrast="doux"] {
    --strong: #22242a; --title: #2b2e35; --text: #4b5058;
    --desc: #5c626b; --muted: #696f77; --dim: #8d939d;
    --accent-text: #a86200; --red: #d42800;
}
[data-theme="neutre"][data-contrast="doux"] {
    --strong: #1e2126; --title: #262a30; --text: #474c54;
    --desc: #585e67; --muted: #656b74; --dim: #888e98;
    --accent-text: #a05c00; --red: #cf2a10;
}
[data-theme="gris"][data-contrast="doux"] {
    --strong: #1a1d22; --title: #23262c; --text: #3f444b;
    --desc: #4d525a; --muted: #4e545c; --dim: #6c727b;
    --accent-text: #7d4600; --red: #a81c08;
}
/* « terre » adoucit moins que les autres : son fond descend jusqu'à
   #e5cfb4, donc éclaircir l'encre autant que sur « chaud » ferait passer
   --dim, --accent-text et --red sous 4,5:1. Valeurs calées au plus clair
   qui tienne encore AA sur cette zone. */
[data-theme="terre"][data-contrast="doux"] {
    --strong: #24211f; --title: #2f2a26; --text: #4d4741;
    --desc: #5b544d; --muted: #67605a; --dim: #746c65;
    --accent-text: #8f4a08; --red: #b02412;
}

/* ═══ Règles d'application ════════════════════════════════════════════
   Tout le reste des couleurs est consommé via var() directement dans
   style.css / topbar.css / pages.css / posts.css / docs.css. Seules
   restent ici les règles qui n'existent que pour la bascule de thème.
   ═══════════════════════════════════════════════════════════════════ */

/* Bascule des icônes de type de post : les deux <img> sont rendues par
   includes/post_item.php, le thème en masque une (cf. README du handoff).
   Sélecteur `img.ico-*` volontairement : `.nf_thumb img` (0,1,1) pose déjà
   display:block, une simple classe (0,1,0) perdrait et laisserait les deux
   icônes visibles. À spécificité égale, themes.css gagne car chargé en dernier. */
img.ico-dark  { display: var(--ico-dark); filter: var(--ico-shadow); }
img.ico-light { display: var(--ico-light); }

/* Halo de lisibilité sur le logo et le menu : laisse voir le fond clair
   sans poser de bandeau opaque par-dessus. */
.header_titre,
.header_titre_compact,
.main_nav a,
.topbar_compact_menu a { text-shadow: var(--halo); }

/* Bouton de bascule sombre / clair (includes/_menu_items.php) */
.theme_toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin: 0 6px;
    padding: 0;
    background: none;
    border: 1px solid var(--bd3);
    border-radius: 4px;
    color: var(--accent-text);
    font-size: 15px;
    line-height: 1;
    cursor: pointer;
    transition: color 0.3s, border-color 0.3s, background 0.3s;
}
.theme_toggle:hover {
    color: var(--red);
    border-color: var(--accent);
    background: var(--hover);
}
.theme_toggle_icon { text-shadow: var(--halo); }
/* L'icône affichée dépend du thème : lune en sombre, soleil en clair.
   --ico-dark / --ico-light valent block ou none selon le thème actif. */
.theme_toggle_sun { display: var(--ico-light); }
.theme_toggle_moon { display: var(--ico-dark); }
/* Le libellé porte le nom accessible du bouton, il n'est pas affiché */
.theme_toggle_label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}
