/* =========================================================================
   « Mon confort » (17 nov. 2026, inc/confort.php, maquette tests/maquette-veille-4-confort.php) :
   lu par les pages élèves (inc/layout.php, après la feuille du design) ET par les jeux (importé par sandbox.css) :
   les mêmes règles partout. Rien ne s'applique tant que <html> ne porte ni data-police, ni data-espace, ni data-contraste.
   On y trouve aussi les fractions à barre horizontale (pour tout le monde, assets/js/fractions.js et p6-sandbox.js),
   la rubrique « Mon confort » (profil.php), le bouton « Aa » de l'en-tête et son panneau.
   ========================================================================= */

/* --- 1. La forme des lettres : Atkinson Hyperlegible ou Andika, polices hébergées (assets/polices/), titres compris ---- */
html[data-police="atkinson"], html[data-police="atkinson"][data-theme] {
  --police: "Atkinson Hyperlegible", Verdana, "Segoe UI", sans-serif;
  --police-titre: "Atkinson Hyperlegible", Verdana, "Segoe UI", sans-serif;
}
html[data-police="andika"], html[data-police="andika"][data-theme] {
  --police: "Andika", "Atkinson Hyperlegible", Verdana, sans-serif;
  --police-titre: "Andika", "Atkinson Hyperlegible", Verdana, sans-serif;
}
/* Les deux polices n'ont que 400 et 700 : le texte courant en 400 (pas tout en gras), les titres et boutons en 700 */
html[data-police] body, html[data-police][data-theme] body { font-weight: 400; }
html[data-police] :is(h1, h2, h3, b, strong, .btn, .titre-geant, .titre-section) { font-weight: 700; font-stretch: 100%; }
/* Jamais de penché ni de lettres serrées pour un lecteur qui peine */
html[data-police] :is(em, i) { font-style: normal; font-weight: 700; }
html[data-police] :is(h1, h2, h3, .titre-geant, .logo) { letter-spacing: 0; }

/* --- 2. Plus d'espace : les valeurs du critère WCAG 1.4.12 (lettres .12em, mots .16em, lignes 1.5 et plus) ------------- */
html[data-espace="large"] body * { letter-spacing: .12em !important; word-spacing: .16em !important; }
html[data-espace="large"] body :is(h1, h2, h3, .titre-geant, .titre-jeu) { letter-spacing: .06em !important; line-height: 1.3 !important; }
html[data-espace="large"] body { line-height: 1.75; }
html[data-espace="large"] body :is(p, li, label, .sous-titre, .pour-toi-titre, .ligne-jeu-nom, .ligne-jeu-competence, .recolte-texte,
  .jeu-texte, .jeu-question, .question, .explication, .jeu-explication, .indice, .jeu-retour, .confort-apercu-question, .confort-apercu-explication) { line-height: 1.75 !important; }
html[data-espace="large"] body p + p { margin-top: .9em; }
/* Les deux gros boutons de l'accueil gardent leur « ! » sur la même ligne */
html[data-espace="large"] :is(.bouton-declic, .bouton-defis) b { white-space: nowrap; }

