/* ── Learn flow (learn.js) ───────────────────────────────────────
   Additive stylesheet, namespaced .lrn-*. Follows the supplied reference: big character on top, large
   Spanish sentence, English + audio, a microphone with live sound waves, progress at the bottom.
   Keeps the Chica look: rounded cards/buttons, existing tokens (--text, --text-muted …) and characters.
   The character itself is the shared .quiz-girl component (quiz-girl.css) — only its size is tuned here. */

/* The old learning home (random "New Sentence", history) is retired: the World Map is the hub and
   sentences now come from the level curriculum. Delete this one rule to get the old screen back. */
#home-screen { display: none !important; }

html.cc-learn-open body { overflow: hidden; }

#learn-screen {
  --lrn-line: rgba(255, 255, 255, .12);
  --lrn-pink: var(--accent); --lrn-pink2: var(--accent2); --lrn-ok: #4ade80; --lrn-warn: #fbbf24; --lrn-bad: #fb7185;
  position: fixed; inset: 0; z-index: 400;
  color: var(--text); font-family: var(--font-body);
}
#learn-screen.hidden { display: none !important; }

.lrn-bg {
  position: absolute; inset: 0; overflow-y: auto; overscroll-behavior: contain;
  background: #1a1a2e;
  display: flex; justify-content: center;
}
.lrn-stage {
  width: 100%; max-width: 480px; min-height: 100%;
  display: flex; flex-direction: column; justify-content: center;
  padding: max(.7rem, env(safe-area-inset-top)) .85rem max(.7rem, env(safe-area-inset-bottom));
  animation: lrn-fade .28s ease both;
}
.lrn-stage--learn { justify-content: stretch; height: 100%; }
@keyframes lrn-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ── The card ───────────────────────────────────────────────────── */
.lrn-card {
  position: relative; display: flex; flex-direction: column; gap: .7rem;
  width: 100%; flex: 1 1 auto; min-height: 0;
  padding: .7rem; border-radius: 30px;

}
.lrn-card--pad { flex: 0 1 auto; padding: 1.2rem 1.1rem 1.3rem; gap: .9rem; align-items: stretch; }

