/* ============================================================
   Nadjmi — feuille de style de base. Mobile-first.
   Univers : ciel étoilé, bleu nuit, turquoise, doré doux.
   ============================================================ */

:root {
  --echelle: 1;
  /* Palette Nadjmi */
  --nuit: #0b1437;
  --profond: #122052;
  --turquoise: #3fc1c9;
  --turquoise-fonce: #2a9aa1;
  --dore: #e8c266;
  --etoile: #ffe9a3;
  --creme: #faf6ec;
  --violet: #8d7bd4;

  /* Mode clair (défaut) */
  --fond: #f4f2ea;
  --surface: #ffffff;
  --surface-2: #f1edf9;
  --texte: #1c2340;
  --texte-doux: #5c637e;
  --accent: #2a9aa1;
  --accent-2: #c99a2e;
  --ok: #2e8b57;
  --erreur: #b6484f;
  --erreur-fond: #fbeaea;
  --bordure: #ddd7cc;
  --rayon: 20px;
  --rayon-petit: 14px;
  --ombre: 0 6px 24px rgba(28, 35, 64, .08);
  --police: 'Baloo 2', 'Segoe UI', system-ui, sans-serif;
  --police-ar: 'Amiri', 'Scheherazade New', serif;
}
html[data-mode="sombre"] {
  --fond: #0b1437;
  --surface: #16224e;
  --surface-2: #1d2b5e;
  --texte: #f2eeff;
  --texte-doux: #a9b0d0;
  --accent: #3fc1c9;
  --accent-2: #e8c266;
  --ok: #5fce93;
  --erreur: #ef8b91;
  --erreur-fond: #3a2030;
  --bordure: #2c3a70;
  --ombre: 0 6px 24px rgba(0, 0, 0, .35);
}
html[data-dyslexie="on"] {
  --police: 'Lexend', 'Segoe UI', sans-serif;
}

/* --- Polices arabes (menu du panneau d'affichage) --- */
html[data-police="classique"]    { --police-ar: "Amiri", "Scheherazade New", "Noto Naskh Arabic", serif; }
html[data-police="scheherazade"] { --police-ar: "Scheherazade New", "Amiri", "Noto Naskh Arabic", serif; }
html[data-police="naskh"]        { --police-ar: "Noto Naskh Arabic", "Amiri", serif; }
html[data-police="cairo"]        { --police-ar: "Cairo", "Noto Naskh Arabic", sans-serif; }
html[data-police="lateef"]       { --police-ar: "Lateef", "Scheherazade New", "Amiri", serif; }
html[data-police="indopak"]      { --police-ar: "IndoPak", "Noto Naskh Arabic", "Scheherazade New", serif; }
@font-face {
  font-family: "IndoPak";
  src: url("/assets/fonts/indopak.ttf") format("truetype");
  font-display: swap;
}
html[data-dyslexie="on"] body { letter-spacing: .04em; word-spacing: .12em; line-height: 1.75; }

* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: calc(100% * var(--echelle)); }
body {
  font-family: var(--police);
  background: var(--fond);
  color: var(--texte);
  min-height: 100vh;
  line-height: 1.55;
}
.ar { font-family: var(--police-ar); direction: rtl; unicode-bidi: isolate; }
.petit { font-size: .85rem; color: var(--texte-doux); }
h1 { font-size: 1.65rem; margin: 1rem 0 .6rem; }
h2 { font-size: 1.25rem; margin: .8rem 0 .4rem; }
p { margin: .4rem 0; }
a { color: var(--accent); }
img, canvas { max-width: 100%; }

.conteneur { width: 100%; max-width: 1060px; margin: 0 auto; padding: 0 1rem; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .6rem 1rem; z-index: 99; }
.skip-link:focus { left: 0; }

/* --- Ciel de fond (mode sombre : étoiles discrètes) --- */
.ciel-fond { position: fixed; inset: 0; pointer-events: none; z-index: -1; }
html[data-mode="sombre"] .ciel-fond {
  background-image:
    radial-gradient(1.5px 1.5px at 12% 22%, rgba(255,233,163,.8) 50%, transparent 51%),
    radial-gradient(1px 1px at 34% 64%, rgba(255,233,163,.5) 50%, transparent 51%),
    radial-gradient(2px 2px at 58% 14%, rgba(255,233,163,.7) 50%, transparent 51%),
    radial-gradient(1px 1px at 72% 42%, rgba(255,233,163,.5) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 86% 76%, rgba(255,233,163,.65) 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 86%, rgba(255,233,163,.45) 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 46% 38%, rgba(255,233,163,.55) 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 18%, rgba(255,233,163,.5) 50%, transparent 51%);
}

/* --- Bandeau mode démo --- */
.bandeau-demo {
  background: var(--dore); color: var(--nuit);
  text-align: center; font-weight: 600; font-size: .85rem;
  padding: .45rem .8rem;
}

