/* ═══════════════════════════════════════════════════════
   Myra Language Teacher – Styles
   Theme: bubbly pink, toddler-friendly, large text
═══════════════════════════════════════════════════════ */

/* ── CSS Variables ─────────────────────────────────── */
:root {
  --pink:       #FF69B4;
  --pink-light: #FFB6C1;
  --pink-dark:  #FF1493;
  --purple:     #9B59B6;
  --purple-dark:#6C3483;
  --yellow:     #FFD700;
  --green:      #2ECC71;
  --red:        #E74C3C;
  --white:      #FFFFFF;
  --bg:         linear-gradient(135deg, #FFE4F0 0%, #E8D5FF 50%, #D5EEFF 100%);
  --card-bg:    rgba(255,255,255,0.85);
  --shadow:     0 8px 32px rgba(155,89,182,0.18);
  --radius:     24px;
  --font-main:  'Nunito', 'Fredoka One', sans-serif;
  --font-title: 'Fredoka One', 'Nunito', sans-serif;
}

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

html { font-size: 18px; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  font-family: var(--font-main);
  color: #3a1a4a;
  overflow-x: hidden;
}

/* ── Header ────────────────────────────────────────── */
header {
  background: linear-gradient(90deg, #FF69B4, #9B59B6);
  padding: 0.6rem 1.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1100px;
  margin: 0 auto;
}

header h1 {
  font-family: var(--font-title);
  font-size: 1.8rem;
  color: var(--white);
  text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
  letter-spacing: 1px;
}

.settings-btn, .back-btn {
  font-size: 1.6rem;
  text-decoration: none;
  color: var(--white);
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  width: 2.4rem;
  height: 2.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.settings-btn:hover, .back-btn:hover { background: rgba(255,255,255,0.38); }

/* ── Main layout ───────────────────────────────────── */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 1.5rem 1rem 2rem;
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
}

/* ── Dino column ───────────────────────────────────── */
.dino-col {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.dino-wrapper {
  position: relative;
  width: clamp(200px, 28vw, 380px);
}

#dino-svg {
  width: 100%;
  height: auto;
  filter: drop-shadow(4px 8px 12px rgba(255,105,180,0.4));
  animation: dino-idle 3s ease-in-out infinite;
  transform-origin: center bottom;
}

/* ── Dino animations ───────────────────────────────── */
@keyframes dino-idle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  30%       { transform: translateY(-8px) rotate(1deg); }
  70%       { transform: translateY(-4px) rotate(-1deg); }
}

@keyframes dino-celebrate {
  0%   { transform: translateY(0) scale(1) rotate(0deg); }
  20%  { transform: translateY(-25px) scale(1.08) rotate(-3deg); }
  40%  { transform: translateY(-10px) scale(1.05) rotate(3deg); }
  60%  { transform: translateY(-20px) scale(1.08) rotate(-2deg); }
  80%  { transform: translateY(-8px) scale(1.04) rotate(2deg); }
  100% { transform: translateY(0) scale(1) rotate(0deg); }
}

@keyframes dino-shake {
  0%, 100% { transform: translateX(0); }
  15%       { transform: translateX(-12px) rotate(-4deg); }
  35%       { transform: translateX(12px)  rotate(4deg); }
  55%       { transform: translateX(-8px)  rotate(-2deg); }
  75%       { transform: translateX(8px)   rotate(2deg); }
}

@keyframes dino-talk {
  0%, 100% { transform: scaleY(1); }
  50%       { transform: scaleY(0.93); }
}

.dino-celebrate { animation: dino-celebrate 0.8s ease-in-out 2 !important; }
.dino-shake     { animation: dino-shake     0.6s ease-in-out !important; }
.dino-talk      { animation: dino-talk      0.3s ease-in-out infinite !important; }
.dino-ask       { animation: dino-ask       3s ease-in-out infinite !important; }

@keyframes dino-ask {
  0%, 100% { transform: scaleX(-1) translateY(0) rotate(0deg); }
  30%       { transform: scaleX(-1) translateY(-8px) rotate(-1deg); }
  70%       { transform: scaleX(-1) translateY(-4px) rotate(1deg); }
}

/* ── NEW: Head tilt (curious expression on first wrong) ── */
@keyframes dino-tilt {
  0%   { transform: rotate(0deg); }
  20%  { transform: rotate(8deg); }
  75%  { transform: rotate(8deg); }
  100% { transform: rotate(0deg); }
}
.dino-tilt { animation: dino-tilt 0.85s ease-in-out forwards !important; }

/* ── NEW: Tail wag during celebrate ── */
@keyframes tailwag {
  0%, 100% { transform: rotate(0deg); }
  30%      { transform: rotate(-14deg); }
  70%      { transform: rotate(14deg); }
}
#dino-svg.dino-celebrate #dino-tail {
  transform-box: fill-box;
  transform-origin: right bottom;
  animation: tailwag 0.45s ease-in-out 5;
}

