/* ═══════════════════════════════════════════════════════════════════
   LESSONG — Styles (OpenDyslexic, child-friendly, mobile-first)
═══════════════════════════════════════════════════════════════════ */

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

:root {
  --purple: #7C3AED;
  --purple-light: #EDE9FE;
  --purple-mid: #DDD6FE;
  --yellow: #F59E0B;
  --yellow-light: #FEF3C7;
  --green: #10B981;
  --green-light: #D1FAE5;
  --orange: #F97316;
  --orange-light: #FFEDD5;
  --pink: #EC4899;
  --bg: #FFF9F0;
  --white: #FFFFFF;
  --text: #1E1B4B;
  --text-light: #6B7280;
  --radius: 20px;
  --shadow: 0 4px 20px rgba(124,58,237,0.12);
}

body {
  font-family: 'OpenDyslexic', 'Comic Sans MS', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 18px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ── Screens ─────────────────────────────────────────────────────── */
.screen { display: none; min-height: 100vh; flex-direction: column; }
.screen.active { display: flex; }

/* ── Home ────────────────────────────────────────────────────────── */
#screen-home {
  background: linear-gradient(160deg, #F5F3FF 0%, #FFF9F0 60%, #FEF3C7 100%);
  align-items: center;
  justify-content: center;
  padding: 2rem;
  text-align: center;
  position: relative;
}

.hero { max-width: 420px; width: 100%; }

.logo {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 4px;
  margin-bottom: 0.5rem;
  line-height: 1;
}
.logo-l  { color: #7C3AED; }
.logo-e  { color: #EC4899; }
.logo-s1 { color: #F59E0B; }
.logo-s2 { color: #10B981; }
.logo-o  { color: #F97316; }
.logo-n  { color: #3B82F6; }
.logo-g  { color: #8B5CF6; }

.tagline  { font-size: 1.3rem; color: var(--purple); font-weight: 700; margin-bottom: 0.5rem; }
.subtitle { font-size: 1.05rem; color: var(--text-light); margin-bottom: 2rem; }

.btn-hero {
  display: inline-flex; align-items: center; gap: 0.6rem;
  background: linear-gradient(135deg, var(--purple), #A855F7);
  color: white; border: none; border-radius: 50px;
  padding: 1rem 2.5rem; font-size: 1.2rem;
  font-family: inherit; cursor: pointer;
  box-shadow: 0 6px 24px rgba(124,58,237,0.35);
  transition: transform .15s, box-shadow .15s;
}
.btn-hero:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(124,58,237,0.4); }

.mascot {
  font-size: 5rem; margin-top: 2.5rem;
  animation: float 3s ease-in-out infinite;
}
@keyframes float {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-12px); }
}

/* ── Top Bar ─────────────────────────────────────────────────────── */
.top-bar {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.2rem; background: white;
  border-bottom: 2px solid var(--purple-light);
  position: sticky; top: 0; z-index: 10;
}

.btn-back {
  background: none; border: 2px solid var(--purple-mid);
  border-radius: 50px; padding: 0.4rem 1rem;
  font-family: inherit; font-size: 0.9rem;
  color: var(--purple); cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-back:hover { background: var(--purple-light); }

.steps {
  display: flex; align-items: center; gap: 0.3rem;
  overflow-x: auto; font-size: 0.8rem; flex: 1;
}
.step       { color: var(--text-light); white-space: nowrap; padding: 0.2rem 0.5rem; border-radius: 50px; }
.step.active{ background: var(--purple); color: white; font-weight: 700; }
.step.done  { background: var(--green); color: white; }
.step-dot   { color: var(--text-light); font-size: 1rem; }

/* ── Screen Content ──────────────────────────────────────────────── */
.screen-content {
  flex: 1; padding: 1.5rem 1.2rem 3rem;
  max-width: 540px; margin: 0 auto; width: 100%;
}
.screen-title { font-size: 1.5rem; font-weight: 800; margin-bottom: 0.4rem; color: var(--text); }
.screen-desc  { color: var(--text-light); margin-bottom: 1.5rem; font-size: 0.95rem; }

/* ── Upload Zone ─────────────────────────────────────────────────── */
.upload-zone {
  border: 3px dashed var(--purple-mid);
  border-radius: var(--radius);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: background .2s, border-color .2s;
  background: white;
  margin-bottom: 1.5rem;
}
.upload-zone:hover { background: var(--purple-light); border-color: var(--purple); }
.upload-icon { font-size: 3rem; margin-bottom: 0.8rem; }
.upload-zone p { color: var(--text-light); font-size: 0.95rem; line-height: 1.5; }

/* ── Preview Grid ────────────────────────────────────────────────── */
.preview-container { margin-bottom: 1.5rem; }

.preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 0.8rem;
  margin-bottom: 1rem;
}

.preview-thumb {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid var(--purple-mid);
  background: white;
  aspect-ratio: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.preview-thumb img { width: 100%; height: 100%; object-fit: cover; }

.thumb-pdf  { font-size: 2.5rem; }
.thumb-name { font-size: 0.65rem; color: var(--text-light); padding: 0.2rem; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 86px; }

.thumb-remove {
  position: absolute; top: 4px; right: 4px;
  background: rgba(0,0,0,0.55); color: white;
  border: none; border-radius: 50%;
  width: 22px; height: 22px;
  font-size: 0.7rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

.preview-actions { display: flex; gap: 0.8rem; flex-wrap: wrap; }

.btn-add {
  background: var(--purple-light); border: 2px solid var(--purple-mid);
  color: var(--purple); border-radius: 50px;
  padding: 0.5rem 1.2rem; font-family: inherit;
  font-size: 0.9rem; cursor: pointer;
  transition: background .15s;
}
.btn-add:hover { background: var(--purple-mid); }

.btn-change {
  background: #FEE2E2; border: 2px solid #FECACA;
  color: #EF4444; border-radius: 50px;
  padding: 0.5rem 1.2rem; font-family: inherit;
  font-size: 0.9rem; cursor: pointer;
}

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn-primary {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; background: linear-gradient(135deg, var(--purple), #A855F7);
  color: white; border: none; border-radius: 50px;
  padding: 1rem; font-size: 1.15rem; font-family: inherit;
  cursor: pointer; margin-top: 1rem;
  box-shadow: 0 4px 16px rgba(124,58,237,0.3);
  transition: transform .15s, box-shadow .15s;
}
.btn-primary:hover { transform: translateY(-2px); }

.btn-secondary {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem;
  width: 100%; background: white; color: var(--purple);
  border: 2px solid var(--purple-mid); border-radius: 50px;
  padding: 0.9rem; font-size: 1.05rem; font-family: inherit;
  cursor: pointer; margin-top: 1rem;
  transition: background .15s;
}
.btn-secondary:hover { background: var(--purple-light); }

.btn-icon { font-size: 1.2rem; }

/* ── Loader ──────────────────────────────────────────────────────── */
.loader {
  position: fixed; inset: 0;
  background: rgba(255,249,240,0.95);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 100; gap: 1rem;
}
.loader.hidden { display: none; }

.loader-owl { font-size: 4rem; animation: bounce 1s ease-in-out infinite; }
.loader-owl.big { font-size: 5rem; }
@keyframes bounce {
  0%,100% { transform: translateY(0); }
  50%      { transform: translateY(-16px); }
}

.loader-text { font-size: 1.3rem; font-weight: 700; color: var(--purple); }

.loader-dots { display: flex; gap: 0.5rem; }
.loader-dots span {
  width: 12px; height: 12px; background: var(--purple);
  border-radius: 50%; animation: dot-pulse 1.2s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.loader-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse {
  0%,80%,100% { transform: scale(0.6); opacity: 0.4; }
  40%         { transform: scale(1);   opacity: 1; }
}

.song-wait-hint { font-size: 0.9rem; color: var(--text-light); text-align: center; margin-top: 0.5rem; }

/* ── Summary / Result ────────────────────────────────────────────── */
.lesson-title {
  font-size: 1.7rem; font-weight: 900;
  color: var(--purple); margin-bottom: 1.2rem;
}

.summary-box {
  background: white; border-radius: var(--radius);
  padding: 1.2rem; box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.summary-header {
  display: flex; align-items: center; gap: 0.6rem;
  font-weight: 700; font-size: 1rem; color: var(--purple);
  margin-bottom: 0.8rem;
}
.summary-icon { font-size: 1.4rem; }
.summary-text { font-size: 1.05rem; line-height: 1.8; color: var(--text); }

.keypoints-title { font-size: 1.1rem; font-weight: 800; color: var(--text); margin-bottom: 0.8rem; }

.keypoint {
  display: flex; align-items: center; gap: 0.8rem;
  background: white; border-radius: 14px;
  padding: 0.8rem 1rem; margin-bottom: 0.6rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.keypoint-num {
  min-width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--purple), #A855F7);
  color: white; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem;
}
.keypoint span { font-size: 0.95rem; }

.result-actions { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 1.5rem; }

/* ── Listen ──────────────────────────────────────────────────────── */
.listen-card {
  background: white; border-radius: var(--radius);
  padding: 1.3rem; box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.listen-title { font-size: 1.2rem; font-weight: 800; color: var(--purple); margin-bottom: 0.8rem; }
.listen-text  { font-size: 1.05rem; line-height: 2; }

.word { display: inline; border-radius: 4px; transition: background .1s; }
.word.highlight { background: var(--yellow-light); color: var(--text); }

.tts-controls {
  display: flex; align-items: center; gap: 1rem;
  flex-wrap: wrap; margin-bottom: 1.5rem;
}
.btn-tts {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--green); color: white;
  border: none; border-radius: 50px;
  padding: 0.7rem 1.5rem; font-family: inherit;
  font-size: 1rem; cursor: pointer;
  box-shadow: 0 4px 14px rgba(16,185,129,0.3);
  transition: transform .15s;
}
.btn-tts:hover { transform: scale(1.04); }
.tts-icon { font-size: 1.2rem; }

.speed-control {
  display: flex; align-items: center; gap: 0.5rem;
  font-size: 0.9rem; color: var(--text-light);
}
.speed-control input { width: 100px; accent-color: var(--purple); }

.keypoints-listen { margin-bottom: 1.5rem; }

/* ── Song ────────────────────────────────────────────────────────── */
.song-preview-box {
  background: linear-gradient(135deg, #F5F3FF, #FEF3C7);
  border-radius: var(--radius); padding: 2rem;
  text-align: center; margin-bottom: 1.5rem;
}
.song-notes { font-size: 2.5rem; margin-bottom: 0.8rem; animation: float 2.5s ease-in-out infinite; }
.song-preview-box p { color: var(--text-light); font-size: 1rem; }

.btn-song { background: linear-gradient(135deg, var(--yellow), var(--orange)); }

.lyrics-box {
  background: white; border-radius: var(--radius);
  padding: 1.3rem; box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}
.lyrics-box h3 { font-size: 1.1rem; color: var(--purple); margin-bottom: 0.8rem; }
.lyrics-text { white-space: pre-line; font-size: 0.95rem; line-height: 2; color: var(--text); }

.player-card {
  background: white; border-radius: var(--radius);
  padding: 1.5rem; box-shadow: var(--shadow);
  text-align: center;
}
.player-art {
  font-size: 5rem; margin-bottom: 0.8rem;
  animation: float 3s ease-in-out infinite;
}
.player-art img { width: 140px; height: 140px; border-radius: 16px; object-fit: cover; }
.player-title  { font-size: 1.2rem; font-weight: 800; color: var(--purple); margin-bottom: 1rem; }
.audio-player  { width: 100%; margin-bottom: 1rem; border-radius: 8px; }

.unavailable-box {
  background: #FFF7ED; border: 2px solid #FED7AA;
  border-radius: var(--radius); padding: 2rem;
  text-align: center;
}
.unavailable-icon { font-size: 3rem; margin-bottom: 0.8rem; }
.unavailable-box h3 { color: var(--orange); margin-bottom: 0.6rem; }
.unavailable-box p  { color: var(--text-light); font-size: 0.95rem; }

/* ── Toast ───────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%);
  background: var(--text); color: white;
  border-radius: 50px; padding: 0.8rem 1.5rem;
  font-size: 0.95rem; z-index: 200;
  box-shadow: 0 4px 20px rgba(0,0,0,0.2);
  max-width: 90vw; text-align: center;
}
.toast.error { background: #EF4444; }
.toast.hidden { display: none; }

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

@media (max-width: 380px) {
  .logo { font-size: 2.8rem; }
  .screen-title { font-size: 1.3rem; }
  body { font-size: 16px; }
}

/* ── Text Input Zone ─────────────────────────────────────────────── */
.or-divider {
  text-align: center; position: relative; margin: 1.2rem 0;
}
.or-divider::before {
  content: ''; position: absolute; top: 50%; left: 0; right: 0;
  height: 2px; background: var(--purple-mid);
}
.or-divider span {
  position: relative; background: var(--bg); padding: 0 1rem;
  color: var(--text-light); font-size: 0.9rem; font-weight: 700;
}

.lesson-textarea {
  width: 100%; padding: 1rem 1.1rem;
  border: 2px solid var(--purple-mid);
  border-radius: var(--radius);
  font-family: inherit; font-size: 1rem; line-height: 1.6;
  resize: vertical; background: white; color: var(--text);
  transition: border-color .2s, box-shadow .2s;
  min-height: 120px;
}
.lesson-textarea:focus {
  outline: none; border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.12);
}
.lesson-textarea::placeholder { color: #C4B5FD; }

/* ── Cache badge ─────────────────────────────────────────────────── */
.cached-badge {
  background: var(--green-light);
  color: var(--green);
  border-radius: 50px;
  padding: 0.4rem 1rem;
  font-size: 0.85rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 0.8rem;
}

/* ── Lang toggle ─────────────────────────────────────────────────── */
.lang-toggle {
  display: flex; gap: 0.4rem;
}
.btn-lang {
  background: white; border: 2px solid var(--purple-mid);
  border-radius: 50px; padding: 0.4rem 0.8rem;
  font-family: inherit; font-size: 0.85rem;
  color: var(--text-light); cursor: pointer;
  transition: all .15s;
}
.btn-lang.active {
  background: var(--purple); border-color: var(--purple);
  color: white; font-weight: 700;
}
