/*! Story Teacher · © 2026 P Om Shiva (M.Tech CSE, Pondicherry University). All rights reserved. Copying or reuse without written permission is not allowed. */
/* ==========================================================================
   Story Teacher: a storybook under an open sky.
   Baloo 2 (made by Ek Type in India) for headings, Atkinson Hyperlegible
   (designed for low-vision readers) for reading. Text colours meet WCAG AA:
   at least 4.5:1 on their backgrounds.
   ========================================================================== */
/* Fonts are served by the app itself (SIL Open Font License, see /fonts). */
@font-face { font-family: 'Baloo 2'; src: url('/fonts/baloo2-latin.woff') format('woff'); font-weight: 400 800; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('/fonts/atkinson-regular.woff') format('woff'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('/fonts/atkinson-bold.woff') format('woff'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Atkinson Hyperlegible'; src: url('/fonts/atkinson-italic.woff') format('woff'); font-weight: 400; font-style: italic; font-display: swap; }

:root {
  --sky: #eaf6ff;
  --sky-deep: #7ccfff;
  --paper: #ffffff;
  --page: #fffdf7; /* storybook page */
  --ink: #1b1640;
  --muted: #4a4668; /* 8.3:1 on white */
  --grape: #5b2ee5; /* white text 6.6:1 */
  --grape-deep: #3d1bb0;
  --grape-soft: #efeaff;
  --mango: #ffb020; /* ink text 9.6:1 */
  --mango-soft: #fff4d6;
  --melon: #ff5a7a; /* decoration only */
  --leaf: #0f7b53; /* 5.4:1 on white */
  --leaf-soft: #e3f7ee;
  --sea: #0a6e8a; /* 5.6:1 on white */
  --sea-soft: #e1f3f8;
  --danger: #b3261e;
  --danger-soft: #fdecea;
  --line: #d9d4f0;
  --field-border: #77739a; /* 4.5:1, field edges need 3:1 */
  --focus: #1a56db;
  --radius: 24px;
  --radius-sm: 14px;
  --lift: 0 2px 0 rgba(27, 22, 64, 0.08), 0 14px 34px rgba(61, 27, 176, 0.12);
  --display: 'Baloo 2', ui-rounded, 'Nunito', system-ui, sans-serif;
  --body: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

html.text-md { font-size: 100%; }
html.text-lg { font-size: 115%; }
html.text-xl { font-size: 130%; }

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

body {
  margin: 0;
  background: var(--sky);
  color: var(--ink);
  font-family: var(--body);
  font-size: 1.05rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }
[tabindex='-1']:focus { outline: none; }

h1, h2, h3 { font-family: var(--display); line-height: 1.12; margin: 0 0 0.5rem; font-weight: 800; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.2rem; font-weight: 700; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 60;
  background: var(--ink); color: #fff; padding: 0.6rem 1rem; border-radius: 10px;
}
.skip-link:focus { top: 1rem; }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(10px);
  border-bottom: 2px solid #dcefff;
}
.header-inner {
  max-width: 1080px; margin: 0 auto; padding: 0.55rem 1rem;
  display: flex; gap: 1rem; align-items: center; justify-content: space-between;
}
.brand { display: flex; gap: 0.55rem; align-items: center; text-decoration: none; color: var(--ink); }
.brand-mark {
  display: grid; place-items: center; width: 44px; height: 44px; border-radius: 14px;
  background: var(--mango); font-size: 1.45rem; transform: rotate(-6deg);
  box-shadow: 0 3px 0 #d98d00;
}
.brand-name { font-family: var(--display); font-weight: 800; font-size: 1.35rem; letter-spacing: -0.01em; }
.header-tools { display: flex; gap: 0.6rem; align-items: center; }
.narrator-pick { display: flex; padding: 3px; border-radius: 999px; background: var(--grape-soft); }
.narrator-label { align-self: center; padding: 0 0.5rem 0 0.7rem; font-weight: 700; color: var(--grape-deep); font-size: 0.95rem; }
.narrator-btn {
  min-height: 40px; padding: 0.2rem 0.8rem; border-radius: 999px; border: 0; cursor: pointer;
  background: transparent; color: var(--grape-deep); font: inherit; font-weight: 700; white-space: nowrap;
}
.narrator-btn[aria-pressed='true'] { background: var(--grape); color: #fff; box-shadow: 0 2px 6px rgba(61, 27, 176, 0.35); }
.star-pill, .stage-badge, .pill, .report-stars { font-family: var(--display); }
.star-pill {
  margin: 0; padding: 0.35rem 0.85rem; border-radius: 999px;
  background: var(--mango-soft); border: 2px solid var(--mango); font-weight: 700; white-space: nowrap;
}
.star-pill.bump { animation: bump 0.5s ease; }
@keyframes bump { 50% { transform: scale(1.2) rotate(-4deg); } }
.text-size { display: flex; gap: 0.25rem; }
.size-btn {
  min-width: 44px; min-height: 44px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--line); background: #fff; color: var(--ink); font-weight: 700; font-family: var(--body);
}
.size-btn[aria-pressed='true'] { background: var(--ink); border-color: var(--ink); color: #fff; }

main { max-width: 1080px; margin: 0 auto; padding: 1.25rem 1rem 3rem; }

/* ---------- Hero: the sky scene ---------- */
.hero {
  position: relative; overflow: hidden; isolation: isolate;
  border-radius: 36px;
  background: linear-gradient(180deg, var(--sky-deep) 0%, #b9e6ff 55%, #dff4ff 100%);
  padding: 3rem 1.5rem 4.5rem;
}
.sky { position: absolute; inset: 0; z-index: -1; pointer-events: none; }
.sun {
  position: absolute; right: -36px; top: -36px; width: 170px; height: 170px; border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, #ffe27a, var(--mango) 70%);
  box-shadow: 0 0 0 18px rgba(255, 210, 90, 0.25), 0 0 0 40px rgba(255, 210, 90, 0.12);
  animation: sunrise 1.2s cubic-bezier(0.2, 0.9, 0.3, 1) both;
}
@keyframes sunrise { from { transform: translateY(140px) scale(0.7); opacity: 0; } }
.cloud {
  position: absolute; height: 44px; border-radius: 999px; background: #fff; opacity: 0.95;
  animation: drift 38s linear infinite;
}
.cloud::before, .cloud::after { content: ''; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 56px; height: 56px; left: 18%; top: -26px; }
.cloud::after { width: 40px; height: 40px; left: 52%; top: -18px; }
.cloud-a { width: 150px; left: 6%; top: 16%; }
.cloud-b { width: 110px; left: 60%; top: 30%; opacity: 0.8; animation-duration: 52s; animation-delay: -20s; }
@keyframes drift { 50% { transform: translateX(60px); } }
.hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 150px; }
.hill-back { fill: #7fd39b; }
.hill-front { fill: #3fb46e; }

.hero-inner { position: relative; max-width: 780px; margin: 0 auto; text-align: center; }
.hero h1 {
  font-size: clamp(2.2rem, 5.4vw, 3.6rem); line-height: 1.02; letter-spacing: -0.02em;
  color: var(--ink); margin-bottom: 0.7rem;
}
.hero-sub { margin: 0 auto 1.8rem; max-width: 600px; font-size: 1.12rem; color: #232050; }

.search-card {
  position: relative;
  background: var(--paper); color: var(--ink); text-align: left;
  border-radius: 28px; padding: 1.4rem 1.4rem 1.25rem;
  box-shadow: 0 6px 0 #c9b8ff, 0 26px 60px rgba(30, 20, 100, 0.25);
}
.field { margin-bottom: 1rem; }
label { display: block; font-weight: 700; margin-bottom: 0.35rem; }
.optional { font-weight: 400; color: var(--muted); }
.search-box {
  display: flex; align-items: center; gap: 0.5rem;
  border: 2px solid var(--field-border); border-radius: 20px; padding: 0.3rem 0.3rem 0.3rem 0.9rem;
  background: #fff;
}
.search-box:focus-within { border-color: var(--grape); box-shadow: 0 0 0 4px var(--grape-soft); }
.search-icon { font-size: 1.2rem; }
.search-box input {
  flex: 1; min-width: 0; border: 0; outline: none; font: inherit; font-size: 1.2rem;
  padding: 0.55rem 0.2rem; background: transparent; color: var(--ink);
}
.search-box input::placeholder { color: #67638a; }
.search-box:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }

input[type='text'] {
  width: 100%; min-height: 50px; padding: 0.6rem 0.9rem; font: inherit; color: var(--ink);
  background: #fff; border: 2px solid var(--field-border); border-radius: 14px;
}
input[aria-invalid='true'], .search-box:has(input[aria-invalid='true']) { border-color: var(--danger); }

.field-row { display: grid; grid-template-columns: 1.3fr 1fr; gap: 0 1.25rem; }
.age-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; }
.stage-badge {
  background: var(--grape-soft); color: var(--grape-deep); border-radius: 999px;
  padding: 0.2rem 0.8rem; font-weight: 700; white-space: nowrap;
}
input[type='range'] { width: 100%; height: 44px; accent-color: var(--grape); cursor: pointer; }
.age-scale { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); margin-top: -0.4rem; }

.field-error { color: var(--danger); font-weight: 700; margin: 0.4rem 0 0; }
.field-error::before { content: '⚠ '; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 50px; padding: 0.6rem 1.35rem; border-radius: 999px;
  font: inherit; font-weight: 700; cursor: pointer; border: 2px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:active { transform: translateY(2px); }
.btn-primary { background: var(--grape); color: #fff; box-shadow: 0 4px 0 var(--grape-deep); }
.btn-primary:hover { background: #4f22d6; }
.btn-primary:active { box-shadow: 0 2px 0 var(--grape-deep); }
.btn-secondary { background: #fff; color: var(--grape-deep); border-color: var(--grape); }
.btn-secondary[aria-pressed='true'] { background: var(--grape-soft); }
.btn-secondary[aria-busy='true'] .btn-label::after { content: ' …'; }
.btn-ghost { background: transparent; color: var(--grape-deep); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--grape); }
.btn-big {
  width: 100%; min-height: 60px; font-family: var(--display); font-size: 1.4rem; font-weight: 800;
  background: var(--mango); color: var(--ink); box-shadow: 0 5px 0 #d98d00;
}
.btn-big:hover { background: #ffbc3d; }
.btn:disabled { opacity: 0.6; cursor: not-allowed; transform: none; }
.surprise-btn { min-height: 44px; padding: 0.4rem 0.9rem; white-space: nowrap; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 1.4rem; }

/* ---------- Explore ---------- */
.explore { margin-top: 2.5rem; }
.explore h2 { font-size: 1.8rem; margin-bottom: 0.1rem; }
.explore-sub { margin: 0 0 1rem; color: var(--muted); }
.category-grid {
  list-style: none; padding: 0; margin: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 1rem;
}
.cat-card {
  width: 100%; height: 100%; text-align: left; cursor: pointer;
  display: flex; gap: 0.85rem; align-items: center;
  padding: 0.9rem 1rem; border-radius: 22px; border: 0;
  font: inherit; color: var(--ink); background: #fff;
  box-shadow: 0 4px 0 var(--cat-edge, var(--line));
  transition: transform 0.15s ease;
}
.cat-card:hover { transform: translateY(-3px) rotate(-1deg); }
.cat-emoji {
  flex: none; display: grid; place-items: center; width: 58px; height: 58px;
  border-radius: 18px; background: var(--cat-bg, var(--grape-soft)); font-size: 2rem;
}
.cat-name { display: block; font-family: var(--display); font-weight: 800; font-size: 1.15rem; line-height: 1.15; }
.cat-sample { display: block; font-size: 0.9rem; color: var(--muted); }
.cat-1 { --cat-bg: #e9e3ff; --cat-edge: #b7a6ff; } .cat-2 { --cat-bg: #fff0cf; --cat-edge: #ffcf66; }
.cat-3 { --cat-bg: #ffe1e8; --cat-edge: #ff9db2; } .cat-4 { --cat-bg: #dcf1ff; --cat-edge: #8fd0ff; }
.cat-5 { --cat-bg: #ddf5e7; --cat-edge: #86d9a8; } .cat-6 { --cat-bg: #ede6ff; --cat-edge: #c2b0ff; }
.cat-7 { --cat-bg: #fde6d2; --cat-edge: #f7b98a; } .cat-8 { --cat-bg: #dcf3ee; --cat-edge: #7fd1c0; }

.how-it-works {
  list-style: none; padding: 0; margin: 2.25rem 0 0;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem;
}
.how-it-works li {
  background: rgba(255, 255, 255, 0.7); border-radius: 20px; padding: 0.9rem 1rem;
  display: flex; flex-direction: column; gap: 0.1rem; color: var(--muted); font-size: 0.95rem;
}
.how-it-works span { font-size: 1.7rem; }
.how-it-works strong { color: var(--ink); font-family: var(--display); font-size: 1.15rem; }

/* ---------- Status ---------- */
.status:not(:empty) {
  display: flex; align-items: center; gap: 0.9rem; margin: 1rem 0 0;
  padding: 1.1rem 1.25rem; background: var(--grape-soft);
  border-radius: 20px; font-weight: 700;
}
.status:not(:empty)::before { content: '📖'; font-size: 1.9rem; animation: flip 1.2s ease-in-out infinite; }
@keyframes flip { 50% { transform: rotateY(180deg) scale(1.1); } }
.error-box {
  margin: 1rem 0 0; padding: 1rem 1.25rem; background: var(--danger-soft); color: var(--danger);
  border-left: 6px solid var(--danger); border-radius: var(--radius-sm); font-weight: 700;
}

/* ---------- Journey stepper ---------- */
.journey {
  list-style: none; padding: 0; margin: 0 0 1.25rem;
  display: flex; gap: 0.4rem; overflow-x: auto;
}
.journey li {
  flex: 1 1 0; min-width: 92px; display: flex; align-items: center; gap: 0.45rem;
  padding: 0.45rem 0.75rem; border-radius: 999px; background: #fff;
  color: var(--muted); font-weight: 700; font-size: 0.95rem; box-shadow: 0 3px 0 var(--line);
}
.j-dot {
  display: grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 50%;
  background: var(--sky); font-size: 0.85rem; font-weight: 700;
}
.journey li.done { color: var(--leaf); box-shadow: 0 3px 0 #9fdcbf; }
.journey li.done .j-dot { background: var(--leaf); color: #fff; }
.journey li[aria-current='step'] { color: #fff; background: var(--grape); box-shadow: 0 3px 0 var(--grape-deep); }
.journey li[aria-current='step'] .j-dot { background: #fff; color: var(--grape); }
.journey li.skipped { opacity: 0.6; }

/* ---------- Cards / panels ---------- */
.card {
  background: var(--paper); border-radius: var(--radius);
  box-shadow: var(--lift); padding: 1.75rem;
}
.panel { animation: rise 0.35s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
.eyebrow { margin: 0 0 0.15rem; color: var(--grape); font-weight: 700; font-size: 0.95rem; }

/* ---------- Story: an open book ---------- */
.book {
  background: var(--paper); border-radius: 28px; box-shadow: var(--lift); padding: 1.75rem;
}
.story-head { display: flex; gap: 1.25rem; align-items: flex-start; justify-content: space-between; }
.story-head-text { flex: 1; min-width: 0; }
.topic-photo { margin: 0; flex: 0 0 250px; transform: rotate(2deg); }
.topic-photo img {
  display: block; width: 100%; height: 165px; object-fit: cover;
  border-radius: 6px; border: 8px solid #fff; border-bottom-width: 26px;
  box-shadow: 0 10px 24px rgba(27, 22, 64, 0.2); background: var(--grape-soft);
}
.topic-photo figcaption {
  font-size: 0.8rem; color: var(--muted); margin-top: -1.35rem; padding: 0 0.6rem;
  display: flex; flex-wrap: wrap; gap: 0.1rem 0.5rem; position: relative;
}
.topic-photo a { color: var(--grape-deep); font-weight: 700; }

.pill-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 0.6rem; }
.pill { padding: 0.2rem 0.85rem; border-radius: 999px; background: var(--grape); color: #fff; font-weight: 700; font-size: 0.9rem; }
.pill-soft { background: var(--grape-soft); color: var(--grape-deep); }
.story-title { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.05; letter-spacing: -0.015em; }
.fallback-note {
  background: var(--sea-soft); color: var(--sea); font-weight: 700;
  border-radius: 14px; padding: 0.6rem 0.9rem; margin: 0 0 0.6rem;
}
.parent-hint { background: var(--mango-soft); border: 2px dashed var(--mango); border-radius: 14px; padding: 0.6rem 0.9rem; }

/* The big "watch" button: the one loud thing on this screen */
.watch-cta {
  display: flex; align-items: center; gap: 1rem; width: 100%; margin: 1rem 0 1.25rem;
  padding: 0.85rem 1.1rem; border: 0; border-radius: 22px; cursor: pointer; text-align: left;
  font: inherit; color: #fff;
  background: linear-gradient(100deg, var(--grape) 0%, #8a3ff0 55%, var(--melon) 130%);
  box-shadow: 0 5px 0 var(--grape-deep);
  transition: transform 0.12s ease;
}
.watch-cta:hover { transform: translateY(-2px); }
.watch-cta:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--grape-deep); }
.watch-play {
  flex: none; position: relative; width: 58px; height: 58px; border-radius: 50%; background: var(--mango);
  box-shadow: 0 0 0 6px rgba(255, 255, 255, 0.25);
}
.watch-play::after {
  content: ''; position: absolute; left: 23px; top: 17px;
  border-left: 20px solid var(--ink); border-top: 12px solid transparent; border-bottom: 12px solid transparent;
}
.watch-text { display: flex; flex-direction: column; line-height: 1.25; }
.watch-text strong { font-family: var(--display); font-size: 1.45rem; font-weight: 800; }
.watch-text span { opacity: 0.95; }

.spread {
  display: grid; grid-template-columns: minmax(280px, 1.1fr) 1fr; gap: 0; align-items: stretch;
  border-radius: 22px; overflow: hidden; background: var(--page);
  box-shadow: inset 0 0 0 2px #f0e9d6, 0 10px 0 -4px #efe6cf, 0 18px 0 -8px #e6dbbd;
}
.page { margin: 0; padding: 1.4rem; min-height: 280px; }
.page-left {
  background: radial-gradient(circle at 25% 20%, #fff3c9 0, transparent 50%), linear-gradient(160deg, #ebe4ff, #d9f0ff);
  border-right: 2px solid #efe6cf;
  box-shadow: inset -18px 0 22px -18px rgba(27, 22, 64, 0.25);
}
.page-right { box-shadow: inset 18px 0 22px -18px rgba(27, 22, 64, 0.18); }

/* Scene board: the diagram for the part being read */
.board { display: flex; flex-direction: column; justify-content: center; gap: 0.8rem; }
.board-stage { display: flex; justify-content: center; }
.board-items { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 0.6rem; }
.board-items.group { display: grid; grid-template-columns: repeat(2, 1fr); }
.tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem;
  min-width: 88px; max-width: 128px; padding: 0.7rem 0.55rem; border-radius: 20px; background: #fff;
  box-shadow: 0 4px 0 rgba(91, 46, 229, 0.18); text-align: center;
  animation: pop 0.45s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.tile:nth-child(2) { animation-delay: 0.35s; }
.tile:nth-child(3) { animation-delay: 0.7s; }
.tile:nth-child(4) { animation-delay: 1.05s; }
@keyframes pop { from { opacity: 0; transform: scale(0.6) translateY(10px); } }
.tile-emoji { font-size: 2.6rem; line-height: 1.1; }
.tile-label { font-family: var(--display); font-weight: 700; font-size: 1rem; line-height: 1.15; }
.board-items.flow { flex-wrap: nowrap; }
.board-items.flow .tile:not(:last-child) { margin-right: 1.4rem; }
.board-items.flow .tile:not(:last-child)::after {
  content: '➜'; position: absolute; right: -1.3rem; top: 50%; transform: translateY(-50%);
  font-size: 1.3rem; color: var(--grape);
}
.board-items.compare .tile:first-child { margin-right: 2.4rem; }
.board-items.compare .tile:first-child::after {
  content: 'vs'; position: absolute; right: -2.1rem; top: 50%; transform: translateY(-50%);
  font-weight: 700; color: var(--grape); background: #fff; border-radius: 999px; padding: 0.1rem 0.45rem;
}
.board-photo { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; width: 100%; }
.board-photo img {
  width: 100%; max-width: 420px; max-height: 240px; object-fit: contain;
  border-radius: 16px; background: #fff; border: 6px solid #fff; box-shadow: 0 8px 22px rgba(27, 22, 64, 0.15);
}
#visual .board-photo { margin-bottom: 1.25rem; }
#visual .board-photo img { max-width: 560px; max-height: 320px; }
.board-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 0.45rem; }
.board-chips li { background: #fff; color: var(--grape-deep); font-weight: 700; border-radius: 999px; padding: 0.3rem 0.85rem; }
.board-emoji { font-size: 4rem; letter-spacing: 0.4rem; text-align: center; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px); } }
.board-caption { text-align: center; font-weight: 700; color: var(--grape-deep); }

.part-progress { display: flex; gap: 0.4rem; margin: 0 0 0.75rem; }
.pdot { width: 40px; height: 8px; border-radius: 99px; background: #ece4cf; transition: background 0.3s; }
.pdot.on { background: var(--mango); }
.part-heading { color: var(--sea); font-size: 1.1rem; }
.story-text { font-size: 1.3rem; line-height: 1.8; white-space: pre-line; margin: 0; max-width: 62ch; }
.story-text .w { border-radius: 6px; transition: background 0.15s; }
.story-text .w.on { background: var(--mango); }
body.young-reader .story-text { font-size: 1.55rem; line-height: 1.9; }

/* ---------- Picture ---------- */
.visual { margin: 1rem 0 1.25rem; }
.cycle-wrap { display: grid; grid-template-columns: minmax(260px, 420px) 1fr; gap: 1.5rem; align-items: center; }
.cycle-svg { width: 100%; height: auto; }
.cycle-svg .ring { fill: none; stroke: var(--grape-soft); stroke-width: 26; }
.cycle-svg .arc { fill: none; stroke: var(--grape); stroke-width: 3.5; stroke-dasharray: 8 6; animation: flow 1.6s linear infinite; }
@keyframes flow { to { stroke-dashoffset: -28; } }
.cycle-svg .arrowhead { fill: var(--grape); }
.cycle-svg .node { fill: #fff; stroke: var(--grape); stroke-width: 3; }
.cycle-svg .node-emoji { font-size: 26px; }
.cycle-svg .node-label { font: 700 11.5px var(--body); fill: var(--ink); }
.cycle-svg .node-num { font: 700 12px var(--body); fill: #fff; }
.cycle-svg .num-bg { fill: var(--grape); }
.cycle-svg .center-text { font: 800 16px var(--display); fill: var(--grape-deep); }

.step-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.75rem; }
.flow { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.flow li { position: relative; }
.v-item {
  height: 100%; background: var(--sky); border-radius: 20px;
  padding: 1rem; display: flex; flex-direction: column; gap: 0.25rem;
}
.v-emoji { font-size: 2.3rem; line-height: 1.1; }
.v-label { font-family: var(--display); font-weight: 700; font-size: 1.15rem; line-height: 1.15; }
.v-detail { color: var(--muted); font-size: 0.97rem; }
.v-num {
  align-self: flex-start; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
  background: var(--grape); color: #fff; font-weight: 700; font-size: 0.85rem;
}
.cycle-list .v-item { flex-direction: row; align-items: flex-start; gap: 0.75rem; padding: 0.7rem 0.9rem; }
.cycle-list .v-emoji { font-size: 1.6rem; }
.parts { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.parts .v-item { background: var(--grape-soft); }

.fun-fact {
  display: flex; gap: 1rem; align-items: flex-start; padding: 1rem 1.25rem; border-radius: 20px;
  background: var(--mango-soft);
}
.fun-fact h3 { margin-bottom: 0.15rem; }
.fun-fact p { margin: 0; }
.fun-fact-icon { font-size: 2rem; }

/* Real animations, videos and pictures from Wikipedia */
.media-box { margin-top: 1.75rem; }
.media-box h3 { font-size: 1.45rem; margin-bottom: 0.1rem; }
.media-sub { margin: 0 0 0.9rem; color: var(--muted); }
.media-moving { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.clip {
  margin: 0; background: var(--ink); color: #fff; border-radius: 20px; overflow: hidden;
  display: flex; flex-direction: column;
}
.clip-frame { position: relative; background: #000; display: grid; place-items: center; aspect-ratio: 16 / 10; }
.clip-frame img, .clip-frame video { width: 100%; height: 100%; object-fit: contain; display: block; }
.clip-badge {
  position: absolute; left: 10px; top: 10px; background: var(--mango); color: var(--ink);
  font-weight: 700; font-size: 0.8rem; border-radius: 999px; padding: 0.1rem 0.6rem;
}
.clip-reveal {
  min-height: 48px; padding: 0.5rem 1.1rem; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--mango); color: var(--ink); font: inherit; font-weight: 700;
}
.clip figcaption { padding: 0.65rem 0.9rem 0.8rem; font-size: 0.88rem; line-height: 1.4; }
.clip figcaption strong { display: block; font-family: var(--display); font-size: 1.05rem; }
.clip figcaption a, .media-pictures a { color: #ffd77a; font-weight: 700; }
.media-pictures {
  list-style: none; padding: 0; margin: 1rem 0 0; display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.media-pictures figure { margin: 0; background: #fff; border-radius: 16px; overflow: hidden; box-shadow: 0 3px 0 var(--line); }
.media-pictures img { width: 100%; height: 120px; object-fit: cover; display: block; background: var(--sky); }
.media-pictures figcaption { padding: 0.4rem 0.6rem 0.5rem; font-size: 0.8rem; color: var(--muted); line-height: 1.3; }
.media-pictures figcaption a { color: var(--grape-deep); }

/* ---------- Game ---------- */
.game-instructions { font-size: 1.15rem; font-weight: 700; margin: 0.25rem 0; }
.game-help { color: var(--muted); margin: 0 0 1rem; }
.game-board { display: grid; grid-template-columns: 1fr 1.4fr; gap: 1rem; }
.col-title { font-size: 1rem; color: var(--muted); }
.game-col { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.6rem; }
.g-card {
  width: 100%; min-height: 60px; text-align: left; cursor: pointer;
  display: flex; align-items: center; gap: 0.6rem; padding: 0.6rem 0.9rem;
  border-radius: 18px; border: 2px solid var(--line); background: #fff;
  font: inherit; color: var(--ink); box-shadow: 0 3px 0 var(--line);
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}
.g-card:hover { border-color: var(--grape); }
.g-card[aria-pressed='true'] { border-color: var(--grape); background: var(--grape-soft); transform: translateY(-2px); }
.g-card.term { font-family: var(--display); font-weight: 700; font-size: 1.1rem; }
.g-emoji { font-size: 1.7rem; }
.g-card.matched { border-color: var(--leaf); background: var(--leaf-soft); color: var(--leaf); cursor: default; animation: pop 0.4s ease; }
.g-card.matched::after { content: '✓'; margin-left: auto; font-weight: 700; }
.g-card.wrong { border-color: var(--danger); animation: shake 0.35s ease; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.game-status:not(:empty) { margin: 1rem 0 0; padding: 0.75rem 1rem; border-radius: 14px; background: var(--sky); font-weight: 700; }
.game-status.win { background: var(--leaf-soft); color: var(--leaf); font-size: 1.15rem; }

/* ---------- Quiz ---------- */
.quiz-top { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.q-dots { display: flex; gap: 0.35rem; }
.q-dot { width: 14px; height: 14px; border-radius: 50%; background: var(--line); }
.q-dot.now { background: var(--grape); }
.q-dot.right { background: var(--leaf); }
.q-dot.wrong { background: var(--danger); }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-size: 1.3rem; font-weight: 700; margin-bottom: 0.9rem; padding: 0; font-family: var(--display); line-height: 1.25; }
.options { display: grid; gap: 0.65rem; }
.option {
  display: flex; align-items: center; gap: 0.8rem; min-height: 58px; padding: 0.65rem 1rem;
  border: 2px solid var(--line); border-radius: 18px; cursor: pointer; background: #fff; box-shadow: 0 3px 0 var(--line);
}
.option:hover { border-color: var(--grape); }
.option input { width: 1.35rem; height: 1.35rem; accent-color: var(--grape); flex: none; }
.option:has(input:checked) { border-color: var(--grape); background: var(--grape-soft); }
.option:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.option-emoji { font-size: 2.3rem; line-height: 1; }
.options.picture-options { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.options.picture-options .option { flex-direction: column; text-align: center; font-size: 1.25rem; padding: 1.1rem; }
/* Higher specificity than the :has(:checked) rule so results always win. */
.options .option.is-correct { border-color: var(--leaf); background: var(--leaf-soft); }
.options .option.is-wrong { border-color: var(--danger); background: var(--danger-soft); }
.option-mark { margin-left: auto; font-weight: 700; }
.options.picture-options .option-mark { margin-left: 0; }
.feedback:not(:empty) { margin-top: 1rem; padding: 1rem 1.25rem; border-radius: 16px; border-left: 6px solid; }
.feedback.correct { background: var(--leaf-soft); border-color: var(--leaf); color: var(--leaf); }
.feedback.wrong { background: var(--mango-soft); border-color: var(--mango); color: var(--ink); }
.feedback strong { display: block; font-size: 1.15rem; }

/* ---------- Report ---------- */
.report-head { display: flex; justify-content: space-between; align-items: flex-start; flex-wrap: wrap; gap: 0.5rem; }
.report-stars { margin: 0; font-size: 1.15rem; font-weight: 700; background: var(--mango-soft); padding: 0.4rem 0.9rem; border-radius: 999px; }
.report-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0.75rem; margin: 1rem 0; }
.report-grid div { background: var(--sky); border-radius: 16px; padding: 0.8rem 1rem; }
.report-grid dt { color: var(--muted); font-size: 0.88rem; font-weight: 700; }
.report-grid dd { margin: 0; font-size: 1.15rem; font-weight: 700; }
.report-columns { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.report-box { border-radius: 16px; padding: 1rem 1.1rem; }
.report-box.good { background: var(--leaf-soft); }
.report-box.practice { background: var(--mango-soft); }
.report-box ul, .sources { margin: 0.25rem 0 0; padding-left: 1.2rem; }
.suggestion { background: var(--sea-soft); padding: 0.9rem 1rem; border-radius: 14px; }
.sources a { color: var(--grape-deep); font-weight: 700; }
.report-date { color: var(--muted); font-size: 0.9rem; }

.why { margin-top: 2.5rem; }
.why-card {
  position: relative; max-width: 820px; margin: 0 auto; padding: 1.75rem 1.9rem 1.5rem;
  background: var(--page); border-radius: 26px; box-shadow: var(--lift);
  border-left: 8px solid var(--mango);
}
.why-card h2 { font-size: 1.9rem; margin-bottom: 0.6rem; }
.why-card p { margin: 0 0 0.8rem; max-width: 68ch; }
.why-dream { font-family: var(--display); font-weight: 700; font-size: 1.3rem; line-height: 1.3; color: var(--grape-deep); }
.why-sign { display: flex; flex-direction: column; margin: 1rem 0 0 !important; }
.why-sign strong { font-family: var(--display); font-size: 1.25rem; }
.why-sign span { color: var(--muted); }
.site-footer .credit { color: var(--ink); font-size: 0.98rem; margin-bottom: 0.4rem; }
.site-footer { text-align: center; color: var(--muted); font-size: 0.9rem; padding: 0 1rem 2rem; max-width: 820px; margin: 0 auto; }

/* ==========================================================================
   Story video ("theatre"): scenes, narrator and captions
   ========================================================================== */
.theatre {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 1rem;
  background: rgba(14, 10, 40, 0.88); backdrop-filter: blur(6px);
}
.th-frame { width: min(1000px, 100%); display: flex; flex-direction: column; gap: 0.6rem; color: #fff; }
.th-top { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.th-title { margin: 0; font-size: 1.3rem; color: #fff; }
.th-progress { display: flex; gap: 5px; }
.th-progress span { flex: 1; height: 6px; border-radius: 99px; background: rgba(255, 255, 255, 0.25); overflow: hidden; }
.th-progress span i { display: block; height: 100%; width: 0; background: var(--mango); }
.th-progress span.done i { width: 100%; }
.th-stage {
  position: relative; aspect-ratio: 16 / 9; width: 100%; max-height: 72vh; overflow: hidden;
  border-radius: 22px; background: linear-gradient(160deg, #3b1fa8, #0a6e8a);
}
.th-bg { position: absolute; inset: 0; background-size: cover; background-position: center; }
.th-bg.photo { filter: saturate(1.1); animation: kenburns 14s ease-out both; }
.th-bg.photo::after { content: ''; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(14, 10, 40, 0.15), rgba(14, 10, 40, 0.65)); }
.th-bg.tone-1 { background: radial-gradient(circle at 20% 20%, #ffd36b 0, transparent 40%), linear-gradient(160deg, #5b2ee5, #2e7fd6); }
.th-bg.tone-2 { background: radial-gradient(circle at 80% 25%, #ff9fb4 0, transparent 40%), linear-gradient(160deg, #0a6e8a, #3fb46e); }
.th-bg.tone-3 { background: radial-gradient(circle at 30% 80%, #ffe27a 0, transparent 45%), linear-gradient(160deg, #8a3ff0, #ff5a7a); }
.th-bg.tone-4 { background: radial-gradient(circle at 70% 70%, #9ce3ff 0, transparent 45%), linear-gradient(160deg, #1b1640, #5b2ee5); }
@keyframes kenburns { from { transform: scale(1.02) translate(0, 0); } to { transform: scale(1.18) translate(-3%, -2%); } }
.th-scene {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; padding: 1.5rem 1.5rem 6.5rem; text-align: center;
}
.th-scene .s-kicker { margin: 0; font-weight: 700; color: #ffe29a; font-size: 1.1rem; }
.th-scene .s-title { margin: 0; font-family: var(--display); font-weight: 800; font-size: clamp(1.8rem, 4.6vw, 3.4rem); line-height: 1.02; text-shadow: 0 3px 0 rgba(0, 0, 0, 0.2); }
.th-scene .s-tiles { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; }
.th-scene .s-tile {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem; min-width: 140px; padding: 1rem 1.1rem;
  border-radius: 24px; background: rgba(255, 255, 255, 0.95); color: var(--ink);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.18); opacity: 0; transform: scale(0.6) translateY(20px);
  transition: opacity 0.4s ease, transform 0.5s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.th-scene .s-tile.in { opacity: 1; transform: none; }
.th-scene .s-tiles { align-items: center; }
.th-scene .s-arrow { font-size: 2rem; color: #ffe29a; opacity: 0; transition: opacity 0.4s ease; }
.th-scene .s-arrow.in { opacity: 1; }
.th-scene .s-tile .e { font-size: clamp(3rem, 7vw, 4.8rem); line-height: 1.05; animation: bob 2.6s ease-in-out infinite; }
.th-scene .s-tile .l { font-family: var(--display); font-weight: 700; font-size: 1.15rem; }
.th-scene .s-media { max-width: 78%; max-height: 62%; border-radius: 16px; box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45); background: #000; }
.th-scene .s-credit { margin: 0; font-size: 0.85rem; opacity: 0.9; }
.th-scene .s-big-emoji { font-size: clamp(4rem, 10vw, 7rem); animation: bob 2.6s ease-in-out infinite; }
.th-scene .s-actions { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; align-items: center; }
.th-scene .s-actions .btn-big { width: auto; padding: 0 2rem; font-size: 1.25rem; }
.th-scene .s-actions .btn-secondary { background: rgba(255, 255, 255, 0.95); }
.th-narrator {
  position: absolute; left: 1rem; bottom: 1rem; display: flex; align-items: center; gap: 0.4rem;
}
.th-face {
  display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; font-size: 2.3rem;
  background: var(--mango); box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.85);
}
.th-wave { display: flex; gap: 3px; align-items: center; height: 24px; }
.th-wave i { width: 5px; height: 6px; border-radius: 3px; background: #fff; }
.theatre.speaking .th-wave i { animation: talk 0.5s ease-in-out infinite alternate; }
.theatre.speaking .th-wave i:nth-child(2) { animation-delay: 0.15s; }
.theatre.speaking .th-wave i:nth-child(3) { animation-delay: 0.3s; }
.theatre.speaking .th-face { animation: nod 0.9s ease-in-out infinite; }
@keyframes talk { to { height: 22px; } }
@keyframes nod { 50% { transform: rotate(-5deg) translateY(-2px); } }
.th-caption {
  position: absolute; left: 6.2rem; right: 1rem; bottom: 1rem; margin: 0;
  padding: 0.55rem 0.9rem; border-radius: 14px; background: rgba(14, 10, 40, 0.82);
  font-size: clamp(1rem, 2.1vw, 1.3rem); line-height: 1.4; min-height: 2.6em;
}
.th-caption:empty { visibility: hidden; }
.th-caption .w.on { color: var(--mango); }
.th-caption.off { display: none; }
.th-controls { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.th-icon-btn, .th-play-btn, .th-chip {
  min-width: 48px; min-height: 48px; border-radius: 999px; cursor: pointer; font: inherit; font-weight: 700;
  border: 2px solid rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.1); color: #fff;
}
.th-play-btn { min-width: 64px; min-height: 56px; background: var(--mango); color: var(--ink); border-color: var(--mango); font-size: 1.1rem; }
.th-chip { padding: 0 1rem; }
.th-chip[aria-pressed='true'] { background: #fff; color: var(--ink); }
.th-count { margin: 0 0 0 auto; opacity: 0.9; }
.theatre :focus-visible { outline-color: var(--mango); }

/* Confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 70; }
.confetti i {
  position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px;
  animation: fall 2.4s ease-in forwards;
}
.confetti i:nth-child(4n) { background: var(--mango); }
.confetti i:nth-child(4n + 1) { background: var(--melon); }
.confetti i:nth-child(4n + 2) { background: var(--grape); }
.confetti i:nth-child(4n + 3) { background: #3fb46e; }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); opacity: 0.8; } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .field-row { grid-template-columns: 1fr; }
  .cycle-wrap { grid-template-columns: 1fr; }
  .spread { grid-template-columns: 1fr; }
  .page-left { border-right: 0; border-bottom: 2px solid #efe6cf; box-shadow: none; }
  .page-right { box-shadow: none; }
  .story-head { flex-direction: column-reverse; }
  .topic-photo { flex-basis: auto; width: 100%; transform: none; }
  .board-items.flow { flex-direction: column; }
  .board-items.flow .tile:not(:last-child) { margin: 0 0 1.4rem; }
  .board-items.flow .tile:not(:last-child)::after { content: '⬇'; right: auto; left: 50%; top: auto; bottom: -1.45rem; transform: translateX(-50%); }
  .game-board { grid-template-columns: 1fr; }
  .hero { padding: 2rem 1rem 4rem; border-radius: 26px; }
  .sun { width: 110px; height: 110px; right: -40px; top: -40px; }
  .card, .book { padding: 1.2rem; }
  .brand-name { display: none; }
  .search-box { flex-wrap: wrap; }
  .surprise-btn { width: 100%; }
  .header-tools { gap: 0.35rem; }
  .text-size { display: none; }
  .narrator-btn { padding: 0.2rem 0.6rem; }
  .narrator-label { display: none; }
  .journey li span:last-child { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  .journey li { min-width: 0; justify-content: center; }
  .theatre { padding: 0.5rem; }
  .th-stage { aspect-ratio: 3 / 4; max-height: 70vh; }
  .th-scene { padding-bottom: 7.5rem; }
  .th-caption { left: 0.6rem; right: 0.6rem; bottom: 0.6rem; }
  .th-narrator { left: auto; right: 0.8rem; top: 0.8rem; bottom: auto; }
  .th-face { width: 48px; height: 48px; font-size: 1.7rem; }
  .th-scene { gap: 0.6rem; }
  .th-scene .s-tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; width: 100%; max-width: 320px; }
  .th-scene .s-arrow { display: none; }
  .th-scene .s-tile { min-width: 0; padding: 0.6rem 0.4rem; border-radius: 18px; }
  .th-scene .s-tile .e { font-size: 2.4rem; }
  .th-scene .s-tile .l { font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
  .th-scene .s-tile { opacity: 1; transform: none; }
  .confetti { display: none; }
}

@media print {
  body { background: #fff; }
  .site-header, .site-footer, .skip-link, #home, nav, #status, #error, .no-print, .theatre,
  #story-panel, #visual-panel, #game-panel, #quiz-panel, .confetti { display: none !important; }
  #lesson, #report-panel { display: block !important; }
  main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #999; }
}