/* ── NEW: Sparkle particles around dino ── */
.sparkle {
  position: absolute;
  font-size: 1.4rem;
  pointer-events: none;
  animation: sparkle-burst 0.75s ease-out forwards;
  z-index: 20;
  user-select: none;
}
@keyframes sparkle-burst {
  0%   { opacity: 1; transform: scale(0) translateY(0); }
  45%  { opacity: 1; transform: scale(1.4) translateY(-18px); }
  100% { opacity: 0; transform: scale(0.7) translateY(-42px); }
}

/* ── NEW: Streak display badge ── */
.streak-display {
  background: linear-gradient(135deg, #FF69B4, #FF1493);
  color: white;
  font-family: var(--font-title);
  font-size: 1.1rem;
  padding: 0.4rem 1.4rem;
  border-radius: 30px;
  box-shadow: 0 4px 12px rgba(255,20,147,0.35);
  letter-spacing: 0.5px;
  text-align: center;
}
.streak-display.streak-pop {
  animation: streak-bounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes streak-bounce {
  0%   { transform: scale(0.6); }
  100% { transform: scale(1); }
}

/* ── NEW: Star pop (+1 ⭐) ── */
.star-pop {
  position: fixed;
  font-family: var(--font-title);
  font-size: 1.5rem;
  color: var(--yellow);
  font-weight: 900;
  text-shadow: 0 2px 6px rgba(0,0,0,0.25);
  pointer-events: none;
  z-index: 1000;
  animation: star-float 1.1s ease-out forwards;
}
@keyframes star-float {
  0%   { opacity: 1; transform: translateY(0) scale(0.7); }
  35%  { opacity: 1; transform: translateY(-22px) scale(1.25); }
  100% { opacity: 0; transform: translateY(-65px) scale(0.9); }
}

/* ── Speech bubble ─────────────────────────────────── */
.speech-bubble {
  position: absolute;
  top: -10px;
  left: -10px;
  background: var(--white);
  border: 3px solid var(--pink);
  border-radius: 20px 20px 20px 4px;
  padding: 0.6rem 1rem;
  max-width: 200px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--purple-dark);
  box-shadow: 0 4px 12px rgba(255,105,180,0.25);
  z-index: 10;
  transition: opacity 0.3s;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -14px;
  left: 20px;
  border: 7px solid transparent;
  border-top-color: var(--pink);
}

/* ── Lesson column ─────────────────────────────────── */
.lesson-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  min-width: 300px;
  max-width: 500px;
}

/* ── Language badge ────────────────────────────────── */
.lang-badge {
  background: linear-gradient(135deg, var(--purple), var(--pink-dark));
  color: var(--white);
  font-family: var(--font-title);
  font-size: 1.1rem;
  padding: 0.4rem 1.5rem;
  border-radius: 30px;
  box-shadow: 0 4px 12px rgba(155,89,182,0.3);
  letter-spacing: 1px;
}

