/* ===== Learn English — styles ===== */
:root {
  --ink: #1F2350;
  --ink-soft: #4A4F7A;
  --orange: #FF7A00;
  --orange-deep: #E06100;
  --green: #0F9D58;
  --green-deep: #0B7A44;
  --sun: #FFC53D;
  --coral: #FF5D6C;
  --lagoon: #EAF7F4;
  --lagoon-deep: #CBEDE5;
  --paper: #FFFFFF;
  --line: #D9E4EF;
  --sky: #3B82F6;
  --radius-lg: 28px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --shadow-press: 0 6px 0 rgba(31, 35, 80, 0.18);
  --font: Roboto, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --fs-xs: 0.875rem;
  --fs-sm: 1rem;
  --fs-md: 1.25rem;
  --fs-lg: 1.75rem;
  --fs-xl: 2.5rem;
  --fs-xxl: 3.5rem;
  --t-fast: 140ms;
  --t-screen: 260ms;
  --wax: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='56' viewBox='0 0 56 56'%3E%3Cg fill='none' stroke='%231F2350' stroke-opacity='.08' stroke-width='3'%3E%3Ccircle cx='28' cy='28' r='9'/%3E%3Ccircle cx='28' cy='28' r='17'/%3E%3Cpath d='M0 0q14 14 0 28M56 0q-14 14 0 28M0 56q14-14 0-28M56 56q-14-14 0-28'/%3E%3C/g%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background: var(--lagoon);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; }
img, svg { display: block; }

#app { position: relative; min-height: 100dvh; overflow-x: hidden; }

/* ----- Démarrage ----- */
.boot { min-height: 100dvh; display: grid; place-content: center; text-align: center; gap: 8px; }
.boot-logo { font-size: 72px; animation: bob 1.4s ease-in-out infinite; }
.boot p { font-weight: 900; font-size: var(--fs-lg); margin: 0; }

