/* =====================================================================
   APPLI SALON — Thème paramétrable (base : design « LA CROISÉE DS »)
   Tout est piloté par les variables injectées par index.php selon la
   charte du client (admin > Personnalisation) :
     --couleur-primaire / --couleur-secondaire / --couleur-fond / --texte
     --sur-primaire (texte lisible sur la couleur primaire)
     --police / --rayon-bouton
   Classes body optionnelles : .immersif  .filigrane-defaut  .filigrane-perso
   Les nuances (cartes, bordures, gris) sont dérivées par color-mix,
   donc le thème fonctionne aussi bien en charte claire que sombre.
   ===================================================================== */
@font-face {
  font-family: 'Montserrat';
  font-style: normal;
  font-weight: 400 800;                 /* police variable : couvre 400 -> 800 */
  font-display: swap;
  src: url('fonts/montserrat-latin.woff2') format('woff2');
}

:root {
  /* Nuances dérivées de la charte (aucune couleur codée en dur) */
  --primaire-fonce: color-mix(in srgb, var(--couleur-primaire) 82%, #000);
  --panneau:     color-mix(in srgb, var(--couleur-fond) 94%, var(--texte));
  --gris-clair:  color-mix(in srgb, var(--couleur-fond) 88%, var(--texte));
  --bordure:     color-mix(in srgb, var(--couleur-fond) 82%, var(--texte));
  --texte-doux:  color-mix(in srgb, var(--texte) 62%, var(--couleur-fond));
  --ombre-primaire: color-mix(in srgb, var(--couleur-primaire) 30%, transparent);
}

/* ---------- Base ---------- */
html, body { height: 100%; overscroll-behavior: none; }
body {
  background: var(--couleur-fond) !important;
  color: var(--texte) !important;
  font-family: var(--police, system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif) !important;
  -webkit-font-smoothing: antialiased;
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
* { text-wrap: pretty; }

/* Remise à plat des utilitaires Tailwind vers les nuances de la charte */
.bg-slate-900 { background: var(--couleur-fond) !important; }
.bg-slate-800 { background: var(--panneau) !important; }
.bg-slate-700 { background: var(--gris-clair) !important; color: var(--texte) !important; }
.bg-slate-600 { background: var(--gris-clair) !important; }
.text-white   { color: var(--texte); }
.border-slate-700, .border-slate-600 { border-color: var(--bordure) !important; }
.text-slate-300, .text-slate-400 { color: var(--texte-doux) !important; }
.text-slate-500 { color: color-mix(in srgb, var(--texte) 45%, var(--couleur-fond)) !important; }
.text-slate-700 { color: color-mix(in srgb, var(--texte) 80%, var(--couleur-fond)) !important; }
.accent-secondaire { color: var(--couleur-secondaire) !important; }
.texte-primaire { color: var(--couleur-primaire) !important; }
.bordure-primaire { border-color: var(--couleur-primaire) !important; }

header { position: relative; z-index: 5; }
main, header { position: relative; z-index: 1; }

/* Navigation entre pages */
.page { display: none; }
.page.active { display: flex; }

/* ---------- Titres : grammaire typographique du storyboard ---------- */
h1, .contenu-riche h1 { font-weight: 800; letter-spacing: -0.02em; line-height: 1.02; }
h2, .contenu-riche h2 { font-weight: 800; letter-spacing: -0.01em; line-height: 1.06; }
h3 { font-weight: 700; }

/* =====================================================================
   BOUTON PRINCIPAL (forme paramétrable : pilule ou arrondi)
   ===================================================================== */
.btn-primaire {
  background: var(--couleur-primaire);
  color: var(--sur-primaire, #fff);
  border: none; border-radius: var(--rayon-bouton, 0.75rem);
  font-family: inherit; font-weight: 700;
  padding: 0.9rem 2.4rem; font-size: 1.25rem;
  box-shadow: 0 6px 18px var(--ombre-primaire);
  transition: transform .12s ease, background .2s ease, box-shadow .2s ease;
  cursor: pointer;
}
.btn-primaire:hover { background: var(--primaire-fonce); }
.btn-primaire:active { transform: scale(.96); }

/* Boutons secondaires (Annuler, Retour...) : contour discret */
button.bg-slate-700 {
  border-radius: var(--rayon-bouton, 0.75rem) !important;
  font-weight: 600;
  color: var(--texte) !important;
  border: 1.5px solid var(--bordure) !important;
  background: var(--couleur-fond) !important;
}

/* =====================================================================
   ÉCRANS IMMERSIFS (option back-office) : accueil + écrans de contenu
   plein cadre couleur primaire, texte inversé, pilule inversée.
   ===================================================================== */
body.immersif:has(#page-accueil.active),
body.immersif:has(#page-contenu.active) {
  background: var(--couleur-primaire) !important;
  color: var(--sur-primaire, #fff) !important;
}
body.immersif:has(#page-accueil.active) .text-white,
body.immersif:has(#page-contenu.active) .text-white,
body.immersif:has(#page-accueil.active) h1,
body.immersif:has(#page-accueil.active) h2,
body.immersif:has(#page-contenu.active) .contenu-riche { color: var(--sur-primaire, #fff) !important; }

body.immersif:has(#page-accueil.active) .text-slate-300,
body.immersif:has(#page-accueil.active) .text-slate-400,
body.immersif:has(#page-accueil.active) .accent-secondaire,
body.immersif:has(#page-contenu.active) .text-slate-300,
body.immersif:has(#page-contenu.active) .text-slate-400 {
  color: color-mix(in srgb, var(--sur-primaire, #fff) 85%, var(--couleur-primaire)) !important;
}

body.immersif:has(#page-accueil.active) .btn-primaire,
body.immersif:has(#page-contenu.active) .btn-primaire {
  background: var(--sur-primaire, #fff);
  color: var(--couleur-primaire);
  box-shadow: 0 8px 24px rgba(0,0,0,.18);
}
body.immersif:has(#page-accueil.active) .btn-primaire:hover,
body.immersif:has(#page-contenu.active) .btn-primaire:hover {
  background: color-mix(in srgb, var(--sur-primaire, #fff) 94%, var(--couleur-primaire));
}

/* Les diodes gardent leurs couleurs d'état partout (voir plus bas) */

/* =====================================================================
   FILIGRANE DÉCORATIF (option back-office : aucun / motif par défaut /
   image personnalisée téléversée). Rendu via mask => recolorié
   automatiquement selon le fond (texte atténué, ou blanc sur immersif).
   ===================================================================== */
body.filigrane-defaut::before,
body.filigrane-perso::before {
  content: "";
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-color: var(--texte);
  opacity: var(--filigrane-opacite, .06);
  -webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
  -webkit-mask-position: left -60px center, right -40px center;
  mask-position: left -60px center, right -40px center;
  -webkit-mask-size: 320px auto, 300px auto;
  mask-size: 320px auto, 300px auto;
}
body.filigrane-defaut::before {
  -webkit-mask-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='560' viewBox='0 0 200 560' fill='none' stroke='black' stroke-width='3'><rect x='70' y='40' width='60' height='300' rx='14'/><rect x='84' y='70' width='32' height='150' rx='10'/><circle cx='100' cy='260' r='16'/><rect x='92' y='276' width='16' height='60' rx='8'/><path d='M60 360h80M60 380h80'/><rect x='78' y='410' width='44' height='120' rx='10'/><circle cx='100' cy='470' r='10'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='560' viewBox='0 0 200 560' fill='none' stroke='black' stroke-width='3'><rect x='60' y='30' width='90' height='60' rx='12'/><path d='M150 60h30a20 20 0 0 1 0 40h-10'/><rect x='84' y='120' width='40' height='240' rx='12'/><circle cx='104' cy='180' r='14'/><path d='M70 400c40-20 60-20 100 0'/><rect x='80' y='430' width='48' height='90' rx='10'/></svg>");
  mask-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='560' viewBox='0 0 200 560' fill='none' stroke='black' stroke-width='3'><rect x='70' y='40' width='60' height='300' rx='14'/><rect x='84' y='70' width='32' height='150' rx='10'/><circle cx='100' cy='260' r='16'/><rect x='92' y='276' width='16' height='60' rx='8'/><path d='M60 360h80M60 380h80'/><rect x='78' y='410' width='44' height='120' rx='10'/><circle cx='100' cy='470' r='10'/></svg>"),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='560' viewBox='0 0 200 560' fill='none' stroke='black' stroke-width='3'><rect x='60' y='30' width='90' height='60' rx='12'/><path d='M150 60h30a20 20 0 0 1 0 40h-10'/><rect x='84' y='120' width='40' height='240' rx='12'/><circle cx='104' cy='180' r='14'/><path d='M70 400c40-20 60-20 100 0'/><rect x='80' y='430' width='48' height='90' rx='10'/></svg>");
}
body.filigrane-perso::before {
  -webkit-mask-image: var(--filigrane), var(--filigrane);
  mask-image: var(--filigrane), var(--filigrane);
}
/* Sur écrans immersifs : filigrane inversé, un peu plus présent */
body.immersif.filigrane-defaut:has(#page-accueil.active)::before,
body.immersif.filigrane-defaut:has(#page-contenu.active)::before,
body.immersif.filigrane-perso:has(#page-accueil.active)::before,
body.immersif.filigrane-perso:has(#page-contenu.active)::before {
  background-color: var(--sur-primaire, #fff);
  opacity: var(--filigrane-opacite, .10);
}

/* =====================================================================
   ÉCRAN QUIZ (écran signature : bandeau progression, puce chrono,
   rangées de réponses numérotées)
   ===================================================================== */
#quiz-progression { font-weight: 700; font-size: 1rem; color: var(--texte) !important; text-transform: none; }
#page-quiz .w-full.h-2 { height: 12px !important; background: var(--gris-clair) !important; border-radius: 9999px; }
#quiz-chrono-barre { background: var(--couleur-primaire) !important; border-radius: 9999px; }

#quiz-chrono-texte {
  display: inline-flex; align-items: center; gap: .35rem;
  background: var(--couleur-primaire); color: var(--sur-primaire, #fff);
  padding: .3rem .85rem; border-radius: 9999px;
  font-weight: 700; font-size: 1.1rem;
}
#quiz-chrono-texte::before { content: "\23F1"; font-size: 1rem; }

#quiz-question { color: var(--texte) !important; font-weight: 700; line-height: 1.2; }
#quiz-image { border: 1px solid var(--bordure); background: var(--panneau); }

/* Rangées de réponses : carte claire + numéro couleur primaire (compteur CSS) */
#quiz-reponses { counter-reset: rep; }
#quiz-reponses > button {
  position: relative;
  display: flex; align-items: center;
  padding: 1rem 1.25rem 1rem 4.75rem !important;
  background: var(--couleur-fond) !important;
  border: 2px solid var(--bordure) !important;
  border-radius: 14px !important;
  color: var(--texte) !important;
  font-weight: 600;
  transition: border-color .15s ease, background .15s ease, transform .1s ease;
}
#quiz-reponses > button::before {
  counter-increment: rep;
  content: counter(rep);
  position: absolute; left: .55rem; top: 50%; transform: translateY(-50%);
  width: 3.1rem; height: calc(100% - 1rem);
  display: flex; align-items: center; justify-content: center;
  color: var(--couleur-primaire); font-weight: 800; font-size: 1.35rem;
  border-right: 2px solid var(--bordure);
}
#quiz-reponses > button:hover { border-color: var(--couleur-primaire) !important; }
#quiz-reponses > button:active { transform: scale(.99); }

/* Bonne réponse (le JS ajoute !bg-emerald-800 / !border-emerald-500) : vert, universel */
#quiz-reponses > button.\!bg-emerald-800 {
  background: #16A34A !important; border-color: #16A34A !important; color: #FFFFFF !important;
}
#quiz-reponses > button.\!bg-emerald-800::before { color: #FFFFFF; border-right-color: rgba(255,255,255,.5); }
#quiz-reponses > button.\!border-emerald-500::after {
  content: "\2714"; position: absolute; right: 1.1rem;
  width: 2rem; height: 2rem; border-radius: 9999px;
  background: #FFFFFF; color: #16A34A; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}
/* Mauvaise réponse : rouge sémantique (indépendant de la charte) */
#quiz-reponses > button.\!bg-red-900 {
  background: #FDECEC !important; border-color: #DC2626 !important; color: #DC2626 !important;
}
#quiz-reponses > button.\!bg-red-900::before { color: #DC2626; }
#quiz-reponses > button.\!border-red-500::after {
  content: "\2716"; position: absolute; right: 1.1rem;
  width: 2rem; height: 2rem; border-radius: 9999px;
  background: #DC2626; color: #fff; font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
}

/* =====================================================================
   FORMULAIRE CONTACT
   ===================================================================== */
#page-contact h2 { color: var(--texte) !important; }
#page-contact input[type=email],
#page-contact input[type=text] {
  background: var(--panneau) !important;
  border: 1.5px solid var(--bordure) !important;
  color: var(--texte) !important;
  border-radius: 12px !important;
}
#page-contact input::placeholder { color: color-mix(in srgb, var(--texte) 40%, var(--couleur-fond)); }
#page-contact input:focus { border-color: var(--couleur-primaire) !important; background: var(--couleur-fond) !important; }
#ct-optin { accent-color: var(--couleur-primaire); }
.text-red-400 { color: #DC2626 !important; }

/* =====================================================================
   PHOTOBOOTH
   ===================================================================== */
#pb-liste-fonds > * {
  border-radius: 16px !important; overflow: hidden;
  border: 2px solid var(--bordure) !important;
  background: var(--panneau) !important;
  transition: border-color .15s ease, transform .1s ease;
}
#pb-liste-fonds > *:hover { border-color: var(--couleur-primaire) !important; }
#pb-liste-fonds img { border-radius: 14px; }

/* Prise de vue : cadre + coins de visée */
#page-pb-camera > div:first-child {
  border: 3px solid var(--texte);
  border-radius: 20px;
  box-shadow: 0 18px 50px rgba(0,0,0,.25);
}
#page-pb-camera > div:first-child::before,
#page-pb-camera > div:first-child::after {
  content: ""; position: absolute; width: 46px; height: 46px; z-index: 3;
  border: 4px solid var(--couleur-primaire); pointer-events: none;
}
#page-pb-camera > div:first-child::before { top: 14px; left: 14px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
#page-pb-camera > div:first-child::after  { bottom: 14px; right: 14px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
#pb-compte-rebours { color: #fff; text-shadow: 0 4px 20px rgba(0,0,0,.5); }
#pb-canvas { border: 3px solid var(--texte); border-radius: 18px; }

/* =====================================================================
   MERCI
   ===================================================================== */
#page-merci h2 { color: var(--couleur-primaire) !important; }
#merci-message { color: var(--texte) !important; }

/* =====================================================================
   OVERLAYS (documents légaux, verrou, réglages) — cartes sur voile
   ===================================================================== */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  background: color-mix(in srgb, var(--texte) 55%, transparent);
  backdrop-filter: blur(2px);
  display: none; align-items: center; justify-content: center;
}
.overlay.active { display: flex; }
.overlay .bg-slate-800 {
  background: var(--couleur-fond) !important;
  color: var(--texte) !important;
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
  border-radius: 20px !important;
}
.overlay .bg-slate-800 h3,
.overlay .bg-slate-800 .contenu-riche,
.overlay label span { color: var(--texte) !important; }
.overlay input, .overlay select {
  background: var(--panneau) !important;
  border: 1.5px solid var(--bordure) !important;
  color: var(--texte) !important;
  border-radius: 12px !important;
}
.overlay .bg-slate-900 { background: var(--panneau) !important; }

/* =====================================================================
   Rendu des écrans de contenu (WYSIWYG admin)
   ===================================================================== */
.contenu-riche h1 { font-size: 2.6rem; margin-bottom: .5rem; }
.contenu-riche h2 { font-size: 1.9rem; margin-bottom: .5rem; }
.contenu-riche p  { margin-bottom: .75rem; line-height: 1.6; }
.contenu-riche ul { list-style: disc; padding-left: 1.5rem; margin-bottom: .75rem; }
.contenu-riche ol { list-style: decimal; padding-left: 1.5rem; margin-bottom: .75rem; }
.contenu-riche img { max-width: 100%; max-height: 40vh; border-radius: 1rem; margin: 0 auto; }
.contenu-riche .ql-align-center { text-align: center; }
.contenu-riche .ql-align-right  { text-align: right; }
.contenu-riche table { border-collapse: collapse; margin: 0 auto .75rem; width: 100%; }
.contenu-riche td, .contenu-riche th { border: 1px solid var(--bordure); padding: .5rem .75rem; }

/* =====================================================================
   Sélecteur de langue (accueil)
   ===================================================================== */
.btn-langue { background: var(--panneau); border-radius: 16px !important; }
.btn-langue.actif { border-color: var(--couleur-primaire) !important; background: var(--gris-clair); }
body.immersif:has(#page-accueil.active) .btn-langue {
  background: color-mix(in srgb, var(--sur-primaire, #fff) 14%, transparent);
}
body.immersif:has(#page-accueil.active) .btn-langue.actif {
  border-color: var(--sur-primaire, #fff) !important;
  background: color-mix(in srgb, var(--sur-primaire, #fff) 28%, transparent);
}

/* =====================================================================
   Diodes d'état (en-tête) — couleurs d'état universelles
   ===================================================================== */
.diode {
  display: inline-block; width: 12px; height: 12px; border-radius: 9999px;
  background: #C4C4C4; box-shadow: 0 0 6px rgba(0,0,0,.15); transition: background .3s;
}
.diode.verte  { background: #16A34A; box-shadow: 0 0 8px #16A34A88; }
.diode.orange { background: #F59E0B; box-shadow: 0 0 8px #F59E0B88; }
.diode.rouge  { background: #DC2626; box-shadow: 0 0 8px #DC262688; }

/* =====================================================================
   Transitions entre écrans (paramétrables back-office)
   ===================================================================== */
@keyframes pageFondu  { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes pageGlisse { from { opacity: 0; transform: translateX(110px); } to { opacity: 1; transform: none; } }
@keyframes pageZoom   { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }
body.anim-fondu      .page.active { animation: pageFondu  .55s ease-out; }
body.anim-glissement .page.active { animation: pageGlisse .5s  cubic-bezier(.2,.8,.2,1); }
body.anim-zoom       .page.active { animation: pageZoom   .45s cubic-bezier(.2,.8,.2,1); }

/* Effets réponses quiz */
@keyframes bonnePop {
  0% { transform: scale(1); }
  35% { transform: scale(1.04); box-shadow: 0 0 0 6px rgba(22,163,74,.28); }
  100% { transform: scale(1); }
}
@keyframes mauvaisShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); } 40% { transform: translateX(10px); }
  60% { transform: translateX(-6px); }  80% { transform: translateX(6px); }
}
.anim-bonne    { animation: bonnePop .55s ease-out; }
.anim-mauvaise { animation: mauvaisShake .45s ease-in-out; }

/* Flash capture / miroir caméra / spinner */
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
.flash { animation: flash .5s ease-out forwards; }
.miroir { transform: scaleX(-1); }
.spinner {
  width: 36px; height: 36px; border-radius: 9999px; display: inline-block;
  border: 4px solid var(--gris-clair); border-top-color: var(--couleur-primaire);
  animation: tourner .9s linear infinite;
}
@keyframes tourner { to { transform: rotate(360deg); } }


/* =====================================================================
   Panneau d'explication du quiz (coulissant depuis le bas, brief LCDS)
   ===================================================================== */
.quiz-panneau {
  position: fixed; left: 50%; bottom: 0; z-index: 30;
  width: min(64rem, calc(100vw - 3rem)); /* = max-w-5xl : aligne sur le bloc questions */
  background: var(--couleur-fond); color: var(--texte);
  border-top: 6px solid var(--bordure);
  box-shadow: 0 -18px 50px rgba(0,0,0,.25);
  border-radius: 24px 24px 0 0;
  padding: 1.5rem 2rem 1.75rem;
  transform: translate(-50%, 105%);
  transition: transform .35s cubic-bezier(.2,.8,.2,1);
}
.quiz-panneau.ouvert { transform: translate(-50%, 0); }
.quiz-panneau.vert  { border-top-color: #16A34A; background: color-mix(in srgb, #16A34A 8%, var(--couleur-fond)); }
.quiz-panneau.vert  #quiz-panneau-titre { color: #16A34A; }
.quiz-panneau.rouge { border-top-color: #DC2626; background: color-mix(in srgb, #DC2626 7%, var(--couleur-fond)); }
.quiz-panneau.rouge #quiz-panneau-titre { color: #DC2626; }
.quiz-panneau.neutre { border-top-color: var(--couleur-primaire); }

/* CTA a pulsation (brief : bouton massif qui capte l'attention) */
@keyframes pulseCta {
  0%, 100% { transform: scale(1); box-shadow: 0 6px 18px var(--ombre-primaire); }
  50% { transform: scale(1.045); box-shadow: 0 10px 30px var(--ombre-primaire); }
}
.btn-pulse { animation: pulseCta 1.8s ease-in-out infinite; }
.btn-pulse:active { animation: none; }

/* Selecteur de langues discret (fixe en bas a gauche) */
.btn-langue-mini {
  width: 3rem; height: 2.1rem; padding: 2px;
  border: 2px solid transparent; border-radius: 10px;
  background: color-mix(in srgb, var(--texte) 10%, var(--couleur-fond));
  opacity: .75; transition: opacity .2s, border-color .2s;
}
.btn-langue-mini.actif { border-color: var(--couleur-primaire); opacity: 1; }
body.immersif:has(#page-accueil.active) .btn-langue-mini,
body.immersif:has(#page-contenu.active) .btn-langue-mini {
  background: color-mix(in srgb, var(--sur-primaire, #fff) 18%, transparent);
}
body.immersif:has(#page-accueil.active) .btn-langue-mini.actif,
body.immersif:has(#page-contenu.active) .btn-langue-mini.actif { border-color: var(--sur-primaire, #fff); }

/* Zone de saisie question ouverte */
#quiz-ouverte {
  background: var(--panneau) !important;
  border: 1.5px solid var(--bordure) !important;
  color: var(--texte) !important;
  border-radius: 12px !important;
}
#quiz-ouverte:focus { border-color: var(--couleur-primaire) !important; background: var(--couleur-fond) !important; }


/* Les popups (documents legaux...) restent toujours lisibles, meme sur les ecrans immersifs
   ou le texte de la page est force en clair : dans une overlay, on revient au texte du theme */
body.immersif:has(#page-accueil.active) .overlay .contenu-riche,
body.immersif:has(#page-contenu.active) .overlay .contenu-riche,
.overlay .contenu-riche { color: var(--texte) !important; }

/* Idem pour le panneau de gestion (5 appuis logo -> verrou -> reglages ⚙) : en immersif,
   les regles ci-dessus teintaient ses textes en rose pale (melange sur-primaire/primaire).
   Dans une overlay on revient TOUJOURS aux couleurs du theme, lisibles sur le panneau. */
body.immersif:has(#page-accueil.active) .overlay :is(h2, h3, span, label, p, b, div),
body.immersif:has(#page-contenu.active) .overlay :is(h2, h3, span, label, p, b, div) {
  color: var(--texte) !important;
}
body.immersif:has(#page-accueil.active) .overlay :is(.text-slate-300, .text-slate-400),
body.immersif:has(#page-contenu.active) .overlay :is(.text-slate-300, .text-slate-400) {
  color: var(--texte-doux) !important;
}
body.immersif:has(#page-accueil.active) .overlay :is(.text-red-400, #verrou-erreur),
body.immersif:has(#page-contenu.active) .overlay :is(.text-red-400, #verrou-erreur) {
  color: #EF4444 !important;
}
body.immersif:has(#page-accueil.active) .overlay .btn-primaire,
body.immersif:has(#page-contenu.active) .overlay .btn-primaire {
  background: var(--couleur-primaire);
  color: var(--sur-primaire, #fff);
  box-shadow: none;
}
/* Les diodes d'etat conservent leur couleur (fond, pas texte) — aucune regle texte ne les affecte. */

/* Réglages ⚙ : pleine page (plus aéré qu'un popup), fond du thème, cartes --panneau */
.overlay.overlay-page {
  background: var(--couleur-fond);
  backdrop-filter: none;
  align-items: stretch; justify-content: stretch;
}
.overlay.overlay-page > .bg-slate-800 {
  width: 100%; height: 100%; max-width: none; max-height: none;
  border-radius: 0 !important; box-shadow: none;
  background: var(--couleur-fond) !important;
}
.overlay.overlay-page .bg-slate-900 {
  background: var(--panneau) !important;
  border: 1.5px solid var(--bordure);
}
.overlay.overlay-page select { background: var(--couleur-fond) !important; }

/* Image de fond : opacite dediee sur l'ecran d'accueil (reglage admin distinct du global) */
body:has(#page-accueil.active) #fond-illustration { opacity: var(--fond-opacite-accueil, 1) !important; }

/* Bouton flottant 🏠 : masque sur l'accueil (on y est deja) et sur l'ecran merci (retour auto) */
body:has(#page-accueil.active) #retour-accueil,
body:has(#page-merci.active) #retour-accueil { display: none; }

/* Accueil : logo plus grand */
body:has(#page-accueil.active) #logo-app { height: 8.5rem; }

/* Questions / explications riches du quiz (HTML issu de l'editeur admin) */
#quiz-question p, #quiz-panneau-texte p, #pb-intro p { margin: 0 0 .35em; }
#quiz-question ul, #quiz-panneau-texte ul, #pb-intro ul { list-style: disc; padding-left: 1.4em; text-align: left; display: inline-block; }
#quiz-question ol, #quiz-panneau-texte ol, #pb-intro ol { list-style: decimal; padding-left: 1.4em; text-align: left; display: inline-block; }
#quiz-question img, #quiz-panneau-texte img, #pb-intro img { max-height: 22vh; border-radius: .8rem; display: inline-block; }

/* Sur l'accueil, les gros drapeaux sont au centre : le switcher discret est masque */
body:has(#page-accueil.active) #langues-flottant { display: none; }
.btn-langue-grand svg, .btn-langue-grand > span { width: 4rem; height: 2.75rem; display: block; }


/* Accueil + ecrans de contenu : logo centre en haut, diodes/roue restent a droite */
body:has(#page-accueil.active) header,
body:has(#page-contenu.active) header { justify-content: center; }
body:has(#page-accueil.active) header .zone-etat,
body:has(#page-contenu.active) header .zone-etat { position: absolute; right: 1.5rem; top: 0.9rem; }

/* Image de fond presente => on retire le filigrane decoratif (sinon superposition) */
body:has(#fond-illustration)::before { content: none !important; }

/* Image de fond d'illustration (uploadee dans Personnalisation) */
#fond-illustration {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-position: center; background-size: cover; background-repeat: no-repeat;
}


/* =====================================================================
   Clavier virtuel integre (option ⚙ : evite le clavier Windows qui
   recouvre les champs en mode borne)
   ===================================================================== */
#clavier-virtuel {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%);
  z-index: 70; width: min(62rem, 100vw - 1rem);
  background: color-mix(in srgb, var(--texte) 6%, var(--couleur-fond));
  border: 1px solid var(--bordure); border-bottom: none;
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -14px 40px rgba(0,0,0,.28);
  padding: .6rem .6rem calc(.6rem + env(safe-area-inset-bottom));
  user-select: none;
}
#clavier-virtuel .clv-ligne { display: flex; gap: .4rem; margin-bottom: .4rem; justify-content: center; }
#clavier-virtuel .clv-ligne:last-child { margin-bottom: 0; }
#clavier-virtuel button {
  flex: 1 1 0; min-width: 0; height: 3.4rem;
  border-radius: 10px; border: 1px solid var(--bordure);
  background: var(--couleur-fond); color: var(--texte);
  font-size: 1.35rem; font-weight: 600; font-family: inherit;
  touch-action: manipulation;
}
#clavier-virtuel button:active { background: var(--couleur-primaire); color: var(--sur-primaire, #fff); }
#clavier-virtuel button.clv-special { flex-grow: 1.6; background: var(--panneau); font-size: 1.1rem; }
#clavier-virtuel button.clv-espace { flex-grow: 5; }
#clavier-virtuel button.clv-ok { flex-grow: 1.8; background: var(--couleur-primaire); color: var(--sur-primaire, #fff); border: none; }
#clavier-virtuel button.clv-actif { background: var(--couleur-primaire); color: var(--sur-primaire, #fff); }
body.clavier-ouvert main { padding-bottom: 21rem; }
body.clavier-ouvert .quiz-panneau { display: none; } /* jamais les deux superposes */