/* ── Word card ─────────────────────────────────────── */
.word-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 3px solid var(--pink-light);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  text-align: center;
  width: 100%;
  box-shadow: var(--shadow);
  transition: transform 0.3s, box-shadow 0.3s;
  animation: card-in 0.4s ease;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(20px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.word-card.correct-flash {
  border-color: var(--green);
  box-shadow: 0 0 0 6px rgba(46,204,113,0.25), var(--shadow);
}

.word-card.wrong-flash {
  border-color: var(--red);
  box-shadow: 0 0 0 6px rgba(231,76,60,0.2), var(--shadow);
}

.word-emoji {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 0.5rem;
}

.word-english {
  font-family: var(--font-title);
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  color: var(--purple-dark);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
}

.word-arrow {
  font-size: clamp(1.4rem, 2vw, 1.8rem);
  color: var(--pink);
  margin: 0.3rem 0;
}

.word-translation {
  font-family: var(--font-title);
  font-size: clamp(1.8rem, 3.2vw, 2.6rem);
  color: var(--pink-dark);
  margin-bottom: 0.4rem;
  line-height: 1.2;
}

.word-romanized {
  font-size: 1rem;
  color: #8a6a9a;
  font-style: italic;
  min-height: 1.4em;
}

/* ── Feedback banner ───────────────────────────────── */
.feedback-banner {
  width: 100%;
  text-align: center;
  padding: 0.8rem 1.5rem;
  border-radius: 16px;
  font-size: 1.2rem;
  font-weight: 900;
  letter-spacing: 0.5px;
  transition: opacity 0.3s;
}

.feedback-banner.correct {
  background: #d4f5e1;
  color: #1a8a45;
  border: 2px solid var(--green);
}

.feedback-banner.wrong {
  background: #fde8e8;
  color: #c0392b;
  border: 2px solid var(--red);
}

.feedback-banner.success {
  background: #d4f5e1;
  color: #1a8a45;
  border: 2px solid var(--green);
}

.feedback-banner.hidden { display: none; }

/* ── Attempt dots ──────────────────────────────────── */
.attempt-dots {
  display: flex;
  gap: 0.8rem;
}

.dot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ddd;
  border: 2px solid #bbb;
  transition: background 0.2s, border-color 0.2s;
}

