/* HEKIMA v0.1 — tablette 8,7" paysage. Jetons tirés de la maquette : rail sombre, dégradé lavande→pêche→menthe, cartes blanches, boutons noirs. */
:root {
  --encre: #1c1b22;
  --encre-2: #3a3846;
  --gris: #8b8a94;
  --papier: #ffffff;
  --fond-1: #e9e4ff;
  --fond-2: #ffe3d6;
  --fond-3: #dff3ea;
  --jaune: #ffc857;
  --corail: #f2766b;
  --bleu: #6c8cff;
  --menthe: #bfe3d0;
  --lavande: #c9bfff;
  --rayon: 24px;
  --rail: 72px;
  --ombre: 0 10px 30px rgba(28, 27, 34, 0.08);
  --police-titre: "Fredoka", "Nunito", system-ui, sans-serif;
  --police-texte: "Nunito", system-ui, sans-serif;
}
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}
html,
body {
  height: 100%;
  margin: 0;
  overscroll-behavior: none;
}
body {
  font-family: var(--police-texte);
  color: var(--encre);
  background: linear-gradient(
    120deg,
    var(--fond-1) 0%,
    var(--fond-2) 55%,
    var(--fond-3) 100%
  );
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
#app {
  height: 100%;
  display: flex;
}
h1,
h2,
h3,
.titre {
  font-family: var(--police-titre);
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}
h1 {
  font-size: 40px;
  line-height: 1.1;
}
h2 {
  font-size: 28px;
}
p {
  margin: 0;
  font-size: 18px;
  line-height: 1.5;
}
button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  padding: 0;
}
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--bleu);
  outline-offset: 3px;
}
[hidden] {
  display: none !important;
}

/* Rail de gauche */
.rail {
  width: var(--rail);
  flex: none;
  background: var(--encre);
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 0;
  gap: 12px;
}
.rail .logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: var(--jaune);
  object-fit: contain;
  padding: 3px;
  margin-bottom: 8px;
}
.rail .espace {
  flex: 1;
}
.rail button {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  opacity: 0.7;
  font-size: 24px;
}
.rail button[aria-current="page"],
.rail button:active {
  background: rgba(255, 255, 255, 0.14);
  opacity: 1;
}
.rail .avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--police-titre);
  font-weight: 700;
  font-size: 20px;
  color: var(--encre);
}

/* Scène */
.scene {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  gap: 16px;
  overflow: hidden;
}
.entete {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.entete .sous {
  color: var(--encre-2);
  font-size: 16px;
}
.carte {
  background: var(--papier);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px;
}
.ligne {
  display: flex;
  align-items: center;
  gap: 12px;
}
.grille {
  display: grid;
  gap: 16px;
}
.centre {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 20px;
  flex: 1;
}
.defiler {
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}
/* Grille qui défile : sans ça, les rangées s'arrêtent au min-height des cartes et le texte en sort. */
.grille.defiler {
  grid-auto-rows: minmax(min-content, auto);
}

/* Boutons */
.pilule {
  background: var(--encre);
  color: #fff;
  border-radius: 999px;
  padding: 0 28px;
  height: 56px;
  font-weight: 700;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.08s ease;
}
.pilule:active {
  transform: scale(0.97);
}
.pilule.clair {
  background: var(--papier);
  color: var(--encre);
  box-shadow: var(--ombre);
}
.pilule.jaune {
  background: var(--jaune);
  color: var(--encre);
}
.pilule.corail {
  background: var(--corail);
  color: #fff;
}
.pilule.grand {
  height: 72px;
  font-size: 22px;
  padding: 0 36px;
}
.pilule:disabled {
  opacity: 0.45;
}
.rond {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--papier);
  box-shadow: var(--ombre);
  font-size: 22px;
}
.rond.grand {
  width: 88px;
  height: 88px;
  font-size: 34px;
}

/* Puces / étiquettes */
.puce {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 6px 14px;
  font-weight: 700;
  font-size: 14px;
  background: var(--fond-1);
  color: var(--encre-2);
}
.puce.ia {
  background: rgba(28, 27, 34, 0.06);
}
.point {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--bleu);
}

