/* Junior Express 1 — lightweight shell styles */
:root {
  --cb: #f5a623;      /* coursebook  */
  --wb: #4a90d9;      /* workbook    */
  --comp: #7ac043;    /* companion   */
  --videos: #e0518a;  /* videos      */
  --games: #9b59b6;   /* games       */
  --ink: #2b2b3a;
  --paper: #fffdf7;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  --radius: 18px;
  font-family: "Baloo 2", "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: #1d2233; color: var(--ink); overflow: hidden; }
.app { height: 100vh; width: 100vw; overflow: hidden; }

/* ---------- generic ---------- */
.screen {
  height: 100vh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3vh;
  padding: 4vh 4vw;
  animation: fade 0.35s ease both;
}
@keyframes fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.title {
  font-size: clamp(28px, 5vw, 64px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.25);
  letter-spacing: .5px;
  margin: 0;
}
.subtitle { color: #cfd6ea; margin: 0; font-size: clamp(14px, 2vw, 20px); }

.btn {
  border: none;
  cursor: pointer;
  border-radius: 999px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  padding: 14px 26px;
  font-size: clamp(15px, 1.6vw, 20px);
  box-shadow: var(--shadow);
  transition: transform .12s ease, filter .12s ease;
  background: #555;
}
.btn:hover { transform: translateY(-2px) scale(1.02); filter: brightness(1.06); }
.btn:active { transform: translateY(0) scale(.99); }
.btn--ghost { background: rgba(255,255,255,.14); backdrop-filter: blur(4px); }

.row { display: flex; flex-wrap: wrap; gap: 16px; justify-content: center; align-items: center; }

/* ---------- home (covers) ---------- */
.home { background: radial-gradient(120% 120% at 50% 0%, #3a4680 0%, #1d2233 70%); }
.covers { display: flex; gap: clamp(16px, 3vw, 40px); flex-wrap: wrap; justify-content: center; }
.cover {
  cursor: pointer;
  width: clamp(140px, 18vw, 240px);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background: #fff;
  transition: transform .18s ease;
  border: 4px solid #fff;
}
.cover:hover { transform: translateY(-6px) rotate(-1deg); }
.cover img { display: block; width: 100%; height: auto; }
.cover span {
  display: block; text-align: center; padding: 8px; font-weight: 700;
  font-size: 13px; color: var(--ink); background: #fff;
}

/* ---------- menu ---------- */
.menu { background: radial-gradient(120% 120% at 50% 0%, #2c3350 0%, #1d2233 70%); }
.parts { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; }
.part-btn {
  width: clamp(150px, 20vw, 230px);
  height: clamp(90px, 12vw, 130px);
  border-radius: var(--radius);
  font-size: clamp(20px, 2.4vw, 30px);
  display: flex; align-items: center; justify-content: center;
  flex-direction: column; gap: 4px;
}
.part-btn small { font-weight: 600; font-size: .55em; opacity: .9; }
.p1 { background: linear-gradient(135deg, #f5a623, #f57f17); }
.p2 { background: linear-gradient(135deg, #4a90d9, #2a63c0); }
.p3 { background: linear-gradient(135deg, #7ac043, #4e9c2a); }

.books-bar { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.book-btn { padding: 12px 20px; font-size: clamp(13px, 1.4vw, 17px); }
.b-coursebook { background: var(--cb); }
.b-workbook   { background: var(--wb); }
.b-companion  { background: var(--comp); }
.b-videos     { background: var(--videos); }
.b-games      { background: var(--games); }
.book-btn.is-active { outline: 4px solid #fff; }

/* ---------- lessons ---------- */
.lessons { justify-content: flex-start; overflow-y: auto; }
.units { width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 16px; }
.unit-card { background: rgba(255,255,255,.96); border-radius: var(--radius); padding: 14px 18px; box-shadow: var(--shadow); }
.unit-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.unit-badge { background: var(--cb); color: #fff; font-weight: 800; border-radius: 10px; padding: 6px 12px; }
.lesson-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: #eef1f8; color: var(--ink); border: none; cursor: pointer;
  border-radius: 999px; padding: 8px 14px; font: inherit; font-weight: 600; font-size: 14px;
  transition: background .12s ease, transform .12s ease;
}
.chip:hover { background: var(--cb); color: #fff; transform: translateY(-1px); }
.chip--sticker { background: #fbe6d0; color: #8a4b12; }
.chip--sticker:hover { background: var(--cb); color: #fff; }
.chip--prep { background: #e7f0ff; color: #234e93; }
.chip--prep:hover { background: var(--wb); color: #fff; }
.chip--song { background: #eaf6df; color: #3d6b1e; }
.chip--song:hover { background: var(--comp); color: #fff; }

/* ---------- viewer ---------- */
.viewer { background: #14182a; gap: 0; padding: 0; }
.viewer-bar {
  height: 56px; width: 100%; display: flex; align-items: center; gap: 10px;
  padding: 0 14px; background: rgba(0,0,0,.35); color: #fff; flex-shrink: 0;
}
.viewer-bar .spacer { flex: 1; }
.viewer-bar .tbtn {
  background: rgba(255,255,255,.14); color:#fff; border:none; cursor:pointer;
  border-radius: 10px; padding: 8px 14px; font: inherit; font-weight: 600;
}
.viewer-bar .tbtn:hover { background: rgba(255,255,255,.28); }
.viewer-bar .tbtn.is-active { background: #f5a623; }
.viewer-bar .label { font-weight: 700; }
.stage {
  flex: 1; width: 100%; display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden; padding: 12px;
}
.stage img { max-height: 100%; max-width: 100%; border-radius: 6px; box-shadow: 0 10px 40px rgba(0,0,0,.5); background:#fff; }
.flipbook { margin: 0 auto; }
.flipbook .stf__item { background: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.4); }
.flipbook .page { background: #fff; }
.flipbook .page img { width: 100%; height: 100%; display: block; object-fit: contain; }
.flipbook .stf__outer, .flipbook .stf__inner { display: none !important; }
.flip-loading { color:#cfd6ea; }
.nav-arrow {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 54px; height: 54px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.85); font-size: 26px; color: var(--ink); box-shadow: var(--shadow);
}
.nav-arrow:hover { background: #fff; }
.nav-arrow:disabled { opacity: .3; cursor: default; }
.nav-arrow.prev { left: 18px; }
.nav-arrow.next { right: 18px; }

.placeholder { color:#cfd6ea; text-align:center; max-width: 560px; }
.placeholder h2 { color:#fff; }

.back-fab {
  position: fixed; top: 14px; left: 14px; z-index: 20;
}

/* ---------- zoom overlay ---------- */
.zoom-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(8,10,20,.94);
  display: flex; align-items: center; justify-content: center; overflow: auto;
  cursor: zoom-out; animation: fade .2s ease both;
}
.zoom-overlay img { height: 94vh; width: auto; max-width: none; box-shadow: 0 10px 60px rgba(0,0,0,.6); border-radius: 6px; background:#fff; }
.zoom-hint { position: fixed; bottom: 16px; left: 0; right: 0; text-align: center; color: #cfd6ea; font-size: 13px; }

/* ---------- exercise zoom + reveal (click an exercise → zoom → tap to reveal) ---------- */
.ex-overlay { position: fixed; inset: 0; z-index: 55; background: rgba(8,10,20,.96);
  display: flex; flex-direction: column; animation: fade .2s ease both; }
.ex-bar { height: 54px; flex-shrink: 0; display: flex; align-items: center; gap: 12px;
  padding: 0 16px; color: #fff; background: rgba(0,0,0,.4); }
.ex-bar .ex-hint { flex: 1; color: #cfd6ea; font-size: 13px; }
.ex-bar button { background: rgba(255,255,255,.16); border: none; color: #fff; cursor: pointer;
  border-radius: 10px; padding: 9px 16px; font: inherit; font-weight: 700; }
.ex-bar button:hover { background: rgba(255,255,255,.3); }
.ex-bar .ex-reveal.is-active { background: #f5a623; }
.ex-bar .ex-close { font-size: 18px; padding: 6px 14px; }
.ex-scroll { flex: 1; overflow: auto; display: flex; justify-content: center; align-items: flex-start;
  -webkit-overflow-scrolling: touch; }
.ex-wrap { position: relative; width: 100%; max-width: 1200px; line-height: 0; background: #fff; }
.ex-base { display: block; width: 100%; cursor: pointer; user-select: none; }
/* full TCH copy, perfectly aligned over the STU page, clipped to the tapped line → seamless answer */
.ex-tch { position: absolute; inset: 0; width: 100%; height: 100%; cursor: pointer; }
/* matching-exercise line canvas (clicks pass through to the page underneath) */
.ex-line { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* ---------- videos ---------- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 18px; width: 100%; max-width: 900px; }
.video-card {
  background: rgba(255,255,255,.96); border-radius: var(--radius); overflow: hidden;
  box-shadow: var(--shadow); cursor: pointer; transition: transform .15s ease; text-align: left;
}
.video-card:hover { transform: translateY(-4px); }
.video-card .thumb {
  height: 118px; background: linear-gradient(135deg, var(--videos), #b23a6a);
  display: flex; align-items: center; justify-content: center; color: #fff; font-size: 40px;
}
.video-card .meta { padding: 10px 14px; }
.video-card .meta b { display: block; color: var(--ink); }
.video-card .meta small { color: #6b7280; }
.video-card.not-ready { opacity: .68; cursor: default; }
.video-card .badge { float: right; font-size: 11px; font-weight: 700; color: #fff; background: #9aa1ad; border-radius: 999px; padding: 2px 8px; }
.video-card.ready .badge { background: var(--comp); }

.video-modal {
  position: fixed; inset: 0; z-index: 60; background: rgba(6,8,16,.95);
  display: flex; align-items: center; justify-content: center; flex-direction: column; gap: 14px;
  animation: fade .2s ease both;
}
.video-modal video { max-width: 92vw; max-height: 82vh; border-radius: 8px; box-shadow: 0 12px 60px rgba(0,0,0,.6); background:#000; }
.video-modal .close-x { position: absolute; top: 16px; right: 20px; font-size: 30px; color: #fff; cursor: pointer; background: none; border: none; }
.video-modal .vtitle { color: #fff; font-weight: 700; font-size: 20px; }

/* ---------- games ---------- */
.chip--game { background: #efe3f7; color: #6a2f92; font-size: 15px; padding: 10px 18px; }
.chip--game:hover { background: var(--games); color: #fff; }

.picker-overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(8,10,20,.9);
  display: flex; align-items: center; justify-content: center; animation: fade .2s ease both;
}
.picker {
  position: relative; background: #fffdf7; border-radius: var(--radius);
  padding: 26px 30px; box-shadow: var(--shadow); max-width: 560px; width: min(92vw, 560px); text-align: center;
}
.picker h2 { margin: 0 0 4px; color: var(--ink); }
.picker-hint { margin: 0 0 16px; color: #6b7280; font-size: 14px; }
.picker-sets { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.picker .close-x { position: absolute; top: 10px; right: 14px; font-size: 22px; color: #6b7280; cursor: pointer; background: none; border: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px);
  background: rgba(20,24,42,.95); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; font-size: 15px; box-shadow: var(--shadow); z-index: 80;
  opacity: 0; transition: opacity .25s ease, transform .25s ease; pointer-events: none;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* in-page video launch button (Coursebook story pages) */
.viewer-bar .tbtn.video-btn { background: var(--videos); }
.viewer-bar .tbtn.video-btn:hover { background: #c4407a; }
.viewer-bar .tbtn.video-btn.is-soon { background: rgba(255,255,255,.14); opacity: .85; }
