/* app.css — l'app téléphone, en portrait. Mêmes couleurs et mêmes formes que
   l'app iPad, mais un écran à la fois et tout en grand : le doigt écrit sur
   une lettre qui occupe toute la largeur. */

@font-face {
  font-family: 'JLJECursive';
  src: url('../fonts/JLJECursive.woff2') format('woff2');
  font-display: swap;
}

:root {
  --fond-appli: #F2F3EF;
  --papier: #FFFFFF;
  --texte: #212121;
  --texte-doux: #6B6F72;
  --bordure: #D6D9D2;
  --appui: #E4E7E0;
  --principal: #37474F;
  --eleve: #1976D2;
  --eleve-bordure: #9CC3EA;
}

* {
  box-sizing: border-box;
}

body {
  /* Fixé : ni rebond ni défilement de la page. */
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  margin: 0;
  overflow: hidden;
  background: var(--fond-appli);
  color: var(--texte);
  font: 17px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

.ecran {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right)
           env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.ecran[hidden],
.message[hidden],
.etat-hors-ligne[hidden] {
  display: none;
}

/* ── Barre du haut ───────────────────────────────────────────────────────── */

.barre {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 52px;
  padding: 6px 14px;
  flex-shrink: 0;
}

.barre h1 {
  /* Le geste lui appartient : sans cela, Android ouvre son menu. */
  touch-action: none;
  /* Zone de toucher franche : le mot seul est trop petit pour un doigt. */
  margin: 0 0 0 -10px;
  padding: 12px 10px;
  margin: 0;
  font-size: 21px;
  font-weight: 600;
}

.infos {
  display: flex;
  align-items: center;
  margin-left: auto;
  font-size: 12px;
  color: var(--texte-doux);
}

.etat-hors-ligne {
  margin-right: 10px;
  font-weight: 600;
}

.etat-hors-ligne.ok {
  color: #2E7D32;
}

.etat-hors-ligne.alerte {
  color: #B26A00;
}

/* JLJECursive monte à 3 interlignes au-dessus de la ligne de base et descend
   à 2 en dessous : sa boîte doit faire 2,6 fois la taille du texte, sinon les
   hampes et les jambages sont rognés (le « f » de la barre, 22-09-2026). */
.titre-lettre {
  font-family: 'JLJECursive', serif;
  font-size: 20px;
  line-height: 52px;
  height: 52px;
}

.nom-exercice {
  margin-left: auto;
  font-size: 13px;
  color: var(--texte-doux);
}

/* JLJECursive suit la réglure : hampes à 3 interlignes au-dessus de la ligne
   de base, jambages à 2 en dessous. Le glyphe est remonté pour tenir dans sa
   boîte. */
.glyphe {
  position: relative;
  top: -0.24em;
}

/* ── Boutons ─────────────────────────────────────────────────────────────── */

.bouton {
  min-height: 46px;
  padding: 6px 14px;
  font: inherit;
  font-size: 17px;
  line-height: 1.2;
  color: var(--texte);
  background: var(--papier);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  touch-action: manipulation;
}

.bouton:active {
  background: var(--appui);
}

.bouton.etroit {
  min-width: 46px;
  padding: 6px 10px;
}

.bouton.eleve {
  color: var(--eleve);
  border-color: var(--eleve-bordure);
}

.bouton[aria-pressed="true"] {
  border-color: var(--eleve);
  box-shadow: inset 0 0 0 1px var(--eleve);
}

.bouton .detail {
  display: block;
  font-size: 13px;
  color: var(--texte-doux);
}

/* ── Écran 1 : les lettres ───────────────────────────────────────────────── */

.grille {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  gap: 10px;
  padding: 4px 12px 24px;
}

.groupe {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  background: var(--papier);
  border: 1px solid var(--bordure);
  border-radius: 14px;
}

.lettre {
  min-width: 46px;
  height: 66px;
  padding: 0 4px;
  font-family: 'JLJECursive', serif;
  font-size: 26px;
  color: var(--texte);
  background: transparent;
  border: 0;
  border-radius: 10px;
  touch-action: manipulation;
}

.lettre:active {
  background: var(--appui);
}

/* ── Écran 2 : les exercices ─────────────────────────────────────────────── */

.exercices {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 4px 14px 20px;
}

.exercice {
  flex: 1;
  min-height: 130px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-align: left;
  font: inherit;
  color: var(--texte);
  background: var(--papier);
  border: 1px solid var(--bordure);
  border-radius: 16px;
  touch-action: manipulation;
}

.exercice:active {
  background: var(--appui);
}

.exercice .titre {
  display: block;
  font-size: 20px;
  font-weight: 600;
}

.exercice .detail {
  display: block;
  margin-top: 4px;
  font-size: 15px;
  color: var(--texte-doux);
}

.exercice canvas {
  flex-shrink: 0;
  width: 116px;
  height: 96px;
  margin-left: auto;
}

/* ── Écran 3 : l'écriture ────────────────────────────────────────────────── */

.zone {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 0 10px;
  overflow: hidden;
  background: var(--papier);
  border-radius: 14px;
}

.ecriture {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
}

.toile {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* Le calque de l'enfant reçoit le doigt : aucun geste ne fait défiler. */
.toile-eleve {
  touch-action: none;
}

/* Signaux du guidage, par-dessus : ils laissent passer les appuis. */
.toile-guidage {
  pointer-events: none;
}

/* Le modèle animé : dans un coin pendant qu'on écrit sur la lettre, en bande
   au-dessus quand on écrit en dessous, et plein cadre quand on le regarde. */
.modele {
  position: absolute;
  padding: 0;
  overflow: hidden;
  background: #F8F9F6;
  border: 1px solid var(--bordure);
  border-radius: 12px;
  /* Le doigt la déplace : le navigateur ne doit pas prendre le geste pour un
     défilement, sinon il l'interrompt (essai de Pierre du 21-09-2026). */
  touch-action: none;
  /* Elle se déplace par `transform` : calque à part, redessiné proprement. */
  will-change: transform;
}

.modele canvas {
  touch-action: none;
}

/* Taille de départ ; js/app.js la fixe en pixels dès la mise en page, car
   elle se retaille au doigt par la poignée. */
.zone--surLaLettre .modele {
  top: 8px;
  right: 8px;
  width: 26%;
  height: 26%;
}

/* Poignée de redimensionnement, en bas à gauche de la vignette. */
.poignee {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 30px;
  height: 30px;
  border-bottom: 2px solid var(--texte-doux);
  border-left: 2px solid var(--texte-doux);
  border-bottom-left-radius: 11px;
  opacity: 0.45;
}

.zone--enDessous .poignee,
.zone--regarder .poignee {
  display: none;
}

.zone--enDessous .modele {
  top: 0;
  right: 0;
  left: 0;
  height: 34%;
  border-width: 0 0 1px;
  border-radius: 14px 14px 0 0;
}

.zone--enDessous .ecriture {
  top: 34%;
}

.zone--regarder .modele {
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--papier);
  border: 0;
  border-radius: 14px;
}

.zone--regarder .ecriture {
  display: none;
}

.commandes {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  padding: 10px;
}

.commandes .bouton {
  flex: 1;
  min-height: 56px;
}

.message {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  white-space: pre-line;
  font-size: 17px;
  color: var(--texte-doux);
  pointer-events: none;
}

/* ── Paysage : l'app s'utilise en portrait ───────────────────────────────── */

.tournez {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--fond-appli);
}

