/* =====================================================================
   ADAM APPREND — DESIGN SYSTEM
   Public : enfant de 4 ans (moyenne section), sur tablette en paysage.
   Principes : rien à lire, cibles énormes, une seule action par écran,
   couleurs franches sur fond ciel/herbe, feedback immédiat et doux.
   ===================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  /* Fond du monde */
  --sky:        #5fb8ff;
  --sky-light:  #dff3ff;
  --grass:      #7ed957;
  --grass-dark: #4caf50;
  --cloud:      #ffffff;
  --paper:      #fffdf7;   /* surfaces (bulles, cartes) */
  --sand:       #fff3d6;   /* surface chaude secondaire */

  /* Encre */
  --ink:        #1d2a44;
  --ink-soft:   #5b6a86;
  --ink-faint:  #cfd8e6;

  /* Accent (bouton principal, étoiles) */
  --sun:        #ff9f1c;
  --sun-dark:   #c86f00;
  --star:       #ffd23f;
  --star-dark:  #d9a600;

  /* Couleurs des mondes (une par domaine) */
  --w-couleurs: #ff5a5f;  --w-couleurs-dark: #c23a3f;
  --w-formes:   #a56cff;  --w-formes-dark:   #7a46d1;
  --w-lettres:  #3d8bff;  --w-lettres-dark:  #2460c4;
  --w-nombres:  #ffb000;  --w-nombres-dark:  #c98600;
  --w-monde:    #2fbf71;  --w-monde-dark:    #1f8f52;
  --w-logique:  #ff7bb0;  --w-logique-dark:  #d4507f;

  /* Couleurs à apprendre (valeurs "pures", lisibles par un enfant) */
  --c-rouge: #e63946;  --c-bleu: #2a6df4;  --c-jaune: #ffd60a;
  --c-vert:  #2dc653;  --c-orange: #ff8c1a; --c-violet: #8e44ad;
  --c-rose:  #ff69b4;  --c-marron: #8b5a2b; --c-noir: #222222;
  --c-blanc: #ffffff;  --c-gris: #9aa3b2;

  /* Sémantique */
  --ok:    #2dc653;
  --oops:  #ff8c1a;   /* jamais de rouge "erreur" : l'orange invite à réessayer */

  /* Typo */
  --font-ui:   "Fredoka", "Nunito", system-ui, sans-serif;  /* enfant : lettres rondes, a et g simples */
  --font-text: "Nunito", system-ui, sans-serif;               /* parent : lecture longue */
  --fs-1: 0.9rem;   /* légende parent */
  --fs-2: 1.1rem;   /* texte parent */
  --fs-3: 1.5rem;   /* étiquette enfant */
  --fs-4: 2rem;     /* consigne */
  --fs-5: 3rem;     /* titre monde */
  --fs-6: 5rem;     /* chiffre / lettre moyenne */
  --fs-7: 9rem;     /* lettre géante */

  /* Espace & forme */
  --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px; --sp-5: 24px; --sp-6: 32px; --sp-7: 48px;
  --r-s: 12px; --r-m: 20px; --r-l: 32px; --r-pill: 999px;
  --touch: 88px;           /* cible minimale pour un doigt de 4 ans */

  /* Relief "jouet" : ombre dure sous l'objet + ombre douce */
  --pop:  0 6px 0 rgba(0,0,0,.18), 0 14px 24px rgba(0,0,0,.14);
  --pop-pressed: 0 2px 0 rgba(0,0,0,.18), 0 6px 10px rgba(0,0,0,.12);
  --float: 0 10px 30px rgba(20,40,80,.16);

  /* Mouvement */
  --ease-pop: cubic-bezier(.34,1.56,.64,1);
  --t-fast: 120ms; --t-med: 260ms; --t-slow: 600ms;
}

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--sky-light);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;           /* pas de zoom au double-tap */
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; border: 0; background: none; padding: 0; cursor: pointer; }
button:focus-visible, [tabindex]:focus-visible { outline: 5px solid var(--sun); outline-offset: 4px; }
svg.ico { width: 1em; height: 1em; display: inline-block; vertical-align: -0.15em; fill: currentColor; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- 3. Fond "monde" (ciel + herbe + nuages) ---------- */
.world-bg {
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-light) 62%, var(--grass) 62.2%, var(--grass-dark) 100%);
}
.cloud { position: absolute; background: var(--cloud); border-radius: var(--r-pill); opacity: .92; pointer-events: none; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: inherit; border-radius: 50%; }
.cloud::before { width: 55%; height: 170%; left: 12%; top: -75%; }
.cloud::after  { width: 40%; height: 120%; left: 50%; top: -45%; }

