/* SHABDA Kids player. Warm SHABDA palette: deep brown #1a1510, warm brown #2d1f0e, gold #b8860b, cream #F5E6C8. */
@font-face {
  font-family: 'VijayaDV';
  src: url('../fonts/VijayaDV.ttf') format('truetype');
  font-display: swap;
}

:root {
  --bg: #fbf1dc;
  --bg-2: #f5e6c8;
  --surface: #fffaf0;
  --surface-2: #f8ecd2;
  --text: #1a1510;
  --muted: #5b4426;
  --line: #d9bf8c;
  --accent: #7a5600;        /* gold deepened for text on cream (AA) */
  --accent-fill: #b8860b;   /* decorative gold */
  --primary: #2d1f0e;
  --on-primary: #fff3d6;
  --chip: #f1dfb8;
  --focus: #1f5fbf;
  --praise-bg: #e3f1d8; --praise-text: #24451a;
  --hint-bg: #fdebd0; --hint-text: #5e3510;
  --within: #b7473d; --around: #2f7a4a; --maths: #2f5f9a;
  --stage-frame: #2d1f0e;
  --shadow: 0 6px 22px rgba(45, 31, 14, 0.14);
  --radius: 22px;
  --font: 'Nunito', 'Baloo 2', 'Noto Sans', 'Noto Sans Devanagari', 'Noto Sans Telugu', 'Noto Sans Kannada', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1510; --bg-2: #221a11; --surface: #2d1f0e; --surface-2: #3a2914; --text: #f5e6c8; --muted: #e0cba3;
    --line: #5c4524; --accent: #f0c457; --accent-fill: #e0b13a; --primary: #f0c457; --on-primary: #1a1510; --chip: #3d2c16;
    --focus: #8ab8ff; --praise-bg: #20361a; --praise-text: #cdeebc; --hint-bg: #3f2914; --hint-text: #ffd9a8;
    --within: #ff9d8f; --around: #8fd7a4; --maths: #9cc3ff; --stage-frame: #0e0b07; --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1a1510; --bg-2: #221a11; --surface: #2d1f0e; --surface-2: #3a2914; --text: #f5e6c8; --muted: #e0cba3;
  --line: #5c4524; --accent: #f0c457; --accent-fill: #e0b13a; --primary: #f0c457; --on-primary: #1a1510; --chip: #3d2c16;
  --focus: #8ab8ff; --praise-bg: #20361a; --praise-text: #cdeebc; --hint-bg: #3f2914; --hint-text: #ffd9a8;
  --within: #ff9d8f; --around: #8fd7a4; --maths: #9cc3ff; --stage-frame: #0e0b07; --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(1200px 500px at 50% -120px, var(--bg-2), var(--bg)) var(--bg);
  color: var(--text); font-family: var(--font); font-size: 1.2rem; line-height: 1.55;
}
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 4px solid var(--focus); outline-offset: 3px; border-radius: 10px; }
.skip-link { position: absolute; left: 12px; top: -80px; background: var(--primary); color: var(--on-primary); padding: 12px 18px; border-radius: 12px; z-index: 10; }
.skip-link:focus { top: 12px; }
[hidden] { display: none !important; }