.tournez p {
  margin: 14px 0 0;
  font-size: 22px;
  font-weight: 600;
  color: var(--principal);
}

@media (orientation: landscape) {
  .tournez {
    display: flex;
  }
}

/* ── Réglages de l'adulte ────────────────────────────────────────────────────
   Ouverts par un appui long sur le titre de l'accueil (demande du 25-09-2026) :
   c'est un verrou pour l'adulte, rien ne doit l'annoncer à l'enfant. */

.barre h1 {
  /* Il pâlit sous un appui long : l'adulte voit qu'il tient les réglages. */
  transition: opacity 0.6s;
}

.modale[hidden] {
  display: none;
}

.modale {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modale-fond {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(33, 33, 33, 0.35);
}

.modale-carte {
  position: relative;
  width: 100%;
  max-width: 400px;
  padding: 20px 18px 16px;
  background: var(--papier);
  border-radius: 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25);
}

.modale-carte h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.modale-detail {
  margin: 6px 0 14px;
  font-size: 14px;
  line-height: 1.35;
  color: var(--texte-doux);
}

.choix-lettres {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.choix-lettres button {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 56px;
  padding: 8px 12px;
  font: inherit;
  font-size: 16px;
  text-align: left;
  color: var(--texte);
  background: var(--papier);
  border: 1px solid var(--bordure);
  border-radius: 12px;
  touch-action: manipulation;
}

.choix-lettres button.actif {
  border-color: var(--eleve);
  box-shadow: inset 0 0 0 1px var(--eleve);
}

/* Le « Aa » du choix, en cursive : la boîte tient les hampes et les jambages. */
.choix-lettres .apercu {
  flex-shrink: 0;
  width: 52px;
  font-family: 'JLJECursive', serif;
  font-size: 20px;
  line-height: 52px;
  height: 52px;
  text-align: center;
}

.modale-carte .bouton {
  width: 100%;
}
