/* « Le hibou range les mots » — version interactive (brouillon tant que le catalogue ne la publie pas).
   Autonome : aucune dépendance au moteur des fiches. Aucun son, aucun chronomètre.
   Le rouge est réservé au graphème (affiché seulement après une bonne réponse). */
:root {
  --encre: #2B2547; --encre-douce: #5A5478; --brume: #F7F5FE; --trait: #ECE8FA;
  --lavande-100: #EEEAFD; --lavande-200: #C9C0F3; --lavande-300: #B8AEEF;
  --violet-600: #5B4BB7; --violet-700: #463897; --violet-800: #3B2F84; --bleu-600: #2F6DB5;
  --fond: #FFFFFF; --interligne: 1.6; --espace-lettres: .01em; --espace-mots: normal; --vert-fond: #E7F5EC; --vert-bord: #7CC79A; --rouge: #D3263A;
  --police-interface: 'Lexend', 'Verdana', 'Segoe UI', system-ui, sans-serif;
  --police-lecture: 'Andika', 'Lexend', 'Verdana', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--fond);  color: var(--encre); font-family: var(--police-interface); font-size: 1.125rem; line-height: var(--interligne); letter-spacing: var(--espace-lettres); word-spacing: var(--espace-mots); }
img { max-width: 100%; height: auto; }
[hidden] { display: none !important; }
.sr-seulement { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.evitement { position: absolute; left: .5rem; top: -4rem; background: var(--violet-700); color: #fff; padding: .6rem 1rem; border-radius: .75rem; z-index: 10; }
.evitement:focus { top: .5rem; }

.entete { display: flex; align-items: center; gap: 1rem; max-width: 46rem; margin: 0 auto; padding: 1rem 1rem .25rem; }
.entete img { flex: none; width: 4rem; height: 4rem; }
.entete h1 { margin: 0; font-size: clamp(1.5rem, 5.4vw, 2.25rem); line-height: 1.15; }
main { max-width: 46rem; margin: 0 auto; padding: .5rem 1rem 2rem; outline: none; }
h2 { font-size: 1.5rem; line-height: 1.25; margin: .5rem 0; overflow-wrap: anywhere; }
.intro { margin: 0 0 1rem; color: var(--encre-douce); font-family: var(--police-lecture); font-size: 1.2rem; }

/* Boutons */
.bouton { font: inherit; font-weight: 600; min-height: 3rem; padding: .6rem 1.25rem; border-radius: 999px; border: 2px solid var(--lavande-300); background: #fff; color: var(--violet-800); cursor: pointer; text-align: center; max-width: 100%; }
.bouton--principal { background: var(--violet-600); border-color: var(--violet-600); color: #fff; box-shadow: 0 .25rem 0 var(--violet-800); }
.bouton--contour:hover, .bouton:hover { background: var(--lavande-100); }
.bouton--principal:hover { background: var(--violet-700); }
.bouton--grand { min-height: 3.75rem; font-size: 1.25rem; width: 100%; margin-top: 1rem; }
:focus-visible { outline: 4px solid var(--bleu-600); outline-offset: 3px; }

/* Choix du niveau */
.niveaux { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.niveau { width: 100%; display: flex; flex-direction: column; align-items: flex-start; gap: .25rem; text-align: left; min-height: 5.5rem; padding: 1rem 1.25rem; border-radius: 1.5rem; border: 2px solid var(--lavande-300); background: var(--brume); color: var(--encre); font: inherit; cursor: pointer; }
.niveau:hover { background: var(--lavande-100); }
.niveau__nom { font-weight: 700; font-size: 1.3rem; color: var(--violet-700); overflow-wrap: anywhere; }
.niveau__info { font-family: var(--police-lecture); color: var(--encre-douce); }

/* Jeu */
.barre { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; }
.barre h2 { margin: 0; }
.progression { margin: .75rem 0 1rem; }
.progression p { margin: 0 0 .25rem; font-family: var(--police-lecture); color: var(--encre-douce); }
progress { display: block; width: 100%; height: 1rem; appearance: none; -webkit-appearance: none; border: 0; border-radius: 999px; background: var(--lavande-100); overflow: hidden; }
progress::-webkit-progress-bar { background: var(--lavande-100); border-radius: 999px; }
progress::-webkit-progress-value { background: var(--violet-600); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--violet-600); border-radius: 999px; }
.carte { display: flex; flex-direction: column; align-items: center; gap: .5rem; width: min(100%, 22rem); margin: 0 auto; padding: 1.25rem 1rem 1rem; background: #fff; border: 3px solid var(--lavande-300); border-radius: 1.75rem; }
.carte img { width: min(55vw, 14rem); height: auto; aspect-ratio: 1; }
.mot { margin: 0; font-family: var(--police-lecture); font-size: clamp(2.25rem, 10vw, 3.25rem); line-height: 1.1; letter-spacing: .03em; overflow-wrap: anywhere; text-align: center; }
.mot .g { color: var(--rouge); font-weight: 700; text-decoration: underline; text-decoration-thickness: .08em; text-underline-offset: .12em; }
.question { margin: 1.25rem 0 .5rem; text-align: center; font-weight: 600; }
.familles { display: grid; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); gap: 1rem; }
.famille { min-height: 4.75rem; font-family: var(--police-lecture); font-weight: 700; font-size: 2.25rem; line-height: 1; border-radius: 1.5rem; border: 3px solid var(--violet-600); background: var(--lavande-100); color: var(--violet-800); cursor: pointer; }
.famille:hover:not(:disabled) { background: var(--lavande-200); }
.famille:disabled { cursor: default; opacity: .55; }
.famille.choisie { background: var(--violet-600); color: #fff; opacity: 1; }
.retour { min-height: 4.5rem; margin-top: 1rem; }
.retour p { margin: 0; padding: .9rem 1.1rem; border-radius: 1.25rem; font-family: var(--police-lecture); font-size: 1.2rem; }
.retour .ok { background: var(--vert-fond); border: 2px solid var(--vert-bord); }
.retour .encore { background: var(--lavande-100); border: 2px solid var(--lavande-300); }

/* Fin */
#ecran-fin { text-align: center; }
.fin__hibou { display: block; margin: .5rem auto; }
.actions { display: grid; gap: 1rem; margin-top: 1rem; }
.pied { text-align: center; color: var(--encre-douce); font-size: .9rem; padding: 1rem; }

@media (min-width: 40rem) { .niveaux { grid-template-columns: repeat(3, 1fr); } .niveau { min-height: 8rem; } .actions { grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); } }
@media (prefers-reduced-motion: no-preference) {
  .carte { animation: apparition .25s ease-out; }
  @keyframes apparition { from { opacity: 0; transform: translateY(.5rem); } to { opacity: 1; transform: none; } }
}
@media (prefers-contrast: more) { :root { --encre-douce: #2B2547; } }

/* Réglages d'affichage : mêmes valeurs que HibouFiches (taille, espacement, fond) */
html[data-taille="normal"] { font-size: 100%; } html[data-taille="grand"] { font-size: 115%; } html[data-taille="tres-grand"] { font-size: 130%; }
html[data-espacement="large"] { --interligne: 1.9; --espace-lettres: .06em; --espace-mots: .22em; }
html[data-fond="creme"] { --fond: #FFF8E7; } html[data-fond="lavande"] { --fond: #F5F2FD; }

.haut { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .5rem 1rem; max-width: 46rem; margin: 0 auto; padding: .75rem 1rem 0; }
.haut .bouton { display: inline-flex; align-items: center; gap: .5rem; text-decoration: none; }
.haut .lien-retour { min-width: 0; min-height: 2.75rem; padding-block: .3rem; line-height: 1.3; }   /* plus compact, caractères inchangés, cible tactile ≥ 44 px */
.reglages { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.reglages__voile { position: absolute; inset: 0; background: rgba(43, 37, 71, .55); }
.reglages__panneau { position: relative; width: min(100%, 34rem); max-height: 92vh; max-height: 92dvh; display: flex; flex-direction: column; background: #fff; color: var(--encre); border-radius: 1.75rem 1.75rem 0 0; box-shadow: 0 -.5rem 2rem rgba(43, 37, 71, .25); }
.reglages__entete { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem .5rem; }
.reglages__entete h2 { margin: 0; }
.bouton--rond { width: 3rem; padding: 0; font-size: 1.75rem; line-height: 1; flex: none; }
.reglages__corps { overflow-y: auto; padding: .5rem 1.25rem 1rem; }
.apercu { margin: 0 0 1rem; padding: .9rem 1rem; border-radius: 1.25rem; background: var(--brume); border: 2px dashed var(--lavande-300); font-family: var(--police-lecture); font-size: 1.25rem; }
.reglage { border: 0; margin: 0 0 1rem; padding: 0; min-width: 0; }
.reglage legend { font-weight: 700; padding: 0; margin-bottom: .5rem; }
.reglage__choix { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fit, minmax(7.5rem, 1fr)); }
.choix { position: relative; display: block; min-width: 0; }
.choix input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.choix__boite { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .15rem; min-height: 4.5rem; padding: .5rem; text-align: center; border: 2px solid var(--lavande-300); border-radius: 1rem; background: #fff; font-size: 1rem; overflow-wrap: anywhere; }
.choix__nom { font-weight: 600; }
.choix__demo { font-family: var(--police-lecture); line-height: 1.1; }
.choix__pastille { width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 2px solid var(--violet-600); }
.choix input:checked + .choix__boite { background: var(--violet-600); border-color: var(--violet-600); color: #fff; }
.choix input:checked + .choix__boite .choix__nom::before { content: "✓ "; }
.choix input:focus-visible + .choix__boite { outline: 4px solid var(--bleu-600); outline-offset: 3px; }
.reglages__pied { display: flex; flex-wrap: wrap; justify-content: space-between; gap: .75rem; padding: .75rem 1.25rem 1.25rem; border-top: 2px solid var(--trait); }
.reglages__pied .bouton { flex: 1 1 9rem; }
body.reglages-ouverts { overflow: hidden; }
@media (min-width: 40rem) { .reglages { align-items: center; } .reglages__panneau { border-radius: 1.75rem; max-height: 88vh; } }

/* Aide « Revoir le son XX » (après deux tentatives incorrectes sur la même carte) */
.retour .lien-fiche { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; min-height: 2.75rem; margin-top: .6rem; padding: .45rem 1.1rem; border: 2px solid var(--lavande-300); border-radius: 999px; background: #fff; color: inherit; font-family: var(--police-lecture); font-size: 1.1rem; font-weight: 700; text-decoration: underline; text-underline-offset: .2em; }
.retour .lien-fiche:hover { background: var(--lavande-100); }
