/* Shared picture-book engine styles */
:root {
  --ink: #3b2f4a;
  --ink-soft: #6b5d7b;
  --paper: #fff8ec;
  --paper-2: #fdeed6;
  --accent: #ff8a5c;
  --accent-2: #ffcf5c;
  --accent-3: #7cc8a4;
  --accent-4: #7aa7ff;
  --shadow: 0 10px 30px rgba(59, 47, 74, .18);
  --radius: 26px;
  --bg: radial-gradient(circle at 15% 10%, #ffe9c7 0, transparent 40%),
        radial-gradient(circle at 90% 90%, #ffd9e4 0, transparent 45%),
        #fff3e0;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: "Baloo 2", "Fredoka", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background: var(--bg);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
button { font-family: inherit; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; max-width: 1180px; margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink);
  font-weight: 800; font-size: clamp(16px, 2.4vw, 22px); line-height: 1.1;
}
.brand .badge {
  width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center;
  background: var(--accent-2); box-shadow: inset 0 -3px 0 rgba(0,0,0,.12); font-size: 20px;
}
.tools { display: flex; gap: 8px; }
.pill {
  border: none; cursor: pointer; border-radius: 999px; padding: 8px 14px;
  background: #fff; color: var(--ink); font-weight: 700; font-size: 15px;
  box-shadow: 0 3px 0 rgba(59,47,74,.15); transition: transform .15s;
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
}
.pill:hover { transform: translateY(-2px); }
.pill:active { transform: translateY(1px); box-shadow: none; }
.pill.on { background: var(--accent-3); color: #fff; }

/* ---------- book ---------- */
/* keep picture + a few lines of text inside one screen on wide displays */
.book { max-width: max(560px, min(1180px, calc((100vh - 300px) * 16 / 9 + 56px))); margin: 0 auto; padding: 0 16px 24px; }
.page { display: none; animation: pageIn .55s cubic-bezier(.2,.9,.3,1.2); }
.page.active { display: block; }
@keyframes pageIn {
  from { opacity: 0; transform: translateY(18px) scale(.98) rotate(-.4deg); }
  to   { opacity: 1; transform: none; }
}

.sheet {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
  position: relative;
}
.sheet::before { /* stitched border */
  content: ""; position: absolute; inset: 6px; border-radius: calc(var(--radius) - 6px);
  border: 2px dashed rgba(107, 93, 123, .18); pointer-events: none;
}

.stage {
  position: relative; width: 100%; aspect-ratio: 16 / 9;
  border-radius: 18px; overflow: hidden; background: #e9dccb;
  user-select: none; -webkit-user-select: none;
}
.stage > img.art {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block;
  pointer-events: none;
}
.layer { position: absolute; inset: 0; pointer-events: none; }
.layer > * { pointer-events: auto; }

.text {
  padding: 16px 18px 8px; font-size: clamp(18px, 2.3vw, 25px); line-height: 1.5;
}
.text h1, .text h2 {
  margin: 0 0 6px; line-height: 1.15; font-weight: 800;
  font-size: clamp(26px, 3.6vw, 40px); color: var(--ink);
}
.text p { margin: 0 0 10px; }
.text .fact {
  display: block; margin-top: 8px; padding: 10px 14px; border-radius: 16px;
  background: #fff; border: 2px solid var(--paper-2); font-size: .82em; color: var(--ink-soft);
}
.text .fact b { color: var(--accent); }
.big { font-weight: 800; color: var(--accent); }
.hl { background: linear-gradient(transparent 55%, #ffe08a 55%); font-weight: 700; }

/* ---------- hotspots & hints ---------- */
.hot {
  position: absolute; border: none; background: transparent; cursor: pointer; padding: 0;
  border-radius: 50%; transform: translate(-50%, -50%);
}
.hot::after { /* pulsing ring hint */
  content: ""; position: absolute; inset: 0; border-radius: inherit;
  border: 4px solid rgba(255, 255, 255, .95);
  box-shadow: 0 0 0 4px rgba(255, 138, 92, .55);
  animation: ring 1.8s ease-out infinite; pointer-events: none;
}
.hot.done::after { display: none; }
@keyframes ring {
  0% { transform: scale(.75); opacity: .95; }
  80%, 100% { transform: scale(1.25); opacity: 0; }
}
.tap-hint {
  position: absolute; z-index: 5; pointer-events: none;
  background: #fff; color: var(--ink); border-radius: 999px; padding: 6px 14px;
  font-weight: 800; font-size: clamp(13px, 1.6vw, 18px);
  box-shadow: 0 4px 0 rgba(59,47,74,.18); animation: bob 1.4s ease-in-out infinite;
  white-space: nowrap;
}
.tap-hint::before { content: "👆 "; }
@keyframes bob { 50% { transform: translateY(-6px); } }

.bubble {
  position: absolute; z-index: 6; max-width: min(46%, 340px);
  background: #fff; color: var(--ink); border-radius: 20px; padding: 10px 14px;
  font-size: clamp(13px, 1.55vw, 18px); line-height: 1.35; font-weight: 600;
  box-shadow: 0 6px 0 rgba(59,47,74,.15), 0 12px 24px rgba(0,0,0,.12);
  animation: pop .35s cubic-bezier(.2,1.4,.4,1); pointer-events: none;
}
.bubble b { color: var(--accent); font-size: 1.12em; display: block; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------- nav ---------- */
.nav {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  max-width: 1180px; margin: 14px auto 0; padding: 0 16px;
}
.nav button.arrow {
  border: none; cursor: pointer; border-radius: 999px; padding: 12px 22px; min-width: 120px;
  font-size: 20px; font-weight: 800; color: #fff; background: var(--accent);
  box-shadow: 0 5px 0 #d9653a; transition: transform .12s;
}
.nav button.arrow.prev { background: var(--accent-4); box-shadow: 0 5px 0 #4f7fd9; }
.nav button.arrow:active { transform: translateY(4px); box-shadow: none; }
.nav button.arrow:disabled { opacity: .35; cursor: default; }
.dots { display: flex; gap: 7px; flex-wrap: wrap; justify-content: center; }
.dots button {
  width: 14px; height: 14px; border-radius: 50%; border: none; padding: 0; cursor: pointer;
  background: rgba(107, 93, 123, .25); transition: transform .2s, background .2s;
}
.dots button.on { background: var(--accent); transform: scale(1.35); }

/* ---------- misc widgets ---------- */
.choice-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 4px; }
.choice {
  border: 3px solid transparent; background: #fff; border-radius: 18px; cursor: pointer;
  padding: 8px 14px; font-size: clamp(15px, 1.8vw, 19px); font-weight: 700; color: var(--ink);
  box-shadow: 0 4px 0 rgba(59,47,74,.15); display: inline-flex; align-items: center; gap: 8px;
  transition: transform .12s;
}
.choice:hover { transform: translateY(-2px); }
.choice.on { border-color: var(--accent); background: #fff3ea; }
.choice.right { border-color: var(--accent-3); background: #e6f7ee; }
.choice.wrong { border-color: #e66; background: #ffecec; animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

.shake-stage { animation: quake .8s; }
@keyframes quake {
  10%, 50%, 90% { transform: translate(-8px, 4px) rotate(-.6deg); }
  30%, 70% { transform: translate(8px, -4px) rotate(.6deg); }
}
.flash {
  position: absolute; inset: 0; background: #fffbe6; opacity: 0; pointer-events: none; z-index: 4;
}
.flash.go { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { opacity: 0; } 8% { opacity: 1; } 100% { opacity: 0; } }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 50; overflow: hidden; }
.confetti i {
  position: absolute; top: -20px; width: 12px; height: 16px; border-radius: 3px;
  animation: fall linear forwards;
}
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); } }

.footer {
  text-align: center; color: var(--ink-soft); font-size: 14px; padding: 18px 16px 28px;
}
.footer a { color: var(--ink-soft); }

/* reading highlight for read-aloud */
.reading { background: #fff2b3; border-radius: 6px; }

@media (max-width: 640px) {
  .book { padding: 0 8px 16px; }
  .sheet { padding: 8px; border-radius: 20px; }
  .text { padding: 12px 8px 4px; }
  .nav button.arrow { min-width: 86px; padding: 10px 14px; font-size: 17px; }
  .pill .lbl { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
