/* ==========================================================================
   Calabro Mitsuko — feuille de style unique
   ========================================================================== */

:root {
  --green: #58cc02;
  --green-dark: #46a302;
  --green-soft: #d7ffb8;
  --blue: #1cb0f6;
  --blue-dark: #1899d6;
  --blue-soft: #ddf4ff;
  --red: #ff4b4b;
  --red-dark: #ea2b2b;
  --red-soft: #ffdfe0;
  --gold: #ffc800;
  --gold-dark: #e6ac00;
  --purple: #ce82ff;
  --orange: #ff9600;

  --bg: #ffffff;
  --bg-alt: #f7f7f7;
  --card: #ffffff;
  --ink: #3c3c3c;
  --ink-soft: #777777;
  --line: #e5e5e5;
  --line-strong: #d4d4d4;

  --radius: 16px;
  --shadow: 0 2px 0 var(--line-strong);
  --header-h: 64px;
  --nav-h: 68px;
  --font: "Nunito", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #131f24;
    --bg-alt: #1a2b32;
    --card: #1a2b32;
    --ink: #f1f7fb;
    --ink-soft: #8fa3ad;
    --line: #37464f;
    --line-strong: #2b3b43;
    --green-soft: #202f36;
    --blue-soft: #1b2b33;
    --red-soft: #3a2224;
    --shadow: 0 2px 0 #0d1518;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button { font-family: inherit; color: inherit; }

.app { min-height: 100vh; }

/* ------------------------------- Layout ---------------------------------- */

.shell {
  min-height: 100vh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: var(--bg);
  border-bottom: 2px solid var(--line);
}

.topbar .spacer { flex: 1; }

.stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 800;
  font-size: 17px;
  background: none;
  border: 0;
  padding: 4px 6px;
  border-radius: 10px;
  cursor: default;
}
.stat .icon { font-size: 20px; line-height: 1; }
.stat.streak { color: var(--orange); }
.stat.gems { color: var(--blue); }
.stat.hearts { color: var(--red); }
.stat.xp { color: var(--gold-dark); }

.flag-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 2px solid var(--line);
  background: var(--card);
  border-radius: 12px;
  padding: 6px 10px;
  font-weight: 800;
  cursor: pointer;
  font-size: 14px;
}
.flag-btn:hover { background: var(--bg-alt); }
.flag-btn .flag { font-size: 20px; }

.page {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.navbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 30;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--bg);
  border-top: 2px solid var(--line);
}
.navbar button {
  flex: 1;
  border: 0;
  background: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: var(--ink-soft);
  cursor: pointer;
}
.navbar button .icon { font-size: 24px; }
.navbar button.active { color: var(--blue); }

/* ------------------------------ Boutons ---------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 14px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--green);
  color: #fff;
  font-weight: 800;
  font-size: 16px;
  letter-spacing: .04em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--green-dark);
  transition: transform .05s ease, filter .1s ease;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 var(--green-dark); }
.btn:disabled { background: var(--line); color: var(--ink-soft); box-shadow: none; cursor: not-allowed; }
.btn.blue { background: var(--blue); box-shadow: 0 4px 0 var(--blue-dark); }
.btn.blue:active:not(:disabled) { box-shadow: 0 1px 0 var(--blue-dark); }
.btn.red { background: var(--red); box-shadow: 0 4px 0 var(--red-dark); }
.btn.red:active:not(:disabled) { box-shadow: 0 1px 0 var(--red-dark); }
.btn.ghost {
  background: transparent;
  color: var(--ink-soft);
  box-shadow: none;
  border: 2px solid var(--line);
}
.btn.ghost:active { transform: none; }
.btn.small { width: auto; padding: 10px 16px; font-size: 14px; }

/* ------------------------------ Parcours --------------------------------- */

.unit-header {
  background: var(--green);
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 18px;
  margin: 18px 0 8px;
  box-shadow: 0 4px 0 var(--green-dark);
}
.unit-header.locked { background: var(--line); color: var(--ink-soft); box-shadow: 0 4px 0 var(--line-strong); }
.unit-header .eyebrow { font-size: 12px; font-weight: 800; text-transform: uppercase; opacity: .85; letter-spacing: .08em; }
.unit-header h2 { margin: 4px 0 0; font-size: 20px; }
.unit-header p { margin: 6px 0 0; font-size: 14px; opacity: .9; }

.path { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 30px 0 4px; }
.path-row { display: flex; align-items: center; gap: 12px; width: 100%; justify-content: center; }

.node {
  position: relative;
  width: 76px; height: 68px;
  border: 0;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 6px 0 var(--green-dark);
  color: #fff;
  font-size: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .05s ease;
}
.node:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 2px 0 var(--green-dark); }
.node.locked { background: var(--line); box-shadow: 0 6px 0 var(--line-strong); color: var(--ink-soft); cursor: not-allowed; }
.node.done { background: var(--gold); box-shadow: 0 6px 0 var(--gold-dark); }
.node.current::after {
  content: "COMMENCER";
  position: absolute;
  top: -34px; left: 50%;
  transform: translateX(-50%);
  background: var(--card);
  color: var(--green);
  border: 2px solid var(--line);
  border-radius: 10px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}
