/* ============ CARAMEL 2 · KIT DE JEU (styles propres à js/ui/kit.js) ============
   Complète css/base.css (.keypad .key .answer .choices .choice .bubble .sheet .overlay .toast)
   sans redéfinir ses jetons ni ses couleurs. Mobile d'abord : cibles ≥ 48 px, retour tactile
   sur :active et .is-pressed (posé au pointerdown et pour le clavier physique). */

/* ---------- pavé numérique ---------- */
.kit-keypad { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.kit-answer {
  min-width: 168px; max-width: 100%; padding: 6px 22px;
  transition: background var(--dur-2), border-color var(--dur-2), color var(--dur-2);
}
.kit-answer-val { white-space: nowrap; }
.kit-keys .key { min-height: clamp(48px, 6.6dvh, 58px); display: grid; place-items: center; line-height: 1; }
.kit-keys .key.ok { grid-column: 1 / -1; font-size: 1.55rem; }
.kit-keys .key.del { font-size: 1.35rem; }
.kit-keys .key.kit-comma { font-size: 2.2rem; padding-bottom: .35em; }   /* virgule bien visible */
.kit-keys .key.is-pressed { transform: translateY(2px); box-shadow: 0 1px 0 var(--pink-200); background: var(--pink-50); }
.kit-keys .key.ok:active, .kit-keys .key.ok.is-pressed { box-shadow: 0 1px 0 var(--amber-500); background: var(--amber-300); }
.kit-key-gap { visibility: hidden; }          /* case vide quand il n'y a pas de virgule */

/* ---------- QCM ---------- */
.kit-choices .choice { position: relative; display: flex; align-items: center; justify-content: center; text-align: center; }
.kit-choices .choice.read { justify-content: flex-start; text-align: left; font-size: 1.12rem; padding: 12px 16px; }
.kit-choices .choice.is-long { font-size: 1.05rem; }
.kit-choices .choice.right { animation: kit-glow 1.4s ease-out 1; }
/* pastille ✓ sur la bonne réponse (trouvée ou montrée) : le juste ne se dit jamais par la seule couleur.
   Rien sur le choix « essaie encore » : la secousse douce et la bulle suffisent, sans marque de faute.
   2e valeur de content : ✓ hors du nom accessible (la 1re sert aux navigateurs qui ne la comprennent pas) */
.kit-choices .choice.right::after {
  content: '✓'; content: '✓' / ''; position: absolute; top: -10px; right: -8px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-size: .95rem; font-weight: 700; line-height: 1;
  background: var(--ok); color: var(--on-ok); border: 2px solid var(--card); box-shadow: var(--shadow-1);
}
.kit-choices .choice[aria-disabled="true"] { cursor: default; }

/* ---------- bulles ---------- */
.kit-bubble {
  display: flex; align-items: flex-end; gap: 10px; width: 100%;
  animation: kit-bubble-in 340ms var(--ease-pop) both; transform-origin: 22px 100%;
}
.kit-bubble-ava {
  flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.45rem; line-height: 1; background: var(--card); border: 2px solid var(--pink-200); box-shadow: var(--shadow-1);
}
.kit-bubble--hint .kit-bubble-ava { background: var(--amber-100); border-color: var(--amber-300); }
.kit-bubble--soft .kit-bubble-ava { background: var(--orange-50); border-color: var(--orange-300); }
.kit-bubble--good .kit-bubble-ava { background: var(--ok-50); border-color: var(--ok-300); }
.kit-bubble-body {                            /* indice et explication : des textes à LIRE, en police de lecture */
  flex: 1; min-width: 0; white-space: pre-line; font-family: var(--font-read); font-weight: 400; font-size: 1.02rem; line-height: 1.4;
  border-bottom-left-radius: 6px; overflow-wrap: break-word;
}
.kit-bubble:not(.no-ava) .kit-bubble-body::before {   /* petite queue tournée vers la pastille */
  content: ''; position: absolute; left: -7px; bottom: 12px; width: 12px; height: 12px;
  background: inherit; border-left: inherit; border-bottom: inherit;
  transform: rotate(45deg); border-bottom-left-radius: 3px;
}

/* ---------- toast (ne capte pas les touches : le pavé dessous reste utilisable) ---------- */
.kit-toast {                   /* left: 50 % ne laisse que la moitié de l'écran au texte : largeur au contenu */
  width: max-content; max-width: calc(100vw - 32px); pointer-events: none; text-wrap: balance;
  animation: kit-toast-in var(--dur-2) var(--ease-out) both;
}
/* feuille ouverte : le toast passe en haut, pour ne pas cacher ses boutons */
html.kit-lock .kit-toast { bottom: auto; top: calc(14px + var(--safe-t)); }
.kit-toast.is-out { animation: kit-toast-out 220ms ease-in both; }

/* ---------- feuille du bas ---------- */
html.kit-lock { overflow: hidden; }
.kit-overlay { touch-action: none; overscroll-behavior: contain; }
.kit-sheet { position: relative; }
.kit-sheet:focus { outline: none; }
.kit-sheet-head {                            /* collé en haut de la feuille quand le contenu défile */
  position: sticky; top: -22px; z-index: 2; background: var(--card);   /* -22px = marge haute de .sheet (le collage se mesure depuis le bord du contenu) */
  margin: -22px -18px 0; padding: 8px 18px 4px; border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.kit-sheet-head.no-grab { padding-top: 18px; }
.kit-sheet-head.no-grab.no-title { min-height: 56px; }
.kit-sheet-grab {                            /* poignée : glisser vers le bas pour fermer */
  height: 22px; margin: 0 auto 2px; display: grid; place-items: center; touch-action: none; cursor: grab;
}
.kit-sheet-grab::before { content: ''; width: 44px; height: 5px; border-radius: 3px; background: var(--pink-200); }
.kit-sheet-x {
  position: absolute; top: 8px; right: 8px; width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.05rem; color: var(--ink-3); background: var(--pink-50);
  transition: transform var(--dur-1) var(--ease-out), background var(--dur-1);
}
.kit-sheet-x:active { transform: scale(.92); background: var(--pink-100); }
.kit-sheet-title {
  font-size: 1.35rem; font-weight: 700; color: var(--title); line-height: 1.2;
  margin: 4px 52px 10px 2px; touch-action: none;
}
.kit-sheet-head.no-grab .kit-sheet-title { margin-top: 6px; }
.kit-sheet.is-center .kit-sheet-title { margin: 6px 48px 10px; text-align: center; }
.kit-sheet-body { color: var(--ink-2); font-size: 1.05rem; line-height: 1.45; }
.kit-sheet-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.kit-sheet-actions.is-pair { display: grid; grid-template-columns: 1fr 1fr; }
.kit-sheet-actions.is-pair .btn { padding-left: 12px; padding-right: 12px; }
.overlay.middle .kit-sheet { max-width: 420px; }

/* confirmation */
.kit-confirm { text-align: center; padding: 4px 6px 0; }
.kit-confirm-ico { font-size: 2.6rem; line-height: 1; margin: 2px 0 10px; }
.kit-confirm-text { font-size: 1.18rem; font-weight: 600; color: var(--ink); line-height: 1.35; }

/* « 🌱 Pas encore appris » (v2.5) : pastille discrète sous l'indice, après une première erreur ; feuille avec le compagnon */
.kit-later {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin-top: 8px; padding: 6px 14px 6px 10px;
  border-radius: 999px; border: 2px solid var(--ok-300); background: var(--ok-50); color: var(--ink-2);
  font: 600 .95rem/1.2 var(--font-ui, inherit); white-space: nowrap; cursor: pointer;
  transition: transform var(--dur-1) var(--ease-out);
}
.kit-later:active { transform: scale(.96); }
.kit-later:focus-visible { outline: 3px solid var(--ok-300); outline-offset: 2px; }
.kit-later-ico { font-size: 1.1rem; line-height: 1; }
.kit-bubble-body .kit-later { display: flex; width: max-content; max-width: 100%; white-space: normal; }
.kit-later-pet { display: flex; justify-content: center; margin: 0 0 8px; }
.kit-later-pet svg { width: 72px; height: auto; }

/* ---------- survol (souris uniquement) ---------- */
@media (hover: hover) and (pointer: fine) {
  .kit-sheet-x:hover { background: var(--pink-100); }
}

/* ---------- keyframes du kit ---------- */
@keyframes kit-bubble-in { from { opacity: 0; transform: scale(.72) translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes kit-toast-in { from { opacity: 0; transform: translate(-50%, 14px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes kit-toast-out { to { opacity: 0; transform: translate(-50%, 10px); } }
@keyframes kit-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes kit-fade-out { to { opacity: 0; } }
@keyframes kit-glow {                          /* halo vert discret sur la bonne réponse */
  0%   { box-shadow: 0 0 0 0 rgba(22, 163, 74, .35), var(--shadow-1); }
  100% { box-shadow: 0 0 0 14px rgba(22, 163, 74, 0), var(--shadow-1); }
}

/* ---------- mouvement réduit / animations douces : fondus uniquement ---------- */
@media (prefers-reduced-motion: reduce) {
  .kit-bubble { animation: kit-fade-in var(--dur-1) ease-out both !important; }
  .kit-toast { animation: kit-fade-in var(--dur-1) ease-out both !important; }
  .kit-toast.is-out { animation: kit-fade-out var(--dur-1) ease-in both !important; }
  .kit-choices .choice.right { animation: none !important; }
}
html.motion-soft .kit-bubble { animation: kit-fade-in var(--dur-1) ease-out both; }
html.motion-soft .kit-toast { animation: kit-fade-in var(--dur-1) ease-out both; }
html.motion-soft .kit-toast.is-out { animation: kit-fade-out var(--dur-1) ease-in both; }
html.motion-soft .kit-choices .choice.right { animation: none; }

/* ---------- 🔊 « Écouter encore » (js/ui/voice.js, listenButton) : rond de 48 px, vagues pendant la lecture ----------
   Voix en panne sur cet appareil (html.vx-quiet, posé par voice.js) : le bouton se fait discret (bord gris pointillé,
   icône en gris) mais reste touchable — un autre essai peut marcher. */
.vx-listen {
  position: relative; flex: none; width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center;
  background: var(--card); border: 2px solid var(--pink-200); box-shadow: var(--shadow-1); font-size: 1.2rem; line-height: 1;
  transition: transform var(--dur-1) var(--ease-out), border-color var(--dur-1);
}
.vx-listen[hidden] { display: none; }
.vx-listen:active { transform: scale(.92); }
.vx-listen:focus-visible { border-radius: 50%; }
.vx-ico { position: relative; z-index: 1; }
.vx-wave { position: absolute; inset: -2px; border-radius: 50%; border: 2px solid var(--pink-400); opacity: 0; pointer-events: none; }
.vx-listen.is-speaking { border-color: var(--pink-400); }
.vx-listen.is-speaking .vx-wave { animation: vx-wave 1.2s var(--ease-out) infinite; }
@keyframes vx-wave { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(1.35); } }
@media (prefers-reduced-motion: reduce) { .vx-listen.is-speaking .vx-wave { animation: none; opacity: .8; } }
html.motion-soft .vx-listen.is-speaking .vx-wave { animation: none; opacity: .8; }
/* is-call : la phrase attend un premier geste pour être dite (visite guidée à l'ouverture de l'appli) : 🔊 appelle */
.vx-listen.is-call { border-color: var(--pink-400); animation: vx-call 1.6s var(--ease-out) infinite; }
@keyframes vx-call { 0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--pink-400) 55%, transparent), var(--shadow-1); }
  60% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--pink-400) 0%, transparent), var(--shadow-1); } }
