/* ==========================================
   MeaghanLingo - Minimalist Stylesheet
   Designed for 5-year-old emergent reader
   ========================================== */

:root {
  --theme-color: #0EA5E9;
  --ambient-color: #0369A1;
  --bg-gradient: linear-gradient(135deg, #E0F2FE 0%, #BAE6FD 100%);
  --card-bg: #FFFFFF;
  --card-shadow: 0 20px 60px rgba(0, 0, 0, 0.08), 0 8px 24px rgba(0, 0, 0, 0.04);
  --text-dark: #1E293B;
  --text-muted: #64748B;
  --radius-card: 48px;
  --radius-btn: 24px;
  --safe-top: env(safe-area-inset-top, 24px);
  --safe-bottom: env(safe-area-inset-bottom, 24px);
}

/* Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  position: fixed;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Fredoka", "Quicksand", "Segoe UI", Roboto, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-dark);
  transition: background 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: manipulation;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: var(--safe-top) 24px var(--safe-bottom) 24px;
}

/* ==========================================
   Child Card Viewport & Interactive Stage
   ========================================== */
.card-viewport {
  width: 100%;
  max-width: 580px;
  height: 75vh;
  max-height: 580px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Ambient Radial Glow */
.ambient-aura {
  position: absolute;
  width: 440px;
  height: 440px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--theme-color) 0%, transparent 70%);
  opacity: 0.18;
  filter: blur(40px);
  pointer-events: none;
  transition: all 0.6s ease;
  z-index: 1;
}

/* Voice Pulse Rings */
.voice-pulse-ring {
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  border: 4px solid var(--theme-color);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.3s ease, transform 0.15s ease-out;
}

.voice-pulse-ring.active {
  opacity: 0.55;
  animation: ringPulse 1.8s infinite ease-out;
}

.voice-pulse-ring.delay.active {
  animation: ringPulse 1.8s infinite ease-out 0.6s;
}

