/* Life Academy — Story Studio (UX-hardened) */
:root {
  --ink: #1a2332;
  --muted: #5a6578;
  --paper: #fff9f0;
  --cream: #fffdf8;
  --teal: #0d9488;
  --teal-deep: #0f766e;
  --coral: #e85d4c;
  --gold: #f0b429;
  --line: #eadfce;
  --shadow: 0 20px 60px rgba(26, 35, 50, 0.12);
  --touch: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Nunito", system-ui, sans-serif;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    linear-gradient(180deg, rgba(255,249,240,0.82) 0%, rgba(255,249,240,0.88) 55%, rgba(255,249,240,0.94) 100%),
    var(--scene, none);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  min-height: 100vh;
  line-height: 1.45;
  padding-bottom: 7.5rem;
}

/* Themed educational scenes — set data-scene on <body> */
body[data-scene="farm"] { --scene: url("../backgrounds/bg-farm.jpg"); }
body[data-scene="city"] { --scene: url("../backgrounds/bg-city.jpg"); }
body[data-scene="forest"] { --scene: url("../backgrounds/bg-forest.jpg"); }
body[data-scene="library"] { --scene: url("../backgrounds/bg-library.jpg"); }
body[data-scene="beach"] { --scene: url("../backgrounds/bg-beach.jpg"); }

/* Fallback soft wash if no scene set */
body:not([data-scene]) {
  background-image:
    radial-gradient(ellipse 90% 60% at 0% 0%, #ccfbf1 0%, transparent 50%),
    radial-gradient(ellipse 70% 50% at 100% 10%, #fed7aa 0%, transparent 45%),
    linear-gradient(180deg, #fff9f0, #f0fdfa);
}

.studio-top {
  max-width: 980px;
  margin: 0 auto;
  padding: 0.75rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  justify-content: space-between;
}
.brand {
  font-family: "Fraunces", Georgia, serif;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}
.brand span { color: var(--teal); }
.meta {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  background: var(--cream);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
}
.back {
  color: var(--teal-deep);
  font-weight: 800;
  text-decoration: none;
  font-size: 0.9rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.mode-bar {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 1rem 0.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.mode-bar button {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: #fff;
  cursor: pointer;
}
.mode-bar button.on {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.mode-hint {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
  flex: 1 1 180px;
}

.book {
  max-width: 920px;
  margin: 0.5rem auto 1rem;
  padding: 0 1rem;
}

.slide {
  display: none;
  background: var(--cream);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  animation: rise 0.3s ease;
}
.slide.active { display: block; }
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hero-art {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
  background: #e8f5f3;
}
.hero-art.svg-wrap {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.hero-art.svg-wrap svg { width: 100%; height: 100%; max-height: 360px; }

.slide-body { padding: 1.2rem 1.25rem 1.4rem; }
.slide-kicker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 0.35rem;
}
.slide-body h2 {
  font-family: "Fraunces", Georgia, serif;
  font-size: clamp(1.35rem, 3.5vw, 1.85rem);
  line-height: 1.15;
  margin: 0 0 0.55rem;
}
.kid-line {
  font-size: clamp(1.2rem, 3.2vw, 1.5rem);
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 0.85rem;
}

.parent-box {
  background: #f0fdfa;
  border-left: 4px solid var(--teal);
  border-radius: 0 14px 14px 0;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  color: var(--muted);
}
.parent-box strong {
  color: var(--teal-deep);
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

body.kid-mode .parent-box,
body.kid-mode .do-row,
body.kid-mode .back,
body.kid-mode .mode-hint-parent,
body.kid-mode .howto {
  display: none !important;
}
body.kid-mode .slide-body h2 { font-size: clamp(1.5rem, 4vw, 2rem); }
body.kid-mode .kid-line { font-size: clamp(1.35rem, 4vw, 1.7rem); }

.word-stage {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
  margin: 1rem 0;
}
.pic-card {
  width: min(148px, 42vw);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  text-align: center;
  box-shadow: 0 8px 24px rgba(26,35,50,0.06);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.pic-card:active, .pic-card.speaking {
  transform: scale(0.97);
  box-shadow: 0 0 0 3px var(--gold);
}
.pic-card .tap-hint {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(15, 118, 110, 0.92);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
}
.pic-card img, .pic-card .svg-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: #fff7ed;
  pointer-events: none;
}
.pic-card .letter {
  font-family: "Fraunces", Georgia, serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--teal-deep);
  padding: 0.35rem 0 0;
}
.pic-card .word {
  font-weight: 800;
  font-size: 1.05rem;
  padding: 0 0.5rem 0.75rem;
}

.do-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.65rem;
  margin-top: 1rem;
}
.do-chip {
  background: #fff;
  border: 1px dashed var(--teal);
  border-radius: 14px;
  padding: 0.75rem;
  font-size: 0.92rem;
  font-weight: 700;
}
.do-chip em {
  display: block;
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--coral);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.25rem;
}

.eq-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fef3c7;
  color: #92400e;
  font-weight: 800;
  font-size: 0.75rem;
  padding: 0.3rem 0.7rem;
  border-radius: 999px;
  margin-bottom: 0.5rem;
}

.howto {
  max-width: 920px;
  margin: 0.5rem auto 0;
  padding: 0 1rem;
}
.howto details {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 14px;
  padding: 0.75rem 1rem;
}
.howto summary {
  font-weight: 800;
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.howto ol { margin: 0.5rem 0 0; padding-left: 1.2rem; font-weight: 700; color: var(--muted); }

.nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr 1.3fr 1.5fr;
  gap: 0.5rem;
  padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom));
  background: rgba(255, 253, 248, 0.97);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(8px);
  width: 100%;
  max-width: 920px;
  margin: 0 auto;
  box-sizing: border-box;
}
.nav .progress {
  grid-column: 1 / -1;
  text-align: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--muted);
}
.nav button {
  font-family: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  min-height: var(--touch);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  background: var(--teal);
  color: #fff;
}
.nav button:disabled { opacity: 0.35; cursor: not-allowed; }
.nav button.ghost {
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--ink);
}
.nav button.read {
  background: #f59e0b;
  color: #1a2332;
}
.dots { display: none; }

.ai-toast {
  position: fixed;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: #134e4a;
  color: #fff;
  font-weight: 800;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: 999px;
  z-index: 80;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.ai-toast.show { opacity: 1; }

@media (max-width: 600px) {
  .slide-body { padding: 1rem; }
  .nav { grid-template-columns: 1fr 1fr; }
  .nav button.read { grid-column: 1 / -1; }
}