/* Jauge de temps (sans chiffre) */
.jauge {
  height: 12px;
  border-radius: 999px;
  background: rgba(28, 27, 34, 0.08);
  overflow: hidden;
  width: 100%;
}
.jauge > i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--jaune), var(--corail));
  transition: width 1s linear;
}

/* Cartes d'activités */
.activites {
  grid-template-columns: repeat(4, 1fr);
}
.activite {
  background: var(--papier);
  border-radius: var(--rayon);
  box-shadow: var(--ombre);
  padding: 20px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  text-align: left;
  gap: 12px;
  transition: transform 0.1s ease;
}
.activite:active {
  transform: scale(0.98);
}
.activite .icone {
  width: 84px;
  height: 84px;
  border-radius: 22px;
  display: grid;
  place-items: center;
}
.activite h3 {
  font-size: 22px;
}
.activite p {
  font-size: 15px;
  color: var(--encre-2);
}
.activite:disabled,
.activite[data-fermee] {
  opacity: 0.55;
}

/* Héros */
.heros {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.heros .carte.sombre {
  background: var(--encre);
  color: #fff;
  position: relative;
  overflow: hidden;
}
.heros .carte.sombre p {
  color: rgba(255, 255, 255, 0.75);
}
/* Profils "Qui utilise la tablette ?" */
.profils {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  justify-content: center;
}
.profil {
  width: 180px;
  height: 200px;
  background: var(--papier);
  border-radius: 28px;
  box-shadow: var(--ombre);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.profil .avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-family: var(--police-titre);
  font-size: 36px;
  font-weight: 700;
  color: var(--encre);
}
.profil .nom {
  font-family: var(--police-titre);
  font-size: 24px;
  font-weight: 600;
}
.profil .classe {
  color: var(--gris);
  font-weight: 700;
}

/* Lecture / Parler */
.deux {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}
.texte-lecture {
  font-family: var(--police-titre);
  font-size: 30px;
  line-height: 1.7;
  font-weight: 500;
}
.texte-lecture .phrase {
  border-radius: 10px;
  padding: 2px 6px;
  transition: background 0.3s;
}
.texte-lecture .phrase.active {
  background: var(--jaune);
}
.texte-lecture .phrase.lue {
  color: var(--gris);
}
.orbe-panneau {
  background: var(--encre);
  color: #fff;
  border-radius: var(--rayon);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.orbe-panneau canvas {
  width: 100%;
  max-width: 260px;
  aspect-ratio: 1;
}
.orbe-panneau .etat {
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  font-size: 16px;
  min-height: 24px;
  text-align: center;
}
.orbe-panneau .sous-titre {
  color: rgba(255, 255, 255, 0.9);
  font-size: 18px;
  line-height: 1.4;
  text-align: center;
  max-height: 4.2em;
  overflow: hidden;
}

/* Ardoise */
.ardoise-cadre {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
}
.modele {
  font-family: var(--police-titre);
  font-size: 120px;
  font-weight: 600;
  line-height: 1;
}
.modele.mot {
  font-size: 64px;
}
.ardoise-toile {
  background: #2e2b3a;
  border-radius: var(--rayon);
  position: relative;
  overflow: hidden;
  touch-action: none;
}
.ardoise-toile canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.ardoise-toile .ligne-guide {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 2px dashed rgba(255, 255, 255, 0.25);
}

/* Sons */
.mot-son {
  font-family: var(--police-titre);
  font-size: 56px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 20px;
}
.mot-son .emoji {
  font-size: 80px;
}
.choix-son {
  display: flex;
  gap: 24px;
}
.choix-son .pilule {
  min-width: 240px;
}

/* Parent */
.parent {
  grid-template-columns: 1fr 1fr;
}
.liste {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.champ {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 700;
  font-size: 15px;
  color: var(--encre-2);
}
input,
select {
  font: inherit;
  font-size: 18px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 2px solid rgba(28, 27, 34, 0.12);
  background: #fff;
  color: var(--encre);
  min-height: 52px;
}
input.pin {
  letter-spacing: 0.5em;
  text-align: center;
  font-size: 32px;
  font-weight: 800;
  width: 240px;
}
.clavier {
  display: grid;
  grid-template-columns: repeat(3, 84px);
  gap: 12px;
}
.clavier button {
  height: 72px;
  border-radius: 20px;
  background: var(--papier);
  box-shadow: var(--ombre);
  font-family: var(--police-titre);
  font-size: 30px;
  font-weight: 600;
}
.clavier button.action {
  background: transparent;
  box-shadow: none;
  font-size: 18px;
  font-family: var(--police-texte);
  font-weight: 700;
}
.points {
  display: flex;
  gap: 16px;
}
.points i {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 3px solid var(--encre);
  display: block;
}
.points i.plein {
  background: var(--encre);
}
.seance {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid rgba(28, 27, 34, 0.08);
  font-size: 15px;
}
.seance .quand {
  color: var(--gris);
  font-weight: 700;
}
.seance .sujets {
  color: var(--encre-2);
}
.erreur {
  color: var(--corail);
  font-weight: 700;
}
.secondaire {
  color: var(--gris);
  font-size: 14px;
}
.texte-legal {
  font-size: 16px;
  line-height: 1.6;
  color: var(--encre-2);
}
.texte-legal h3 {
  margin-top: 16px;
  font-size: 20px;
}
.texte-legal ul {
  padding-left: 20px;
}

/* Animation */
@keyframes apparait {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.scene > * {
  animation: apparait 0.25s ease both;
}
@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}
.pulse {
  animation: pulse 1.6s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* Tablette 8,7" (≈ 893×533 px CSS) : tout doit tenir sans faire défiler la page */
@media (max-height: 620px) {
  h1 {
    font-size: 32px;
  }
  .scene {
    padding: 14px 18px;
    gap: 12px;
  }
  .activite {
    min-height: 140px;
    padding: 14px;
    gap: 8px;
  }
  .activite .icone {
    width: 70px;
    height: 70px;
  }
  .activite h3 {
    font-size: 19px;
  }
  .activite p {
    font-size: 13px;
  }
  .heros .carte {
    padding: 16px;
  }
  .heros .carte.sombre {
    min-height: 120px !important;
  }
  .modele {
    font-size: 88px;
  }
  .modele.mot {
    font-size: 48px;
  }
  .pilule.grand {
    height: 60px;
    font-size: 20px;
  }
  .ardoise-cadre > .carte {
    overflow-y: auto;
    gap: 8px !important;
  }
  .texte-lecture {
    font-size: 26px;
    line-height: 1.6;
  }
  .profil {
    width: 160px;
    height: 176px;
  }
  .mot-son {
    font-size: 48px;
  }
  .mot-son .emoji {
    font-size: 64px;
  }
}

@media (max-width: 1000px) {
  .parent {
    grid-template-columns: 1fr;
  }
}

/* Petit écran de secours (téléphone) */
@media (max-width: 760px) {
  .activites {
    grid-template-columns: repeat(2, 1fr);
  }
  .heros,
  .deux,
  .parent,
  .ardoise-cadre {
    grid-template-columns: 1fr;
  }
  h1 {
    font-size: 30px;
  }
}

/* Icônes Phosphor (js/icone.js) : taille et couleur suivent le texte. */
.ph {
  width: 1em;
  height: 1em;
  flex: none;
  vertical-align: -0.125em;
}
.grande-icone {
  font-size: 88px;
  line-height: 0;
}
/* Maki, la mascotte (app/assets/maki/, poses détourées) */
.maki {
  height: 110px;
  width: auto;
  flex: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.maki.grand {
  height: 180px;
}
.heros .carte.sombre {
  padding-right: 185px; /* Maki et sa queue */
}
.heros .maki {
  position: absolute;
  right: 10px;
  bottom: 0;
  height: min(100%, 170px);
}
.activite .icone img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
@media (max-height: 620px) {
  .maki.grand {
    height: 150px;
  }
}
.sablier {
  font-size: 24px;
  line-height: 0;
  color: var(--encre-2);
}
.clavier button.action .ph {
  font-size: 30px;
}
/* Surfaces du navigateur aux couleurs de l'app (règle « browser surfaces » d'Impeccable). */
::selection {
  background: var(--lavande);
  color: var(--encre);
}
input,
textarea {
  caret-color: var(--corail);
  accent-color: var(--encre);
}
table,
.chiffres {
  font-variant-numeric: tabular-nums;
}