/* Main Card Frame */
.card-frame {
  width: 100%;
  height: 100%;
  background: var(--card-bg);
  border-radius: var(--radius-card);
  box-shadow: var(--card-shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
  border: 6px solid rgba(255, 255, 255, 0.9);
}

.card-frame:active,
.card-frame.card-pressed {
  transform: scale(0.96);
}

/* SVG Illustration Container */
.svg-container {
  width: 82%;
  height: 82%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.concept-svg {
  width: 100%;
  height: 100%;
  max-width: 380px;
  max-height: 380px;
  filter: drop-shadow(0 12px 20px rgba(0, 0, 0, 0.06));
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Listening State on Card */
.card-frame.state-listening {
  border-color: var(--theme-color);
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.12), 0 0 0 12px rgba(14, 165, 233, 0.15);
  animation: breatheGlow 2.2s infinite ease-in-out;
}

.card-frame.state-playing {
  border-color: #FBBF24;
}

/* Listening Mic Visual (Zero text) */
.mic-indicator {
  position: absolute;
  bottom: 28px;
  width: 58px;
  height: 58px;
  background: var(--theme-color);
  color: #FFFFFF;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.mic-indicator.active {
  opacity: 1;
  transform: scale(1);
}

/* Celebration Overlay */
.celebration-overlay {
  position: absolute;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  z-index: 20;
}

.celebration-overlay.active {
  opacity: 1;
}

.sparkle-particle {
  position: absolute;
  font-size: 3rem;
  opacity: 0;
}

.celebration-overlay.active .p1 { animation: popSparkle1 0.8s ease-out forwards; }
.celebration-overlay.active .p2 { animation: popSparkle2 0.8s ease-out forwards 0.05s; }
.celebration-overlay.active .p3 { animation: popSparkle3 0.8s ease-out forwards 0.1s; }
.celebration-overlay.active .p4 { animation: popSparkle4 0.8s ease-out forwards 0.15s; }
.celebration-overlay.active .p5 { animation: popSparkle5 0.8s ease-out forwards 0.2s; }

/* ==========================================
   Ambient Language Switcher Discs (Tactile)
   ========================================== */
.ambient-lang-switcher {
  position: fixed;
  bottom: calc(var(--safe-bottom) + 16px);
  display: flex;
  gap: 18px;
  z-index: 30;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  padding: 8px 14px;
  border-radius: 40px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  border: 1.5px solid rgba(255, 255, 255, 0.8);
}

.disc-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  background: #FFFFFF;
  color: var(--text-dark);
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.disc-btn:active {
  transform: scale(0.9);
}

.disc-btn.disc-en.active {
  background: #0EA5E9;
  color: #FFFFFF;
  transform: scale(1.12);
  box-shadow: 0 8px 20px rgba(14, 165, 233, 0.4);
}

.disc-btn.disc-zh.active {
  background: #E76F51;
  color: #FFFFFF;
  transform: scale(1.12);
  box-shadow: 0 8px 20px rgba(231, 111, 81, 0.4);
}

.disc-btn.disc-ms.active {
  background: #10B981;
  color: #FFFFFF;
  transform: scale(1.12);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

/* ==========================================
   Discreet Parent Gate & Trigger
   ========================================== */
.parent-gate-trigger {
  position: fixed;
  top: auto;
  left: 12px;
  bottom: calc(76px + var(--safe-bottom) + 10px);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 45;
  opacity: 0.4;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.parent-gate-trigger:hover,
.parent-gate-trigger:active {
  opacity: 0.9;
  transform: scale(1.08);
}

.parent-lock-icon {
  font-size: 1.15rem;
}

/* Parent Gate Math Modal */
.parent-gate-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.parent-gate-modal.visible {
  opacity: 1;
  pointer-events: auto;
}

.parent-gate-dialog {
  background: #FFFFFF;
  border-radius: 28px;
  padding: 32px;
  width: 90%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
}

.parent-gate-dialog h3 {
  font-size: 1.3rem;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.parent-gate-dialog p {
  font-size: 1.1rem;
  color: var(--text-muted);
  margin-bottom: 20px;
}

.parent-gate-dialog input {
  width: 100%;
  padding: 14px;
  font-size: 1.5rem;
  text-align: center;
  border: 2px solid #E2E8F0;
  border-radius: 16px;
  margin-bottom: 16px;
  outline: none;
  font-weight: 700;
}

.parent-gate-dialog input:focus {
  border-color: #0EA5E9;
}

.gate-buttons {
  display: flex;
  gap: 12px;
}

.gate-buttons button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 16px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary {
  background: #0EA5E9;
  color: #FFFFFF;
}

.btn-secondary {
  background: #F1F5F9;
  color: var(--text-dark);
}

.gate-error {
  color: #EF4444;
  font-size: 0.9rem;
  margin-top: 10px;
}

/* ==========================================
   Full Screen Parent Studio Drawer
   ========================================== */
.parent-drawer-panel {
  position: fixed;
  inset: 0;
  background: #F8FAFC;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.parent-drawer-panel.open {
  transform: translateY(0);
}

.parent-drawer-header {
  padding: calc(var(--safe-top) + 12px) 24px 16px 24px;
  background: #FFFFFF;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #E2E8F0;
}

.header-left h2 {
  font-size: 1.4rem;
  color: var(--text-dark);
}

.header-left p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.btn-close {
  background: #F1F5F9;
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 1.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
}

/* Drawer Language Tabs */
.drawer-lang-selector {
  display: flex;
  background: #FFFFFF;
  padding: 12px 24px;
  gap: 10px;
  border-bottom: 1px solid #E2E8F0;
  overflow-x: auto;
}

.lang-tab {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid #E2E8F0;
  background: #FFFFFF;
  border-radius: 16px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.lang-tab.active {
  background: #0EA5E9;
  color: #FFFFFF;
  border-color: #0EA5E9;
}

/* Drawer Nav */
.drawer-nav {
  display: flex;
  padding: 12px 24px;
  gap: 12px;
  overflow-x: auto;
}

.drawer-nav-btn {
  padding: 10px 18px;
  border: none;
  background: #E2E8F0;
  color: var(--text-dark);
  border-radius: 14px;
  font-weight: 600;
  cursor: pointer;
}

.drawer-nav-btn.active {
  background: #1E293B;
  color: #FFFFFF;
}

/* Drawer Content & Concepts Grid */
.drawer-content {
  flex: 1;
  padding: 16px 24px 48px 24px;
  max-width: 900px;
  width: 100%;
  margin: 0 auto;
}

.category-filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 14px;
  margin-bottom: 16px;
}

.cat-pill {
  padding: 8px 16px;
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.cat-pill.active {
  background: #0EA5E9;
  color: #FFFFFF;
  border-color: #0EA5E9;
}

.concepts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}

.concept-record-card {
  background: #FFFFFF;
  border-radius: 20px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  border: 2px solid #F1F5F9;
}

.concept-record-card.has-custom-voice {
  border-color: #FCD34D;
  background: #FFFBEB;
}

.concept-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-dark);
}

.concept-sub {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.badge-status {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 12px;
}

.badge-custom {
  background: #FEF3C7;
  color: #92400E;
}

.badge-synth {
  background: #F1F5F9;
  color: #475569;
}

.card-actions {
  display: flex;
  gap: 8px;
}

.btn-action {
  padding: 8px 14px;
  border: none;
  border-radius: 12px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-play {
  background: #E0F2FE;
  color: #0369A1;
  flex: 1;
}

.btn-record {
  background: #DCFCE7;
  color: #15803D;
  flex: 1.2;
}

.btn-record.recording {
  background: #FEE2E2;
  color: #DC2626;
  animation: pulseRecording 1.2s infinite;
}

.btn-delete {
  background: #FEE2E2;
  color: #DC2626;
  width: 36px;
}

/* Spaced Repetition Mastery View */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.progress-hero {
  background: #FFFFFF;
  padding: 24px;
  border-radius: 24px;
  text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.04);
}

.progress-ring-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
}

.stat-number {
  font-size: 3rem;
  font-weight: 800;
  color: #0EA5E9;
}

.stat-label {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.stat-card {
  background: #FFFFFF;
  padding: 18px;
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
}

.card-num {
  font-size: 2rem;
  font-weight: 700;
}

.card-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.color-mastered { color: #10B981; }
.color-practicing { color: #0EA5E9; }
.color-new { color: #8B5CF6; }
.color-help { color: #F59E0B; }

.srs-explanation-box {
  background: #F1F5F9;
  padding: 20px;
  border-radius: 20px;
}

.srs-explanation-box h4 {
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.srs-explanation-box p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.progress-actions {
  display: flex;
  justify-content: center;
  margin-top: 12px;
}

.btn-danger {
  background: #FEE2E2;
  color: #DC2626;
  border: none;
  padding: 12px 24px;
  border-radius: 16px;
  font-weight: 600;
  cursor: pointer;
}