/* ── top bar ── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--surface); border-bottom: 3px solid var(--accent-fill);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { width: 44px; height: 44px; }
.brand-ring { fill: #2d1f0e; } .brand-drop { fill: #e0b13a; } .brand-eye { fill: #1a1510; }
.brand-text { font-weight: 800; font-size: 1.45rem; letter-spacing: 0.04em; }
.brand-kids { color: var(--accent); font-style: italic; letter-spacing: 0.01em; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.icon-btn {
  min-height: 48px; min-width: 48px; display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px;
  border: 2px solid var(--line); border-radius: 999px; background: var(--surface-2); cursor: pointer; font-size: 1rem; font-weight: 700;
}
.icon-btn[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.icon-btn .icon { font-size: 1.2rem; }

main { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 16px; outline: none; }
.footer { text-align: center; padding: 16px; font-size: 0.95rem; color: var(--muted); }
.footer p { margin: 0; }

/* ── buttons ── */
.btn {
  min-height: 52px; padding: 10px 22px; border-radius: 999px; border: 2px solid transparent; cursor: pointer;
  font-weight: 800; font-size: 1.15rem; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn.primary { background: var(--primary); color: var(--on-primary); }
.btn.ghost { background: transparent; border-color: var(--line); color: var(--text); }
.btn:disabled { opacity: 0.6; cursor: default; }

/* ── sign-in ── */
.screen-signin, .screen-subscribe, .screen-error, .screen-loading { display: grid; place-items: center; min-height: 60vh; }
.signin-card {
  max-width: 620px; text-align: center; background: var(--surface); border-radius: 28px; padding: 28px 24px 30px;
  box-shadow: var(--shadow); border: 2px solid var(--line);
}
.signin-card h1 { font-size: clamp(1.6rem, 4.5vw, 2.3rem); line-height: 1.2; margin: 6px 0 12px; }
.signin-mascot { width: 120px; height: 120px; }
.lead { font-size: 1.25rem; margin: 0 0 10px; }
.parent-note { color: var(--muted); font-size: 1.05rem; margin: 0 0 20px; }
.google .g-mark {
  width: 32px; height: 32px; border-radius: 50%; background: #fff; color: #1a73e8; display: inline-grid; place-items: center; font-weight: 900;
}
.signin-status { min-height: 1.6em; margin: 14px 0 0; color: var(--muted); }
.loading-text { font-size: 1.4rem; color: var(--muted); }

/* ── home ── */
.hero { display: flex; align-items: center; gap: 16px; margin: 4px 0 16px; }
.hero h1 { margin: 0; font-size: clamp(1.8rem, 5vw, 2.6rem); }
.hero .lead { margin: 2px 0 0; color: var(--muted); }
.hero-mascot { width: 92px; height: 92px; flex: none; }
.tabs { display: flex; gap: 10px; flex-wrap: wrap; border-bottom: 3px solid var(--line); padding-bottom: 10px; }
.tab {
  min-height: 56px; padding: 8px 18px; border-radius: 18px; border: 2px solid var(--line); background: var(--surface);
  font-weight: 800; font-size: 1.2rem; cursor: pointer; display: inline-flex; align-items: center; gap: 10px;
}
.tab[aria-selected="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tab-count { min-width: 32px; height: 32px; border-radius: 999px; display: inline-grid; place-items: center; background: var(--chip); color: var(--text); font-size: 1rem; padding: 0 8px; }
.tab[aria-selected="true"] .tab-count { background: var(--on-primary); color: var(--primary); }
.home-tools { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin: 14px 0; }
.series-filter { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  min-height: 48px; padding: 6px 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--surface-2);
  cursor: pointer; font-weight: 700; font-size: 1.05rem;
}
.chip[aria-pressed="true"] { background: var(--accent-fill); border-color: var(--accent-fill); color: #1a1510; }
.lang-pick { display: flex; align-items: center; gap: 8px; }
.lang-label { font-weight: 700; color: var(--muted); font-size: 1rem; }
.lang-select {
  min-height: 48px; padding: 6px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface); font-size: 1.1rem; font-weight: 700;
}
.empty { font-size: 1.35rem; padding: 34px 20px; text-align: center; background: var(--surface); border: 2px dashed var(--line); border-radius: var(--radius); }
.cards { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: 18px; }
.card {
  display: flex; flex-direction: column; height: 100%; text-decoration: none; color: var(--text); background: var(--surface);
  border-radius: var(--radius); padding: 16px 18px 18px; box-shadow: var(--shadow); border: 2px solid var(--line);
  border-top: 10px solid var(--series, var(--accent-fill)); transition: transform 0.2s ease;
}
.card:hover { transform: translateY(-3px); }
.card.series-within { --series: var(--within); } .card.series-around { --series: var(--around); } .card.series-maths { --series: var(--maths); }
.card-top { display: flex; justify-content: center; background: var(--surface-2); border-radius: 16px; margin-bottom: 10px; }
.card-art { width: 140px; height: 105px; }
.card-title { font-size: 1.35rem; line-height: 1.25; margin: 4px 0 6px; }
.card-summary { margin: 0 0 10px; color: var(--muted); font-size: 1.05rem; flex: 1; }
.card-meta { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 0 0 12px; font-size: 0.98rem; font-weight: 700; }
.meta-series { color: var(--series); }
.meta-time::before, .meta-langs::before { content: '· '; color: var(--muted); }
.card-note { font-size: 0.95rem; color: var(--muted); margin: -6px 0 10px; }
.card-play {
  align-self: flex-start; min-height: 48px; padding: 10px 20px; border-radius: 999px; background: var(--primary); color: var(--on-primary); font-weight: 800;
}

/* ── player ── */
.screen-player { display: flex; flex-direction: column; gap: 12px; }
.player-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.lesson-title { flex: 1 1 260px; margin: 0; font-size: clamp(1.4rem, 3.6vw, 2rem); line-height: 1.2; }
.beat-strip { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: thin; }
.beat-chip {
  min-height: 48px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; white-space: nowrap;
  border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700; font-size: 1rem;
}
.chip-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--accent-fill); }
.beat-chip.done .chip-dot { background: var(--accent-fill); }
.beat-chip[aria-current="step"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.beat-chip[aria-current="step"] .chip-dot { background: var(--on-primary); border-color: var(--on-primary); }

.stage-box {
  position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: var(--radius); overflow: hidden;
  border: 6px solid var(--stage-frame); background: #f6e7cc; box-shadow: var(--shadow); container-type: inline-size;
}
.stage-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-svg .camera, .stage-svg .node, .stage-svg .pose, .stage-svg .piece, .stage-svg .count-item { transform-box: view-box; transform-origin: 0 0; }
.stage-svg .halo { fill: rgba(242, 182, 50, 0.32); stroke: #f2b632; stroke-width: 6; }
.stage-svg .join-ring { fill: none; stroke: #b8860b; stroke-width: 6; stroke-dasharray: 14 10; opacity: 0; }
.stage-svg .trail { stroke: #b8860b; stroke-width: 5; stroke-dasharray: 4 12; stroke-linecap: round; }
.stage-svg .trail-head { fill: #b8860b; }
.stage-svg .pulse-dot { fill: #c8443a; stroke: #fff6e3; stroke-width: 2; }
.stage-svg .count-badge circle { fill: #2d1f0e; }
.stage-svg .count-badge text { fill: #fff6e3; font: 800 15px var(--font); }
.stage-svg .debug-name { fill: #1a1510; font: 700 13px var(--font); paint-order: stroke; stroke: #fff6e3; stroke-width: 4px; }
.stage-label {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%); margin: 0; padding: 6px 18px; border-radius: 999px;
  background: rgba(26, 21, 16, 0.86); color: #fff3d6; font-weight: 800; font-size: clamp(1.1rem, 3cqw, 1.8rem);
}
.overlay { position: absolute; inset: 0; }
.overlay .target, .overlay .token {
  position: absolute; width: max(48px, var(--size, 64px)); height: max(48px, var(--size, 64px)); transform: translate(-50%, -50%);
  border-radius: 50%; cursor: pointer; padding: 0;
}
.overlay .target { background: rgba(255, 246, 227, 0.08); border: 3px dashed rgba(184, 134, 11, 0.95); }
.overlay .target:hover { background: rgba(242, 182, 50, 0.22); }
.overlay .target.not-this { border-color: rgba(120, 90, 60, 0.6); }
.overlay .target.is-right { background: rgba(120, 190, 90, 0.35); border-style: solid; border-color: #2f7a4a; }
.overlay .token { background: rgba(255, 250, 240, 0.85); border: 3px solid #b8860b; touch-action: none; z-index: 2; transition: left 0.4s ease, top 0.4s ease; }
.overlay .token.loose { width: 52px; height: 52px; }
.overlay .token.dragging { transition: none; cursor: grabbing; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3); }
.overlay .token svg { width: 100%; height: 100%; }

.caption {
  margin: 0; min-height: 3.2em; padding: 12px 18px; border-radius: 18px; background: var(--surface); border: 2px solid var(--line);
  font-size: clamp(1.25rem, 2.6vw, 1.6rem); font-weight: 700; line-height: 1.4;
}
.voice-note { margin: -4px 4px 0; font-size: 1rem; color: var(--muted); }
.controls { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.ctrl {
  min-width: 64px; min-height: 60px; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  padding: 6px 14px; border-radius: 18px; border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 800; font-size: 0.95rem;
}
.ctrl .ctrl-icon { font-size: 1.35rem; line-height: 1.1; }
.ctrl.pause { background: var(--primary); color: var(--on-primary); border-color: var(--primary); min-width: 84px; }
.ctrl.voice[aria-pressed="false"] { opacity: 0.85; text-decoration: line-through; text-decoration-thickness: 2px; }
.ctrl:disabled { opacity: 0.45; cursor: default; }

.activity {
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow);
}
.activity h2, .prompt { margin: 0 0 12px; font-size: clamp(1.3rem, 3vw, 1.7rem); line-height: 1.3; }
.sub { margin: 0 0 10px; color: var(--muted); font-weight: 700; }
.choice-row { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 12px; padding: 0; list-style: none; }
.choice {
  min-height: 60px; min-width: 60px; padding: 10px 18px; border-radius: 18px; border: 3px solid var(--line); background: var(--surface-2);
  cursor: pointer; font-weight: 800; font-size: 1.2rem; display: inline-flex; align-items: center; gap: 10px;
}
.choice .pic { width: 72px; height: 72px; display: inline-block; }
.choice .pic svg { width: 100%; height: 100%; }
.choice.not-this { border-style: dashed; opacity: 0.85; }
.choice.is-right, .choice.is-right:disabled { border-color: #2f7a4a; background: var(--praise-bg); color: var(--praise-text); opacity: 1; }
.choice.was-chosen { border-style: dashed; }
.choice:disabled { cursor: default; }
.num-row { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.num-choice {
  min-width: 72px; min-height: 72px; border-radius: 50%; border: 3px solid var(--line); background: var(--surface-2); font-size: 1.6rem; font-weight: 900; cursor: pointer;
}
.num-choice.not-this { border-style: dashed; }
.num-choice.is-right { border-color: #2f7a4a; background: var(--praise-bg); color: var(--praise-text); }
.num-choice:disabled:not(.is-right) { opacity: 0.6; }
.feedback { margin: 6px 0 0; min-height: 1.5em; font-weight: 800; border-radius: 14px; }
.feedback.hint { background: var(--hint-bg); color: var(--hint-text); padding: 10px 14px; }
.feedback.praise { background: var(--praise-bg); color: var(--praise-text); padding: 10px 14px; }
.go-on { margin-top: 14px; }

.question { border-top: 2px dashed var(--line); padding-top: 12px; margin-top: 12px; }
.question:first-child { border-top: 0; margin-top: 0; padding-top: 0; }
.q-num { margin: 0; color: var(--muted); font-weight: 800; font-size: 1rem; }
.answer-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.answer-row label { font-weight: 700; }
.num-input, .short-input {
  min-height: 52px; padding: 8px 12px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg); font-size: 1.3rem;
}
.num-input { width: 7ch; }
.short-input { flex: 1 1 260px; }
.reveal p { margin: 10px 0 0; }
.reveal .praise { color: var(--praise-text); background: var(--praise-bg); padding: 8px 12px; border-radius: 12px; font-weight: 800; }
.reveal .gentle { color: var(--hint-text); background: var(--hint-bg); padding: 8px 12px; border-radius: 12px; font-weight: 800; }
.reveal .answer { font-weight: 800; }
.reveal .explain { color: var(--muted); }

.say-it { text-align: center; }
.remember-label, .sa-label { margin: 0; font-weight: 800; color: var(--muted); font-size: 1rem; text-transform: uppercase; letter-spacing: 0.06em; }
.remember { font-size: clamp(1.3rem, 3vw, 1.7rem); font-weight: 800; margin: 4px 0 14px; }
.sa-term { background: var(--surface-2); border-radius: 20px; padding: 14px; border: 2px solid var(--accent-fill); }
.sa-deva { font-family: 'VijayaDV', 'Noto Serif Devanagari', serif; font-size: clamp(3rem, 11vw, 5.5rem); line-height: 1.25; margin: 4px 0; color: var(--text); }
.sa-iast { font-style: italic; font-size: 1.4rem; margin: 0; color: var(--accent); font-weight: 700; }
.sa-meaning { margin: 4px 0 10px; font-size: 1.2rem; }
.go-card { text-align: center; background: linear-gradient(180deg, var(--surface), var(--surface-2)); }
.go-text { font-size: clamp(1.25rem, 2.8vw, 1.55rem); font-weight: 700; }
.the-end { color: var(--muted); }
.go-actions { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; }

@media (max-width: 600px) {
  body { font-size: 1.1rem; }
  .btn-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .brand-text { font-size: 1.2rem; }
  .hero-mascot { width: 64px; height: 64px; }
  .ctrl { min-width: 56px; padding: 6px 8px; }
  .ctrl .ctrl-label { font-size: 0.8rem; }
  .back-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .stage-box { border-width: 4px; border-radius: 16px; }
}

/* Calm motion: no transitions; the stage engine swaps to still frames itself. */
.calm *, .calm *::before, .calm *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
.calm .card:hover { transform: none; }
main:focus, main:focus-visible { outline: none; }
.meta-langs { flex-basis: 100%; }
.meta-langs::before { content: none; }
.stage-box { width: min(100%, calc(62vh * 16 / 9)); margin: 0 auto; min-width: min(100%, 340px); }
