/* Palette de thèmes d'alpha : bouton dans l'en-tête et panneau de vignettes.
   Les couleurs viennent des rôles du thème en cours, avec repli sur les rôles des feuilles Études et Véhicules
   électriques, puis sur les valeurs d'origine : la palette se lit sur toutes les pages. Les vignettes sont à la fin. */
.palette, .palette__panneau {
  --pal-fond: var(--carte, var(--card, #ffffff));
  --pal-texte: var(--texte, var(--txt, #25313b));
  --pal-doux: var(--texte-doux, var(--soft, #5a6a75));
  --pal-bord: var(--bord, var(--line, #dfe5ea));
  --pal-accent: var(--accent, #2f6f94);
  --pal-doux-fond: var(--accent-doux, var(--tint, #e3edf3));
  --pal-rayon: min(var(--rayon, 14px), 18px);
}
.palette { position: relative; display: inline-flex; align-items: center; flex: none; }
.palette__panneau *, .palette__panneau *::before, .palette__panneau *::after { box-sizing: border-box; }
.palette *, .palette *::before, .palette *::after { box-sizing: border-box; }
.palette__bouton {
  display: inline-grid; place-items: center; width: 40px; height: 40px; padding: 0; margin: 0;
  border: 1px solid var(--pal-bord); border-radius: 50%; background: transparent; color: var(--pal-doux);
  cursor: pointer; -webkit-tap-highlight-color: transparent; font: inherit;
}
.palette__bouton:hover, .palette__bouton[aria-expanded="true"] { color: var(--pal-accent); border-color: var(--pal-accent); background: var(--pal-doux-fond); }
.palette__bouton:focus-visible, .palette__theme:focus-visible { outline: 2px solid var(--pal-accent); outline-offset: 2px; }
.palette__icone { display: block; width: 20px; height: 20px; }
/* Sur le bandeau sombre du tableau */
.palette--entete .palette__bouton { color: #ccd6e0; border-color: rgba(255, 255, 255, .28); }
.palette--entete .palette__bouton:hover, .palette--entete .palette__bouton[aria-expanded="true"] { color: #ffffff; border-color: rgba(255, 255, 255, .6); background: rgba(255, 255, 255, .12); }
.palette--entete .palette__bouton:focus-visible { outline-color: #ffffff; }

.palette__panneau {
  position: fixed; z-index: 1000; top: 56px; left: 8px; width: min(360px, calc(100vw - 16px)); max-height: calc(100vh - 72px);
  overflow-y: auto; overscroll-behavior: contain; padding: 12px; color: var(--pal-texte); background: var(--pal-fond);
  border: 1px solid var(--pal-bord); border-radius: var(--pal-rayon);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 16px 40px rgba(0, 0, 0, .22);
  font: 14px/1.4 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; text-align: left;
}
.palette__panneau[hidden] { display: none; }
.palette__tete { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 4px 10px; }
.palette__titre { font-weight: 700; font-size: 15px; color: var(--pal-texte); }
.palette__etat { font-size: 12.5px; color: var(--pal-doux); min-height: 1.4em; }
.palette__liste { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; grid-template-columns: 1fr; }
.palette__liste li { margin: 0; padding: 0; }
.palette__theme {
  position: relative; display: grid; grid-template-columns: 60px 1fr; gap: 2px 12px; align-items: center; width: 100%;
  min-height: 52px; padding: 7px 10px; margin: 0; text-align: left; font: inherit; color: var(--pal-texte);
  background: transparent; border: 1px solid var(--pal-bord); border-radius: calc(var(--pal-rayon) * .7); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.palette__theme:hover { background: var(--pal-doux-fond); border-color: var(--pal-accent); }
.palette__theme[aria-pressed="true"] { border-color: var(--pal-accent); box-shadow: inset 0 0 0 1px var(--pal-accent); background: var(--pal-doux-fond); }
.palette__vignette {
  grid-row: 1 / span 2; position: relative; width: 60px; height: 40px; overflow: hidden; border-radius: 8px;
  background: var(--v1, #f6f8fa); border: 1px solid rgba(128, 128, 128, .35);
}
.palette__vignette i { position: absolute; display: block; }
.palette__vignette .pv-carte { left: 7px; top: 8px; right: 7px; bottom: 7px; border-radius: 5px; background: var(--v2, #ffffff); }
.palette__vignette .pv-ligne { left: 13px; top: 15px; width: 26px; height: 4px; border-radius: 2px; background: var(--v4, #25313b); }
.palette__vignette .pv-ligne2 { left: 13px; top: 23px; width: 17px; height: 3px; border-radius: 2px; background: var(--v4, #25313b); opacity: .55; }
.palette__vignette .pv-point { right: 12px; bottom: 11px; width: 10px; height: 10px; border-radius: 50%; background: var(--v3, #2f6f94); }
.palette__vignette--auto { background: linear-gradient(135deg, #f6f8fa 0 50%, #141a20 50% 100%); }
.palette__vignette--auto i { display: none; }
.palette__nom { font-weight: 700; font-size: 14px; align-self: end; padding-right: 22px; }
.palette__desc { font-size: 12.5px; line-height: 1.35; color: var(--pal-doux); align-self: start; }
.palette__coche { display: none; position: absolute; top: 8px; right: 9px; width: 16px; height: 16px; color: var(--pal-accent); }
.palette__theme[aria-pressed="true"] .palette__coche { display: block; }
@media (min-width: 560px) {
  .palette__panneau { width: 420px; }
  .palette__liste { grid-template-columns: 1fr 1fr; }
  .palette__panneau { width: 640px; max-width: calc(100vw - 16px); }
}
/* Téléphone : un panneau qui monte du bas de l'écran, toujours entier, la page derrière ne défile pas. */
@media (max-width: 559px) {
  .palette__panneau {
    left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; max-width: none;
    max-height: 85vh !important; max-height: 85dvh !important; border-radius: 18px 18px 0 0; border-bottom: 0;
    padding: 8px 14px calc(16px + env(safe-area-inset-bottom));
    box-shadow: 0 -8px 40px rgba(0, 0, 0, .28), 0 0 0 100vmax rgba(10, 16, 22, .32);
  }
  .palette__tete { padding-top: 14px; position: relative; }
  .palette__tete::before { content: ""; position: absolute; top: 2px; left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: 2px; background: var(--pal-bord); }
  html.palette-ouverte, html.palette-ouverte body { overflow: hidden; }
}
@media (prefers-reduced-motion: no-preference) {
  .palette__panneau:not([hidden]) { animation: palette-entree .14s ease-out; }
  @keyframes palette-entree { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}

/* Vignettes des thèmes (produites par scripts/themes/generer.py) : quatre couleurs par thème. */
.palette__vignette--alpha { --v1: #f6f8fa; --v2: #ffffff; --v3: #2f6f94; --v4: #25313b; }
.palette__vignette--sombre { --v1: #141a20; --v2: #1f272f; --v3: #84bbdc; --v4: #e6ebef; }
.palette__vignette--minimaliste { --v1: #f7f7f7; --v2: #ffffff; --v3: #4d5b66; --v4: #4a4a4a; }
.palette__vignette--verreclair { --v1: #eef1f8; --v2: #fbfcff; --v3: #4861b7; --v4: #3a4866; }
.palette__vignette--design { --v1: #f3f3f3; --v2: #ffffff; --v3: #455fa1; --v4: #4a4a4a; }
.palette__vignette--fengshui { --v1: #eceeea; --v2: #f7f8f5; --v3: #436c54; --v4: #404741; }
.palette__vignette--laurentides { --v1: #edf2ef; --v2: #fbfcfb; --v3: #1d5a3e; --v4: #2f4e3d; }
.palette__vignette--cotenord { --v1: #e7ecf0; --v2: #f6f8fa; --v3: #1d5c87; --v4: #33485b; }
.palette__vignette--nunavut { --v1: #0b111d; --v2: #121a29; --v3: #3fdc9b; --v4: #9abee2; }
.palette__vignette--mileend { --v1: #d7d8da; --v2: #eff0f1; --v3: #42596a; --v4: #37393c; }
.palette__vignette--hochelaga { --v1: #dedfe1; --v2: #f2f2f3; --v3: #245171; --v4: #3a3c3f; }
.palette__vignette--tungstene { --v1: #1a1b1d; --v2: #222325; --v3: #e3a46b; --v4: #c4c6c8; }
.palette__vignette--contraste { --v1: #ffffff; --v2: #ffffff; --v3: #0a3d91; --v4: #111111; }

/* Styles d'affichage (src/styles.php) : vignettes aux couleurs de chaque style. */
.palette__vignette--sty-f { --v1: #f6f6f3; --v2: #ffffff; --v3: #2b5a80; --v4: #1b232c; }
.palette__vignette--sty-m { --v1: #ffffff; --v2: #ffffff; --v3: #2b5a80; --v4: #2d363f; }
.palette__vignette--sty-m .pv-carte { border-radius: 0; border-bottom: 1px solid #e2e2e0; }
.palette__vignette--sty-d { --v1: #0c0e12; --v2: #12151b; --v3: #82b1ff; --v4: #e1e5ec; }
.palette__vignette--sty-d .pv-carte { border-radius: 2px; }
.palette__vignette--sty-e { --v1: #ffffff; --v2: #ffffff; --v3: #d7261c; --v4: #0b0b0b; }
.palette__vignette--sty-e .pv-carte { border-radius: 0; border-top: 2px solid #0b0b0b; }
.palette__vignette--sty-e .pv-point { border-radius: 0; }

/* Logo d'alpha : quatre dessins du même mot, une seule encre. */
.palette__sous { margin: 14px 4px 8px; font-size: 12.5px; color: var(--pal-doux); }
.palette__logos { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.palette__logo {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 42px; margin: 0; padding: 0 6px;
  font: 760 17px/1 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; letter-spacing: -.01em;
  color: var(--pal-texte); background: transparent; border: 1px solid var(--pal-bord); border-radius: calc(var(--pal-rayon) * .7); cursor: pointer;
}
.palette__logo:hover { background: var(--pal-doux-fond); border-color: var(--pal-accent); }
.palette__logo[aria-pressed="true"] { border-color: var(--pal-accent); box-shadow: inset 0 0 0 1px var(--pal-accent); background: var(--pal-doux-fond); }
.palette__logo:focus-visible { outline: 2px solid var(--pal-accent); outline-offset: 2px; }
.af-logo-b { font-family: Georgia, "Times New Roman", serif !important; font-style: italic; font-weight: 600 !important; letter-spacing: 0 !important; }
.af-logo-c { display: inline-flex; align-items: center; gap: 7px; }
.af-logo-c .af-logo-sceau { display: inline-grid; place-items: center; width: 22px; height: 22px; border: 1.5px solid currentColor; border-radius: 6px; font: 600 14px/1 Georgia, serif; font-style: normal; }
.af-logo-d { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace !important; font-weight: 600 !important; letter-spacing: -.02em !important; }
.af-logo-d .af-logo-curseur { color: var(--accent, #2b5a80); }
@media (max-width: 559px) { .palette__logos { grid-template-columns: 1fr 1fr; } }

/* Accueils Terminal et Éditorial : bouton fin, à la mesure de leur en-tête. */
.ad-barre .palette__bouton, .ae-bar .palette__bouton { width: 32px; height: 30px; border-radius: 7px; }
.ae-bar .palette__bouton { border-radius: 0; border-color: #0b0b0b; color: #0b0b0b; }
.ad-barre .palette__bouton { border-radius: 4px; }
.ad-barre .palette__icone, .ae-bar .palette__icone { width: 16px; height: 16px; }
.ad-html .palette__panneau { --pal-fond: #12151b; --pal-texte: #e1e5ec; --pal-doux: #a9b1bd; --pal-bord: #222731; --pal-accent: #82b1ff; --pal-doux-fond: #191d25; }

/* Langue, et sections ajoutées par une page (vues d'un sujet) */
.palette__langues { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.palette__langue, .palette__vue {
  display: flex; align-items: center; justify-content: center; height: 34px; padding: 0 8px; font-size: 13.5px; color: var(--pal-texte);
  text-decoration: none; border: 1px solid var(--pal-bord); border-radius: calc(var(--pal-rayon) * .7);
}
a.palette__langue:hover, a.palette__vue:hover { background: var(--pal-doux-fond); border-color: var(--pal-accent); color: var(--pal-accent); }
span.palette__langue, .palette__vue[aria-current] { border-color: var(--pal-accent); box-shadow: inset 0 0 0 1px var(--pal-accent); background: var(--pal-doux-fond); }
.palette__vues { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
@media (max-width: 559px) { .palette__langues { grid-template-columns: 1fr 1fr; } }

/* Couleurs (teintes) et bouton Images (src/themes.php, palette_bouton). */
:root[data-style="d"] .palette__teintes, :root[data-style="e"] .palette__teintes { display: none; }
.palette__pastilles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.palette__teinte { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--pal-bord); border-radius: 9px;
  background: transparent; color: var(--pal-texte); font: inherit; font-size: 13px; cursor: pointer; text-align: left; }
.palette__teinte:hover { border-color: var(--pal-accent); }
.palette__teinte[aria-pressed="true"] { border-color: var(--pal-accent); box-shadow: inset 0 0 0 1px var(--pal-accent); font-weight: 600; }
.palette__teinte:focus-visible, .palette__images:focus-visible { outline: 2px solid var(--pal-accent); outline-offset: 2px; }
.palette__pastille { position: relative; flex: none; width: 22px; height: 22px; border-radius: 50%; overflow: hidden; border: 1px solid rgba(0, 0, 0, .12); }
.palette__pastille i { position: absolute; inset: 0; }
.palette__pastille i + i { inset: 50% 0 0 0; }
.palette__pastille--alpha i { background: #f6f6f3; } .palette__pastille--alpha i + i { background: #2b5a80; }
.palette__pastille--ardoise i { background: #f1f3f5; } .palette__pastille--ardoise i + i { background: #3d5a73; }
.palette__pastille--brume i { background: #f2f5f3; } .palette__pastille--brume i + i { background: #3f6f5e; }
.palette__pastille--lavande i { background: #f6f4f9; } .palette__pastille--lavande i + i { background: #6a4f9a; }
.palette__pastille--aurore i { background: #fbf6f3; } .palette__pastille--aurore i + i { background: #a84a35; }
.palette__pastille--minuit i { background: #14181d; } .palette__pastille--minuit i + i { background: #8fb9da; }
.palette__images { display: flex; align-items: center; gap: 10px; width: 100%; margin-top: 12px; padding: 8px 10px; border: 1px solid var(--pal-bord);
  border-radius: 9px; background: transparent; color: var(--pal-texte); font: inherit; cursor: pointer; text-align: left; }
.palette__images-t { flex: 1; display: grid; }
.palette__images-t strong { font-size: 13.5px; }
.palette__images-t small { font-size: 12px; color: var(--pal-doux); }
.palette__images-etat { font-size: 12.5px; color: var(--pal-doux); min-width: 64px; text-align: right; }
.palette__interrupteur { position: relative; flex: none; width: 34px; height: 20px; border-radius: 999px; background: var(--pal-bord); transition: background .15s; }
.palette__interrupteur i { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .15s; }
.palette__images[aria-pressed="true"] .palette__interrupteur { background: var(--pal-accent); }
.palette__images[aria-pressed="true"] .palette__interrupteur i { transform: translateX(14px); }
@media (prefers-reduced-motion: reduce) { .palette__interrupteur, .palette__interrupteur i { transition: none; } }
