/* =========================================================================
   style.css  —  looks + animations for the storybook
   ========================================================================= */
:root {
  --ui: rgba(255, 255, 255, 0.92);
  --ui-shadow: rgba(0, 0, 0, 0.30);
  --font: "Comic Sans MS", "Baloo 2", "Trebuchet MS", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
  font-family: var(--font); background: #1b1030;
  user-select: none; -webkit-user-select: none; touch-action: none;
}

/* ---- Stage ---- */
#stage { position: fixed; inset: 0; overflow: hidden; }

.scene {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  transition: transform 0.55s ease, opacity 0.55s ease;
}
.scene.enter-from-right { transform: translateX(100%); opacity: 0; }
.scene.enter-from-left  { transform: translateX(-100%); opacity: 0; }
.scene.leave-to-left    { transform: translateX(-100%); opacity: 0; }
.scene.leave-to-right   { transform: translateX(100%); opacity: 0; }
.scene.active           { transform: translateX(0); opacity: 1; }

/* the visual area above the text panel */
.scene-inner { position: relative; flex: 1; overflow: hidden; }
/* soft vignette for a cohesive storybook feel */
.scene-inner::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 140px rgba(0,0,0,0.22);
}

/* ---- Props (decorative emoji) ---- */
.prop {
  position: absolute; transform: translate(-50%, -50%); line-height: 1;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.30));
  opacity: 0; animation: pop-in 0.6s ease forwards;
}
@keyframes pop-in {
  0% { opacity: 0; transform: translate(-50%,-50%) scale(0.4); }
  70% { opacity: 1; transform: translate(-50%,-50%) scale(1.08); }
  100% { opacity: 1; transform: translate(-50%,-50%) scale(1); }
}
.prop .motion { display: inline-block; will-change: transform; }
.anim-float .motion    { animation: float 3.5s ease-in-out infinite; }
.anim-bob .motion      { animation: bob 2.2s ease-in-out infinite; }
.anim-sway .motion     { animation: sway 3s ease-in-out infinite; }
.anim-twinkle .motion  { animation: twinkle 1.8s ease-in-out infinite; }
.anim-spin-slow .motion{ animation: spin 12s linear infinite; }
@keyframes float   { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-16px);} }
@keyframes bob     { 0%,100%{transform:translateY(0);} 50%{transform:translateY(-8px);} }
@keyframes sway    { 0%,100%{transform:rotate(-6deg);} 50%{transform:rotate(6deg);} }
@keyframes twinkle { 0%,100%{transform:scale(1);opacity:1;} 50%{transform:scale(1.25);opacity:0.6;} }
@keyframes spin    { from{transform:rotate(0);} to{transform:rotate(360deg);} }

