/* ============================================================
   Toy Story Phonics — Classroom flashcards
   Designed for projector display + young learners
   ============================================================ */

:root {
  /* Phoneme colors — research-backed, friendly but distinct */
  --c-consonant: #2563eb;   /* Blue */
  --c-vowel:     #dc2626;   /* Red */
  --c-digraph:   #16a34a;   /* Green */
  --c-blend:     #9333ea;   /* Purple */
  --c-silent:    #94a3b8;   /* Gray */

  /* UI palette — warm, calm */
  --bg:          #fef9f3;
  --bg-card:     #ffffff;
  --ink:         #1f2937;
  --ink-soft:    #6b7280;
  --accent:      #f59e0b;
  --accent-soft: #fef3c7;
  --border:      #e5e7eb;

  --r-card: 24px;
  --r-btn:  14px;

  --shadow-soft: 0 4px 20px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 8px 40px rgba(0, 0, 0, 0.06);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}

body { display: flex; flex-direction: column; }

/* ============== TOP BAR ============== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  z-index: 10;
  flex-shrink: 0;
}

.brand .badge {
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  background: var(--accent-soft);
  color: #92400e;
  border-radius: 999px;
  letter-spacing: 0.3px;
}

.modes {
  display: flex;
  gap: 6px;
}

.mode-btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--r-btn);
  color: var(--ink-soft);
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn:hover { background: var(--bg-card); }
.mode-btn.active {
  background: var(--ink);
  color: white;
}

.tools { display: flex; gap: 8px; align-items: center; }
.link-btn {
  font-size: 13px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--r-btn);
  border: 1px solid var(--border);
}
.link-btn:hover { background: var(--bg-card); }

#fullscreenBtn {
  font-size: 18px;
  width: 36px; height: 36px;
  border: 1px solid var(--border);
  background: white;
  border-radius: var(--r-btn);
  cursor: pointer;
}
#fullscreenBtn:hover { background: var(--accent-soft); }

/* Fullscreen mode hides UI chrome */
body:fullscreen .topbar { display: none; }
body:fullscreen .progress { opacity: 0.4; }

/* ============== STAGE ============== */
.stage {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.card {
  background: var(--bg-card);
  border-radius: var(--r-card);
  padding: 60px 80px;
  width: 100%;
  max-width: 1100px;
  min-height: 60vh;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  text-align: center;
}

/* ============== WORD DISPLAY ============== */
.word-big {
  font-size: clamp(96px, 18vw, 240px);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
  font-feature-settings: "ss01" on;
}

.word-big span { display: inline-block; }
.word-big .c-c { color: var(--c-consonant); }
.word-big .c-v { color: var(--c-vowel); }
.word-big .c-d { color: var(--c-digraph); }
.word-big .c-b { color: var(--c-blend); }
.word-big .c-silent { color: var(--c-silent); }

.character-tag {
  font-size: 16px;
  font-weight: 600;
  padding: 8px 18px;
  background: var(--accent-soft);
  color: #92400e;
  border-radius: 999px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.scene {
  font-size: clamp(20px, 2.4vw, 28px);
  font-style: italic;
  color: var(--ink-soft);
  max-width: 800px;
  line-height: 1.4;
}

.scene-light {
  font-size: 18px;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 12px;
}

/* ============== LEGEND ============== */
.legend {
  display: flex;
  gap: 18px;
  font-size: 14px;
  color: var(--ink-soft);
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 8px;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.swatch {
  width: 14px; height: 14px; border-radius: 4px;
  display: inline-block;
}
.swatch.c-consonant { background: var(--c-consonant); }
.swatch.c-vowel { background: var(--c-vowel); }
.swatch.c-digraph { background: var(--c-digraph); }
.swatch.c-blend { background: var(--c-blend); }
.swatch.c-silent { background: var(--c-silent); }

/* ============== SOUND-OUT MODE ============== */
.prompt-small {
  font-size: 22px;
  font-weight: 600;
  color: var(--ink);
}

.phoneme-row {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.phoneme-box {
  font-family: inherit;
  width: clamp(100px, 12vw, 160px);
  height: clamp(120px, 14vw, 180px);
  border-radius: 20px;
  border: 4px solid;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-weight: 800;
  font-size: clamp(56px, 8vw, 96px);
  line-height: 1;
}

.phoneme-box.c-c { border-color: var(--c-consonant); color: var(--c-consonant); }
.phoneme-box.c-v { border-color: var(--c-vowel); color: var(--c-vowel); }
.phoneme-box.c-d { border-color: var(--c-digraph); color: var(--c-digraph); }
.phoneme-box.c-b { border-color: var(--c-blend); color: var(--c-blend); }
.phoneme-box.c-silent { border-color: var(--c-silent); color: var(--c-silent); border-style: dashed; }

.phoneme-box:hover { transform: translateY(-4px); }
.phoneme-box.active {
  transform: scale(1.1) translateY(-6px);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.15);
}

.celebration {
  font-size: 80px;
  animation: pop 0.6s ease-out;
}
@keyframes pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* ============== FAMILY MODE ============== */
.family-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  width: 100%;
  max-width: 600px;
}

.family-btn {
  font-family: inherit;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 700;
  padding: 24px;
  border: 3px solid var(--border);
  background: white;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--ink);
}
.family-btn:hover { border-color: var(--accent); transform: translateY(-2px); }
.family-btn.correct {
  border-color: #16a34a;
  background: #dcfce7;
  color: #15803d;
}
.family-btn.wrong {
  border-color: #dc2626;
  background: #fee2e2;
  color: #b91c1c;
  animation: shake 0.3s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-8px); }
  75% { transform: translateX(8px); }
}