/* ---------- 4. Boutons ---------- */
.btn {
  display: inline-grid; place-items: center; gap: var(--sp-1);
  min-width: var(--touch); min-height: var(--touch);
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--r-pill);
  background: var(--paper); color: var(--ink);
  font-weight: 600; font-size: var(--fs-3); line-height: 1;
  box-shadow: var(--pop);
  transition: transform var(--t-fast) var(--ease-pop), box-shadow var(--t-fast);
}
.btn:active, .btn.is-pressed { transform: translateY(4px) scale(.97); box-shadow: var(--pop-pressed); }
.btn-sun   { background: var(--sun); color: #fff; box-shadow: 0 6px 0 var(--sun-dark), 0 14px 24px rgba(0,0,0,.18); }
.btn-sun:active { box-shadow: 0 2px 0 var(--sun-dark), 0 6px 10px rgba(0,0,0,.12); }
.btn-round { width: var(--touch); height: var(--touch); padding: 0; border-radius: 50%; font-size: 2.2rem; }
.btn-round.lg { width: 140px; height: 140px; font-size: 4rem; }
.btn-ghost { background: rgba(255,255,255,.85); box-shadow: var(--float); }

/* ---------- 5. Tuiles de réponse (le composant le plus utilisé) ---------- */
.tiles { display: grid; gap: var(--sp-5); grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: stretch; }
.tile {
  display: grid; place-items: center; align-content: center; gap: var(--sp-2);
  min-height: 170px; padding: var(--sp-4);
  border-radius: var(--r-l);
  background: var(--paper); color: var(--ink);
  font-size: var(--fs-3); font-weight: 600;
  box-shadow: var(--pop);
  border: 6px solid transparent;
  transition: transform var(--t-fast) var(--ease-pop), box-shadow var(--t-fast), border-color var(--t-fast);
}
.tile:active { transform: scale(.96); box-shadow: var(--pop-pressed); }
.tile > svg, .tile .art { width: clamp(72px, 14vmin, 130px); height: clamp(72px, 14vmin, 130px); }
.tile.big-glyph { font-size: var(--fs-6); line-height: 1; }
.tile.is-right { border-color: var(--ok); animation: bounce var(--t-slow) var(--ease-pop); }
.tile.is-wrong { animation: shake 420ms ease; opacity: .55; }
.tile.is-hint  { animation: wiggle 900ms ease-in-out infinite; }
.swatch { width: clamp(72px, 14vmin, 130px); aspect-ratio: 1; border-radius: 50%; box-shadow: inset -10px -10px 0 rgba(0,0,0,.12), 0 0 0 5px #fff; }

/* ---------- 6. Mascotte & bulle ---------- */
.mascot { width: clamp(90px, 16vmin, 160px); height: auto; filter: drop-shadow(0 8px 10px rgba(0,0,0,.18)); }
.mascot.talk { animation: talk 700ms ease-in-out infinite; }
.bubble {
  position: relative;
  background: var(--paper); color: var(--ink);
  border-radius: var(--r-l); padding: var(--sp-4) var(--sp-5);
  font-size: var(--fs-4); font-weight: 600; line-height: 1.2; text-wrap: balance;
  box-shadow: var(--float);
}
.bubble::before { content: ""; position: absolute; left: -18px; top: 40%; border: 14px solid transparent; border-right-color: var(--paper); }
.bubble strong { color: var(--w-couleurs); }

/* ---------- 7. Progression ---------- */
.stars { display: inline-flex; gap: 6px; font-size: 1.8rem; line-height: 1; }
.stars svg { width: 1em; height: 1em; }
.stars .on  { color: var(--star); filter: drop-shadow(0 2px 0 var(--star-dark)); }
.stars .off { color: rgba(255,255,255,.75); }
.chip { display: inline-flex; align-items: center; gap: 8px; background: rgba(255,255,255,.9); border-radius: var(--r-pill); padding: 8px 16px; font-weight: 600; box-shadow: var(--float); min-height: 52px; }

/* Étape sur le chemin */
.step {
  position: absolute; width: clamp(84px, 13vmin, 120px); aspect-ratio: 1; border-radius: 50%;
  display: grid; place-items: center; transform: translate(-50%, -50%);
  background: var(--paper); border: 6px solid var(--star);
  box-shadow: var(--pop); font-size: 2.6rem; font-weight: 700;
  transition: transform var(--t-fast) var(--ease-pop);
}
.step:active { transform: translate(-50%, -50%) scale(.94); }
.step > svg { width: 62%; height: 62%; }
.step.done { background: var(--star); border-color: #fff; }
.step.next { animation: glow 1.6s ease-in-out infinite; }
.step.lock { background: #e9eee6; border-color: #cfd8c8; color: #9aa596; box-shadow: var(--pop-pressed); }
.step .stars { position: absolute; top: -22px; font-size: 1.1rem; }
.step .label { position: absolute; bottom: -34px; white-space: nowrap; font-size: 1rem; font-weight: 600; background: rgba(255,255,255,.9); border-radius: var(--r-pill); padding: 2px 12px; color: var(--ink); }

/* ---------- 8. Barre du haut (parents, étoiles, retour) ---------- */
.topbar { position: absolute; inset: 0 0 auto 0; display: flex; justify-content: space-between; align-items: center; padding: var(--sp-4); gap: var(--sp-3); z-index: 5; pointer-events: none; }
.topbar > * { pointer-events: auto; }

/* ---------- 9. Coin parents (texte, lisibilité) ---------- */
.parent { font-family: var(--font-text); font-size: var(--fs-2); line-height: 1.55; color: var(--ink); background: var(--paper); -webkit-user-select: text; user-select: text; }
.parent h1, .parent h2, .parent h3 { font-family: var(--font-ui); line-height: 1.15; text-wrap: balance; margin: 0 0 .4em; }
.parent h1 { font-size: 2.2rem; } .parent h2 { font-size: 1.6rem; margin-top: 1.6em; } .parent h3 { font-size: 1.2rem; margin-top: 1.2em; }
.parent p { max-width: 68ch; margin: .5em 0; }
.parent table { border-collapse: collapse; width: 100%; font-size: 1rem; }
.parent th, .parent td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--ink-faint); vertical-align: top; }
.parent th { font-family: var(--font-ui); color: var(--ink-soft); text-transform: uppercase; letter-spacing: .06em; font-size: .8rem; }
.parent input, .parent select { font: inherit; padding: .5rem .8rem; border-radius: var(--r-s); border: 2px solid var(--ink-faint); background: #fff; color: var(--ink); }
.parent .btn { font-family: var(--font-ui); font-size: 1.1rem; min-height: 56px; min-width: 56px; }

/* ---------- 10. Mouvement ---------- */
@keyframes bounce { 0%{transform:scale(1)} 40%{transform:scale(1.12)} 70%{transform:scale(.96)} 100%{transform:scale(1.04)} }
@keyframes shake  { 0%,100%{transform:translateX(0)} 25%{transform:translateX(-10px)} 75%{transform:translateX(10px)} }
@keyframes wiggle { 0%,100%{transform:rotate(-3deg)} 50%{transform:rotate(3deg)} }
@keyframes glow   { 0%,100%{box-shadow:0 0 0 0 rgba(255,210,63,.6), var(--pop)} 50%{box-shadow:0 0 0 18px rgba(255,210,63,0), var(--pop)} }
@keyframes talk   { 0%,100%{transform:translateY(0) rotate(0)} 50%{transform:translateY(-6px) rotate(-2deg)} }
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
@keyframes pulse  { 50%{transform:scale(1.06)} }
.floaty { animation: floaty 3.5s ease-in-out infinite; }
.pulse  { animation: pulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 1ms !important; }
}

/* ---------- 11. Pico (SVG inline) : clignement et bouche qui parle ---------- */
.fox { display: block; overflow: visible; }
.fox .eye { transform-box: fill-box; transform-origin: center; animation: blink 4.5s ease-in-out infinite; }
.fox .mouth { transform-box: fill-box; transform-origin: center; }
.fox.talk .mouth { animation: mouthy 220ms ease-in-out infinite alternate; }
.fox.talk .head { transform-box: fill-box; transform-origin: 50% 90%; animation: nod 700ms ease-in-out infinite; }
@keyframes blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(.08); } }
@keyframes mouthy { from { transform: scaleY(1); } to { transform: scaleY(1.9) translateY(1px); } }
@keyframes nod { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(-3deg); } }
.word-card { background: var(--sand); border-radius: var(--r-m); padding: 12px 16px; display: grid; justify-items: center; gap: 6px; font-weight: 600; text-align: center; box-shadow: var(--pop-pressed); }
.word-card svg { width: clamp(60px, 12vmin, 110px); height: clamp(60px, 12vmin, 110px); }
.word-card b { font-size: clamp(3rem, 9vmin, 5rem); line-height: 1; color: var(--w-lettres); }