/* --- En-tête --- */
.site-header {
  position: sticky; top: 0; z-index: 50;
  background: var(--nuit);
  color: var(--creme);
  box-shadow: 0 2px 14px rgba(0, 0, 0, .25);
}
.header-inner { display: flex; align-items: center; gap: .8rem; min-height: 62px; }
.logo { display: flex; align-items: center; gap: .55rem; text-decoration: none; color: var(--creme); }
.logo-etoile { width: 40px; height: 40px; flex: 0 0 auto; filter: drop-shadow(0 0 8px rgba(255, 233, 163, .5)); }
.logo-nom { font-weight: 700; font-size: 1.15rem; color: var(--etoile); display: block; line-height: 1.1; }
.logo-nom .ar { font-size: 1em; color: var(--dore); }
.logo-texte small { color: rgba(250, 246, 236, .7); font-size: .68rem; }

.nav-principale { display: none; margin-inline-start: auto; }
.nav-principale a {
  color: rgba(250, 246, 236, .85); text-decoration: none; font-weight: 600;
  padding: .55rem .8rem; border-radius: 12px;
}
.nav-principale a:hover { background: rgba(63, 193, 201, .15); color: #fff; }
.nav-principale a.actif { background: rgba(63, 193, 201, .22); color: var(--etoile); }
.header-actions { display: flex; align-items: center; gap: .4rem; margin-inline-start: auto; }
.nav-principale + .header-actions, .nav-principale ~ .header-actions { margin-inline-start: 0; }
.pseudo-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  background: rgba(255, 233, 163, .14); color: var(--etoile);
  border: 1px solid rgba(232, 194, 102, .4); border-radius: 999px;
  padding: .35rem .8rem; font-weight: 700; font-size: .85rem; white-space: nowrap;
}
.btn-icone {
  background: rgba(250, 246, 236, .1); color: var(--creme);
  border: 1px solid rgba(250, 246, 236, .2); border-radius: 12px;
  min-width: 44px; min-height: 44px; font-size: 1.1rem; cursor: pointer;
}
.btn-icone:hover { background: rgba(63, 193, 201, .25); }

/* Menu mobile : la nav devient un tiroir sous l'en-tête */
@media (max-width: 799px) {
  .nav-principale.ouverte {
    display: flex; flex-direction: column; position: absolute; left: 0; right: 0; top: 100%;
    background: var(--nuit); padding: .6rem 1rem 1rem; gap: .2rem;
    box-shadow: 0 12px 24px rgba(0, 0, 0, .35);
  }
  .nav-principale.ouverte a { padding: .9rem 1rem; font-size: 1.05rem; }
}
@media (min-width: 800px) {
  .nav-principale { display: flex; gap: .2rem; }
  .nav-burger { display: none; }
  .header-actions { margin-inline-start: 0; }
}

/* --- Panneau d'affichage --- */
.panneau-affichage {
  position: absolute; right: .6rem; top: calc(100% + .4rem);
  background: var(--surface); color: var(--texte);
  border: 1px solid var(--bordure); border-radius: var(--rayon);
  box-shadow: var(--ombre); padding: 1rem 1.2rem; width: min(330px, 92vw); z-index: 60;
}
.panneau-affichage h3 { font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--texte-doux); margin: .8rem 0 .35rem; }
.panneau-affichage h3:first-child { margin-top: 0; }
.panneau-affichage button {
  background: var(--surface-2); color: var(--texte);
  border: 1px solid var(--bordure); border-radius: 10px;
  padding: .5rem .75rem; cursor: pointer; font-family: inherit; font-size: .9rem;
  min-height: 42px;
}
.panneau-affichage button:hover, .panneau-affichage button.choisi { border-color: var(--accent); color: var(--accent); }
.choix-mode, .choix-dyslexie, .choix-taille { display: flex; gap: .45rem; flex-wrap: wrap; align-items: center; }
.choix-police { display: flex; flex-direction: column; gap: .45rem; }
.choix-police button { display: flex; align-items: center; gap: .6rem; text-align: left; border-radius: 999px; padding: .55rem 1rem; }
.choix-police button .ar { font-size: 1.25rem; min-width: 3.2rem; text-align: center; }
.echelle-actuelle { min-width: 3.4em; text-align: center; font-weight: 600; }
.note-panneau { font-size: .78rem; color: var(--texte-doux); margin-top: .5rem; }

