/* AllenVoice, aperçu E-ameliore-Impeccable-v1.2 : bascule de thème et thème sombre « Comptoir de nuit ».
   Le sombre est composé à partir des mêmes rôles que le clair (style.css) : on remappe les variables,
   on ne réinvente pas les composants. Aucun halo, aucun flou, aucune ombre colorée.
   Le bloc SOMBRE est écrit une seule fois avec le préfixe @D ; theme_css.py l'émet deux fois :
   1) html[data-theme="dark"] (choix Sombre, ou Système résolu en sombre par le script de tête) ;
   2) @media (prefers-color-scheme: dark) + html:not([data-theme]) : repli sans JavaScript. */

/* ============================== COMMUN ============================== */
/* Rendus jumeaux : rendu « jour » par défaut, rendu de nuit en sombre. */
.th-d { display: none !important; }

/* Bascule : visible seulement si le script de tête a tourné (sinon le site suit le système). */
.theme { position: relative; display: none; }
html[data-theme] .theme { display: block; }
.theme-btn { display: grid; place-items: center; width: 44px; height: 44px; padding: 0; border-radius: var(--r-sm); border: 1px solid var(--line-strong); background: transparent; color: var(--ink); cursor: pointer; transition: background-color .15s, border-color .15s; }
.theme-btn:hover { background: var(--paper); border-color: var(--ink); }
.theme-btn svg { width: 20px; height: 20px; grid-area: 1 / 1; }
.theme-btn .i-sombre, .theme-btn .i-systeme { display: none; }
html[data-theme-pref="sombre"] .theme-btn .i-clair, html[data-theme-pref="systeme"] .theme-btn .i-clair { display: none; }
html[data-theme-pref="sombre"] .theme-btn .i-sombre { display: block; }
html[data-theme-pref="systeme"] .theme-btn .i-systeme { display: block; }
.theme-btn[aria-expanded="true"] { background: var(--paper); border-color: var(--ink); }
.theme-pop { position: absolute; right: 0; top: calc(100% + 8px); z-index: 60; width: 240px; padding: 6px; border-radius: var(--r-md); background: var(--paper); border: 1px solid var(--edge); }
.theme-pop fieldset { margin: 0; padding: 0; border: 0; min-width: 0; display: grid; gap: 2px; }
.theme-pop legend { padding: 8px 12px; font: 620 .85rem/1.2 var(--font); color: var(--ink-3); }
.theme-opt { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 12px; border-radius: 10px; font: 600 .95rem/1.25 var(--font); color: var(--ink); cursor: pointer; transition: background-color .15s; flex-wrap: wrap; }
.theme-opt:hover { background: var(--line-2); }
.theme-opt:has(input:checked) { background: var(--stone); }
.theme-opt svg { width: 18px; height: 18px; flex-shrink: 0; color: var(--ink-2); }
.theme-opt small { flex-basis: 100%; padding-left: 56px; margin-top: -4px; font-weight: 450; font-size: .8rem; color: var(--ink-3); }
.theme-pop input[type="radio"] { appearance: none; -webkit-appearance: none; width: 18px; height: 18px; min-height: 0; margin: 0; padding: 0; flex-shrink: 0; border: 1.5px solid var(--line-strong); border-radius: 50%; box-shadow: none; background: transparent; cursor: pointer; }
.theme-pop input[type="radio"]:checked { border-color: var(--blue); background: var(--blue); box-shadow: inset 0 0 0 3.5px var(--paper); }
.theme-pop input[type="radio"]:focus { box-shadow: none; }
.theme-pop input[type="radio"]:checked:focus { box-shadow: inset 0 0 0 3.5px var(--paper); }
.theme-pop input[type="radio"]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 50%; }
@media (max-width: 600px) { .header-cta { gap: 8px; } }
@media (min-width: 961px) and (max-width: 1100px) {
  .header .wrap { gap: 12px; }
  .nav { gap: 0; }
  .nav a { padding: 9px 9px; white-space: nowrap; }
  .header-cta { gap: 8px; }
  .header-cta .btn { white-space: nowrap; padding-left: 14px; padding-right: 14px; }
}
@media (max-width: 360px) { .theme-pop { width: min(240px, calc(100vw - 24px)); } }

/* États désactivés (prévus pour les deux thèmes). */
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
input:disabled, textarea:disabled, select:disabled { background: var(--counter); color: var(--ink-3); border-style: dashed; cursor: not-allowed; }

