/* ===== Andy's Little Learning World - Main Styles ===== */
:root {
  --bg: #FFF8F0;
  --bg-card: #FFFFFF;
  --text: #2D3436;
  --text-soft: #636E72;
  --primary: #FF9F43;
  --primary-dark: #E67E22;
  --success: #00B894;
  --warning: #FDCB6E;
  --radius: 20px;
  --shadow: 0 8px 24px rgba(0,0,0,0.08);
  --shadow-soft: 0 4px 12px rgba(0,0,0,0.06);
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.4;
  touch-action: manipulation;
}

body {
  display: flex;
  flex-direction: column;
  max-width: 100vw;
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
  position: absolute;
  inset: 0;
  background: var(--bg);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

.screen.active {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Splash */
#splash {
  justify-content: center;
  align-items: center;
  background: linear-gradient(160deg, #FFEAA7 0%, #FF9F43 50%, #FF6B6B 100%);
}

.splash-content {
  text-align: center;
  color: white;
  padding: 2rem;
}

.logo-circle {
  width: 120px;
  height: 120px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1.5rem;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  animation: bounce 1.5s ease infinite;
}

.logo-emoji {
  font-size: 4rem;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.app-title {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 0.5rem;
  text-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.tagline {
  font-size: 1.1rem;
  opacity: 0.95;
  margin-bottom: 2rem;
}

.loading-bar {
  width: 180px;
  height: 8px;
  background: rgba(255,255,255,0.3);
  border-radius: 4px;
  margin: 0 auto;
  overflow: hidden;
}

.loading-fill {
  height: 100%;
  width: 0%;
  background: white;
  border-radius: 4px;
  animation: load 1.8s ease forwards;
}

@keyframes load {
  to { width: 100%; }
}

/* Home */
.home-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem 0.5rem;
}

.greeting {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.pip-avatar {
  font-size: 2.5rem;
  background: white;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-soft);
}

.greeting h2 {
  font-size: 1.35rem;
  font-weight: 700;
}

.greeting p {
  font-size: 0.9rem;
  color: var(--text-soft);
}

.btn-parent {
  background: white;
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 1.4rem;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.worlds-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  padding: 0.75rem 1.25rem;
  flex: 1;
  overflow-y: auto;
  align-content: start;
}

.world-card {
  background: var(--bg-card);
  border: none;
  border-radius: var(--radius);
  padding: 1.1rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  position: relative;
  overflow: hidden;
  min-height: 110px;
}

.world-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: var(--card-color);
}

.world-card:active {
  transform: scale(0.97);
}

.world-icon {
  font-size: 2.2rem;
}

.world-name {
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
  color: var(--text);
}

.world-progress {
  font-size: 0.75rem;
  color: var(--text-soft);
  background: #F0F0F0;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

.today-section, .moral-section {
  padding: 0 1.25rem 1rem;
}

.today-section h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-soft);
}

.today-card {
  background: white;
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.today-label {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.today-meta {
  font-size: 0.85rem;
  color: var(--text-soft);
}

.moral-card {
  width: 100%;
  background: linear-gradient(135deg, #A29BFE, #6C5CE7);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  text-align: left;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.moral-icon {
  font-size: 2rem;
}

.moral-card strong {
  display: block;
  font-size: 1.05rem;
}

.moral-card p {
  font-size: 0.85rem;
  opacity: 0.9;
}

/* Common headers */
.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  background: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  z-index: 10;
}

.screen-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  flex: 1;
  text-align: center;
}

.btn-back {
  background: #F0F0F0;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon {
  background: #F0F0F0;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
}

.header-spacer {
  width: 40px;
}

/* Area Hub */
.area-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.week-block {
  margin-bottom: 1.5rem;
}

.week-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 0.6rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.lesson-card {
  background: white;
  border-radius: 16px;
  padding: 1rem;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  border-left: 5px solid var(--primary);
}

.lesson-card.completed {
  border-left-color: var(--success);
  opacity: 0.85;
}

.lesson-card.locked {
  opacity: 0.5;
  pointer-events: none;
}

.lesson-num {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.lesson-card.completed .lesson-num {
  background: var(--success);
}

.lesson-info {
  flex: 1;
}

.lesson-info strong {
  display: block;
  font-size: 1rem;
}

.lesson-info span {
  font-size: 0.8rem;
  color: var(--text-soft);
}

.lesson-status {
  font-size: 1.2rem;
}

/* Lesson Player */
.lesson-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
}

.lesson-step {
  display: none;
}

.lesson-step.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.step-intro {
  text-align: center;
  padding: 1rem 0;
}

.step-intro .big-emoji {
  font-size: 4rem;
  margin-bottom: 1rem;
}

.step-intro h3 {
  font-size: 1.4rem;
  margin-bottom: 0.5rem;
}

.step-intro p {
  color: var(--text-soft);
  font-size: 1.05rem;
  max-width: 320px;
  margin: 0 auto;
}

.teach-box {
  background: white;
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow-soft);
  margin-bottom: 1rem;
}

.teach-box h4 {
  font-size: 1.1rem;
  margin-bottom: 0.75rem;
  color: var(--primary-dark);
}

.teach-visual {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 1rem 0;
}

.sound-card, .number-card, .object-card {
  background: #FFF5EB;
  border: 3px solid var(--primary);
  border-radius: 16px;
  padding: 1rem;
  min-width: 80px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
}

.sound-card:active, .number-card:active {
  transform: scale(0.95);
}

.sound-card .letter {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.sound-card .sound {
  font-size: 1rem;
  color: var(--text-soft);
  margin-top: 0.25rem;
}

.pip-speak {
  background: #E8F5E9;
  border-radius: 16px;
  padding: 1rem;
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  margin: 1rem 0;
}

.pip-speak .pip-mini {
  font-size: 1.8rem;
  flex-shrink: 0;
}

.lesson-nav {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1.25rem 1.25rem;
  background: white;
  box-shadow: 0 -2px 10px rgba(0,0,0,0.04);
}

.btn-nav {
  flex: 1;
  padding: 0.9rem;
  border: none;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  background: #F0F0F0;
  color: var(--text);
}

.btn-nav.primary {
  background: var(--primary);
  color: white;
}

.btn-nav:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Pip Overlay */
.pip-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 1.5rem;
  padding-bottom: max(1.5rem, var(--safe-bottom));
}

.pip-overlay.hidden {
  display: none;
}

.pip-bubble {
  background: white;
  border-radius: 24px;
  padding: 1.25rem 1.5rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.2);
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { transform: translateY(40px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.pip-face {
  font-size: 2.5rem;
  display: block;
  text-align: center;
  margin-bottom: 0.5rem;
}

#pip-text {
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.pip-controls {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.btn-small {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 600;
  background: #F0F0F0;
  cursor: pointer;
}

.btn-small:last-child {
  background: var(--primary);
  color: white;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #2D3436;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 30px;
  font-size: 0.95rem;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transition: opacity 0.3s;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
}

.toast.success {
  background: var(--success);
}

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

/* Landscape adjustments */
@media (orientation: landscape) and (max-height: 500px) {
  .worlds-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .logo-circle { width: 80px; height: 80px; }
  .logo-emoji { font-size: 2.5rem; }
  .app-title { font-size: 1.5rem; }
}

@media (min-width: 600px) {
  .worlds-grid {
    grid-template-columns: repeat(3, 1fr);
    max-width: 700px;
    margin: 0 auto;
  }
  .today-section, .moral-section {
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
  }
}