.feedback {
  font-size: 22px;
  font-weight: 600;
  min-height: 30px;
}
.feedback .ok { color: #15803d; }
.feedback .no { color: #b91c1c; }

/* ============== MAGIC-E MODE ============== */
.magic-word .ml {
  display: inline-block;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.magic-word .v {
  color: var(--c-vowel);
}
.magic-word .magic {
  color: var(--accent);
  animation: sparkle 1.2s ease-in-out;
  transform-origin: center;
}
@keyframes sparkle {
  0% { transform: scale(0) rotate(-180deg); opacity: 0; }
  60% { transform: scale(1.3) rotate(20deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.sound-label {
  font-size: 22px;
  color: var(--ink-soft);
}
.sound-label strong { color: var(--ink); }

.rule-hint {
  font-size: 16px;
  color: var(--ink-soft);
  font-style: italic;
  margin-top: 8px;
}

.big-action {
  font-family: inherit;
  font-size: 20px;
  font-weight: 600;
  padding: 16px 32px;
  background: var(--ink);
  color: white;
  border: none;
  border-radius: var(--r-btn);
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow-soft);
}
.big-action:hover { transform: translateY(-2px); background: #111; }
.big-action.wand {
  background: var(--accent);
  color: white;
}
.big-action.wand:hover { background: #d97706; }

/* ============== NAVIGATION ============== */
.nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: white;
  border: 1px solid var(--border);
  font-size: 28px;
  cursor: pointer;
  box-shadow: var(--shadow-soft);
  color: var(--ink-soft);
  transition: all 0.15s;
  font-family: inherit;
}
.nav:hover { color: var(--ink); transform: translateY(-50%) scale(1.05); }
.nav.prev { left: 24px; }
.nav.next { right: 24px; }

/* ============== PROGRESS ============== */
.progress {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-soft);
}

.dots {
  display: flex;
  gap: 4px;
  max-width: 600px;
  flex-wrap: wrap;
  justify-content: center;
}
.dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--border);
}
.dot.active {
  background: var(--accent);
  width: 18px;
  border-radius: 3px;
}

/* ============== HINT ============== */
.hint {
  position: absolute;
  bottom: 16px;
  right: 16px;
  font-size: 12px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  transition: opacity 0.6s;
}
.hint.hidden { opacity: 0; pointer-events: none; }
.hint kbd {
  font-family: monospace;
  background: var(--bg);
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid var(--border);
  font-size: 11px;
}

/* ============== RESPONSIVE ============== */
@media (max-width: 768px) {
  .card { padding: 32px 24px; min-height: 70vh; }
  .topbar { flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .modes { order: 3; width: 100%; overflow-x: auto; }
  .nav { width: 44px; height: 44px; font-size: 22px; }
  .nav.prev { left: 8px; }
  .nav.next { right: 8px; }
  .family-choices { grid-template-columns: 1fr; }
}
