/* kids.css — styles for the Kids tab, syllable chips, visual quantity, gamification. */

/* Topbar rewards strip */
.top-right {
  position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  display: flex; align-items: center; gap: 10px;
}
.reward-strip { display: inline-flex; gap: 6px; }
.reward-chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 13px; font-weight: 600;
  padding: 4px 10px; border-radius: var(--radius-pill);
  background: var(--surface-2); color: var(--ink-2);
}

/* Kids subtabs */
.subtabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-pill);
  margin: 4px auto 18px; width: fit-content;
}
.subtab {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 6px 14px; border-radius: var(--radius-pill);
  font: inherit; font-weight: 500; font-size: 13px;
  transition: background 0.15s, color 0.15s;
}
.subtab:hover { color: var(--ink); }
.subtab.active {
  background: var(--surface); color: var(--ink);
  box-shadow: var(--shadow-soft);
  font-weight: 600;
}

.panel-kids { text-align: center; }
.kid-panel { padding: 4px 0 12px; }

/* Kids tab highlight */
.tab-kids { background: linear-gradient(135deg, var(--accent-soft), transparent); }

/* Match — choice grid */
.choice-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  max-width: 420px; margin: 20px auto 0;
}
.choice {
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--border); border-radius: var(--radius-md);
  padding: 16px 14px; font-size: 17px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.08s;
}
.choice:hover { background: var(--accent-soft); border-color: var(--accent-soft); }
.choice:active { transform: scale(0.97); }
.choice-correct { background: #d4f5e3 !important; border-color: var(--good) !important; color: var(--ink) !important; }
.choice-wrong   { background: #ffe0db !important; border-color: var(--bad) !important;  color: var(--ink) !important; }
html[data-theme="dark"] .choice-correct { background: rgba(46, 232, 142, 0.18) !important; }
html[data-theme="dark"] .choice-wrong   { background: rgba(255, 122, 92, 0.18) !important; }

/* Listen — pill digit input + mini keypad */
.input-pills {
  display: inline-flex; gap: 8px; margin: 14px 0 6px; min-height: 50px;
}
.input-pill {
  display: inline-grid; place-items: center;
  min-width: 44px; height: 50px; padding: 0 10px;
  background: var(--surface-2); border-radius: 10px;
  font-size: 24px; font-weight: 700;
  color: var(--ink); border: 2px solid var(--border);
}
.input-pill:empty::before { content: "_"; color: var(--muted-2); }

.mini-keypad {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  max-width: 280px; margin: 14px auto 0;
}
.mini-keypad button {
  aspect-ratio: 1/1; font-size: 22px; font-weight: 700;
  background: var(--surface); color: var(--ink);
  border: 2px solid var(--border); border-radius: 14px;
  cursor: pointer; transition: background 0.15s;
}
.mini-keypad button:hover { background: var(--accent-soft); }
.mini-keypad .mini-key-primary {
  background: var(--accent); color: var(--accent-ink); border-color: var(--accent);
}

.target-display { min-height: 24px; margin-top: 10px; color: var(--muted); font-size: 14px; }

/* Count — number grid */
.count-grid {
  display: grid; gap: 4px;
  margin: 18px auto 0; max-width: 480px;
}
.count-cell {
  aspect-ratio: 1/1;
  font-size: 15px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2);
  border: 0; border-radius: 8px;
  cursor: pointer; padding: 0;
  display: grid; place-items: center;
  transition: background 0.15s, color 0.15s, transform 0.1s;
}
.count-cell:hover { background: var(--accent-soft); }
.count-cell.is-done { background: rgba(46, 207, 132, 0.15); color: var(--good); }
.count-cell.is-current {
  background: var(--accent); color: var(--accent-ink); transform: scale(1.1);
  box-shadow: 0 4px 14px rgba(107, 92, 255, 0.35);
  z-index: 1;
}

/* Trace */
.trace-wrap {
  display: flex; justify-content: center; margin: 14px 0;
}
#kid-trace-canvas {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-md);
  background: var(--bg);
  touch-action: none;
  cursor: crosshair;
  max-width: 100%;
}
#kid-trace-target { font-size: 28px; margin: 0; opacity: 0.6; }