/* ── Character ─────────────────────────────────────────────────── */
.lrn-girl.quiz-girl {
  border-radius: 22px; border: 1.5px solid rgba(255, 255, 255, .12); box-shadow: none;
}
.lrn-girl.quiz-girl img { object-position: 10% 28%; }   /* same crop as the quiz: keeps her face and the name tag drawn in the artwork */
.lrn-girl.quiz-girl[data-state="inlove"] { border-color: var(--accent); box-shadow: none; }
.lrn-girl.quiz-girl[data-state="angry"] { border-color: #ff4d3d; box-shadow: none; }

.lrn-close, .lrn-levelpill {
  position: absolute; z-index: 3; border: 0; color: #fff; cursor: pointer; -webkit-tap-highlight-color: transparent;
  background: rgba(15, 15, 26, .85);
}
.lrn-close { right: .6rem; top: .6rem; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; }
.lrn-close svg { width: 20px; height: 20px; }
.lrn-levelpill { left: .6rem; bottom: .6rem; min-height: 32px; padding: 0 .8rem; border-radius: 999px; font: 700 .7rem/1 var(--font-body); letter-spacing: .1em; text-transform: uppercase; }
.lrn-close:active, .lrn-levelpill:active { transform: scale(.95); }
.lrn-girl .quiz-girl-timer { display: none; }

/* ── Sentence ──────────────────────────────────────────────────── */
.lrn-phrase {
  flex: none; padding: .85rem 1rem .75rem; border-radius: 18px; text-align: center;
  background: var(--surface); border: 1.5px solid var(--surface2);
}
.lrn-es {
  font: 600 clamp(1.7rem, 8vw, 2.35rem)/1.12 var(--font-display); letter-spacing: -.005em; color: #fff;
  text-wrap: balance; overflow-wrap: anywhere;
}
.lrn-es.lrn-in { animation: lrn-pop .38s cubic-bezier(.2, .9, .3, 1.2) both; }
@keyframes lrn-pop { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
.lrn-en-row { display: flex; align-items: center; justify-content: center; gap: .6rem; margin-top: .6rem; }
.lrn-flag { width: 26px; height: 18px; border-radius: 4px; flex: none; background: linear-gradient(#c60b1e 0 25%, #ffc400 25% 75%, #c60b1e 75%); box-shadow: 0 0 0 1px rgba(255, 255, 255, .25); }
.lrn-en { font-size: 1.05rem; color: rgba(255, 255, 255, .78); text-wrap: balance; }
.lrn-listen {
  flex: none; width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: #fff;
  background: var(--surface2); border: 0; margin-left: auto; -webkit-tap-highlight-color: transparent;
}
.lrn-listen svg { width: 22px; height: 22px; }
.lrn-listen:active { transform: scale(.93); }

/* ── Voice: microphone + waves ─────────────────────────────────── */
.lrn-slot { flex: none; }
.lrn-voice { display: flex; flex-direction: column; align-items: center; gap: .55rem; }
.lrn-try { font: 600 1rem/1 var(--font-body); color: rgba(255, 255, 255, .92); min-height: 1rem; }
.lrn-mic-row {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: .4rem;
}
.lrn-wave { flex: 1 1 0; height: 54px; display: flex; align-items: center; gap: 4px; }
.lrn-wave--l { justify-content: flex-end; }
.lrn-wave--r { justify-content: flex-start; }
.lrn-wave i {
  display: block; width: 4px; border-radius: 3px; flex: none;
  height: calc(10% + var(--h, .12) * 90%); max-height: 100%;
  background: var(--accent2); opacity: calc(.95 - var(--k) * .06);
  transition: height .09s linear;
}
/* idle = a calm static skyline, like the reference */
.lrn-wave i { --h: calc(.16 + (10 - var(--k)) * .045); }
[data-voice="idle"] .lrn-wave i { --h: calc(.16 + (10 - var(--k)) * .05); }
.lrn-voice.is-sim .lrn-wave i { animation: lrn-sim .8s ease-in-out infinite alternate; animation-delay: calc(var(--k) * -.11s); transition: none; }
@keyframes lrn-sim { from { height: 16%; } to { height: calc(30% + (10 - var(--k)) * 6.5%); } }

.lrn-mic {
  position: relative; flex: none; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; cursor: pointer; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent2)); border: 0; box-shadow: 0 3px 0 rgba(0, 0, 0, .3);

}
.lrn-mic svg { width: 38px; height: 38px; position: relative; z-index: 1; }
.lrn-mic:active { transform: scale(.94); }
.lrn-mic:focus-visible { outline: 3px solid #fff; outline-offset: 4px; }
.lrn-mic-ring { position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--accent2); opacity: 0; pointer-events: none; }
[data-voice="listening"] .lrn-mic { transform: scale(1.06); }
[data-voice="listening"] .lrn-mic-ring { animation: lrn-ripple 1.3s ease-out infinite; }
@keyframes lrn-ripple { from { opacity: .9; transform: scale(1); } to { opacity: 0; transform: scale(1.7); } }
.lrn-mic-spin { display: none; position: absolute; inset: -6px; border-radius: 50%; border: 3px solid transparent; border-top-color: #fff; animation: lrn-spin .8s linear infinite; }
[data-voice="processing"] .lrn-mic-spin { display: block; }
[data-voice="processing"] .lrn-mic { opacity: .8; }
@keyframes lrn-spin { to { transform: rotate(360deg); } }

.lrn-tip { padding: .5rem 1.1rem; border-radius: 12px; font-size: .88rem; color: rgba(255, 255, 255, .85); background: var(--surface); text-align: center; }

/* ── Feedback ──────────────────────────────────────────────────── */
.lrn-result { display: flex; flex-direction: column; align-items: center; gap: .5rem; text-align: center; max-height: 46dvh; overflow-y: auto; padding: .1rem; animation: lrn-fade .25s ease both; }
.lrn-r-title { font: 800 1.6rem/1.1 var(--font-display); color: #fff; }
.lrn-r-sub { font-size: .92rem; color: rgba(255, 255, 255, .72); }
.lrn-result--ok .lrn-r-title { color: var(--lrn-ok); }
.lrn-result--wrong .lrn-r-title, .lrn-result--error .lrn-r-title { color: var(--lrn-bad); }
.lrn-xp { font-weight: 700; font-size: .9rem; color: var(--accent2); }
.lrn-actions { display: flex; gap: .6rem; width: 100%; margin-top: .2rem; flex-wrap: wrap; }
.lrn-actions .lrn-btn { flex: 1 1 0; padding: 0 .7rem; white-space: nowrap; font-size: .92rem; }
.lrn-actions .lrn-btn--ghost { flex: 0 1 36%; }

/* ── Buttons ───────────────────────────────────────────────────── */
.lrn-btn {
  min-height: 50px; padding: 0 1.2rem; border-radius: 14px; font: 700 .98rem/1 var(--font-body); cursor: pointer;
  border: 0; -webkit-tap-highlight-color: transparent; transition: transform .12s, filter .15s;
}
.lrn-btn:active { transform: scale(.97); }
.lrn-btn--primary { color: #fff; background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.lrn-btn--ghost { color: #fff; background: var(--surface2); }
.lrn-btn--link { background: none; color: rgba(255, 255, 255, .6); min-height: 40px; font-weight: 600; font-size: .85rem; }
.lrn-btn--wide { width: 100%; }
.lrn-btn:focus-visible, .lrn-choice-btn:focus-visible, .lrn-other:focus-visible, .lrn-back:focus-visible, .lrn-close:focus-visible, .lrn-listen:focus-visible, .lrn-levelpill:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }

/* ── Progress (dots / bar) ─────────────────────────────────────── */
.lrn-progress { flex: none; display: flex; align-items: center; justify-content: center; gap: 1.1rem; padding: .1rem .3rem .15rem; min-height: 28px; }
.lrn-dots { display: flex; align-items: center; }
.lrn-dots--center { justify-content: center; }
.lrn-dot { width: 16px; height: 16px; border-radius: 50%; flex: none; background: rgba(255, 255, 255, .16); transition: background .3s, box-shadow .3s, transform .3s; }
.lrn-dot.is-active { background: var(--accent2); box-shadow: 0 0 0 3px rgba(231, 111, 81, .3); }
.lrn-dot.is-done { background: var(--lrn-pink2); }
.lrn-dotline { width: 34px; height: 3px; background: rgba(255, 255, 255, .16); } .lrn-dotline.is-done { background: var(--lrn-pink2); }
.lrn-count { font: 700 1.2rem/1 var(--font-display); color: rgba(255, 255, 255, .9); font-variant-numeric: tabular-nums; }
.lrn-bar { flex: 1 1 auto; max-width: 260px; height: 10px; border-radius: 999px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.lrn-bar i, .lrn-mini i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(135deg, var(--accent), var(--accent2)); transition: width .5s ease; }

/* ── Batch complete / overview ─────────────────────────────────── */
.lrn-center { display: flex; flex-direction: column; align-items: center; gap: .8rem; text-align: center; padding: 2rem 1rem; color: rgba(255, 255, 255, .85); }
.lrn-big { font: 800 1.3rem/1.2 var(--font-display); } .lrn-muted { color: rgba(255, 255, 255, .6); }
.lrn-spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, .15); border-top-color: var(--accent2); animation: lrn-spin .8s linear infinite; }
.lrn-eyebrow { font: 800 .74rem/1 var(--font-body); letter-spacing: .2em; text-transform: uppercase; color: var(--accent2); text-align: center; }
.lrn-eyebrow--sub { margin-top: .4rem; color: rgba(255, 255, 255, .55); text-align: left; }
.lrn-h { font: 800 1.55rem/1.15 var(--font-display); text-align: center; color: #fff; }
.lrn-bigcheck { width: 76px; height: 76px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 2.4rem; font-weight: 900; color: #fff; background: #16a34a; animation: lrn-pop .5s cubic-bezier(.2, .9, .3, 1.4) both; }
.lrn-learned { list-style: none; display: flex; flex-direction: column; gap: .45rem; }
.lrn-learned li { display: flex; flex-direction: column; padding: .6rem .9rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--surface2); }
.lrn-learned b { font-size: 1.05rem; color: #fff; } .lrn-learned span { font-size: .85rem; color: rgba(255, 255, 255, .65); }
.lrn-quizintro { text-align: center; font-size: .95rem; color: rgba(255, 255, 255, .8); }
.lrn-quizintro b { display: block; font-size: 1.1rem; color: #fff; margin-bottom: .15rem; }
.lrn-banner { text-align: center; padding: .6rem .8rem; border-radius: 12px; font-weight: 700; font-size: .92rem; color: #fff; background: rgba(231, 76, 60, .18); border: 1px solid rgba(231, 111, 81, .45); }
.lrn-pop { animation: lrn-pop .5s cubic-bezier(.2, .9, .3, 1.2) both; }

.lrn-over-top { display: flex; }
.lrn-back { display: inline-flex; align-items: center; gap: .25rem; min-height: 40px; padding: 0 .9rem 0 .5rem; border-radius: 12px; cursor: pointer; font: 700 .85rem/1 var(--font-body); color: #fff; background: var(--surface2); border: 0; }
.lrn-back svg { width: 18px; height: 18px; }
.lrn-steps { list-style: none; display: flex; flex-direction: column; gap: .55rem; }
.lrn-step { display: flex; gap: .8rem; align-items: flex-start; padding: .75rem .85rem; border-radius: 14px; background: var(--surface); border: 1.5px solid var(--surface2); }
.lrn-step-ico { flex: none; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: rgba(255, 255, 255, .1); color: #fff; }
.lrn-step-ico svg { width: 18px; height: 18px; }
.lrn-step-body { min-width: 0; flex: 1; }
.lrn-step-title { font-weight: 800; font-size: .98rem; color: #fff; }
.lrn-step-meta { font-size: .85rem; color: rgba(255, 255, 255, .7); margin-top: .1rem; } .lrn-step-meta b { color: #fff; }
.lrn-mini { height: 6px; border-radius: 999px; background: rgba(255, 255, 255, .12); margin-top: .5rem; overflow: hidden; }
.lrn-step--done { border-color: rgba(74, 222, 128, .45); } .lrn-step--done .lrn-step-ico { background: #16a34a; }
.lrn-step--active { border-color: var(--accent); } .lrn-step--active .lrn-step-ico { background: linear-gradient(135deg, var(--accent), var(--accent2)); }
.lrn-step--mastered { border-color: rgba(251, 191, 36, .6); } .lrn-step--mastered .lrn-step-ico { background: #d97706; }
.lrn-step--locked { opacity: .62; } .lrn-step--locked .lrn-step-ico { background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .6); }

.lrn-choice { display: grid; grid-template-columns: 1fr 1fr; gap: .6rem; }
.lrn-choice-btn { display: flex; flex-direction: column; align-items: center; gap: .2rem; padding: .9rem .5rem; min-height: 112px; border-radius: 14px; cursor: pointer; color: #fff; text-align: center; font: inherit;
  background: var(--surface2); border: 0; -webkit-tap-highlight-color: transparent; transition: transform .12s; }
.lrn-choice-btn:active:not(:disabled) { transform: scale(.97); }
.lrn-choice-btn b { font-size: .98rem; } .lrn-choice-btn small { font-size: .78rem; color: rgba(255, 255, 255, .65); }
.lrn-choice-ico { font-size: 1.6rem; }
.lrn-choice-btn--hot { background: linear-gradient(135deg, var(--accent), var(--accent2)); } .lrn-choice-btn--hot small { color: rgba(255, 255, 255, .9); }
.lrn-choice-btn:disabled { opacity: .5; cursor: default; }
.lrn-others { list-style: none; display: flex; flex-direction: column; gap: .4rem; }
.lrn-other { width: 100%; display: flex; justify-content: space-between; align-items: center; gap: .6rem; min-height: 44px; padding: .5rem .9rem; border-radius: 12px; cursor: pointer; color: #fff; font: 700 .82rem/1.2 var(--font-body); text-align: left; background: var(--surface); border: 1px solid var(--surface2); }
.lrn-other em { font-style: normal; font-weight: 500; color: rgba(255, 255, 255, .65); font-size: .78rem; text-align: right; }

/* ── Level quiz banner (quiz-screen, existing quiz) ────────────── */
.quiz-levelquiz-banner { padding: .5rem .9rem; border-radius: 12px; text-align: center; background: rgba(231, 76, 60, .14); border: 1px solid rgba(231, 111, 81, .4); }
.quiz-levelquiz-title { font-weight: 800; font-size: .95rem; } .quiz-levelquiz-sub { font-size: .8rem; color: var(--text-muted); }

/* small phones: keep everything on screen without scrolling */
@media (max-height: 700px) {
  .lrn-es { font-size: clamp(1.4rem, 7vw, 1.9rem); }
  .lrn-mic { width: 70px; height: 70px; } .lrn-mic svg { width: 32px; height: 32px; }
  .lrn-wave { height: 44px; } .lrn-tip { display: none; }
  .lrn-girl.quiz-girl { min-height: 90px; }
}
@media (prefers-reduced-motion: reduce) {
  .lrn-stage, .lrn-es.lrn-in, .lrn-result, .lrn-bigcheck, .lrn-pop { animation: none; }
  [data-voice="idle"] .lrn-mic, [data-voice="listening"] .lrn-mic-ring, .lrn-voice.is-sim .lrn-wave i { animation: none; }
  .lrn-wave i, .lrn-bar i, .lrn-mini i { transition: none; }
}

/* Level 2 characters in the Learn screen: same top-aligned crop as in the quiz (beats `.lrn-girl.quiz-girl img` above) */
.lrn-girl.quiz-girl.quiz-girl--l2 img { object-position: 50% 3%; }
