/* ============================================================
   style.css — Main styles for Kids World Learning
   ============================================================ */

/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700;800;900&family=Fredoka+One&display=swap');

/* ===== CSS Variables ===== */
:root {
  --primary:    #FF6B6B;
  --secondary:  #4ECDC4;
  --accent:     #FFE66D;
  --purple:     #C3A6FF;
  --green:      #A8E6CF;
  --orange:     #FFB347;
  --pink:       #FF8B94;
  --bg:         #FFF9F0;
  --card-bg:    #FFFFFF;
  --text:       #333333;
  --text-light: #666666;
  --radius-sm:  12px;
  --radius-md:  20px;
  --radius-lg:  32px;
  --shadow:     0 8px 30px rgba(0,0,0,.12);
  --shadow-lg:  0 16px 50px rgba(0,0,0,.18);
  --font-body:  'Nunito', sans-serif;
  --font-title: 'Fredoka One', cursive;
}

/* ===== Reset ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; border: none; font-family: var(--font-body); }

/* ===== Global Header ===== */
.kwl-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: linear-gradient(135deg, #FF6B6B, #FF8B94);
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 4px 20px rgba(255,107,107,.4);
}

.kwl-header .logo {
  font-family: var(--font-title);
  font-size: 1.6rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.kwl-header .logo span { font-size: 2rem; }

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.star-badge {
  background: var(--accent);
  color: #333;
  padding: 6px 16px;
  border-radius: 50px;
  font-weight: 800;
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon {
  background: rgba(255,255,255,.25);
  color: #fff;
  border: 2px solid rgba(255,255,255,.5);
  border-radius: 50px;
  padding: 8px 18px;
  font-size: 0.95rem;
  font-weight: 700;
  transition: all .2s;
}
.btn-icon:hover { background: rgba(255,255,255,.4); transform: scale(1.05); }
.btn-icon.active { background: var(--accent); color: #333; border-color: var(--accent); }

/* ===== Page Title Banner ===== */
.page-banner {
  text-align: center;
  padding: 40px 20px 20px;
  position: relative;
}
.page-banner h1 {
  font-family: var(--font-title);
  font-size: clamp(2rem, 5vw, 3.5rem);
  color: var(--primary);
  text-shadow: 3px 3px 0 rgba(255,107,107,.2);
}
.page-banner p {
  font-size: 1.15rem;
  color: var(--text-light);
  margin-top: 8px;
}

/* ===== Card Grid ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 20px;
  padding: 20px 24px 40px;
  max-width: 1400px;
  margin: 0 auto;
}

/* ===== Learning Card ===== */
.learn-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  position: relative;
  overflow: hidden;
  border: 3px solid transparent;
}

.learn-card::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity .2s;
  background: radial-gradient(circle at center, rgba(255,255,255,.5), transparent);
}

.learn-card:hover {
  transform: translateY(-8px) scale(1.03);
  box-shadow: var(--shadow-lg);
}
.learn-card:hover::before { opacity: 1; }
.learn-card:active { transform: scale(.97); }

.learn-card .card-emoji {
  font-size: 3.5rem;
  line-height: 1;
  margin-bottom: 10px;
  display: block;
  animation: floatEmoji 3s ease-in-out infinite;
}

.learn-card .card-title {
  font-family: var(--font-title);
  font-size: 1.4rem;
  margin-bottom: 4px;
}

.learn-card .card-sub {
  font-size: 0.9rem;
  color: var(--text-light);
}

.learn-card .speak-btn {
  margin-top: 12px;
  background: linear-gradient(135deg, var(--secondary), #6decb9);
  color: #fff;
  border-radius: 50px;
  padding: 8px 20px;
  font-size: 0.9rem;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(78,205,196,.4);
  transition: transform .2s;
}
.learn-card .speak-btn:hover { transform: scale(1.1); }

/* ===== Detail View (Alphabet / Number player) ===== */
.detail-view {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

.detail-card {
  background: #fff;
  border-radius: 32px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.detail-card .big-emoji {
  font-size: 8rem;
  animation: floatEmoji 2.5s ease-in-out infinite;
  display: block;
}

.detail-card .big-letter {
  font-family: var(--font-title);
  font-size: 9rem;
  line-height: 1;
  color: var(--primary);
  text-shadow: 5px 5px 0 rgba(255,107,107,.2);
}

.detail-card .small-letter {
  font-family: var(--font-title);
  font-size: 4rem;
  color: var(--secondary);
}

.detail-card .word-label {
  font-family: var(--font-title);
  font-size: 2.2rem;
  margin: 10px 0;
}

.detail-controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 28px;
  flex-wrap: wrap;
}

.ctrl-btn {
  padding: 14px 28px;
  border-radius: 50px;
  font-family: var(--font-title);
  font-size: 1.1rem;
  font-weight: 700;
  transition: transform .2s, box-shadow .2s;
  box-shadow: 0 4px 16px rgba(0,0,0,.15);
}
.ctrl-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.ctrl-btn:active { transform: scale(.95); }
.ctrl-btn.primary   { background: var(--primary); color: #fff; }
.ctrl-btn.secondary { background: var(--secondary); color: #fff; }
.ctrl-btn.accent    { background: var(--accent); color: #333; }
.ctrl-btn.purple    { background: var(--purple); color: #fff; }
.ctrl-btn.green     { background: var(--green); color: #333; }

/* ===== Progress Dots ===== */
.progress-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 16px 0;
  flex-wrap: wrap;
}
.progress-dots .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: #ddd;
  transition: all .3s;
  cursor: pointer;
}
.progress-dots .dot.active { background: var(--primary); transform: scale(1.4); }
.progress-dots .dot.done   { background: var(--secondary); }

/* ===== Quiz Styles ===== */
.quiz-container {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

.quiz-card {
  background: #fff;
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  padding: 36px;
}

.quiz-question {
  font-family: var(--font-title);
  font-size: 1.8rem;
  text-align: center;
  color: var(--primary);
  margin-bottom: 8px;
}
.quiz-emoji { font-size: 4rem; text-align: center; display: block; margin: 10px 0 24px; }

.quiz-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.option-btn {
  padding: 18px;
  border-radius: var(--radius-md);
  font-family: var(--font-title);
  font-size: 1.4rem;
  background: #f0f4ff;
  border: 3px solid #e0e8ff;
  color: #333;
  transition: all .2s;
}
.option-btn:hover { background: #e0e8ff; transform: scale(1.04); }
.option-btn.correct { background: #d4edda; border-color: #28a745; color: #155724; animation: correctPop .4s; }
.option-btn.wrong   { background: #f8d7da; border-color: #dc3545; color: #721c24; animation: shake .4s; }

.quiz-score {
  text-align: center;
  padding: 12px;
  font-size: 1.1rem;
  font-weight: 700;
}

/* ===== Rhyme / Story Player ===== */
.player-card {
  background: #fff;
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  padding: 36px;
  max-width: 700px;
  margin: 0 auto 60px;
}

.player-title {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--primary);
  text-align: center;
  margin-bottom: 8px;
}

.rhyme-lines {
  line-height: 2.2;
  font-size: 1.2rem;
  padding: 16px 0;
}

.rhyme-line {
  padding: 4px 12px;
  border-radius: 8px;
  transition: background .3s, color .3s;
}
.rhyme-line.active {
  background: var(--accent);
  color: #333;
  font-weight: 700;
  transform: scale(1.02);
}

.player-controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 24px;
  flex-wrap: wrap;
}

/* ===== Story Page ===== */
.story-page {
  background: #fff;
  border-radius: 28px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  text-align: center;
  max-width: 680px;
  margin: 0 auto;
}

.story-scene {
  font-size: 6rem;
  margin: 20px 0;
  animation: floatEmoji 2s ease-in-out infinite;
}

.story-text {
  font-size: 1.25rem;
  line-height: 1.9;
  color: #444;
  margin-bottom: 24px;
}

.page-indicator {
  font-weight: 700;
  color: var(--text-light);
  margin-bottom: 16px;
}

/* ===== Memory Game ===== */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 24px 60px;
}

.mem-card {
  aspect-ratio: 1;
  border-radius: 16px;
  cursor: pointer;
  perspective: 800px;
  position: relative;
}

.mem-card-inner {
  width: 100%; height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform .5s;
}
.mem-card.flipped .mem-card-inner { transform: rotateY(180deg); }

.mem-front, .mem-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.4rem;
  box-shadow: var(--shadow);
}

.mem-front {
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 2rem;
}
.mem-back {
  background: #fff;
  transform: rotateY(180deg);
  border: 3px solid #e8e8e8;
}
.mem-card.matched .mem-back {
  background: linear-gradient(135deg, #a8edea, #fed6e3);
  border-color: var(--secondary);
  animation: matchedPulse .5s;
}

/* ===== Drawing Board ===== */
.drawing-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 24px 60px;
  gap: 16px;
}

.canvas-wrapper {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  border: 4px solid var(--secondary);
}

#draw-canvas {
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.drawing-toolbar {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 800px;
  width: 100%;
}

.tool-btn {
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 1.3rem;
  background: #f0f4ff;
  border: 2px solid transparent;
  transition: all .2s;
}
.tool-btn:hover { border-color: var(--secondary); transform: scale(1.08); }
.tool-btn.active { background: var(--secondary); color: #fff; border-color: var(--secondary); }

.color-swatch {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: transform .2s;
}
.color-swatch:hover { transform: scale(1.2); }
.color-swatch.active { border-color: #333; transform: scale(1.25); }

/* ===== Rewards Page ===== */
.rewards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  padding: 20px 24px 60px;
  max-width: 900px;
  margin: 0 auto;
}

.badge-card {
  background: #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 24px 16px;
  text-align: center;
  border: 3px solid var(--accent);
}
.badge-card .badge-icon { font-size: 3rem; }
.badge-card .badge-name { font-weight: 700; margin-top: 8px; font-size: 0.95rem; }
.badge-card.locked { opacity: .4; filter: grayscale(1); border-color: #ddd; }

/* ===== Home Grid ===== */
.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 22px;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
}

.home-card {
  background: var(--card-bg);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 28px 16px 20px;
  text-align: center;
  cursor: pointer;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  text-decoration: none;
  color: inherit;
  display: block;
  border: 3px solid transparent;
}
.home-card:hover {
  transform: translateY(-10px) scale(1.04);
  box-shadow: var(--shadow-lg);
}
.home-card:active { transform: scale(.96); }

.home-card .card-icon { font-size: 4rem; display: block; margin-bottom: 12px; animation: floatEmoji 3s ease-in-out infinite; }
.home-card .card-name { font-family: var(--font-title); font-size: 1.3rem; }
.home-card .card-desc { font-size: 0.85rem; color: var(--text-light); margin-top: 4px; }

/* ===== Mascot ===== */
.mascot {
  text-align: center;
  padding: 30px 20px 10px;
  position: relative;
}
.mascot .mascot-img {
  font-size: 8rem;
  animation: mascotBounce 1.5s ease-in-out infinite;
  display: block;
}
.mascot .speech-bubble {
  display: inline-block;
  background: #fff;
  border-radius: 20px;
  padding: 14px 24px;
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--primary);
  box-shadow: var(--shadow);
  margin-top: 10px;
  position: relative;
}
.mascot .speech-bubble::before {
  content: '';
  position: absolute;
  top: -16px; left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-bottom-color: #fff;
}

/* ===== Floating Decorations ===== */
.floating-deco {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  font-size: 2rem;
  animation: floatUp 8s ease-in-out infinite;
  opacity: 0.15;
}

/* ===== Section Headings ===== */
.section-heading {
  font-family: var(--font-title);
  font-size: 2rem;
  color: var(--primary);
  text-align: center;
  padding: 32px 20px 8px;
}

/* ===== Confetti animation keyframe ===== */
@keyframes confettiFall {
  0%   { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(300px) rotate(720deg); opacity: 0; }
}

@keyframes rippleOut {
  0%   { transform: scale(0); opacity: 1; }
  100% { transform: scale(8); opacity: 0; }
}

/* ===== Celebration Overlay ===== */
.celebration-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.6);
  z-index: 5000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.celebration-overlay.show { opacity: 1; pointer-events: all; }

.celebration-box {
  background: #fff;
  border-radius: 32px;
  padding: 40px 48px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  animation: popIn .4s cubic-bezier(.34,1.56,.64,1);
}
.celebration-box .cel-emoji { font-size: 5rem; }
.celebration-box h2 { font-family: var(--font-title); font-size: 2.4rem; color: var(--primary); margin: 12px 0; }
.celebration-box p { font-size: 1.1rem; color: var(--text-light); }
.celebration-box .stars-earned { font-size: 2rem; margin: 12px 0; color: var(--accent); font-weight: 900; }

/* ===== Utilities ===== */
.text-center { text-align: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.hidden { display: none !important; }
.flex-center { display: flex; align-items: center; justify-content: center; }

/* ===== Tab Selector ===== */
.tab-bar {
  display: flex;
  justify-content: center;
  gap: 10px;
  padding: 16px 24px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 10px 22px;
  border-radius: 50px;
  font-family: var(--font-title);
  font-size: 1rem;
  background: #f0f4ff;
  border: 2px solid #e0e8ff;
  color: #555;
  transition: all .2s;
}
.tab-btn:hover { background: #e0e8ff; }
.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 4px 16px rgba(255,107,107,.4);
}

/* ===== Shape Display ===== */
.shape-display {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 180px;
  margin: 16px 0;
}

.shape-svg {
  animation: floatEmoji 2.5s ease-in-out infinite;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,.15));
}

/* Color card */
.color-card {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  overflow: hidden;
  cursor: pointer;
  transition: transform .25s cubic-bezier(.34,1.56,.64,1);
}
.color-card:hover { transform: translateY(-8px) scale(1.04); }
.color-swatch-big {
  height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3.5rem;
}
.color-name {
  background: #fff;
  text-align: center;
  padding: 14px;
  font-family: var(--font-title);
  font-size: 1.3rem;
}