.dot.used  { background: var(--red);   border-color: #a93226; }
.dot.right { background: var(--green); border-color: #1e8449; }

/* ── Buttons ───────────────────────────────────────── */
.btn-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-row.centered { justify-content: center; }

.btn {
  font-family: var(--font-title);
  font-size: 1.2rem;
  border: none;
  border-radius: 50px;
  padding: 0.75rem 1.8rem;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, filter 0.15s;
  box-shadow: 0 5px 15px rgba(0,0,0,0.12);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.btn:active { transform: scale(0.96); }

.btn-play {
  background: linear-gradient(135deg, #9B59B6, #6C3483);
  color: var(--white);
}
.btn-play:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(108,52,131,0.4); }

.btn-record {
  background: linear-gradient(135deg, var(--pink-dark), var(--pink));
  color: var(--white);
  font-size: 1.3rem;
  padding: 0.9rem 2.2rem;
}
.btn-record:hover { filter: brightness(1.08); transform: translateY(-2px); box-shadow: 0 8px 20px rgba(255,20,147,0.4); }

.btn-record.recording {
  background: linear-gradient(135deg, var(--red), #C0392B);
  animation: pulse-red 1s ease-in-out infinite;
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(231,76,60,0.5); }
  50%       { box-shadow: 0 0 0 12px rgba(231,76,60,0); }
}

.btn-skip {
  background: linear-gradient(135deg, #BDC3C7, #95A5A6);
  color: #2c3e50;
}
.btn-skip:hover { filter: brightness(1.08); transform: translateY(-2px); }

.btn-stop {
  background: linear-gradient(135deg, #7F8C8D, #5D6D7E);
  color: var(--white);
}
.btn-stop:hover { filter: brightness(1.08); transform: translateY(-2px); }

.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

/* ── Recording indicator ───────────────────────────── */
.recording-indicator {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 700;
  color: var(--red);
  font-size: 1rem;
  animation: fade-in 0.3s;
}

.recording-indicator.hidden { display: none; }

.rec-dot {
  width: 12px;
  height: 12px;
  background: var(--red);
  border-radius: 50%;
  animation: blink 0.8s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Score row ─────────────────────────────────────── */
.score-row {
  display: flex;
  gap: 2rem;
  font-size: 1rem;
  color: var(--purple-dark);
  font-weight: 700;
}

/* ── Confetti ──────────────────────────────────────── */
#confetti-container {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  opacity: 0.9;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 0.9; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ── Settings page ─────────────────────────────────── */
body.settings-page { background: var(--bg); }

.settings-main {
  max-width: 680px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.settings-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 2px solid var(--pink-light);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  box-shadow: var(--shadow);
}

.settings-card h2 {
  font-family: var(--font-title);
  font-size: 1.4rem;
  color: var(--purple-dark);
  margin: 1.2rem 0 0.5rem;
}

.settings-card h2:first-child { margin-top: 0; }

.hint {
  font-size: 0.9rem;
  color: #8a6a9a;
  margin-bottom: 0.6rem;
}

hr { border: none; border-top: 2px dashed var(--pink-light); margin: 1.4rem 0; }

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255,105,180,0.08);
  border: 2px solid var(--pink-light);
  border-radius: 12px;
  padding: 0.5rem 1rem;
  cursor: pointer;
  font-weight: 700;
  transition: background 0.2s, border-color 0.2s;
}

.checkbox-label:hover { background: rgba(255,105,180,0.18); }
.checkbox-label input[type=checkbox]:checked ~ * { color: var(--pink-dark); }

.checkbox-label input[type=checkbox] {
  width: 20px;
  height: 20px;
  accent-color: var(--pink-dark);
  cursor: pointer;
}

.lang-sample {
  font-size: 1.1rem;
  color: var(--pink-dark);
  margin-left: 0.3rem;
}

.option-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin: 0.8rem 0;
  flex-wrap: wrap;
}

.option-row label { font-weight: 700; color: var(--purple-dark); }

.option-row input[type=range] { flex: 1; min-width: 120px; accent-color: var(--pink-dark); }
.option-row input[type=checkbox] { width: 24px; height: 24px; accent-color: var(--pink-dark); cursor: pointer; }

.text-input, .select-input {
  width: 100%;
  padding: 0.65rem 1rem;
  border: 2px solid var(--pink-light);
  border-radius: 12px;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 700;
  color: var(--purple-dark);
  background: white;
  outline: none;
  transition: border-color 0.2s;
  margin-top: 0.3rem;
}

.text-input:focus, .select-input:focus { border-color: var(--pink-dark); }

/* ── Debug panel ───────────────────────────────────── */
.debug-panel {
  width: 100%;
  background: #1e1e2e;
  color: #cdd6f4;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  border-radius: 12px;
  padding: 0.7rem 1rem;
  line-height: 1.7;
  border: 1px solid #45475a;
}
.debug-panel div:empty { display: none; }
#debug-error { color: #f38ba8; }
#debug-sim   { color: #a6e3a1; }
#debug-heard { color: #89dceb; }

/* ── Utility ───────────────────────────────────────── */
.hidden { display: none !important; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 700px) {
  main {
    flex-direction: column;
    align-items: center;
    padding: 1rem;
    gap: 1rem;
  }

  .dino-wrapper { width: 220px; }

  .speech-bubble { font-size: 0.82rem; max-width: 160px; left: -5px; }

  .word-english     { font-size: 1.8rem; }
  .word-translation { font-size: 2rem; }
  .word-emoji       { font-size: 3rem; }

  .btn { font-size: 1rem; padding: 0.65rem 1.2rem; }

  .settings-card { padding: 1.2rem 1rem; }
}