.node-label {
  flex: 0 0 auto;
  max-width: 180px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.crowns { display: flex; gap: 2px; justify-content: center; font-size: 11px; margin-top: 2px; height: 14px; }

/* ------------------------------- Cartes ---------------------------------- */

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card h3 { margin: 0 0 8px; font-size: 17px; }
.card p { margin: 0 0 10px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.card p:last-child { margin-bottom: 0; }

.hero {
  text-align: center;
  padding: 28px 16px 8px;
}
.hero .big { font-size: 56px; }
.hero h1 { font-size: 26px; margin: 8px 0 4px; }
.hero p { color: var(--ink-soft); margin: 0 0 18px; font-size: 15px; }

.course-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 12px;
  cursor: pointer;
  font: inherit;
}
.course-card:hover { background: var(--bg-alt); }
.course-card.selected { border-color: var(--blue); background: var(--blue-soft); }
.course-card .flag { font-size: 34px; }
.course-card .t { font-weight: 800; font-size: 17px; }
.course-card .s { color: var(--ink-soft); font-size: 13px; margin-top: 2px; }

.grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.tile {
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.tile .v { font-size: 24px; font-weight: 800; }
.tile .k { font-size: 12px; color: var(--ink-soft); text-transform: uppercase; font-weight: 800; letter-spacing: .05em; margin-top: 2px; }

.progress {
  height: 16px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}
.progress > i {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: 999px;
  transition: width .3s ease;
}
.progress.blue > i { background: var(--blue); }

/* ------------------------------- Leçon ----------------------------------- */

.lesson {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}
.lesson-top {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}
.quit {
  border: 0; background: none; cursor: pointer;
  font-size: 26px; color: var(--ink-soft); line-height: 1; padding: 0 4px;
}
.lesson-body {
  flex: 1;
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
  padding: 10px 16px 200px;
}
.prompt { font-size: 22px; font-weight: 800; margin: 10px 0 20px; }
.sentence {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
.phon { color: var(--ink-soft); font-size: 14px; font-weight: 600; margin: 0 0 16px; font-style: italic; }
.ipa {
  font-family: "DejaVu Sans", "Segoe UI", system-ui, sans-serif;
  font-style: normal;
  opacity: .8;
  white-space: nowrap;
}

.speak {
  flex: 0 0 auto;
  width: 52px; height: 52px;
  border-radius: 14px;
  border: 0;
  background: var(--blue);
  color: #fff;
  font-size: 24px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--blue-dark);
}
.speak:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--blue-dark); }
.speak.big { width: 110px; height: 110px; font-size: 48px; border-radius: 24px; margin: 20px auto; display: block; }
.speak.slow { background: var(--card); color: var(--blue); border: 2px solid var(--line); box-shadow: 0 4px 0 var(--line-strong); width: 44px; height: 44px; font-size: 18px; }

.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--card);
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}
.choice:hover { background: var(--bg-alt); }
.choice.selected { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); }
.choice.ok { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); }
.choice.ko { border-color: var(--red); background: var(--red-soft); color: var(--red-dark); }
.choice .num {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  border: 2px solid var(--line);
  border-radius: 6px;
  font-size: 12px;
  display: grid; place-items: center;
  color: var(--ink-soft);
}

.bank-answer {
  min-height: 100px;
  border-top: 2px solid var(--line);
  border-bottom: 2px solid var(--line);
  padding: 12px 0;
  margin: 8px 0 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-content: flex-start;
}
.bank { display: flex; flex-wrap: wrap; gap: 8px; }
.word {
  background: var(--card);
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
}
.word:hover { background: var(--bg-alt); }
.word.used { visibility: hidden; }
.word.ghost { opacity: .25; pointer-events: none; }

.type-input {
  width: 100%;
  min-height: 110px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  font-size: 18px;
  font-family: inherit;
  font-weight: 600;
  background: var(--card);
  color: var(--ink);
  resize: none;
}
.type-input:focus { outline: none; border-color: var(--blue); }

.pairs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.pair {
  background: var(--card);
  border: 2px solid var(--line);
  border-bottom-width: 4px;
  border-radius: 12px;
  padding: 14px 10px;
  font-weight: 700;
  font-size: 16px;
  cursor: pointer;
  font-family: inherit;
  color: inherit;
  min-height: 56px;
}
.pair.selected { border-color: var(--blue); background: var(--blue-soft); color: var(--blue-dark); }
.pair.matched { border-color: var(--green); background: var(--green-soft); color: var(--green-dark); opacity: .55; pointer-events: none; }
.pair.wrong { border-color: var(--red); background: var(--red-soft); }

.footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  border-top: 2px solid var(--line);
  background: var(--bg);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 25;
}
.footer .inner { max-width: 640px; margin: 0 auto; }
.footer.ok { background: var(--green-soft); border-top-color: transparent; }
.footer.ko { background: var(--red-soft); border-top-color: transparent; }
.verdict { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; }
.verdict .mark { font-size: 30px; line-height: 1; }
.verdict .txt { font-size: 18px; font-weight: 800; }
.verdict .sub { font-size: 15px; font-weight: 700; margin-top: 2px; }
.footer.ok .verdict { color: var(--green-dark); }
.footer.ko .verdict { color: var(--red-dark); }

.select {
  border: 2px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
}
.select:hover { background: var(--bg-alt); }
.select:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.note {
  background: var(--blue-soft);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  margin: 14px 0 0;
  line-height: 1.5;
}
.note b { color: var(--blue-dark); }

.heart-pop { animation: pop .4s ease; }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.5); } 100% { transform: scale(1); } }
.shake { animation: shake .3s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* ------------------------------ Mascotte --------------------------------- */

.mascot { display: inline-block; line-height: 0; flex: 0 0 auto; }
.mascot svg { display: block; overflow: visible; }

.mascot.bobbing { animation: bob 3.2s ease-in-out infinite; }
@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-1deg); }
  50% { transform: translateY(-7px) rotate(1deg); }
}

/* Clignement des yeux : deux battements, puis une longue pause. */
.mascot .eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: blink 5.5s infinite;
}
@keyframes blink {
  0%, 92%, 96%, 100% { transform: scaleY(1); }
  94%, 98% { transform: scaleY(.1); }
}

.mascot-celebrate { animation: cheer .9s ease-in-out infinite; }
@keyframes cheer {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-12px) rotate(3deg); }
}
.mascot .sparkles { animation: twinkle 1.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes twinkle {
  0%, 100% { opacity: .35; transform: scale(.85); }
  50% { opacity: 1; transform: scale(1.1); }
}

.mascot-sad { animation: none; }
.mascot-sleep { animation: bob 5s ease-in-out infinite; }
.mascot-sleep .eyes { animation: none; }

@media (prefers-reduced-motion: reduce) {
  .mascot, .mascot .eyes, .mascot .sparkles { animation: none !important; }
}

.mascot-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 8px 0;
}
.mascot-row.reverse { flex-direction: row-reverse; }

.bubble {
  position: relative;
  flex: 1;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 16px;
  padding: 12px 14px;
  min-width: 0;
}
.bubble::before,
.bubble::after {
  content: "";
  position: absolute;
  top: 26px;
  border: 9px solid transparent;
}
.bubble::before { left: -20px; border-right-color: var(--line); }
.bubble::after { left: -16px; border-right-color: var(--card); }
.mascot-row.reverse .bubble::before { left: auto; right: -20px; border-right-color: transparent; border-left-color: var(--line); }
.mascot-row.reverse .bubble::after { left: auto; right: -16px; border-right-color: transparent; border-left-color: var(--card); }

.bubble-text { font-weight: 800; font-size: 16px; }
.bubble-sub { color: var(--ink-soft); font-size: 13px; margin-top: 3px; }

.footer .mascot-row { margin: 0 0 12px; }
.footer .bubble { background: transparent; border: 0; padding: 0; }
.footer .bubble::before, .footer .bubble::after { display: none; }

/* ------------------------------- Divers ---------------------------------- */

.center { text-align: center; }
.muted { color: var(--ink-soft); }
.stack > * + * { margin-top: 12px; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.badge {
  display: inline-block;
  background: var(--bg-alt);
  border: 2px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 800;
  color: var(--ink-soft);
}
.title { font-size: 22px; font-weight: 800; margin: 18px 0 10px; }
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 2px solid var(--line);
}
.list-item:last-child { border-bottom: 0; }
.list-item .main { flex: 1; }
.list-item .main .a { font-weight: 800; }
.list-item .main .b { font-size: 13px; color: var(--ink-soft); }

dialog.sheet {
  border: 0;
  border-radius: 20px;
  padding: 20px;
  max-width: 400px;
  width: calc(100% - 32px);
  background: var(--card);
  color: var(--ink);
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
}
dialog.sheet::backdrop { background: rgba(0,0,0,.45); }

@media (min-width: 700px) {
  .navbar {
    top: 0; bottom: 0; left: 0; right: auto;
    width: 200px;
    height: 100vh;
    flex-direction: column;
    justify-content: flex-start;
    padding-top: 20px;
    gap: 6px;
    border-top: 0;
    border-right: 2px solid var(--line);
  }
  .navbar button {
    flex: 0 0 auto;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 18px;
    font-size: 13px;
  }
  .shell { padding-left: 200px; padding-bottom: 40px; }
  .topbar { padding-left: 24px; }
}
