/* Jeux de couleurs intégrés d'Osmium (liste : osmiumThemes() dans System/theme.php).
   Thème actif : <meta name="osmium-theme" content="…"> ajouté par importElement() ; « cobalt » = palette de global.css.
   Un thème personnalisé n'est pas ici : ses variables sont générées par System/theme.php (<style id="osmium-theme-perso">).
   Les couleurs d'accent (étincelle, aegis-valide/alerte/ardoise) ne changent pas. */

/* Émeraude (palette Cobalt, teinte tournée) */
html:has(meta[name="osmium-theme"][content="emeraude"]) {
    --sentinel-abysse: #0C261E;
    --sentinel-rade: #113E2E;
    --sentinel-vigie: #19543F;
    --sentinel-rempart: #216C51;
    --sentinel-bastion: #2C8464;
    --sentinel-marine: #3A9C78;
    --sentinel-faisceau: #4DB08B;
    --sentinel-reflet: #67C49F;
    --sentinel-brume: #8ED6BA;
    --sentinel-ciel-voile: #BDE8D6;
    --horizon-profondeur: #0F502C;
    --horizon-courant: #13693A;
    --horizon-lagune: #178347;
    --horizon-signal: #1C9C52;
    --horizon-eclat: #25B761;
    --horizon-azur: #36CE73;
    --horizon-vague: #54E08B;
    --horizon-ecume: #7AE9A4;
    --horizon-vapeur: #A7F1C3;
    --horizon-givre: #D4F8E1;
    --aegis-encre: #11442F;
    --aegis-profond: #186746;
    --aegis-primaire: #238D5D;
    --aegis-survol: #35AF74;
    --aegis-secondaire: #65CA96;
    --aegis-teinte: #ACE3C7;
    --aegis-pale: #E9F7F0;
}

/* Sombre : gris neutres + accent bleu, sans motif (classique) */
html:has(meta[name="osmium-theme"][content="sombre"]) {
    --sentinel-abysse: #0D1117;
    --sentinel-rade: #161B22;
    --sentinel-vigie: #1C2128;
    --sentinel-rempart: #262C36;
    --sentinel-bastion: #30363D;
    --sentinel-marine: #3D444D;
    --sentinel-faisceau: #545D68;
    --sentinel-reflet: #6E7681;
    --sentinel-brume: #8B949E;
    --sentinel-ciel-voile: #C9D1D9;
    --horizon-profondeur: #0C2D6B;
    --horizon-courant: #0D419D;
    --horizon-lagune: #1158C7;
    --horizon-signal: #1F6FEB;
    --horizon-eclat: #2F81F7;
    --horizon-azur: #388BFD;
    --horizon-vague: #58A6FF;
    --horizon-ecume: #79C0FF;
    --horizon-vapeur: #A5D6FF;
    --horizon-givre: #CAE8FF;
    --aegis-encre: #161B22;
    --aegis-profond: #0D1117;
    --aegis-primaire: #30363D;
    --aegis-survol: #3D444D;
    --aegis-secondaire: #8B949E;
    --aegis-teinte: #B1BAC4;
    --aegis-pale: #E6EDF3;
    --bouton-fond: #2F81F7;
    --bouton-survol: #58A6FF;
    --bouton-texte: #FFFFFF;
    --bouton-rayon: 8px;
    --contour-couleur: #8B949E;
    --contour-force: 1.4;
    --contour-rayon: 12px;
}

/* Clair : fond blanc, textes foncés, accent bleu, sans motif.
   Les échelles sont INVERSÉES : « abysse » est la couleur de fond la plus claire, « pale » le texte le plus foncé. */