/* ----- Écrans + transitions ----- */
.screen {
  position: absolute; inset: 0;
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(32px + env(safe-area-inset-bottom));
  will-change: transform, opacity;
}
.screen-inner { max-width: 760px; margin: 0 auto; }
.screen.enter { animation: screen-in var(--t-screen) cubic-bezier(.2,.8,.2,1) both; }
.screen.enter.back { animation-name: screen-in-back; }
.screen.leave { animation: screen-out var(--t-screen) ease both; pointer-events: none; }
.screen.leave.back { animation-name: screen-out-back; }
@keyframes screen-in { from { transform: translateX(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes screen-in-back { from { transform: translateX(-40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes screen-out { to { transform: translateX(-40px); opacity: 0; } }
@keyframes screen-out-back { to { transform: translateX(40px); opacity: 0; } }

/* ----- Typo ----- */
h1, h2, h3 { margin: 0; line-height: 1.1; letter-spacing: -0.02em; }
h1 { font-size: var(--fs-xl); font-weight: 900; }
h2 { font-size: var(--fs-lg); font-weight: 900; }
h3 { font-size: var(--fs-md); font-weight: 800; }
p { line-height: 1.5; margin: 0; }
.muted { color: var(--ink-soft); }
.fr { color: var(--ink-soft); font-size: var(--fs-sm); }
.en-big { font-size: var(--fs-xxl); font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.en-mid { font-size: var(--fs-xl); font-weight: 900; letter-spacing: -0.02em; line-height: 1.1; }
.center { text-align: center; }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.spacer { flex: 1; }

/* ----- Boutons ----- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  min-height: 60px; padding: 0 28px;
  border-radius: var(--radius-md);
  font-size: var(--fs-md); font-weight: 800;
  background: var(--paper); color: var(--ink);
  box-shadow: var(--shadow-press), inset 0 0 0 3px var(--line);
  transition: transform var(--t-fast) ease, box-shadow var(--t-fast) ease, opacity var(--t-fast);
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  touch-action: manipulation;
}
.btn:active { transform: translateY(5px); box-shadow: 0 1px 0 rgba(31,35,80,.18), inset 0 0 0 3px var(--line); }
.btn:focus-visible, .choice:focus-visible, .node:focus-visible, .icon-btn:focus-visible { outline: 4px solid var(--sky); outline-offset: 3px; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-primary { background: var(--orange); color: #fff; box-shadow: 0 6px 0 var(--orange-deep); }
.btn-primary:active { box-shadow: 0 1px 0 var(--orange-deep); }
.btn-go { background: var(--green); color: #fff; box-shadow: 0 6px 0 var(--green-deep); }
.btn-go:active { box-shadow: 0 1px 0 var(--green-deep); }
.btn-ghost { background: transparent; box-shadow: none; color: var(--ink-soft); min-height: 48px; font-size: var(--fs-sm); text-decoration: underline; text-underline-offset: 4px; }
.btn-ghost:active { box-shadow: none; }
.btn-wide { width: 100%; }
.icon-btn {
  appearance: none; border: 0; cursor: pointer;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--paper); box-shadow: 0 4px 0 rgba(31,35,80,.15), inset 0 0 0 3px var(--line);
  font-size: 26px; display: grid; place-items: center;
  transition: transform var(--t-fast);
}
.icon-btn:active { transform: translateY(3px) scale(.96); }
.icon-btn.sm { width: 36px; height: 36px; font-size: 16px; box-shadow: 0 3px 0 rgba(31,35,80,.12), inset 0 0 0 2px var(--line); }
.fr-line { display: inline-flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; }
.bubble .fr-line { justify-content: flex-start; }
.bubble .icon-btn.sm { width: 34px; height: 34px; font-size: 15px; }
.icon-btn.speaking { animation: pulse-soft .8s ease-in-out infinite; background: var(--sun); }

/* ----- Cartes ----- */
.card {
  background: var(--paper);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: 0 10px 0 var(--lagoon-deep);
}
.card.big { min-height: 300px; display: grid; place-content: center; text-align: center; gap: 14px; }
.emoji-xl { font-size: 96px; line-height: 1; }
.emoji-l { font-size: 56px; line-height: 1; }

/* ----- Barre de progression ----- */
.lesson-top { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.progress { flex: 1; height: 18px; background: var(--lagoon-deep); border-radius: 99px; overflow: hidden; }
.progress > i { display: block; height: 100%; width: 100%; background: var(--green); border-radius: 99px; transform-origin: left; transform: scaleX(0); transition: transform 400ms cubic-bezier(.2,.8,.2,1); }

/* ----- Personnages / bulles ----- */
.speaker { display: flex; align-items: flex-end; gap: 12px; }
.speaker.me { flex-direction: row-reverse; }
.avatar {
  flex: none; width: 64px; height: 64px; border-radius: 50%;
  display: grid; place-items: center; font-size: 38px;
  background: var(--sun); box-shadow: inset 0 0 0 4px rgba(255,255,255,.6);
}
.avatar.amy { background: #FFB4C2; }
.avatar.tom { background: var(--sun); }
.avatar.konan { background: #A7D8FF; }
.avatar.me { background: #B7F0C8; }
.bubble {
  position: relative; background: var(--paper); border-radius: 22px 22px 22px 6px;
  padding: 14px 18px; max-width: 80%;
  box-shadow: 0 5px 0 var(--lagoon-deep);
  animation: bubble-in 320ms cubic-bezier(.2,.9,.3,1.3) both;
}
.speaker.me .bubble { border-radius: 22px 22px 6px 22px; background: #DFF7E8; }
.bubble .en { font-size: var(--fs-md); font-weight: 800; }
.bubble .fr { margin-top: 4px; }
.bubble .row { margin-top: 8px; gap: 8px; }
.bubble .icon-btn { width: 44px; height: 44px; font-size: 20px; }
.dialogue { display: grid; gap: 14px; }
@keyframes bubble-in { from { transform: translateY(12px) scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }

/* ----- Micro ----- */
.mic-zone { display: grid; justify-items: center; gap: 14px; padding: 8px 0; }
.mic {
  --lvl: 0;
  position: relative; width: 112px; height: 112px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--orange); color: #fff; font-size: 48px;
  box-shadow: 0 8px 0 var(--orange-deep);
  display: grid; place-items: center; touch-action: manipulation;
  transition: transform var(--t-fast);
}
.mic::before {
  content: ""; position: absolute; inset: -14px; border-radius: 50%;
  background: var(--orange); opacity: .25;
  transform: scale(calc(0.85 + var(--lvl) * 0.5));
  transition: transform 90ms linear;
  z-index: -1;
}
.mic:active { transform: translateY(4px); }
.mic.listening { background: var(--coral); box-shadow: 0 8px 0 #D93E4E; }
.mic.listening::before { background: var(--coral); }
.mic[disabled] { opacity: .5; }
.mic-label { font-weight: 800; color: var(--ink-soft); min-height: 1.5em; text-align: center; }
.live { min-height: 2em; font-size: var(--fs-md); font-weight: 700; text-align: center; color: var(--ink-soft); font-style: italic; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { padding: 8px 14px; border-radius: 99px; font-weight: 800; font-size: var(--fs-md); background: var(--lagoon-deep); }
.chip.ok { background: #C8F2D8; color: var(--green-deep); animation: pop-in 260ms cubic-bezier(.2,.9,.3,1.4) both; }
.chip.ko { background: #FFD6DB; color: #B3192C; text-decoration: underline wavy; text-underline-offset: 5px; }
.fallback { background: #FFF4D6; border-radius: var(--radius-md); padding: 16px; display: grid; gap: 12px; text-align: center; }

/* ----- Choix ----- */
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; }
.choice {
  appearance: none; border: 0; cursor: pointer;
  min-height: 96px; padding: 16px; border-radius: var(--radius-md);
  background: var(--paper); box-shadow: 0 6px 0 var(--lagoon-deep), inset 0 0 0 3px var(--line);
  font-size: var(--fs-md); font-weight: 800; display: grid; place-items: center; gap: 6px;
  transition: transform var(--t-fast), background var(--t-fast);
  touch-action: manipulation;
}
.choice .emoji-l { font-size: 44px; }
.choice:active { transform: translateY(4px); }
.choice.right { background: #C8F2D8; box-shadow: 0 6px 0 var(--green), inset 0 0 0 3px var(--green); }
.choice.wrong { background: #FFD6DB; box-shadow: 0 6px 0 var(--coral), inset 0 0 0 3px var(--coral); }

/* ----- Saisie ----- */
.input {
  width: 100%; min-height: 64px; border-radius: var(--radius-md); border: 3px solid var(--line);
  font: inherit; font-size: var(--fs-lg); font-weight: 800; text-align: center; padding: 0 16px;
  background: var(--paper); color: var(--ink);
}
.input:focus { outline: none; border-color: var(--sky); }

/* ----- Remise en ordre ----- */
.tray { min-height: 72px; border-radius: var(--radius-md); border: 3px dashed var(--line); padding: 10px; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; }
.word-tile {
  appearance: none; border: 0; cursor: pointer; padding: 12px 18px; border-radius: 14px;
  background: var(--paper); font-size: var(--fs-md); font-weight: 800;
  box-shadow: 0 4px 0 var(--lagoon-deep), inset 0 0 0 3px var(--line);
  animation: pop-in 220ms ease both;
}

/* ----- Pied d'étape ----- */
.step-footer { position: sticky; bottom: 0; padding: 16px 0 8px; display: grid; gap: 10px; }
.feedback { border-radius: var(--radius-md); padding: 14px 18px; font-weight: 800; font-size: var(--fs-md); animation: slide-up 240ms cubic-bezier(.2,.8,.2,1) both; }
.feedback.good { background: #C8F2D8; color: var(--green-deep); }
.feedback.bad { background: #FFE3E6; color: #B3192C; }

/* ----- Carte des niveaux ----- */
.map-head {
  position: sticky; top: calc(-1 * max(16px, env(safe-area-inset-top))); z-index: 5;
  margin: calc(-1 * max(16px, env(safe-area-inset-top))) -16px 0;
  padding: max(16px, env(safe-area-inset-top)) 16px 16px;
  background: var(--ink) var(--wax); background-blend-mode: soft-light;
  color: #fff;
}
.map-head .inner { max-width: 760px; margin: 0 auto; display: flex; align-items: center; gap: 12px; }
.map-head .avatar { width: 52px; height: 52px; font-size: 30px; }
.map-head .name { font-weight: 900; font-size: var(--fs-md); }
.stat { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; font-size: var(--fs-md); background: rgba(255,255,255,.12); padding: 6px 12px; border-radius: 99px; }
.map-head .icon-btn { width: 48px; height: 48px; font-size: 22px; }
.map-actions { max-width: 760px; margin: 16px auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.phase-title { margin: 36px 0 8px; text-align: center; }
.phase-title h2 { font-size: var(--fs-md); color: var(--ink-soft); font-weight: 800; letter-spacing: 0; }
.path { position: relative; display: grid; gap: 18px; padding: 12px 0 40px; }
.path svg.trail { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.path-row { display: flex; position: relative; z-index: 1; }
.node {
  appearance: none; border: 0; cursor: pointer; position: relative;
  width: 108px; height: 108px; border-radius: 50%;
  background: var(--c, var(--orange)) var(--wax); background-size: 28px;
  box-shadow: 0 8px 0 rgba(31,35,80,.25), inset 0 0 0 6px rgba(255,255,255,.35);
  display: grid; place-items: center; font-size: 44px;
  transition: transform var(--t-fast);
  touch-action: manipulation;
}
.node:active { transform: translateY(5px) scale(.97); }
.node.locked { background: #C9D1DD var(--wax); filter: grayscale(1); box-shadow: 0 8px 0 #A5AFBF; font-size: 36px; }
.node.current::after {
  content: ""; position: absolute; inset: -10px; border-radius: 50%;
  border: 5px solid var(--c, var(--orange)); opacity: .55;
  animation: ring 1.6s ease-out infinite;
}
.node .stars { position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); font-size: 18px; white-space: nowrap; background: var(--paper); border-radius: 99px; padding: 2px 8px; box-shadow: 0 3px 0 var(--lagoon-deep); }
.node-label { margin-top: 22px; text-align: center; font-weight: 800; max-width: 150px; font-size: var(--fs-sm); line-height: 1.2; }
.node-wrap { display: grid; justify-items: center; }
.node.unlocking { animation: unlock 900ms cubic-bezier(.2,.9,.3,1.3) both; }

/* ----- Fin de leçon ----- */
.end { min-height: 80dvh; display: grid; place-content: center; text-align: center; gap: 20px; }
.end-stars { display: flex; justify-content: center; gap: 12px; font-size: 72px; }
.end-stars span { opacity: .18; filter: grayscale(1); transform: scale(.7); transition: all 400ms cubic-bezier(.2,.9,.3,1.5); }
.end-stars span.on { opacity: 1; filter: none; transform: scale(1); }

/* ----- Formulaires onboarding / parent ----- */
.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.avatars .choice { font-size: 48px; min-height: 88px; }
.avatars .choice.selected { background: var(--sun); box-shadow: 0 6px 0 var(--orange-deep), inset 0 0 0 3px var(--orange); }
.pin-dots { display: flex; justify-content: center; gap: 14px; margin: 8px 0; }
.pin-dots i { width: 22px; height: 22px; border-radius: 50%; background: var(--lagoon-deep); transition: transform var(--t-fast), background var(--t-fast); }
.pin-dots i.on { background: var(--ink); transform: scale(1.15); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 320px; margin: 0 auto; }
.keypad .btn { font-size: var(--fs-lg); min-height: 68px; padding: 0; }

.section { margin-top: 28px; display: grid; gap: 12px; }
.list { display: grid; gap: 10px; }
.list-item { background: var(--paper); border-radius: var(--radius-md); padding: 14px 16px; display: flex; align-items: center; gap: 12px; box-shadow: 0 4px 0 var(--lagoon-deep); }
.list-item .grow { flex: 1; min-width: 0; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 140px; padding: 8px 0; }
.bars .bar { flex: 1; display: grid; justify-items: center; gap: 6px; height: 100%; align-content: end; }
.bars .bar i { display: block; width: 100%; border-radius: 10px 10px 4px 4px; background: var(--green); min-height: 4px; }
.bars .bar span { font-size: var(--fs-xs); color: var(--ink-soft); font-weight: 700; }
.seg { display: inline-flex; background: var(--lagoon-deep); border-radius: 99px; padding: 4px; gap: 4px; }
.seg button { border: 0; background: transparent; border-radius: 99px; padding: 10px 18px; font-weight: 800; cursor: pointer; }
.seg button.on { background: var(--paper); box-shadow: 0 2px 0 rgba(31,35,80,.15); }
.rating { display: flex; gap: 8px; }
.rating button { font-size: 32px; width: 60px; height: 60px; border-radius: 50%; border: 0; background: var(--lagoon-deep); cursor: pointer; transition: transform var(--t-fast); }
.rating button.on { background: var(--sun); transform: scale(1.1); }
.tag { display: inline-block; padding: 4px 10px; border-radius: 99px; background: var(--lagoon-deep); font-weight: 800; font-size: var(--fs-xs); }

/* ----- Toast ----- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 14px 22px; border-radius: 99px; font-weight: 800;
  z-index: 100; animation: slide-up 240ms ease both; max-width: calc(100% - 32px); text-align: center;
}

/* ----- Effets ----- */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 90; overflow: hidden; }
.fx-piece { position: absolute; width: 12px; height: 16px; border-radius: 3px; will-change: transform, opacity; }
.fx-star { position: absolute; font-size: 36px; will-change: transform, opacity; }

@keyframes pop-in { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slide-up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes bob { 50% { transform: translateY(-10px); } }
@keyframes pulse-soft { 50% { transform: scale(1.08); } }
@keyframes ring { from { transform: scale(.9); opacity: .7; } to { transform: scale(1.25); opacity: 0; } }
@keyframes unlock { 0% { transform: scale(.6) rotate(-20deg); filter: grayscale(1); } 60% { transform: scale(1.18) rotate(6deg); } 100% { transform: none; filter: none; } }
.shake { animation: shake 380ms ease both; }
@keyframes shake { 20% { transform: translateX(-10px); } 40% { transform: translateX(9px); } 60% { transform: translateX(-6px); } 80% { transform: translateX(4px); } }
.pop { animation: pop 380ms cubic-bezier(.2,.9,.3,1.5) both; }
@keyframes pop { 40% { transform: scale(1.08); } }

/* ----- Paysage ----- */
@media (orientation: landscape) and (min-width: 900px) {
  .step-split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}
