/* =============================================================================
   MindSTREAM Feature Extensions CSS v1.0
   Styles for the 10 new features added by mindmaths-features.js
   ============================================================================= */

/* ── Feature 4: Streak Tile ──────────────────────────────────────────────── */
.streak-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: var(--panel, #fff);
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow: 0 4px 12px rgba(15,23,42,.08);
  text-align: center;
}

.streak-tile strong {
  font-size: 2rem;
  font-weight: 700;
  color: #f97316;
}

.streak-tile span {
  font-size: 0.78rem;
  color: var(--muted, #64748b);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Feature 1: Weak-Spot Panel ──────────────────────────────────────────── */
.weak-spots-panel {
  margin-top: 24px;
  padding: 20px;
  background: var(--panel, #fff);
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(15,23,42,.08);
}

.weak-spots-title {
  margin: 0 0 12px 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text, #0f172a);
}

.weak-spots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.weak-spot-card {
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  font-size: 0.82rem;
  border: 2px solid transparent;
  transition: transform .15s;
}

.weak-spot-card:hover { transform: translateY(-2px); }

.weak-spot-card[data-level="danger"] {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

.weak-spot-card[data-level="warn"] {
  background: #fff7ed;
  border-color: #fdba74;
  color: #c2410c;
}

.weak-spot-card[data-level="ok"] {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
}

.ws-topic {
  font-weight: 600;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-avg {
  font-size: 1.4rem;
  font-weight: 700;
}

.ws-count {
  font-size: 0.72rem;
  opacity: .75;
  margin-top: 2px;
}

/* ── Feature 5: Mock Exam Timer ──────────────────────────────────────────── */
.exam-timer-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-radius: 10px;
  margin-bottom: 14px;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  transition: background .3s, border-color .3s;
  position: relative;
  overflow: hidden;
}

.exam-timer-bar::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: var(--pct, 100%);
  transition: width 1s linear, background .5s;
  z-index: 0;
  opacity: .15;
  border-radius: 8px;
}

.exam-timer-bar[data-level="ok"]::before  { background: #22c55e; }
.exam-timer-bar[data-level="warn"]::before { background: #f97316; }
.exam-timer-bar[data-level="danger"]::before { background: #ef4444; }

.exam-timer-bar[data-level="danger"] {
  border-color: #ef4444;
  animation: timerPulse 1s infinite;
}

@keyframes timerPulse {
  0%, 100% { border-color: #ef4444; }
  50%       { border-color: #fca5a5; }
}

.exam-timer-display {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text, #0f172a);
  position: relative;
  z-index: 1;
  min-width: 80px;
}

.timer-controls {
  display: flex;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.timer-controls .btn {
  font-size: 0.82rem;
  padding: 6px 12px;
}

/* ── Feature 7: Video Modal ───────────────────────────────────────────────── */












/* ── Feature 9: Parent Portal ─────────────────────────────────────────────── */
#page-parent {
  padding: 20px 16px;
}

#page-parent h2 {
  margin: 0 0 16px;
  font-size: 1.2rem;
}

#page-parent h3 {
  margin: 24px 0 10px;
  font-size: 1rem;
  font-weight: 600;
}

.parent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}

.parent-card {
  background: var(--panel, #fff);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(15,23,42,.07);
  font-size: 0.88rem;
}

.parent-card strong {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted, #64748b);
  margin-bottom: 4px;
}

.parent-card p {
  margin: 0;
  font-weight: 600;
  font-size: 1rem;
  color: var(--text, #0f172a);
}

.parent-weak-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 8px;
}

.parent-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  margin-top: 8px;
}

.parent-table th,
.parent-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line, #e2e8f0);
}

.parent-table th {
  font-weight: 600;
  color: var(--muted, #64748b);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── Feature 10: Language Toggle ──────────────────────────────────────────── */
.lang-toggle {
  font-size: 0.78rem;
  padding: 5px 10px;
  font-weight: 700;
  letter-spacing: .06em;
  border-radius: 6px;
  border: 2px solid currentColor;
  background: transparent;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.lang-toggle:hover {
  background: rgba(29,78,216,.1);
  color: #1d4ed8;
}

/* ── Feature 3: Review Tag (Spaced Repetition) ────────────────────────────── */
.review-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  background: #7c3aed;
  color: #fff;
  border-radius: 4px;
  padding: 2px 6px;
  margin-left: 8px;
  vertical-align: middle;
  letter-spacing: .04em;
  text-transform: uppercase;
}

/* ── Feature 8: Interactive Graph Tooltip ─────────────────────────────────── */
.coord-tooltip {
  pointer-events: none;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  fill: #1d4ed8;
  font-weight: 600;
}

/* ── Muted helper ─────────────────────────────────────────────────────────── */
.muted {
  color: var(--muted, #64748b);
  font-size: 0.875rem;
}

/* ── Flashcard Engine ──────────────────────────────────────────────────────── */
.fc-controls { display:flex; flex-wrap:wrap; gap:10px; align-items:flex-end; }
.fc-controls label { font-weight:700; font-size:13px; color:#475569; display:block; margin-bottom:4px; }
.fc-controls select { min-width:180px; padding:8px 10px; border:1px solid #bfdbfe; border-radius:10px; font-size:14px; }

.fc-card-scene { width:100%; max-width:560px; margin:0 auto; perspective:1200px; }
.fc-card { width:100%; min-height:320px; position:relative; transform-style:preserve-3d; transition:transform 0.55s cubic-bezier(.4,0,.2,1); cursor:pointer; }
.fc-card.is-flipped { transform:rotateY(180deg); }
.fc-face { position:absolute; width:100%; min-height:320px; backface-visibility:hidden; border-radius:20px; padding:24px; box-sizing:border-box; }
.fc-front { background:linear-gradient(135deg,#1d4ed8,#7c3aed); color:#fff; display:flex; flex-direction:column; justify-content:space-between; }
.fc-back { background:#fff; border:2px solid #bfdbfe; transform:rotateY(180deg); }
.fc-grade-badge { font-size:11px; font-weight:900; text-transform:uppercase; letter-spacing:.12em; opacity:.75; margin-bottom:12px; }
.fc-question { font-size:18px; font-weight:700; line-height:1.5; flex:1; margin:12px 0; }
.fc-flip-btn { margin-top:auto; background:rgba(255,255,255,.18); border:1.5px solid rgba(255,255,255,.4); color:#fff; border-radius:999px; padding:10px 22px; font-weight:800; cursor:pointer; width:100%; }
.fc-flip-btn:hover { background:rgba(255,255,255,.3); }
.fc-answer-label { font-size:11px; font-weight:900; text-transform:uppercase; letter-spacing:.1em; color:#1d4ed8; margin-bottom:6px; }
.fc-answer-text { font-size:20px; font-weight:900; color:#0f172a; margin-bottom:12px; }
.fc-steps { font-size:13px; color:#374151; line-height:1.7; margin-bottom:10px; }
.fc-steps div { margin-bottom:4px; }
.fc-memory-tip { background:#eff6ff; border:1px solid #bfdbfe; border-radius:10px; padding:10px 12px; font-size:13px; color:#1d4ed8; font-weight:700; margin-bottom:12px; }
.fc-all-options { font-size:12px; color:#64748b; margin-bottom:14px; }
.fc-rating-row { display:flex; gap:8px; }
.fc-rate-btn { flex:1; padding:10px 6px; border-radius:12px; border:1.5px solid; font-weight:800; font-size:13px; cursor:pointer; }
.fc-again { border-color:#fca5a5; background:#fef2f2; color:#dc2626; }
.fc-gotit { border-color:#86efac; background:#f0fdf4; color:#16a34a; }
.fc-easy { border-color:#fde68a; background:#fffbeb; color:#b45309; }
.fc-rate-btn:hover { filter:brightness(.95); }
.fc-counter { text-align:center; margin-top:12px; font-size:13px; color:#64748b; font-weight:700; }
.fc-progress-bar { height:6px; background:#e2e8f0; border-radius:999px; margin-top:10px; overflow:hidden; }
.fc-progress-bar-fill { height:100%; background:linear-gradient(90deg,#1d4ed8,#7c3aed); border-radius:999px; transition:width .3s ease; }
.fc-summary { text-align:center; padding:32px; background:#fff; border:1px solid #bfdbfe; border-radius:20px; }
.fc-summary h3 { font-size:22px; margin-bottom:10px; }

/* ── Concept Notes ─────────────────────────────────────────────────────────── */
.concept-notes-card { border-left:4px solid #1d4ed8 !important; }
.cn-header { display:flex; align-items:center; justify-content:space-between; margin-bottom:12px; }
.cn-topic-label { font-size:11px; font-weight:900; text-transform:uppercase; letter-spacing:.12em; color:#1d4ed8; }
.cn-close-btn { min-width:auto; padding:4px 10px; font-size:13px; }
.cn-title { font-size:16px; font-weight:900; color:#0f172a; margin-bottom:14px; }
.cn-section { margin-bottom:14px; }
.cn-section-heading { font-size:12px; font-weight:900; text-transform:uppercase; letter-spacing:.1em; color:#7c3aed; margin-bottom:4px; }
.cn-section-body { font-size:14px; color:#1e293b; line-height:1.7; }

/* ── Interleaved mode ──────────────────────────────────────────────────────── */
label:has(#interleavedMode) { display:flex; align-items:center; gap:8px; font-size:14px; color:#374151; cursor:pointer; margin-top:6px; }

/* ── Confidence rating ─────────────────────────────────────────────────────── */
.confidence-row { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:10px; padding:10px 12px; background:#f8faff; border:1px solid #e0eaff; border-radius:12px; }
.confidence-label { font-size:12px; font-weight:700; color:#64748b; width:100%; margin-bottom:4px; }
.conf-btn { padding:6px 14px; border-radius:999px; border:1.5px solid #bfdbfe; background:#fff; font-size:13px; font-weight:700; cursor:pointer; }
.conf-btn.selected { background:#1d4ed8; color:#fff; border-color:#1d4ed8; }

/* ── Knowledge Points tile ─────────────────────────────────────────────────── */
#homeKP { color:#7c3aed; }

/* ── Leaderboard ───────────────────────────────────────────────────────────── */
.leaderboard-table { width:100%; border-collapse:collapse; margin-top:10px; font-size:13px; }
.leaderboard-table th { text-align:left; padding:8px 10px; background:#eff6ff; color:#1d4ed8; font-weight:900; font-size:11px; text-transform:uppercase; }
.leaderboard-table td { padding:8px 10px; border-bottom:1px solid #f1f5f9; }
.leaderboard-table tr:first-child td { font-weight:900; color:#7c3aed; }

/* ══════════════════════════════════════════════════════════════════════════
   MindMATHS AI Tutor Chat UI
   ══════════════════════════════════════════════════════════════════════════ */

/* Floating bubble */
.mm-ai-bubble {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 12px 20px 12px 16px;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 28px rgba(124,58,237,.45);
  transition: transform .2s, box-shadow .2s;
}
.mm-ai-bubble:hover { transform: translateY(-3px); box-shadow: 0 14px 36px rgba(124,58,237,.55); }
.mm-ai-bubble.mm-ai-bubble-active { background: linear-gradient(135deg, #1d4ed8, #0f172a); }
.mm-ai-bubble-icon { font-size: 1.2rem; line-height: 1; }
.mm-ai-bubble-label { font-size: 13px; font-weight: 800; }

/* Chat panel */
.mm-ai-panel {
  position: fixed;
  bottom: 88px;
  right: 24px;
  z-index: 8999;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 600px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 20px;
  box-shadow: 0 24px 64px rgba(15,23,42,.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(20px) scale(.97);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s cubic-bezier(.4,0,.2,1), opacity .25s ease;
}
.mm-ai-panel.mm-ai-panel-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* Header */
.mm-ai-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  flex-shrink: 0;
}
.mm-ai-header-info { display: flex; align-items: center; gap: 10px; }
.mm-ai-avatar { font-size: 1.6rem; line-height: 1; }
.mm-ai-title { font-size: 14px; font-weight: 900; }
.mm-ai-subtitle { font-size: 11px; opacity: .8; margin-top: 1px; }
.mm-ai-close {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.mm-ai-close:hover { background: rgba(255,255,255,.28); }

/* Messages area */
.mm-ai-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
}

/* Individual messages */
.mm-ai-msg { display: flex; }
.mm-ai-msg-user { justify-content: flex-end; }
.mm-ai-msg-ai   { justify-content: flex-start; }
.mm-ai-msg-bubble {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
}
.mm-ai-msg-user .mm-ai-msg-bubble {
  background: linear-gradient(135deg, #7c3aed, #2563eb);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.mm-ai-msg-ai .mm-ai-msg-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 6px rgba(15,23,42,.06);
}

/* Typing indicator */
.mm-ai-typing-indicator { display: flex; gap: 4px; align-items: center; padding: 8px 12px; }
.mm-ai-typing-indicator span {
  width: 7px; height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: mm-bounce 1.2s infinite;
}
.mm-ai-typing-indicator span:nth-child(2) { animation-delay: .2s; }
.mm-ai-typing-indicator span:nth-child(3) { animation-delay: .4s; }
@keyframes mm-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .5; }
  40%           { transform: translateY(-5px); opacity: 1; }
}

/* Input row */
.mm-ai-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}
.mm-ai-input {
  flex: 1;
  min-height: 38px;
  max-height: 120px;
  border: 1.5px solid #bfdbfe;
  border-radius: 12px;
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  resize: none;
  color: #0f172a;
  background: #f8fafc;
  outline: none;
  transition: border-color .15s;
  width: auto !important;
  -webkit-appearance: none;
}
.mm-ai-input:focus { border-color: #7c3aed; background: #fff; }
.mm-ai-send {
  min-width: 38px !important;
  width: 38px;
  height: 38px;
  border-radius: 12px !important;
  padding: 0 !important;
  font-size: 15px !important;
  flex-shrink: 0;
  background: linear-gradient(135deg, #7c3aed, #2563eb) !important;
  color: #fff !important;
  border-color: transparent !important;
}
.mm-ai-send:disabled { opacity: .5; cursor: not-allowed; }

/* Footer */
.mm-ai-footer {
  font-size: 10px;
  color: #94a3b8;
  text-align: center;
  padding: 4px 12px 8px;
  background: #fff;
  flex-shrink: 0;
}

/* Mobile */
@media (max-width: 480px) {
  .mm-ai-panel { right: 12px; bottom: 80px; width: calc(100vw - 24px); }
  .mm-ai-bubble { right: 12px; bottom: 16px; padding: 10px 14px 10px 12px; }
}

/* ══════════════════════════════════════════════════════════════════════════
   Grade R and Grade 1-2 — Fun, colourful, age-appropriate theme
   ══════════════════════════════════════════════════════════════════════════ */

/* Body theme for Grade R */
body.grade-r-fun {
  background: linear-gradient(135deg, #fef3c7 0%, #fce7f3 40%, #ede9fe 70%, #d1fae5 100%) !important;
  background-attachment: fixed !important;
}
body.grade-r-fun #appShell {
  background: transparent !important;
}

/* Body theme for Grade 1-2 */
body.grade-early-fun {
  background: linear-gradient(135deg, #eff6ff 0%, #f0fdf4 40%, #fef9c3 70%, #fce7f3 100%) !important;
  background-attachment: fixed !important;
}
body.grade-early-fun #appShell {
  background: transparent !important;
}

/* Fun header for early grades */
body.grade-r-fun .header,
body.grade-early-fun .header {
  background: linear-gradient(135deg, #8b5cf6, #ec4899, #f97316) !important;
  border-radius: 0 0 24px 24px !important;
  box-shadow: 0 8px 24px rgba(139,92,246,.3) !important;
}
body.grade-r-fun .copy h1,
body.grade-early-fun .copy h1 {
  color: #fff !important;
  font-size: 22px !important;
  text-shadow: 0 2px 8px rgba(0,0,0,.2) !important;
}
body.grade-r-fun .copy p,
body.grade-early-fun .copy p {
  color: rgba(255,255,255,.9) !important;
}

/* Fun tabs */
body.grade-r-fun .tab,
body.grade-early-fun .tab {
  border-radius: 999px !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  background: rgba(255,255,255,.25) !important;
  border-color: rgba(255,255,255,.4) !important;
  color: #fff !important;
}
body.grade-r-fun .tab.active,
body.grade-early-fun .tab.active {
  background: #fff !important;
  color: #7c3aed !important;
  box-shadow: 0 4px 12px rgba(0,0,0,.15) !important;
}

/* Fun cards for early grades */
body.grade-r-fun .card,
body.grade-r-fun .banner,
body.grade-r-fun .panel {
  border-radius: 24px !important;
  border: 2px solid rgba(139,92,246,.2) !important;
  box-shadow: 0 8px 24px rgba(139,92,246,.12) !important;
}
body.grade-early-fun .card,
body.grade-early-fun .banner,
body.grade-early-fun .panel {
  border-radius: 20px !important;
  border: 2px solid rgba(37,99,235,.15) !important;
  box-shadow: 0 6px 20px rgba(37,99,235,.1) !important;
}

/* Big colourful buttons for young learners */
body.grade-r-fun .btn,
body.grade-early-fun .btn {
  border-radius: 999px !important;
  font-size: 15px !important;
  font-weight: 900 !important;
  min-height: 48px !important;
  padding: 0 20px !important;
}
body.grade-r-fun .btn.primary,
body.grade-early-fun .btn.primary {
  background: linear-gradient(135deg, #8b5cf6, #ec4899) !important;
  box-shadow: 0 6px 20px rgba(139,92,246,.4) !important;
  color: #fff !important;
  border-color: transparent !important;
  transform: scale(1.02);
}
body.grade-r-fun .btn.primary:hover,
body.grade-early-fun .btn.primary:hover {
  transform: scale(1.06) translateY(-2px) !important;
  box-shadow: 0 10px 28px rgba(139,92,246,.5) !important;
}

/* Fun question cards */
body.grade-r-fun .question-card,
body.grade-early-fun .question-card {
  border-radius: 24px !important;
  border: 3px solid #c4b5fd !important;
  background: linear-gradient(180deg, #fdf4ff, #fff) !important;
  box-shadow: 0 8px 24px rgba(139,92,246,.15) !important;
}
body.grade-r-fun .question-card h4,
body.grade-early-fun .question-card h4 {
  font-size: 20px !important;
  line-height: 1.5 !important;
  color: #4c1d95 !important;
}
body.grade-r-fun .option-row,
body.grade-early-fun .option-row {
  border-radius: 16px !important;
  border: 2px solid #ddd6fe !important;
  background: #f5f3ff !important;
  padding: 14px !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  cursor: pointer !important;
  transition: all .15s !important;
}
body.grade-r-fun .option-row:hover,
body.grade-early-fun .option-row:hover {
  border-color: #8b5cf6 !important;
  background: #ede9fe !important;
  transform: scale(1.01) !important;
}
body.grade-r-fun .option-tag,
body.grade-early-fun .option-tag {
  width: 34px !important;
  height: 34px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #8b5cf6, #ec4899) !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 900 !important;
  border: none !important;
}

/* Big check button */
body.grade-r-fun .btn.check-btn,
body.grade-early-fun .btn.check-btn {
  background: linear-gradient(135deg, #059669, #0891b2) !important;
  color: #fff !important;
  border-color: transparent !important;
  border-radius: 999px !important;
  font-size: 15px !important;
  min-height: 46px !important;
  padding: 0 24px !important;
}

/* Feedback */
body.grade-r-fun .feedback.good,
body.grade-early-fun .feedback.good {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0) !important;
  border: 2px solid #34d399 !important;
  border-radius: 16px !important;
  font-size: 18px !important;
  text-align: center !important;
  padding: 16px !important;
}
body.grade-r-fun .feedback.bad,
body.grade-early-fun .feedback.bad {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8) !important;
  border: 2px solid #f9a8d4 !important;
  border-radius: 16px !important;
  font-size: 15px !important;
  padding: 14px !important;
}

/* Grade R/1 star reward animation */
@keyframes mm-star-pop {
  0%   { transform: scale(0) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
@keyframes mm-bounce-in {
  0%   { transform: scale(0.5) translateY(20px); opacity: 0; }
  70%  { transform: scale(1.1) translateY(-5px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
@keyframes mm-confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(60px) rotate(360deg); opacity: 0; }
}
.mm-reward-overlay {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: rgba(139,92,246,.15);
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.mm-reward-star {
  font-size: 5rem; line-height: 1;
  animation: mm-star-pop .5s cubic-bezier(.4,0,.2,1) forwards;
}
.mm-reward-text {
  font-size: 2rem; font-weight: 900; color: #7c3aed;
  text-shadow: 0 2px 8px rgba(124,58,237,.3);
  margin-top: 12px;
  animation: mm-bounce-in .6s .3s cubic-bezier(.4,0,.2,1) both;
}
.mm-reward-sub {
  font-size: 1.1rem; color: #6d28d9; margin-top: 8px;
  animation: mm-bounce-in .6s .5s cubic-bezier(.4,0,.2,1) both;
}
.mm-confetti-piece {
  position: absolute; font-size: 1.5rem;
  animation: mm-confetti-fall 1.2s ease-in forwards;
}

/* Grade R emoji bar above questions */
.mm-emoji-bar {
  text-align: center; font-size: 1.8rem; margin-bottom: 12px;
  letter-spacing: 8px; line-height: 1;
}

/* Star progress bar for early grades */
.mm-star-progress {
  display: flex; gap: 6px; justify-content: center;
  margin: 8px 0 16px; flex-wrap: wrap;
}
.mm-star-progress span {
  font-size: 1.4rem; transition: transform .2s;
}
.mm-star-progress span.earned { animation: mm-star-pop .4s ease both; }

/* ── WhatsApp floating button (grade pages) ────────────────────────────────── */
#mm-wa-btn {
  position: fixed;
  bottom: 88px;  /* above the AI bubble */
  right: 24px;
  z-index: 8998;
  width: 50px;
  height: 50px;
  background: #25D366;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(37,211,102,.45);
  transition: transform .2s, box-shadow .2s;
  color: #fff;
  text-decoration: none;
}
#mm-wa-btn:hover {
  transform: translateY(-3px) scale(1.08);
  box-shadow: 0 12px 28px rgba(37,211,102,.55);
}
@media(max-width:480px){
  #mm-wa-btn { right: 12px; bottom: 80px; width: 44px; height: 44px; }
}

/* ── Flashcard Visual Renderer (fc-visual) ── */
.fc-visual { margin: 12px 0; }
.fc-visual .algebra-box { font-size: 1.4rem; font-weight: 800; color: #1e40af; background: #eff6ff; border-radius: 10px; padding: 10px 18px; display: inline-block; }
.fc-visual .picto-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0; }
.fc-visual .picto-card { font-size: 1.6rem; }
.fc-visual .group-grid { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.fc-visual .group-card { background: rgba(255,255,255,0.18); border-radius: 10px; padding: 8px 12px; text-align: center; }
.fc-visual .group-icons { font-size: 1.2rem; }
.fc-visual .group-label { font-size: 0.8rem; color: rgba(255,255,255,0.8); margin-top: 4px; }
.fc-visual .fc-bar-chart { width: 100%; }
.fc-visual .fc-bar-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.fc-visual .fc-bar-label { font-size: 12px; color: rgba(255,255,255,0.9); width: 60px; text-align: right; flex-shrink: 0; }
.fc-visual .fc-bar { height: 18px; background: rgba(255,255,255,0.7); border-radius: 4px; min-width: 4px; }
.fc-visual .fc-bar-val { font-size: 12px; color: #fff; font-weight: 700; }
.fc-visual .fc-number-line { display: flex; gap: 12px; padding: 10px; background: rgba(255,255,255,0.15); border-radius: 8px; justify-content: center; flex-wrap: wrap; }
.fc-visual .fc-number-line span { font-size: 1rem; font-weight: 700; color: #fff; }
.fc-visual .fc-shape-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.fc-visual .fc-shape-card { font-size: 1.3rem; background: rgba(255,255,255,0.18); border-radius: 8px; padding: 6px 10px; text-align: center; color: #fff; }

/* ═══════════════════════════════════════════════════════════════════
   MindMATHS Rich Visual Enhancements — mindmaths-visuals.js
   Added for Grades 3–12 interactive visual learning
   ════════════════════════════════════════════════════════════════ */

/* Visual containers */
.mm-visual { margin: 14px 0; text-align: center; }
.mm-visual svg { max-width: 100%; height: auto; }

/* Pie chart */
.mm-pie-slice { cursor: pointer; transition: opacity 0.2s; }
.mm-pie-slice:hover { opacity: 0.8; }
.mm-pie-slice.selected { stroke: #fff; stroke-width: 3; }
.mm-pie-legend { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 8px; }
.mm-pie-legend-item { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #e2e8f0; }
.mm-pie-swatch { width: 12px; height: 12px; border-radius: 2px; flex-shrink: 0; }

/* Fraction bar */
.mm-frac-bar { display: flex; height: 40px; border: 2px solid #cbd5e1; border-radius: 4px; overflow: hidden; margin: 8px auto; max-width: 360px; }
.mm-frac-part { transition: all 0.2s; cursor: pointer; flex: 1; }
.mm-frac-part.shaded { background: #7c3aed; }
.mm-frac-part:not(.shaded) { background: #f1f5f9; }
.mm-frac-part:hover { filter: brightness(1.1); }

/* Coordinate grid */
.mm-coord-svg { border: 1px solid #334155; border-radius: 8px; background: #0f172a; }
.mm-coord-axis { stroke: #64748b; stroke-width: 1.5; fill: none; }
.mm-coord-grid-line { stroke: #1e293b; stroke-width: 0.5; }
.mm-coord-point { fill: #2563eb; stroke: #fff; stroke-width: 2; cursor: pointer; }
.mm-coord-line { stroke: #f59e0b; stroke-width: 2; fill: none; }
.mm-coord-curve { stroke: #a855f7; stroke-width: 2; fill: none; }
.mm-coord-label { fill: #94a3b8; font-size: 11px; }

/* Trig triangle */
.mm-trig-hyp { stroke: #f59e0b; stroke-width: 3; }
.mm-trig-opp { stroke: #ef4444; stroke-width: 3; }
.mm-trig-adj { stroke: #22c55e; stroke-width: 3; }
.mm-trig-label { font-size: 13px; font-weight: 700; }
.mm-trig-angle { fill: none; stroke: #7c3aed; stroke-width: 2; }
.mm-soh-cah-toa { background: #1e293b; border-radius: 8px; padding: 8px 12px; font-size: 12px; display: inline-block; margin-top: 8px; color: #e2e8f0; }

/* Bar chart */
.mm-bar-chart svg { overflow: visible; }
.mm-bar-rect { cursor: pointer; transition: opacity 0.2s; }
.mm-bar-rect:hover { opacity: 0.8; }
.mm-bar-tooltip { pointer-events: none; }

/* Venn diagram */
.mm-venn-circle { fill-opacity: 0.25; stroke-width: 2; }
.mm-venn-elem { font-size: 13px; cursor: pointer; }
.mm-venn-elem:hover { font-weight: bold; }

/* Geometry shape */
.mm-geo-polygon { fill: rgba(37,99,235,0.15); stroke: #2563eb; stroke-width: 2; }
.mm-geo-highlight { stroke: #f59e0b; stroke-width: 3; }
.mm-geo-angle-arc { fill: rgba(124,58,237,0.3); stroke: #7c3aed; }
.mm-geo-label { font-size: 13px; fill: #e2e8f0; font-weight: 700; }

/* Concept visual card */
.mm-concept-visual { background: rgba(37,99,235,0.08); border: 1px solid rgba(37,99,235,0.3); border-radius: 12px; padding: 16px; margin: 12px 0; }
.mm-concept-visual h4 { color: #60a5fa; font-size: 14px; margin: 0 0 10px; }

/* Box whisker */
.mm-bw-box { fill: rgba(124,58,237,0.3); stroke: #7c3aed; stroke-width: 2; }
.mm-bw-whisker { stroke: #94a3b8; stroke-width: 2; }
.mm-bw-median { stroke: #f59e0b; stroke-width: 3; }
.mm-bw-outlier { fill: #ef4444; }

/* Finance timeline */
.mm-fin-bar { fill: #2563eb; rx: 4; }
.mm-fin-label { fill: #e2e8f0; font-size: 11px; text-anchor: middle; }

/* Stem-and-leaf */
.mm-stem-table { border-collapse: collapse; margin: 0 auto; font-family: monospace; }