/* --- Boutons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font-family: inherit; font-weight: 600; font-size: .95rem;
  border-radius: 14px; border: 1px solid transparent;
  padding: .65rem 1.15rem; min-height: 44px;
  cursor: pointer; text-decoration: none; transition: transform .15s, box-shadow .15s;
}
.btn:active { transform: scale(.97); }
.btn-principal { background: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(42, 154, 161, .35); }
.btn-principal:hover { transform: translateY(-2px); }
.btn-secondaire { background: var(--accent-2); color: #fff; }
.btn-discret { background: var(--surface-2); color: var(--texte); border-color: var(--bordure); }
.btn-discret:hover { border-color: var(--accent); }
.btn.choisi { background: var(--accent); color: #fff; border-color: var(--accent); }

/* --- Bouton de vocalisation (les petits ne lisent pas encore) --- */
.btn-vocal {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; min-height: 44px; font-size: 1.15rem;
  background: var(--surface-2); border: 1px solid var(--bordure); border-radius: 50%;
  cursor: pointer; vertical-align: middle; margin-inline-start: .35rem;
  transition: transform .15s;
}
.btn-vocal:hover { border-color: var(--accent); transform: scale(1.08); }
.btn-vocal.joue { background: var(--accent); border-color: var(--accent); animation: vocal-pulse 1s infinite; }
@keyframes vocal-pulse { 50% { transform: scale(1.12); } }

/* --- Cartes --- */
.carte {
  background: var(--surface); border: 1px solid var(--bordure);
  border-radius: var(--rayon); box-shadow: var(--ombre);
  padding: 1.1rem 1.2rem; margin: .8rem 0;
}

/* --- Explications (contrat de confiance : toujours un retour) --- */
.explication { border-radius: var(--rayon-petit); padding: .8rem 1rem; margin-top: .6rem; border: 1px solid var(--bordure); background: var(--surface-2); }
.explication.ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface)); }
.explication.ko { border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 10%, var(--surface)); }
.explication .verdict { font-weight: 700; }

/* --- Toasts --- */
#zone-toasts { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); display: flex; flex-direction: column; gap: .5rem; z-index: 90; width: min(430px, 94vw); }
.toast {
  display: flex; gap: .7rem; align-items: flex-start;
  background: var(--surface); color: var(--texte);
  border: 1px solid var(--bordure); border-radius: var(--rayon-petit);
  box-shadow: var(--ombre); padding: .8rem 1rem;
  animation: toast-entree .3s ease;
}
.toast .emoji { font-size: 1.4rem; }
.toast .titre { font-weight: 700; }
.toast .texte { font-size: .85rem; color: var(--texte-doux); }
.toast.sortie { opacity: 0; transform: translateY(8px); transition: all .3s; }
.toast.badge-toast { border-color: var(--accent-2); }
@keyframes toast-entree { from { opacity: 0; transform: translateY(10px); } }

/* --- Pluie d'étoiles (célébrations) --- */
.etoile-fete {
  position: fixed; top: -4vh; z-index: 95; pointer-events: none;
  animation: etoile-chute linear forwards;
}
@keyframes etoile-chute {
  to { transform: translateY(108vh) rotate(360deg); opacity: .1; }
}

/* --- Quiz d'application --- */
.quiz-question { font-size: 1.05rem; margin: .6rem 0; }
.quiz-ar { font-size: 1.7rem; text-align: center; margin: .5rem 0; color: var(--accent); }
.quiz-choix { display: flex; flex-direction: column; gap: .55rem; margin-top: .7rem; }
.quiz-opt { text-align: left; justify-content: flex-start; font-size: 1rem; padding: .85rem 1.1rem; }
.quiz-opt.quiz-juste { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.quiz-opt.quiz-faux { border-color: var(--erreur); background: var(--erreur-fond); }
.quiz-fin { text-align: center; padding: .8rem 0; }
.quiz-fin-etoile { font-size: 3rem; animation: fete-etoile 1s ease; }
@keyframes fete-etoile { 0% { transform: scale(.3) rotate(-30deg); } 70% { transform: scale(1.25); } }
.quiz-retour .quiz-suivant { margin-top: .6rem; }

/* --- Pied de page --- */
.site-footer { background: var(--nuit); color: rgba(250, 246, 236, .85); margin-top: 3rem; }
.footer-inner { display: grid; gap: 1.4rem; padding: 2rem 1rem 1rem; grid-template-columns: 1fr; }
@media (min-width: 700px) { .footer-inner { grid-template-columns: repeat(3, 1fr); } }
.footer-col h4 { color: var(--etoile); margin-bottom: .4rem; }
.footer-col a { display: block; color: rgba(250, 246, 236, .8); text-decoration: none; padding: .3rem 0; }
.footer-col a:hover { color: var(--turquoise); }
.footer-callig { font-size: 2rem; color: var(--dore); }
.footer-bas {
  display: flex; flex-wrap: wrap; gap: .5rem 1.4rem; justify-content: center; align-items: center;
  border-top: 1px solid rgba(250, 246, 236, .15); padding: 1rem; font-size: .8rem; color: rgba(250, 246, 236, .6);
}
.footer-bas .ar { color: var(--dore); font-size: 1.05rem; }

/* --- Animations à l'entrée --- */
.anim-en-vue { opacity: 0; transform: translateY(14px); transition: all .5s ease; }
.anim-en-vue.visible { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