/* ---- Characters (drawn as cartoons) ---- */
.cast {
  position: absolute; left: 0; right: 0; bottom: 2vh; z-index: 3;
  display: flex; justify-content: center; align-items: flex-end; gap: clamp(4px, 2vw, 26px);
}
.person {
  width: clamp(74px, 12vw, 150px); opacity: 0;
  animation: rise-in 0.6s ease forwards;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.28));
}
.person svg { width: 100%; height: auto; display: block; }
.person .avatar-photo {
  width: 100%; aspect-ratio: 1 / 1; object-fit: cover; display: block;
  border-radius: 50%; border: 4px solid #fff;
  box-shadow: 0 6px 14px rgba(0,0,0,0.30);
}
.person .b { display: inline-block; animation: bob 2.6s ease-in-out infinite; }
.person:nth-child(2) .b { animation-delay: 0.3s; }
.person:nth-child(3) .b { animation-delay: 0.6s; }
.person:nth-child(4) .b { animation-delay: 0.9s; }
@keyframes rise-in { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Illustration (from images/) — becomes the whole scene ---- */
.scene-illustration {
  position: absolute; inset: 0; z-index: 4; margin: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 3vh 5vw 1vh;
}
.scene-illustration img {
  max-width: min(94%, 1040px); max-height: 82%;
  object-fit: contain; animation: rise 0.5s ease;
  filter: drop-shadow(0 12px 26px rgba(0,0,0,0.28));
}
/* when a real illustration is showing, hide the emoji/cartoon fallback layer */
.scene.has-illustration .cast,
.scene.has-illustration .prop { display: none; }

/* ---- Story text panel ---- */
.text-panel {
  flex: none; width: min(1000px, 94vw); margin: 0 auto 4vh;
  padding: clamp(14px, 2.4vw, 26px) clamp(20px, 4vw, 44px);
  background: var(--ui); border-radius: 26px; box-shadow: 0 10px 30px var(--ui-shadow);
  text-align: center; color: #2a2140; line-height: 1.4;
  font-size: clamp(1.15rem, 2.7vw, 1.9rem);
  opacity: 0; animation: rise 0.6s ease 0.15s forwards;
}
.text-panel .chapter { display: block; font-size: 0.62em; color: #8a5fb0; margin-bottom: 0.35em; font-weight: bold; }
.text-panel .credit { display: block; margin-top: 0.7em; font-size: 0.5em; font-weight: normal; color: #9186b3; }
@keyframes rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Top bar ---- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 14px;
}
.hud-btn {
  border: none; border-radius: 16px; background: var(--ui); color: #5a3fa0;
  font-family: var(--font); font-weight: bold; font-size: clamp(1rem, 2.4vw, 1.4rem);
  padding: 10px 16px; box-shadow: 0 4px 12px var(--ui-shadow); cursor: pointer;
  transition: transform 0.12s ease;
}
.hud-btn:active { transform: scale(0.93); }
#page-label {
  background: rgba(255,255,255,0.85); color: #5a3fa0; font-weight: bold;
  padding: 8px 16px; border-radius: 999px; box-shadow: 0 4px 12px var(--ui-shadow);
  font-size: clamp(0.9rem, 2.2vw, 1.15rem);
}

/* ---- Side nav buttons ---- */
.nav-btn {
  position: fixed; bottom: 50%; transform: translateY(50%); z-index: 25;
  width: clamp(52px, 9vw, 84px); height: clamp(52px, 9vw, 84px);
  border: none; border-radius: 50%; background: var(--ui);
  box-shadow: 0 6px 18px var(--ui-shadow); color: #5a3fa0;
  font-size: clamp(1.6rem, 4vw, 2.4rem); cursor: pointer; display: grid; place-items: center;
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.nav-btn:active { transform: translateY(50%) scale(0.9); }
.nav-btn.prev { left: 2.5vw; }
.nav-btn.next { right: 2.5vw; }
.nav-btn[disabled] { opacity: 0; pointer-events: none; }

/* =========================================================================
   SCENE BACKGROUNDS
   ========================================================================= */
.theme-bedroom      { background: linear-gradient(180deg,#4b3b74 0%,#7d5f9c 55%,#caa27a 100%); }
.theme-airport      { background: linear-gradient(180deg,#a9c8e8 0%,#eaf3fc 100%); }
.theme-plane        { background: linear-gradient(180deg,#6cc0ff 0%,#cfeaff 100%); }
.theme-arrival      { background: linear-gradient(180deg,#bfe08a 0%,#6fb84e 100%); }
.theme-lane         { background: linear-gradient(180deg,#a9d7f0 0%,#78b356 62%,#5d9a41 100%); }
.theme-cottage-out  { background: linear-gradient(180deg,#a7d5f0 0%,#8fce74 64%,#6fae52 100%); }
.theme-cottage-in   { background: linear-gradient(180deg,#6e4a30 0%,#a9713f 60%,#c98f52 100%); }
.theme-night-cottage{ background: linear-gradient(180deg,#0b1130 0%,#241d46 60%,#3a2f5e 100%); }
.theme-hills        { background: linear-gradient(180deg,#a9dcff 0%,#7ec95e 56%,#5aa63f 100%); }
.theme-cliffs       { background: linear-gradient(180deg,#9bd0f2 0%,#4f8fbb 62%,#2b5f86 100%); }
.theme-cove         { background: linear-gradient(180deg,#bfe6f5 0%,#8fcfe0 46%,#ecdca6 100%); }
.theme-rain         { background: linear-gradient(180deg,#79838f 0%,#a7b1bd 100%); }
.theme-garden       { background: linear-gradient(180deg,#bfe6ff 0%,#8fce74 58%,#6fae52 100%); }
.theme-beach-night  { background: linear-gradient(180deg,#0a1030 0%,#213763 55%,#3a4a6b 100%); }
