/* ============================================================
   LUMIO ENGLISH — Design System v2 "Polished"
   Modern kids-EdTech: soft gradients, layered depth,
   refined type scale. Brand: sun yellow / orange / cocoa.
   ============================================================ */

:root {
  --orange: var(--lumio-orange);
  --orange-2: var(--lumio-orange-light);
  --amber: var(--lumio-amber);
  --sun: var(--lumio-sun);
  --sun-soft: var(--lumio-sun-soft);
  --cocoa: var(--lumio-cocoa);
  --ink: var(--lumio-ink);
  --muted: var(--lumio-muted);
  --paper: var(--lumio-paper);
  --card: var(--lumio-surface);
  --teal: var(--lumio-teal);
  --teal-soft: var(--lumio-teal-soft);
  --coral: var(--lumio-coral);
  --green: var(--lumio-green);
  --green-soft: var(--lumio-green-soft);
  --line: var(--lumio-line);
  --sun-light: var(--sun-soft);
  --cocoa-soft: var(--muted);
  --border: 1px solid var(--line);
  --radius: var(--r-lg);
  --radius-sm: var(--r-md);
  --sticker-shadow: var(--sh-md);

  --r-lg: 28px; --r-md: 18px; --r-sm: 12px;
  --sh-sm: 0 1px 2px rgba(67,48,31,.05), 0 4px 12px rgba(67,48,31,.06);
  --sh-md: 0 2px 4px rgba(67,48,31,.05), 0 10px 30px rgba(67,48,31,.10);
  --sh-lg: 0 4px 8px rgba(67,48,31,.06), 0 24px 60px rgba(249,115,22,.14);
  --grad-brand: var(--lumio-grad-brand);
  --grad-sun: var(--lumio-grad-sun);
  --font-display: var(--lumio-font-display);
  --font-body: var(--lumio-font-body);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; overflow-x: hidden; }

body {
  font-family: var(--font-body);
  background:
    var(--lumio-page-bg);
  color: var(--ink);
  min-height: 100vh;
  font-size: 16.5px;
  line-height: 1.55;
  overflow-x: hidden; /* safety net for decorative elements (floating chips, sparkles) that intentionally bleed slightly past their container's edge */
}

h1, h2, h3, .display { font-family: var(--font-display); font-weight: 700; letter-spacing: -.01em; color: var(--cocoa); }
h2 { font-size: 1.65rem; }
h3 { font-size: 1.15rem; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 24px 22px; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: rgba(255,255,255,.82);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 50;
}
.topbar .logo-mini {
  height: 54px; width: auto; border-radius: 0;
  object-fit: contain; box-shadow: none; background: transparent;
}
.topbar .brand {
  font-family: var(--font-display); font-size: 1.35rem; font-weight: 800;
  background: var(--grad-brand); -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: var(--orange);
}
.topbar .brand span { -webkit-text-fill-color: var(--cocoa); }
.topbar .spacer { flex: 1; }
.topbar .hello-chip {
  background: var(--sun-soft); color: var(--cocoa);
  border-radius: 999px; padding: 8px 18px;
  font-weight: 800; font-size: .92rem; box-shadow: inset 0 0 0 1px rgba(245,158,11,.25);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-display); font-weight: 700; font-size: 1.02rem;
  padding: 13px 28px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); text-decoration: none; color: var(--cocoa);
  background: var(--card); box-shadow: var(--sh-sm);
  transition: transform .15s ease, box-shadow .15s ease, filter .15s ease;
  user-select: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-2px); box-shadow: var(--sh-md); }
.btn:active { transform: translateY(0) scale(.98); }
.btn-primary {
  background: var(--grad-brand); color: #fff; border: none;
  box-shadow: 0 2px 4px rgba(249,115,22,.25), 0 10px 24px rgba(249,115,22,.35);
}
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 4px 8px rgba(249,115,22,.28), 0 14px 32px rgba(249,115,22,.4); }
.btn-sun  { background: var(--grad-sun); border: none; color: var(--cocoa);
  box-shadow: 0 2px 4px rgba(245,158,11,.22), 0 10px 24px rgba(255,197,61,.4); }