@media (prefers-reduced-motion: reduce) { .vx-listen.is-call { animation: none; box-shadow: 0 0 0 4px var(--pink-200), var(--shadow-1); } }
html.motion-soft .vx-listen.is-call { animation: none; box-shadow: 0 0 0 4px var(--pink-200), var(--shadow-1); }
html.vx-quiet .vx-listen { background: transparent; border-style: dashed; border-color: var(--ink-3); box-shadow: none; }
html.vx-quiet .vx-listen .vx-ico { filter: grayscale(1); opacity: .75; }

/* ---------- visite guidée (kit.tour) : projecteur doux sur UN élément, le reste atténué ----------
   Le voile est l'ombre portée du projecteur (une seule couche) ; anneau clair puis anneau de focus du thème autour de
   l'élément ; bulle du compagnon (phrase en police de lecture), gros « Suivant ▶ », petit « Passer ». */
.kit-tour { --tour-dim: color-mix(in srgb, var(--ink) 58%, transparent); position: fixed; inset: 0; z-index: 75; }
.kit-tour-hole {
  position: absolute; left: 0; top: 0; width: 0; height: 0; border-radius: 18px; pointer-events: none;
  box-shadow: 0 0 0 4px var(--card), 0 0 0 7px var(--focus), 0 0 26px 12px color-mix(in srgb, var(--card) 45%, transparent),
    0 0 0 200vmax var(--tour-dim);
}
.kit-tour.is-ready .kit-tour-hole {
  transition: transform 420ms var(--ease-out), width 420ms var(--ease-out), height 420ms var(--ease-out), border-radius 420ms var(--ease-out);
}
.kit-tour-card {
  position: absolute; left: 0; top: 0; width: min(380px, calc(100vw - 24px)); padding: 14px 14px 6px;
  background: var(--card); border: 3px solid var(--amber-200); border-radius: var(--r-xl); box-shadow: var(--shadow-2);
}
.kit-tour.is-ready .kit-tour-card { transition: transform 420ms var(--ease-out); }
/* le compagnon parle : son visage, et son 🔊 juste dessous ; la phrase prend toute la largeur restante */
.kit-tour-say { display: grid; grid-template-columns: 60px minmax(0, 1fr); column-gap: 12px; row-gap: 8px; align-items: center; }
.kit-tour-who {
  grid-column: 1; grid-row: 1; width: 60px; height: 60px; border-radius: 50%; overflow: hidden; display: grid; place-items: end center;
  background: linear-gradient(180deg, var(--n-sky-2) 0 56%, var(--n-grass-1) 56% 100%); border: 3px solid var(--card);
  box-shadow: 0 0 0 2px var(--pink-200);
}
.kit-tour-who svg { width: 100%; height: 100%; }
.kit-tour-text { grid-column: 2; grid-row: 1 / span 2; min-width: 0; margin: 0; font-family: var(--font-read); font-weight: 600; font-size: 1.2rem; line-height: 1.35; color: var(--ink); }
.kit-tour-say .vx-listen { grid-column: 1; grid-row: 2; justify-self: center; }
.kit-tour-next { margin-top: 12px; gap: 12px; }
.kit-tour-next-ico { font-size: 1.1rem; line-height: 1; }
.kit-tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 2px; }
.kit-tour-dots { display: flex; gap: 6px; padding-left: 6px; }
.kit-tour-dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--card); border: 2px solid color-mix(in srgb, var(--ink-3) 80%, var(--card)); }
.kit-tour-dots i.is-done { background: var(--ink-3); border-color: var(--ink-3); }
.kit-tour-dots i.is-now { background: var(--amber-400); border-color: var(--title); }
.kit-tour-skip {
  min-height: 48px; min-width: 72px; padding: 0 12px; border-radius: var(--r-pill); background: none;
  color: var(--ink-3); font-weight: 600; font-size: 1rem; text-decoration: underline; text-underline-offset: 3px;
}
.kit-tour-skip:active { background: var(--pink-100); }
@media (prefers-reduced-motion: reduce) {
  .kit-tour.is-ready .kit-tour-hole, .kit-tour.is-ready .kit-tour-card { transition: none; }
}
html.motion-soft .kit-tour.is-ready .kit-tour-hole, html.motion-soft .kit-tour.is-ready .kit-tour-card { transition: none; }