/* --- 3. Plus contrasté : un fond uni, le texte « doux » à pleine encre, des liens soulignés, un repère de clavier épais ----- */
html[data-contraste="eleve"] { --creme: #FFFFFF; --doux: var(--encre); }
html[data-contraste="eleve"] body { background-image: none !important; background-color: var(--creme) !important; }
html[data-contraste="eleve"] :is(.sous-titre, small, .logo-slogan, .pour-toi-quoi, .ligne-jeu-competence, .ligne-jeu-info, .ligne-jeu-attente,
  .astuce-favoris, .jeu-competence, .titre-section small, .titre-matiere small, .petit, .glissades, .barreau-num, .jeu-progression,
  .confort-aide, .confort-ligne-aide, .confort-apercu-num, .moi-forum-ferme, .jeu-consigne) { opacity: 1 !important; color: var(--encre) !important; }
html[data-contraste="eleve"] :is(p, li) a:not(.btn), html[data-contraste="eleve"] .vn-carte-liens a { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
html[data-contraste="eleve"] :focus-visible { outline: 4px solid var(--encre) !important; outline-offset: 3px; box-shadow: 0 0 0 8px var(--jaune) !important; }
html[data-contraste="eleve"] .moi-etoiles { color: var(--encre); }
/* Studio clair : les filets gris très pâles deviennent de vrais traits ; le texte un cran plus noir */
html[data-theme="studio"][data-contraste="eleve"] { --encre: #0B0D16; --doux: #0B0D16; --ligne: #4A5068; --creme: #FFFFFF; }
/* Studio sombre : fond noir, texte blanc plein, filets clairs */
html[data-theme="studio-sombre"][data-contraste="eleve"] { --encre: #FFFFFF; --doux: #FFFFFF; --creme: #000000; --papier: #10121A; --ligne: #A3AABD; }
html[data-theme^="studio"][data-contraste="eleve"] :is(.ligne-jeu, .pour-toi-carte, .compteur, .btn, .favori-tuile, .filtre-matiere, .bouton-defis, .bouton-declic,
  .confort, .confort-option, .confort-apercu, .jeu-carte, .choix button, .choix .btn, .joker, .recherche-champ, .moi-enveloppe, .moi-carte, .cadre-jeu, .profil-apercu, .choix-avatar) { border: 2px solid var(--ligne) !important; }
/* Affiche : on garde le papier, les encres et le vert du juste ; on enlève le grain derrière le texte, les traits passent au noir
   (le grain passe par deux variables : les vider suffit ; un « background-image: none » général effaçait les barreaux de
   l'échelle, dessinés en dégradé par le gabarit — vu sur la maquette) */
html[data-theme="affiche"][data-contraste="eleve"] { --encre: #000000; --doux: #000000; --ligne: #1C1B1A; --graphite: #4A4845;
  --grain-encre: linear-gradient(transparent, transparent); --grain-papier: linear-gradient(transparent, transparent); }
html[data-theme="affiche"][data-contraste="eleve"] :is(.titre-section, .titre-matiere, .jeu-titre, .partie-titre) { color: var(--encre) !important; }
html[data-theme="affiche"][data-contraste="eleve"] :is(.ligne-jeu, .pour-toi-carte, .compteur, .btn, .favori-tuile, .filtre-matiere, .confort-option, .confort-apercu,
  .jeu-carte, .choix button, .choix .btn, .joker, .recherche-champ, .moi-enveloppe, .cadre-jeu) { border: 2px solid var(--encre) !important; }

/* --- Fractions à barre horizontale (pour tout le monde : assets/js/fractions.js sur les pages, p6-sandbox.js dans les jeux) ---
   La barre oblique reste dans le texte, cachée : le jeu, la lecture à voix haute et un copier-coller lisent toujours « 3/7 ».
   (.frac et pas .fr : les leçons « Déclic ! » ont déjà leur .fr, qu'on ne touche pas) */
.frac { position: relative; display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle;
  margin: 0 .12em; font-size: .9em; line-height: 1.05; font-variant-numeric: lining-nums tabular-nums; }
html body .frac, html body .frac * { letter-spacing: 0 !important; word-spacing: 0 !important; line-height: 1.05 !important; }
.frac-n { min-width: 1em; padding: 0 .22em .08em; text-align: center; border-bottom: max(2px, .09em) solid currentColor; }
.frac-d { min-width: 1em; padding: .08em .22em 0; text-align: center; }
.frac-barre { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* --- La rubrique « Mon confort » (profil.php) et le panneau du bouton « Aa » : un bloc par réglage, titre avec icône,
   une phrase qui dit ce qui change, des tuiles qui montrent l'effet (choix 11 B de Julien) ------------------------------- */
.confort {
  margin: 18px 0 8px; padding: 18px 20px 16px; background: var(--papier); color: var(--encre);
  border: var(--trait, 3px) solid var(--encre); border-radius: var(--rayon, 22px); box-shadow: var(--ombre, 4px 4px 0 var(--encre));
}
.confort-tete { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; align-items: center; margin-bottom: 12px; }
.confort-tete .pastille { grid-row: 1 / 3; width: 52px; height: 52px; }
.confort-tete h2 { margin: 0; font-size: 1.45rem; }
.confort-aide { margin: 0; font-size: .95rem; opacity: .8; }
.confort-corps { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 16px 26px; align-items: start; }
.confort-reglages { display: grid; gap: 0; margin: 0; padding: 0; }
.confort-ligne { display: block; min-width: 0; margin: 0; padding: 12px 0; border: 0; border-top: 2px dashed color-mix(in srgb, var(--encre) 25%, transparent); }
.confort-ligne:first-child { border-top: 0; padding-top: 0; }
.confort-ligne legend { float: left; width: 100%; display: flex; align-items: center; gap: 8px; padding: 0; font-family: var(--police-titre); font-size: 1.1rem; font-weight: 700; }
.confort-ligne legend .ico { width: 22px; height: 22px; flex: none; }
.confort-ligne-aide { clear: both; margin: 2px 0 8px; font-size: .9rem; opacity: .8; }
.confort-options { display: flex; flex-wrap: wrap; gap: 8px; }
.confort-option {
  position: relative; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 7.5em; max-width: 11em; min-height: 76px; padding: 8px 12px; cursor: pointer; text-align: center;
  font: inherit; font-weight: 700; color: var(--encre); background: var(--papier);
  border: var(--trait, 3px) solid var(--encre); border-radius: 16px; box-shadow: 3px 3px 0 var(--encre);
}
.confort-option[aria-pressed="true"] { background: var(--jaune); }
.confort-option[aria-pressed="true"]::before { content: ""; position: absolute; top: 6px; left: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--encre); }
.confort-option:focus-visible { outline: 3px solid var(--bleu, #6FB3F2); outline-offset: 2px; }
.confort-option small { display: block; font-size: .78em; font-weight: 600; opacity: .8; }
.confort-ex, .confort-option .taille-exemple { font-family: var(--police-titre); font-weight: 700; font-size: 1.55em; line-height: 1.1; }
.confort-option .taille-exemple-grand { font-size: 1.9em; }
.confort-option .taille-exemple-tres-grand { font-size: 2.3em; }
.confort-ex .ico { width: 26px; height: 26px; }
.confort-ex-atkinson { font-family: "Atkinson Hyperlegible", Verdana, sans-serif; }
.confort-ex-andika { font-family: "Andika", Verdana, sans-serif; font-weight: 400; }
.confort-ex-large { letter-spacing: .3em !important; }
.confort-ex-pale { opacity: .45; }
.confort-ex-fort { color: inherit; text-decoration: underline 2px; text-underline-offset: 3px; }
/* L'aperçu : une vraie question de jeu, qui change en même temps que toute la page */
.confort-apercu { padding: 14px 16px; background: var(--creme); border: var(--trait, 3px) dashed var(--encre); border-radius: 16px; }
.confort-apercu-titre { margin: 0 0 6px; font-weight: 800; font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; }
.confort-apercu-num { margin: 0; font-size: .9rem; opacity: .7; }
.confort-apercu-question { margin: 2px 0 10px; font-family: var(--police-titre); font-size: 1.2rem; font-weight: 700; line-height: 1.3; }
.confort-apercu-choix { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.confort-apercu-choix > span { padding: 6px 18px; font-weight: 800; background: var(--papier); border: var(--trait, 3px) solid var(--encre); border-radius: 12px; }
.confort-apercu-choix .juste { background: var(--vert); }
.confort-apercu-explication { margin: 0; font-size: .98rem; line-height: 1.45; }
.confort-pied { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 14px 0 0; }
.confort-garde { display: inline-flex; align-items: center; gap: 8px; margin: 0; font-size: .92rem; }
.confort-garde .ico { width: 20px; height: 20px; flex: none; }
.confort-enregistre { margin: 0; }
@media (max-width: 760px) {
  .confort { padding: 14px 14px 12px; }
  .confort-corps { grid-template-columns: 1fr; }
  .confort-tete .pastille { width: 44px; height: 44px; }
  .confort-tete h2 { font-size: 1.25rem; }
  .confort-option { min-width: 6.5em; }
}
/* Le bouton « Aa » de l'en-tête et son panneau, posé sur la page en cours (même pendant un jeu : la partie continue) */
.moi-confort { font-family: "Atkinson Hyperlegible", var(--police-titre); font-size: 1.05rem; font-weight: 700; letter-spacing: 0 !important; cursor: pointer; }
.moi-confort[aria-expanded="true"] { background: var(--jaune); }
.entete { position: relative; }
.confort-panneau { position: absolute; z-index: 60; top: calc(100% - 6px); right: clamp(16px, 4vw, 40px); width: min(580px, calc(100vw - 32px));
  max-height: calc(100vh - 110px); overflow-y: auto; border-radius: var(--rayon, 22px); }
.confort-panneau[hidden] { display: none; }
.confort-panneau .confort { margin: 0; box-shadow: 6px 6px 0 var(--encre); }
.confort-panneau .confort-corps { grid-template-columns: 1fr; }
.confort-panneau-fermer { position: absolute; z-index: 1; top: 12px; right: 14px; }
.confort-panneau .confort-tete { padding-right: 96px; }
.confort-panneau-lien { font-weight: 800; }
@media (max-width: 600px) {
  .confort-panneau { position: fixed; top: 8px; left: 8px; right: 8px; width: auto; max-height: calc(100vh - 16px); }
}
/* Studio */
html[data-theme^="studio"] .confort { border: 1px solid var(--ligne); box-shadow: var(--ombre); }
html[data-theme^="studio"] .confort-option { font-weight: 500; border: 1px solid var(--ligne); box-shadow: none; }
html[data-theme^="studio"] .confort-option[aria-pressed="true"] { background: var(--encre); color: var(--papier); border-color: var(--encre); }
html[data-theme^="studio"] .confort-option[aria-pressed="true"]::before { background: var(--papier); }
html[data-theme^="studio"] .confort-ligne legend, html[data-theme^="studio"] .confort-apercu-titre { font-weight: 600; }
html[data-theme^="studio"] .confort-ligne { border-top-color: var(--ligne); border-top-width: 1px; }
html[data-theme^="studio"] .confort-apercu { border: 1px dashed var(--ligne); }
html[data-theme^="studio"] .confort-apercu-choix > span { font-weight: 600; border: 1px solid var(--ligne); }
html[data-theme^="studio"] .confort-apercu-choix .juste { background: color-mix(in srgb, var(--vert) 30%, var(--papier)); border-color: var(--vert); }
html[data-theme^="studio"] .confort-panneau .confort { box-shadow: var(--ombre-haut, var(--ombre)); }
/* Affiche */
html[data-theme="affiche"] .confort { border: 2px solid var(--encre); }
html[data-theme="affiche"] .confort-option { border: 2px solid var(--encre); box-shadow: none; border-radius: 4px; font-family: var(--police); }
html[data-theme="affiche"] .confort-option[aria-pressed="true"] { background-color: var(--jaune-riso, var(--jaune)); background-image: var(--grain-encre); }
html[data-theme="affiche"] .confort-apercu { background: var(--papier); border: 2px dashed var(--encre); }
html[data-theme="affiche"] .confort-apercu-choix > span { border: 2px solid var(--encre); border-radius: 4px; }
html[data-theme="affiche"] .confort-apercu-choix .juste { background-color: var(--juste, var(--vert)); }
html[data-theme="affiche"] .confort-panneau .confort { box-shadow: 6px 6px 0 var(--rose-fluo, var(--encre)); }