html:has(meta[name="osmium-theme"][content="clair"]) {
    color-scheme: light;
    --sentinel-abysse: #F6F8FA;
    --sentinel-rade: #FFFFFF;
    --sentinel-vigie: #FFFFFF;
    --sentinel-rempart: #E7EBEF;
    --sentinel-bastion: #D0D7DE;
    --sentinel-marine: #AFB8C1;
    --sentinel-faisceau: #8C959F;
    --sentinel-reflet: #6E7781;
    --sentinel-brume: #59636E;
    --sentinel-ciel-voile: #424A53;
    --horizon-profondeur: #DDF4FF;
    --horizon-courant: #B6E3FF;
    --horizon-lagune: #80CCFF;
    --horizon-signal: #54AEFF;
    --horizon-eclat: #218BFF;
    --horizon-azur: #0969DA;
    --horizon-vague: #0550AE;
    --horizon-ecume: #0550AE;
    --horizon-vapeur: #033D8B;
    --horizon-givre: #0A3069;
    --aegis-encre: #FFFFFF;
    --aegis-profond: #F6F8FA;
    --aegis-primaire: #D0D7DE;
    --aegis-survol: #AFB8C1;
    --aegis-secondaire: #6E7781;
    --aegis-teinte: #59636E;
    --aegis-pale: #1F2328;
    --texte-fort: #1F2328;
    --texte: #24292F;
    --voile: #000;
    --bouton-fond: #0969DA;
    --bouton-survol: #218BFF;
    --bouton-texte: #FFFFFF;
    --bouton-rayon: 8px;
    --contour-couleur: #1F2328;
    --contour-force: 0.9;
    --contour-rayon: 12px;
}

/* Sombre, Clair et Auto : fond uni (le motif n'est gardé que si l'utilisateur a choisi sa propre image) */
html:has(meta[name="osmium-theme"][content="sombre"]):not(:has(meta[name="osmium-bg-custom"])),
html:has(meta[name="osmium-theme"][content="clair"]):not(:has(meta[name="osmium-bg-custom"])),
html:has(meta[name="osmium-theme"][content="auto"]):not(:has(meta[name="osmium-bg-custom"])) {
    --osm-bg: none;
    background-color: var(--sentinel-abysse);
}

/* Clair : textes blancs à garder sur les fonds de couleur pleine */
html:has(meta[name="osmium-theme"][content="clair"]) :is(.button-danger, .badge-ok, .app-logout:hover) {
    color: #fff;
}

/* Clair : couleurs du code plus foncées (lisibles sur fond blanc) */
html:has(meta[name="osmium-theme"][content="clair"]) {
    --code-kw: #CF222E;
    --code-str: #0A6C3A;
    --code-num: #953800;
    --code-fn: #0550AE;
    --code-attr: #8250DF;
    --code-builtin: #0E6E78;
    --code-meta: #BF3989;
}