/* Syllable chips (Spell output enhancement) */
.syllable-row {
  display: flex; flex-wrap: wrap; gap: 6px; justify-content: center;
  margin: 12px 0 6px;
}
.syllable-word { display: inline-flex; align-items: center; gap: 2px; }
.syl-chip {
  border: 0; background: var(--surface-2); color: var(--ink-2);
  padding: 6px 10px; border-radius: var(--radius-pill);
  font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.syl-chip:hover { background: var(--accent); color: var(--accent-ink); }
.syl-sep   { color: var(--muted-2); margin: 0 1px; font-size: 12px; }
.syl-hyphen { color: var(--muted); margin: 0 3px; font-weight: 600; }

/* Quantity row (dots + base-10 blocks) */
.quantity-row {
  display: flex; justify-content: center; align-items: flex-end;
  margin: 12px 0 2px;
  min-height: 30px;
  overflow-x: auto;
}
.quantity-row svg { max-width: 100%; height: auto; }

/* Celebration overlay */
.celebrate {
  position: fixed; inset: 0; pointer-events: none;
  z-index: 99; opacity: 0; transition: opacity 0.2s;
}
.celebrate.active { opacity: 1; }
.celebrate-center {
  position: absolute; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  text-align: center;
  animation: pop-in 0.25s ease-out;
}
.celebrate-mascot {
  font-size: 72px; line-height: 1;
  animation: bounce 0.6s ease-out;
}
.celebrate-msg {
  background: var(--accent); color: var(--accent-ink);
  padding: 8px 16px; border-radius: var(--radius-pill);
  font-weight: 700; font-size: 16px;
  box-shadow: var(--shadow-pop);
  margin-top: 12px; display: inline-block;
}
.confetti {
  position: absolute; top: -10px;
  width: 10px; height: 14px; border-radius: 2px;
  animation: fall 1.1s ease-in forwards;
}
@keyframes pop-in  { from { transform: translate(-50%, -50%) scale(0.4); opacity: 0; }
                     to   { transform: translate(-50%, -50%) scale(1);    opacity: 1; } }
@keyframes bounce  { 0% { transform: translateY(0); } 30% { transform: translateY(-20px); }
                     60% { transform: translateY(0); } 80% { transform: translateY(-8px); }
                     100% { transform: translateY(0); } }
@keyframes fall    { from { transform: translateY(0) rotate(0deg); opacity: 1; }
                     to   { transform: translateY(100vh) rotate(540deg); opacity: 0; } }

/* Prefer-reduced-motion safety */
@media (prefers-reduced-motion: reduce) {
  .celebrate-center, .celebrate-mascot, .confetti { animation: none !important; }
  .count-cell.is-current { transform: none !important; }
}

/* ========================================================================
   BLAST — Math-Blaster-style arcade, modern-soft (no pixel retro).
   ======================================================================== */
.blast-hud {
  display: flex; justify-content: space-between; align-items: center;
  max-width: 480px; margin: 8px auto 10px; padding: 0 4px;
  font-size: 14px; color: var(--ink-2);
}
.blast-hud strong { color: var(--ink); font-variant-numeric: tabular-nums; font-weight: 700; }
.blast-lives { letter-spacing: 2px; }

.blast-stage {
  position: relative;
  max-width: 480px; height: 320px; margin: 0 auto;
  background: linear-gradient(180deg,
    var(--surface) 0%,
    var(--accent-soft) 100%);
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-soft);
}

.blast-card {
  position: absolute;
  display: inline-grid; place-items: center;
  min-width: 70px; padding: 12px 18px;
  background: var(--surface);
  border: 2px solid var(--accent);
  border-radius: 16px;
  font-size: 26px; font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  box-shadow: 0 6px 18px rgba(107, 92, 255, 0.25);
  transform: translateX(-50%);
  will-change: top;
  user-select: none;
  pointer-events: none; /* we tap the chip, not the card */
}
.blast-card-pop {
  animation: blast-pop 0.22s ease-out forwards;
}
@keyframes blast-pop {
  0%   { transform: translateX(-50%) scale(1);    opacity: 1; }
  60%  { transform: translateX(-50%) scale(1.25); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.4);  opacity: 0; }
}

.blast-overlay {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  gap: 10px; padding: 20px; text-align: center;
  z-index: 2;
}
html[data-theme="dark"] .blast-overlay { background: rgba(11, 11, 16, 0.65); }
.blast-title {
  font-size: 32px; font-weight: 800; letter-spacing: -0.02em;
  color: var(--accent); margin: 0;
}

.blast-particle {
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  pointer-events: none;
  animation: blast-puff 0.65s ease-out forwards;
  --dx: 0px; --dy: 0px;
}
@keyframes blast-puff {
  from { transform: translate(0, 0) scale(1);   opacity: 1; }
  to   { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

.blast-options { margin-top: 14px; }
.blast-choice { font-size: 16px; padding: 14px 12px; }
.blast-choice-wrong {
  animation: shake 0.4s ease-out;
  border-color: var(--bad) !important;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
}

/* Reduced-motion: no shake, no scale pop */
@media (prefers-reduced-motion: reduce) {
  .blast-card-pop, .blast-particle, .blast-choice-wrong { animation: none !important; }
}

/* Small-screen tweaks */
@media (max-width: 420px) {
  .choice-grid { grid-template-columns: 1fr; }
  .count-grid { max-width: 100%; }
  .count-cell { font-size: 13px; }
  .blast-stage { height: 280px; }
  .blast-card  { font-size: 22px; padding: 10px 14px; min-width: 58px; }
  .blast-title { font-size: 26px; }
}