/* Changement de thème : fondu court, seulement à la bascule, jamais au chargement ni en mouvement réduit. */
html.theme-fade, html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after {
  transition: background-color .3s ease, color .3s ease, border-color .3s ease, fill .3s ease, stroke .3s ease !important;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-fade, html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after { transition: none !important; }
}

/* ============================== SOMBRE ============================== */
/* 1) Choix explicite ou mode Système résolu par le script de tête */

html[data-theme="dark"] {
  color-scheme: dark;
  --stone: #0E1526; --counter: #141D33; --edge: #2E3A5A; --paper: #19233D; --field-bg: #0A1020;
  --sheet: #0E1526; --sheet-2: #141D33; --well: #0E1526; --seam: #2E3A5A; /* v1.2 : en sombre, mêmes valeurs qu'en v1.1 (pierre, comptoir, arête) */
  --ink: #EEF1F7; --ink-2: #C7CEDD; --ink-3: #A3ACC1;
  --blue: #2F52E6; --blue-hover: #3F60EE; --on-blue: #FFFFFF; --link: #AEBFFF; --focus: #AEBFFF;
  --sage-2: #1D3227; --sage-ink: #BFE0C8; --sage-line: rgba(191, 224, 200, .3);
  --line: rgba(214, 224, 255, .16); --line-2: rgba(214, 224, 255, .08); --line-strong: #7F8DAB;
  --error: #FF9B8F;
  --bubble: #212D4B;
  --band-bg: #0A1124; --band-ink: #EEF1F7; --band-ink-2: #C7CEDD; --band-line: rgba(214, 224, 255, .16);
  --scrim: rgba(3, 6, 14, .6);
}
html[data-theme="dark"] a:hover { color: var(--ink); }
html[data-theme="dark"] .skip, html[data-theme="dark"] .skip:focus { background: var(--link); color: #0E1526; }
html[data-theme="dark"] .band { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
html[data-theme="dark"] .ledger, html[data-theme="dark"] .slip, html[data-theme="dark"] .next, html[data-theme="dark"] .cases, html[data-theme="dark"] .faq, html[data-theme="dark"] .verifs, html[data-theme="dark"] .scope { border-top-color: var(--line-strong); }
html[data-theme="dark"] .case.is-open .case-btn .pm { color: #0E1526; }
html[data-theme="dark"] .th-l { display: none !important; }
html[data-theme="dark"] .th-d { display: block !important; }

/* 2) Repli sans JavaScript : le site suit prefers-color-scheme */
@media (prefers-color-scheme: dark) {

html:not([data-theme]) {
  color-scheme: dark;
  --stone: #0E1526; --counter: #141D33; --edge: #2E3A5A; --paper: #19233D; --field-bg: #0A1020;
  --sheet: #0E1526; --sheet-2: #141D33; --well: #0E1526; --seam: #2E3A5A; /* v1.2 : en sombre, mêmes valeurs qu'en v1.1 (pierre, comptoir, arête) */
  --ink: #EEF1F7; --ink-2: #C7CEDD; --ink-3: #A3ACC1;
  --blue: #2F52E6; --blue-hover: #3F60EE; --on-blue: #FFFFFF; --link: #AEBFFF; --focus: #AEBFFF;
  --sage-2: #1D3227; --sage-ink: #BFE0C8; --sage-line: rgba(191, 224, 200, .3);
  --line: rgba(214, 224, 255, .16); --line-2: rgba(214, 224, 255, .08); --line-strong: #7F8DAB;
  --error: #FF9B8F;
  --bubble: #212D4B;
  --band-bg: #0A1124; --band-ink: #EEF1F7; --band-ink-2: #C7CEDD; --band-line: rgba(214, 224, 255, .16);
  --scrim: rgba(3, 6, 14, .6);
}
html:not([data-theme]) a:hover { color: var(--ink); }
html:not([data-theme]) .skip, html:not([data-theme]) .skip:focus { background: var(--link); color: #0E1526; }
html:not([data-theme]) .band { border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
html:not([data-theme]) .ledger, html:not([data-theme]) .slip, html:not([data-theme]) .next, html:not([data-theme]) .cases, html:not([data-theme]) .faq, html:not([data-theme]) .verifs, html:not([data-theme]) .scope { border-top-color: var(--line-strong); }
html:not([data-theme]) .case.is-open .case-btn .pm { color: #0E1526; }
html:not([data-theme]) .th-l { display: none !important; }
html:not([data-theme]) .th-d { display: block !important; }
}

/* Modes à contraste forcé : on rend la main au bouton radio natif. */
@media (forced-colors: active) { .theme-pop input[type="radio"] { appearance: auto; -webkit-appearance: auto; background: none; box-shadow: none; } }