html:has(meta[name="osmium-theme"][content="clair"]) .cm-s-osmium .cm-col0 { color: #0550AE; }
html:has(meta[name="osmium-theme"][content="clair"]) .cm-s-osmium .cm-col1 { color: #0A6C3A; }
html:has(meta[name="osmium-theme"][content="clair"]) .cm-s-osmium .cm-col2 { color: #953800; }
html:has(meta[name="osmium-theme"][content="clair"]) .cm-s-osmium .cm-col3 { color: #8250DF; }
html:has(meta[name="osmium-theme"][content="clair"]) .cm-s-osmium .cm-col4 { color: #BF3989; }
html:has(meta[name="osmium-theme"][content="clair"]) .cm-s-osmium .cm-col5 { color: #0E6E78; }

html:has(meta[name="osmium-theme"][content="clair"]) .nav {
    background: color-mix(in srgb, #fff 85%, transparent);
}

/* --- Auto : Clair ou Sombre selon le réglage de l'appareil (demande du propriétaire, 2026-11-14) ---
   Mêmes valeurs que les blocs « sombre » et « clair » ci-dessus : à garder identiques si on les modifie.
   Le changement se fait tout seul, sans recharger, quand l'appareil passe du mode clair au mode sombre. */
@media (prefers-color-scheme: dark) {
    html:has(meta[name="osmium-theme"][content="auto"]) {
        color-scheme: dark;
        --sentinel-abysse: #0D1117;
        --sentinel-rade: #161B22;
        --sentinel-vigie: #1C2128;
        --sentinel-rempart: #262C36;
        --sentinel-bastion: #30363D;
        --sentinel-marine: #3D444D;
        --sentinel-faisceau: #545D68;
        --sentinel-reflet: #6E7681;
        --sentinel-brume: #8B949E;
        --sentinel-ciel-voile: #C9D1D9;
        --horizon-profondeur: #0C2D6B;
        --horizon-courant: #0D419D;
        --horizon-lagune: #1158C7;
        --horizon-signal: #1F6FEB;
        --horizon-eclat: #2F81F7;
        --horizon-azur: #388BFD;
        --horizon-vague: #58A6FF;
        --horizon-ecume: #79C0FF;
        --horizon-vapeur: #A5D6FF;
        --horizon-givre: #CAE8FF;
        --aegis-encre: #161B22;
        --aegis-profond: #0D1117;
        --aegis-primaire: #30363D;
        --aegis-survol: #3D444D;
        --aegis-secondaire: #8B949E;
        --aegis-teinte: #B1BAC4;
        --aegis-pale: #E6EDF3;
        --bouton-fond: #2F81F7;
        --bouton-survol: #58A6FF;
        --bouton-texte: #FFFFFF;
        --bouton-rayon: 8px;
        --contour-couleur: #8B949E;
        --contour-force: 1.4;
        --contour-rayon: 12px;
    }
}
@media (prefers-color-scheme: light) {
    html:has(meta[name="osmium-theme"][content="auto"]) {
        color-scheme: light;
        --sentinel-abysse: #F6F8FA;
        --sentinel-rade: #FFFFFF;
        --sentinel-vigie: #FFFFFF;
        --sentinel-rempart: #E7EBEF;
        --sentinel-bastion: #D0D7DE;
        --sentinel-marine: #AFB8C1;
        --sentinel-faisceau: #8C959F;
        --sentinel-reflet: #6E7781;
        --sentinel-brume: #59636E;
        --sentinel-ciel-voile: #424A53;
        --horizon-profondeur: #DDF4FF;
        --horizon-courant: #B6E3FF;
        --horizon-lagune: #80CCFF;
        --horizon-signal: #54AEFF;
        --horizon-eclat: #218BFF;
        --horizon-azur: #0969DA;
        --horizon-vague: #0550AE;
        --horizon-ecume: #0550AE;
        --horizon-vapeur: #033D8B;
        --horizon-givre: #0A3069;
        --aegis-encre: #FFFFFF;
        --aegis-profond: #F6F8FA;
        --aegis-primaire: #D0D7DE;
        --aegis-survol: #AFB8C1;
        --aegis-secondaire: #6E7781;
        --aegis-teinte: #59636E;
        --aegis-pale: #1F2328;
        --texte-fort: #1F2328;
        --texte: #24292F;
        --voile: #000;
        --bouton-fond: #0969DA;
        --bouton-survol: #218BFF;
        --bouton-texte: #FFFFFF;
        --bouton-rayon: 8px;
        --contour-couleur: #1F2328;
        --contour-force: 0.9;
        --contour-rayon: 12px;
        --code-kw: #CF222E;
        --code-str: #0A6C3A;
        --code-num: #953800;
        --code-fn: #0550AE;
        --code-attr: #8250DF;
        --code-builtin: #0E6E78;
        --code-meta: #BF3989;
    }
    html:has(meta[name="osmium-theme"][content="auto"]) :is(.button-danger, .badge-ok, .app-logout:hover) { color: #fff; }
    html:has(meta[name="osmium-theme"][content="auto"]) .cm-s-osmium .cm-col0 { color: #0550AE; }
    html:has(meta[name="osmium-theme"][content="auto"]) .cm-s-osmium .cm-col1 { color: #0A6C3A; }
    html:has(meta[name="osmium-theme"][content="auto"]) .cm-s-osmium .cm-col2 { color: #953800; }
    html:has(meta[name="osmium-theme"][content="auto"]) .cm-s-osmium .cm-col3 { color: #8250DF; }
    html:has(meta[name="osmium-theme"][content="auto"]) .cm-s-osmium .cm-col4 { color: #BF3989; }
    html:has(meta[name="osmium-theme"][content="auto"]) .cm-s-osmium .cm-col5 { color: #0E6E78; }
    html:has(meta[name="osmium-theme"][content="auto"]) .nav { background: color-mix(in srgb, #fff 85%, transparent); }
}

/* --- Couleurs du code au choix (Paramètres › Interface › Couleurs du code, 2026-11-25) ---
   Un seul réglage pour tous les outils ; « auto » = pas de balise, le code suit le thème du site (règles ci-dessus).
   Valeurs reprises des PALETTES d'Osmium Markdown (Index/publique-outils/Osmium-Markdown.js, « Nuancier du code ») : à garder identiques.
   Le bloc prend aussi le fond et le texte du style (sinon des couleurs claires sur fond clair seraient illisibles). */
html:has(meta[name="osmium-code-theme"][content="clair"]) {
    --code-fond: #f2f4f7; --code-texte: #000000; --code-numeros: #59636e; --code-op: #57606a;
    --code-kw: #a01ec8; --code-str: #00641e; --code-com: #6e7781; --code-num: #ff0000; --code-fn: #46b4d2;
    --code-tag: #461464; --code-attr: #aa0a0a; --code-builtin: #32745a; --code-meta: #0550ae;
}
html:has(meta[name="osmium-code-theme"][content="sombre"]) {
    --code-fond: #161b22; --code-texte: #e6edf3; --code-numeros: #9da7b3; --code-op: #ff7b72;
    --code-kw: #ff7b72; --code-str: #a5d6ff; --code-com: #8b949e; --code-num: #79c0ff; --code-fn: #d2a8ff;
    --code-tag: #7ee787; --code-attr: #ffa657; --code-builtin: #ffa657; --code-meta: #79c0ff;
}
html:has(meta[name="osmium-code-theme"][content="osmium"]) {
    --code-fond: #0b1a2e; --code-texte: #d6e4f0; --code-numeros: #a3c4dd; --code-op: #ff9e9e;
    --code-kw: #ff9e9e; --code-str: #a3ddf5; --code-com: #7f9bb3; --code-num: #ffc20e; --code-fn: #c9b6ff;
    --code-tag: #7ee2a8; --code-attr: #ffb86b; --code-builtin: #ffb86b; --code-meta: #ffc20e;
}
html:has(meta[name="osmium-code-theme"][content="papier"]) {
    --code-fond: #f1e9da; --code-texte: #2b2620; --code-numeros: #6b5f50; --code-op: #a3301f;
    --code-kw: #a3301f; --code-str: #2f6b2f; --code-com: #8a7f70; --code-num: #8a4b0f; --code-fn: #6b3fa0;
    --code-tag: #2f6b2f; --code-attr: #a35a00; --code-builtin: #a35a00; --code-meta: #8a4b0f;
}
/* Blocs : éditeur et visionneuse (CodeMirror), blocs Markdown recolorés (pre.cm-s-osmium), coloration de secours */
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium,
html:has(meta[name="osmium-code-theme"]) :is(.ex-md, .ed-preview, .wm-md) pre {
    color: var(--code-texte);
    background: var(--code-fond);
}
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .CodeMirror-gutters { background: var(--code-fond); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .CodeMirror-linenumber { color: var(--code-numeros); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .CodeMirror-cursor { border-left-color: var(--code-texte); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium :is(.cm-operator, .cm-bracket) { color: var(--code-op); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .cm-header { color: var(--code-texte); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .cm-col0 { color: var(--code-fn); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .cm-col1 { color: var(--code-str); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .cm-col2 { color: var(--code-num); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .cm-col3 { color: var(--code-attr); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .cm-col4 { color: var(--code-kw); }
html:has(meta[name="osmium-code-theme"]) .cm-s-osmium .cm-col5 { color: var(--code-builtin); }