.btn-teal { background: linear-gradient(135deg, #2DD4BF, #14B8A6); color: #fff; border: none;
  box-shadow: 0 2px 4px rgba(20,184,166,.25), 0 10px 24px rgba(20,184,166,.32); }
.btn-ghost { box-shadow: none; border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { background: rgba(67,48,31,.05); box-shadow: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none !important; }
.btn-big { font-size: 1.18rem; padding: 17px 38px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 28px;
  box-shadow: var(--sh-md);
}
.card-sun { background: linear-gradient(160deg, #FFF8E8, #FFEFC9); border-color: rgba(245,158,11,.18); }

/* ---------- Chips ---------- */
.chip {
  display: inline-block; padding: 6px 16px; border-radius: 999px;
  font-weight: 800; font-size: .82rem; letter-spacing: .02em;
  background: var(--sun-soft); color: #B45309;
}
.chip-teal   { background: var(--teal-soft); color: #0F766E; }
.chip-orange { background: #FFEDD5; color: #C2410C; }

/* ---------- Stars ---------- */
/* Earned stars are gold: they used to inherit the cocoa text colour and
   read as near-black on the results card. Deeper than --lumio-sun so they
   still show on the cream .card-sun. */
.stars { letter-spacing: 3px; color: #F5A300; text-shadow: 0 2px 0 rgba(194,83,10,.22); }
.star-off { color: #EADFCE; text-shadow: none; }

/* ---------- Progress bar ---------- */
.progressbar {
  height: 14px; border-radius: 999px;
  background: #F3EADB; overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(67,48,31,.08);
}
.progressbar > div {
  height: 100%; background: var(--grad-brand);
  border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1);
}

/* ============================================================
   TEEN THEME — Level 3-6's lesson.html (prep) only, matching the
   already-established Present/teen-deck look (see
   lib/deck_template_teen.py's own palette comments, which this
   mirrors exactly: dark indigo background, sharp-cornered white
   cards, Fredoka headings, purple/orange/teal accents). Applied via
   body.theme-teen so it only ever affects pages that opt in
   (js/lesson.js adds the class for level3-6 only) — every rule below
   is scoped under that selector, so pre-a/level1/level2 and every
   other page on the site are completely unaffected.

   Redefining the existing --variables (rather than writing new
   selectors) is deliberate: almost every component below already
   reads var(--cocoa), var(--paper), var(--card), var(--line), and
   var(--font-display), so most of the re-theme is "free" once these
   are redefined at this scope. Only the handful of components that
   hardcode a hex value instead of using a variable (chips, the
   progress bar track) need an explicit override underneath.
   ============================================================ */
body.theme-teen {
  --cocoa: var(--lumio-night-ink);
  --ink: var(--lumio-night-ink);
  --muted: var(--lumio-night-muted);
  --cocoa-soft: var(--lumio-night-muted);
  --line: rgba(255,243,214,.14);
  --card: #FFFFFF;
  --r-lg: 14px; --r-md: 12px; --r-sm: 10px;
  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --grad-brand: linear-gradient(135deg, #F97316 0%, #EA580C 100%);
  --teal: #14B8A6;
  --teal-soft: rgba(20,184,166,.16);
  background: linear-gradient(160deg, #3A2A1C 0%, var(--lumio-night-deep) 100%);
}
body.theme-teen h1, body.theme-teen h2, body.theme-teen h3, body.theme-teen .display { color: var(--cocoa); }
body.theme-teen .topbar {
  background: rgba(28,22,16,.75); border-bottom: 1px solid var(--line);
}
body.theme-teen .topbar .brand { -webkit-text-fill-color: #fff; }
body.theme-teen .topbar .brand span { -webkit-text-fill-color: var(--cocoa); }
body.theme-teen .topbar .hello-chip { background: rgba(249,115,22,.18); color: var(--cocoa); box-shadow: inset 0 0 0 1px rgba(249,115,22,.35); }
/* Base .btn text color follows --cocoa, which is now light -- fine for
   ghost buttons sitting directly on the dark page background, but
   .btn (plain, results-screen "Play again"/game/homework links) and
   .btn-sun (bright yellow Listen button, Spell's letter tiles) both
   sit on light backgrounds (a white .btn or the yellow --grad-sun)
   and need to stay dark-on-light. Order matters here: this dark-text
   rule must come BEFORE .btn-ghost's own override below it, so ghost
   buttons -- which really do sit on the dark background -- win back
   the light color despite matching this broader .btn selector too. */
body.theme-teen .btn:not(.btn-primary):not(.btn-teal):not(.btn-ghost) { color: var(--lumio-ink); }
body.theme-teen .btn-ghost { color: var(--cocoa-soft); }
body.theme-teen .btn-ghost:hover { background: rgba(255,243,214,.08); }
/* .btn-ghost is used in two different contexts that need opposite
   treatment: the topbar "← Map" link sits on the dark page background
   (light text, handled above), but Spell's "↺ Start over" sits INSIDE
   a white .card -- caught this by actually looking at a rendered
   Spell screenshot, where the light lavender text was legible but
   noticeably washed-out against white. Card-scoped override wins on
   specificity for the in-card case. */
body.theme-teen .card .btn-ghost { color: var(--lumio-muted); }
body.theme-teen .card .btn-ghost:hover { background: rgba(43,38,64,.06); }
body.theme-teen .card { color: var(--lumio-ink); }
body.theme-teen .card h1, body.theme-teen .card h2, body.theme-teen .card h3 { color: var(--lumio-ink); }
body.theme-teen .card-sun { background: linear-gradient(160deg, #FFF8E8, #FFEFC9); border-color: rgba(245,158,11,.18); }
/* Chips always render nested inside a white .card in lesson.html's
   activities (confirmed by checking js/lesson.js directly, not
   assumed) -- so they keep their original light-pastel-bg/dark-text
   styling unchanged here. A dark-on-dark reskin would only make sense
   if chips ever sat directly on the page background, which they don't. */
body.theme-teen .progressbar { background: rgba(255,243,214,.14); box-shadow: inset 0 1px 3px rgba(0,0,0,.2); }
body.theme-teen .star-off { color: rgba(43,38,64,.2); }

/* ---------- Forms ---------- */
input[type="text"], input[type="password"], select {
  font-family: var(--font-body); font-weight: 700; font-size: 1.08rem;
  color: var(--ink); background: #fff;
  border: 1.5px solid rgba(67,48,31,.14); border-radius: var(--r-md);
  padding: 14px 18px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 4px rgba(249,115,22,.14); }
.btn:focus-visible { outline: 3px solid rgba(249,115,22,.4); outline-offset: 2px; }
label { font-weight: 800; display: block; margin: 16px 0 8px; font-size: .95rem; color: var(--muted); }

/* ---------- Lesson path (signature) ---------- */
.path {
  display: grid; grid-template-columns: repeat(5, 1fr);
  gap: 58px 12px; padding: 64px 8px 30px; justify-items: center;
  position: relative;
}
.node {
  width: 82px; height: 82px; border-radius: 50%;
  background: #fff; border: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: var(--font-display); font-weight: 800; font-size: 1.3rem;
  cursor: pointer; text-decoration: none; color: var(--cocoa);
  box-shadow: var(--sh-md), inset 0 0 0 3px #F3EADB;
  transition: transform .15s ease, box-shadow .15s ease;
  position: relative;
}
.node:hover { transform: translateY(-4px) scale(1.04); }
.node .n-stars { font-size: .68rem; letter-spacing: 1px; margin-top: -2px; color: var(--amber); }
.node.done {
  background: var(--grad-sun); color: var(--cocoa);
  box-shadow: 0 2px 4px rgba(245,158,11,.25), 0 12px 26px rgba(255,197,61,.45), inset 0 0 0 3px rgba(255,255,255,.55);
}
.node.current {
  background: var(--grad-brand); color: #fff;
  box-shadow: 0 4px 10px rgba(249,115,22,.35), 0 16px 36px rgba(249,115,22,.4);
  animation: floaty 2.2s ease-in-out infinite;
}
.node.current::after {
  content: ""; position: absolute; inset: -8px; border-radius: 50%;
  border: 3px solid rgba(249,115,22,.35); animation: ringPulse 2.2s ease-out infinite;
}
.node.locked {
  background: #F6EFE3; color: #C9B79C;
  box-shadow: inset 0 2px 6px rgba(67,48,31,.06); cursor: not-allowed;
}
/* Prep is finished, waiting on the live class with the teacher to be
   marked attended before the next lesson's prep unlocks. Calm/teal
   rather than the urgent "do this now" orange of .current, since
   there's nothing more for the student to do here right now. */
.node.awaiting {
  background: var(--teal-soft); color: var(--teal);
  box-shadow: 0 2px 4px rgba(20,184,166,.15), inset 0 0 0 3px rgba(20,184,166,.18);
}
.node.awaiting .n-clock { font-size: 1.05rem; line-height: 1; }
.node.awaiting .n-wait-label {
  font-family: var(--font-body); font-weight: 800; font-size: .58rem;
  letter-spacing: .2px; margin-top: 1px; color: var(--teal);
}
/* Prep AND the live class are both done -- homework is the one thing left
   before the next lesson's prep unlocks. Violet rather than .awaiting's
   teal, so the two "waiting" states read as visually distinct at a glance
   (this one still has an action the student can take right now; .awaiting
   genuinely doesn't). */
.node.awaiting-hw {
  background: var(--lumio-orange-soft); color: var(--lumio-orange-dark);
  box-shadow: 0 2px 4px rgba(124,58,237,.15), inset 0 0 0 3px rgba(124,58,237,.18);
}
.node.awaiting-hw .n-clock { font-size: 1.05rem; line-height: 1; }
.node.awaiting-hw .n-wait-label {
  font-family: var(--font-body); font-weight: 800; font-size: .58rem;
  letter-spacing: .2px; margin-top: 1px; color: var(--lumio-orange-dark);
}
.node.current::before {
  content: ""; position: absolute; top: -60px; width: 58px; height: 58px;
  background: url('../assets/story/characters/lumi-hero.png') center/contain no-repeat;
  filter: drop-shadow(0 6px 10px rgba(67,48,31,.25));
}
@keyframes floaty { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes ringPulse { 0% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1.35); opacity: 0; } }

/* ---------- Hero ---------- */
.hero {
  display: grid; grid-template-columns: 1.05fr .95fr; gap: 40px;
  align-items: center; padding: 60px 0 34px;
}
.hero h1 { font-size: clamp(2.4rem, 5.4vw, 3.9rem); line-height: 1.08; font-weight: 800; }
.hero h1 .hl {
  background: var(--grad-brand);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero p.lead { font-size: 1.22rem; font-weight: 600; color: var(--muted); margin: 18px 0 30px; max-width: 46ch; }
.hero-visual { position: relative; justify-self: center; }
.hero-visual::before {
  content: ""; position: absolute; inset: -8% -6%;
  background: radial-gradient(closest-side, rgba(255,197,61,.5), rgba(255,197,61,0));
  border-radius: 50%; z-index: 0; filter: blur(4px);
}
.hero-art {
  position: relative; z-index: 1;
  width: 100%; max-width: 400px;
  filter: drop-shadow(0 18px 30px rgba(249,115,22,.28));
}
.float-chip {
  position: absolute; z-index: 2; background: #fff; border-radius: 16px;
  padding: 10px 16px; font-weight: 800; font-size: .92rem; box-shadow: var(--sh-md);
  animation: floaty 3s ease-in-out infinite;
}
.float-chip.a { top: 6%; left: -10%; animation-delay: .2s; }
.float-chip.b { bottom: 12%; right: -8%; animation-delay: 1.1s; color: #0F766E; }

/* ---------- Feature grid ---------- */
.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px; margin: 34px 0;
}
.feature-grid .card { text-align: center; padding: 26px 20px; transition: transform .18s ease, box-shadow .18s ease; }
.feature-grid .card:hover { transform: translateY(-4px); box-shadow: var(--sh-lg); }
.feature-grid .emoji-badge {
  font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: var(--orange);
  display: inline-flex; align-items: center; justify-content: center;
  width: 64px; height: 64px; border-radius: 20px; margin-bottom: 14px;
  background: var(--sun-soft); letter-spacing: 1px;
}
.feature-grid .card:nth-child(2) .emoji-badge { background: var(--teal-soft); color: var(--teal); }
.feature-grid .card:nth-child(3) .emoji-badge { background: #FFE8EC; color: #E11D48; }
.feature-grid .card:nth-child(4) .emoji-badge { background: var(--lumio-orange-soft); color: var(--lumio-orange-dark); }
.feature-grid p { color: var(--muted); font-weight: 600; font-size: .95rem; margin-top: 6px; }

/* ---------- Character strip ---------- */
.char-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 20px; }
.char-strip figure { background: #fff; border-radius: var(--r-lg); padding: 12px; box-shadow: var(--sh-sm);
  transition: transform .18s ease, box-shadow .18s ease; }
.char-strip figure:hover { transform: translateY(-4px) rotate(-.5deg); box-shadow: var(--sh-lg); }
.char-strip img { width: 100%; height: 220px; object-fit: contain; display: block;
  filter: drop-shadow(0 8px 14px rgba(67,48,31,.16)); }
.char-strip figcaption { text-align: center; font-weight: 800; padding: 10px 0 4px; font-family: var(--font-display); }

/* ---------- Tables ---------- */
table.lumio {
  width: 100%; border-collapse: separate; border-spacing: 0;
  border-radius: var(--r-md); overflow: hidden;
  background: #fff; box-shadow: var(--sh-sm);
}
table.lumio th, table.lumio td { padding: 14px 16px; text-align: left; }
table.lumio th { background: var(--sun-soft); font-family: var(--font-display); font-size: .9rem; color: #92600A; }
table.lumio td { border-top: 1px solid var(--line); font-weight: 600; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%);
  background: var(--cocoa); color: #fff; font-weight: 800;
  padding: 13px 28px; border-radius: 999px; z-index: 200;
  box-shadow: var(--sh-lg);
  animation: pop .3s cubic-bezier(.2,1.4,.4,1);
}
@keyframes pop { from { transform: translateX(-50%) scale(.7) translateY(10px); opacity: 0; } }

/* ---------- Utility ---------- */
.center { text-align: center; }
.mt { margin-top: 22px; } .mb { margin-bottom: 22px; }
.row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.ar { direction: rtl; }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; text-align: center; padding-top: 36px; }
  .hero p.lead { margin-inline: auto; }
  .hero .row { justify-content: center; }
  .hero-art { max-width: 300px; }
  .float-chip.a { left: 0; } .float-chip.b { right: 0; }
  .path { grid-template-columns: repeat(4, 1fr); gap: 52px 8px; }
  .node { width: 70px; height: 70px; }
  .node.current::before { width: 48px; height: 48px; top: -50px; }
  .card { padding: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
