/* Buddy's Beach Day — story player styles. Mobile-first at 375px. */

.story-page { background: var(--lw-bg, #FFFBF5); }
.story-page [hidden] { display: none !important; }
.story-page main { max-width: 1080px; margin: 0 auto; padding: 8px 10px 28px; }

#player { position: relative; }
/* Pre-boot: the static splash is #player's only child; give it the stage's
   aspect so it paints immediately (LCP) and the page has height before JS
   builds the stage. The JS-rebuilt splash is never :first-child. */
#player > .splash:first-child { position: relative; inset: auto; aspect-ratio: 1000 / 572; min-height: 300px; }

.stage-wrap { position: relative; display: flex; flex-direction: column; gap: 8px; }

/* ---------------------------------------------------------------- stage */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1600 / 915;
  max-height: 62vh;
  margin: 0 auto;
  border-radius: var(--lw-radius-lg, 22px);
  overflow: hidden;
  background: linear-gradient(180deg, #BEE9F5 0%, #FFF3DE 62%, #FFE0B8 100%);
  box-shadow: 0 10px 30px rgba(30, 42, 74, .16);
  touch-action: manipulation;
}
@supports not (aspect-ratio: 1) {
  .stage { height: 0; padding-bottom: 57.2%; }
}

.scene-layer {
  position: absolute; inset: 0;
  background-size: cover; background-position: center;
  opacity: 0; z-index: 1;
  will-change: opacity, transform;
}
.scene-layer.active { opacity: 1; }
.scene-layer.enter { opacity: 0; transform: scale(1.04); z-index: 2; }
.scene-layer.enter.from-right { transform: translateX(6%) scale(1.03); }
.scene-layer.enter.from-left  { transform: translateX(-6%) scale(1.03); }
.scene-layer.enter.in {
  opacity: 1; transform: translateX(0) scale(1);
  transition: opacity .45s ease, transform .45s cubic-bezier(.22,.9,.32,1.1);
}
.scene-layer.out { transition: opacity .45s ease, transform .45s ease; opacity: 0; }
.scene-layer.out.to-left  { transform: translateX(-4%) scale(.99); }
.scene-layer.out.to-right { transform: translateX(4%) scale(.99); }

/* ---------------------------------------------------------------- hotspots */
.hotspots { position: absolute; inset: 0; z-index: 5; transition: opacity .3s ease; }
.hotspots.fading { opacity: 0; pointer-events: none; }

/* round-4: instant press acknowledgement (compositor-only properties) */
.pressing:not(.hotspot) { transform: scale(.94); transition: transform .05s ease-out; filter: brightness(1.05); }
.hotspot.pressing { box-shadow: 0 0 0 3px rgba(255,255,255,.75), 0 0 18px 6px rgba(255,255,255,.45); }

.hotspot {
  position: absolute;
  background: transparent;
  border: 0; padding: 0; cursor: pointer;
  border-radius: 18px;
  -webkit-tap-highlight-color: transparent;
}
/* gentle discoverability shimmer */
.hotspot::before {
  content: "";
  position: absolute; inset: 4%;
  border-radius: inherit;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, .55), 0 0 22px 6px rgba(255, 214, 120, .5);
  opacity: 0;
  animation: lw-hs-glow 3.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes lw-hs-glow {
  0%, 62%, 100% { opacity: 0; transform: scale(.97); }
  74%, 86% { opacity: .8; transform: scale(1); }
}
.hotspot.found::before { animation: none; opacity: .35; box-shadow: 0 0 0 3px rgba(255,255,255,.5), 0 0 16px 4px rgba(126, 217, 133, .55); }
.hotspot:focus-visible { outline: 3px solid var(--lw-sky, #58B7E6); outline-offset: 3px; }
.hotspot.active { animation: lw-bounce-tap .45s var(--lw-ease-pop, cubic-bezier(.34,1.56,.64,1)); }

.hs-label {
  position: absolute; left: 50%; bottom: 100%;
  transform: translate(-50%, 6px) scale(.6);
  background: var(--lw-surface, #fff);
  color: var(--lw-ink, #1E2A4A);
  font-family: var(--lw-font-display, sans-serif);
  font-weight: 700; font-size: clamp(.85rem, 2.6vw, 1.25rem);
  padding: .28em .85em; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(30,42,74,.25);
  opacity: 0; pointer-events: none; white-space: nowrap;
  transition: opacity .2s ease, transform .25s var(--lw-ease-pop, ease);
  z-index: 6;
}
.hotspot.active .hs-label,
.hotspot:hover .hs-label { opacity: 1; transform: translate(-50%, -4px) scale(1); }
.hotspot.found .hs-label { opacity: .95; transform: translate(-50%, -4px) scale(.92); }

.hs-badge {
  position: absolute; top: -6px; right: -6px;
  width: 26px; height: 26px; line-height: 26px;
  border-radius: 50%; text-align: center;
  background: var(--lw-leaf, #7ED985); color: #fff;
  font-size: .8rem;
  transform: scale(0); transition: transform .35s var(--lw-ease-pop, ease);
  pointer-events: none;
}
.hotspot.found .hs-badge { transform: scale(1); }

.hs-sprite-pop {
  position: absolute; z-index: 7;
  width: 19%; max-width: 150px;
  transform: translate(-50%, -58%) scale(.2);
  filter: drop-shadow(0 8px 14px rgba(30,42,74,.3));
  animation: lw-sprite-pop .5s var(--lw-ease-pop, cubic-bezier(.34,1.56,.64,1)) forwards;
  pointer-events: none;
}
@keyframes lw-sprite-pop {
  to { transform: translate(-50%, -78%) scale(1); }
}
.hs-sprite-pop.gone { transition: opacity .4s ease, transform .4s ease; opacity: 0; }

/* ---------------------------------------------------------------- nav */
.edge-zone {
  position: absolute; top: 0; bottom: 0; width: 12%;
  background: transparent; border: 0; padding: 0; cursor: pointer;
  z-index: 3; -webkit-tap-highlight-color: transparent;
}
.edge-zone.left { left: 0; } .edge-zone.right { right: 0; }
.edge-zone:focus-visible { outline: 3px dashed rgba(255,255,255,.8); outline-offset: -6px; }

.chev {
  position: absolute; top: 50%; transform: translateY(-50%);
  z-index: 8;
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; cursor: pointer;
  background: rgba(255, 251, 245, .88);
  color: var(--lw-primary-deep, #BE4327);
  font-size: 1.7rem; line-height: 1; font-family: inherit;
  box-shadow: 0 4px 12px rgba(30,42,74,.22);
  transition: transform .18s var(--lw-ease-pop, ease), opacity .2s;
  display: grid; place-items: center; padding-bottom: 4px;
}
.chev.prev { left: 8px; } .chev.next { right: 8px; }
.chev:hover, .chev:focus-visible { transform: translateY(-50%) scale(1.12); }
.chev:disabled { opacity: .35; cursor: default; transform: translateY(-50%); }

/* ---------------------------------------------------------------- progress */
.progress {
  position: absolute; top: 8px; left: 50%; transform: translateX(-50%);
  z-index: 8; display: flex; flex-direction: column; align-items: center; gap: 4px;
  pointer-events: none;
}
.progress-label {
  background: rgba(30,42,74,.55); color: #fff;
  font-size: .72rem; font-weight: 600; letter-spacing: .02em;
  padding: 3px 12px; border-radius: 999px;
  backdrop-filter: blur(4px);
}
.progress-segs { display: flex; gap: 3px; }
.progress-segs i {
  width: 12px; height: 5px; border-radius: 3px;
  background: rgba(255,255,255,.45);
  transition: background .3s ease;
}
.progress-segs i.on { background: var(--lw-sun, #FFC94D); }
.progress-segs i.complete { background: var(--lw-leaf, #7ED985); }

/* ---------------------------------------------------------------- buddy */
.buddy {
  position: absolute; left: 8px; bottom: 6px; z-index: 9;
  width: clamp(64px, 17%, 110px);
  pointer-events: none;
}
.buddy img { width: 100%; display: block; filter: drop-shadow(0 6px 10px rgba(30,42,74,.35)); }
.buddy.buddy-pop img { animation: lw-buddy-pop .55s var(--lw-ease-pop, cubic-bezier(.34,1.56,.64,1)); }
@keyframes lw-buddy-pop {
  0% { transform: scale(.82) rotate(-4deg); }
  55% { transform: scale(1.12) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}
.buddy-bubble {
  position: absolute; bottom: 92%; left: 45%;
  min-width: 130px; max-width: 220px;
  background: var(--lw-surface, #fff); color: var(--lw-ink, #1E2A4A);
  font-size: .8rem; font-weight: 600; line-height: 1.3;
  padding: 8px 12px; border-radius: 14px 14px 14px 4px;
  box-shadow: 0 6px 16px rgba(30,42,74,.25);
  opacity: 0; transform: translateY(6px) scale(.9); transform-origin: bottom left;
  transition: opacity .25s ease, transform .3s var(--lw-ease-pop, ease);
}
.buddy-bubble.show { opacity: 1; transform: translateY(0) scale(1); }

/* ---------------------------------------------------------------- caption + strip */
.caption-row {
  display: flex; align-items: flex-start; gap: 10px;
  background: var(--lw-surface, #fff);
  border-radius: var(--lw-radius, 16px);
  padding: 10px 14px;
  box-shadow: 0 4px 14px rgba(30,42,74,.08);
  min-height: 58px;
}
.narr-replay {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  border: 0; cursor: pointer; font-size: 1.1rem;
  background: var(--lw-bg-warm, #FFF0E8);
  transition: transform .18s var(--lw-ease-pop, ease);
}
.narr-replay:hover, .narr-replay:focus-visible { transform: scale(1.1); }
.narr-replay.playing { animation: lw-pulse-ring 1.2s ease infinite; }
.caption {
  margin: 4px 0 0; font-size: .95rem; line-height: 1.45; color: var(--lw-ink, #1E2A4A);
}

.strip[hidden] { display: none; }
.strip {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: #EAF6FF;
  border: 1.5px dashed var(--lw-sky, #58B7E6);
  border-radius: var(--lw-radius, 16px);
  padding: 8px 12px;
}
.strip-title {
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: #2A6E96;
}
.strip-words { display: flex; gap: 8px; flex-wrap: wrap; }
.target-chip {
  display: inline-flex; align-items: center; gap: 7px;
  border: 0; cursor: pointer;
  background: var(--lw-surface, #fff);
  border-radius: 999px; padding: 6px 12px;
  box-shadow: 0 2px 8px rgba(30,42,74,.1);
  font-family: inherit;
  transition: transform .15s var(--lw-ease-pop, ease);
}
.target-chip:hover, .target-chip:focus-visible { transform: scale(1.05); }
.target-chip .tw { font-weight: 700; color: var(--lw-ink, #1E2A4A); }
.target-chip .tt { font-size: .7rem; color: #6b7a99; }
.target-chip .tick { color: var(--lw-leaf, #7ED985); font-weight: 800; opacity: 0; transition: opacity .25s; }
.target-chip.hit .tick { opacity: 1; }
.target-chip.hit { background: #F0FBF1; }

/* ---------------------------------------------------------------- toolbar */
.toolbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.dial-slot { flex: 0 1 auto; }
.tool-btns { display: flex; gap: 8px; margin-left: auto; }
.tool-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: var(--lw-tap-min, 44px); min-height: var(--lw-tap-min, 44px);
  padding: 5px 10px; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--lw-surface, #fff);
  box-shadow: 0 2px 8px rgba(30,42,74,.1);
  font-family: inherit;
  transition: transform .15s var(--lw-ease-pop, ease), background .2s;
}
.tool-btn .ic { font-size: 1.05rem; line-height: 1; }
.tool-btn .tb-label { font-size: .62rem; font-weight: 700; color: #6b7a99; letter-spacing: .02em; }
.tool-btn:hover, .tool-btn:focus-visible { transform: scale(1.07); }
.tool-btn.is-on { background: var(--lw-primary, #F28B6E); }
.tool-btn.is-on .tb-label, .tool-btn.is-on .ic { color: #fff; }

/* ---------------------------------------------------------------- splash */
.splash {
  position: absolute; inset: 0; z-index: 30;
  border-radius: var(--lw-radius-lg, 22px);
  background: linear-gradient(180deg, #BEE9F5, #FFE0B8);
  background-size: cover; background-position: center;
  display: grid; place-items: center;
  text-align: center;
  overflow: hidden;
  transition: opacity .4s ease, transform .4s ease;
}
.splash.bye { opacity: 0; transform: scale(1.05); pointer-events: none; }
.splash-inner { padding: 24px; max-width: 480px; }
.splash-buddy {
  width: clamp(96px, 26vw, 150px);
  filter: drop-shadow(0 10px 18px rgba(30,42,74,.4));
  animation: lw-wiggle 2.6s ease-in-out infinite;
}
.splash h1 {
  font-family: var(--lw-font-display, sans-serif);
  color: #fff; text-shadow: 0 3px 14px rgba(30,42,74,.55);
  font-size: clamp(1.7rem, 6vw, 2.6rem); margin: .35em 0 .15em;
}
.splash-sub { color: #fff; text-shadow: 0 2px 8px rgba(30,42,74,.55); font-weight: 600; margin: 0 0 18px; }
.splash-start { font-size: 1.1rem; }
.splash-hint {
  color: #fff; text-shadow: 0 2px 8px rgba(30,42,74,.6);
  font-size: .85rem; margin-top: 16px; opacity: .95;
}

/* ---------------------------------------------------------------- quiz */
.quiz-overlay {
  position: absolute; inset: 0; z-index: 40;
  background: rgba(30, 42, 74, .45);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 14px;
  border-radius: var(--lw-radius-lg, 22px);
}
.quiz-card {
  position: relative;
  width: min(460px, 100%);
  max-height: 100%; overflow: auto;
  text-align: center;
  padding: 22px 20px;
  animation: lw-pop-in .4s var(--lw-ease-pop, cubic-bezier(.34,1.56,.64,1));
}
.quiz-buddy { width: 84px; filter: drop-shadow(0 6px 12px rgba(30,42,74,.3)); }
.quiz-buddy.big { width: 120px; animation: lw-wiggle 2.4s ease-in-out infinite; }
.quiz-card h2 {
  font-family: var(--lw-font-display, sans-serif);
  color: var(--lw-ink, #1E2A4A);
  font-size: 1.25rem; margin: .5em 0 .8em;
}
.quiz-top { text-align: left; }
.quiz-count {
  font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  color: var(--lw-primary-deep, #BE4327);
}
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.quiz-choice {
  border: 2px solid var(--lw-bg-warm, #FFF0E8);
  background: var(--lw-bg, #FFFBF5);
  border-radius: 16px; padding: 14px 10px;
  font-family: inherit; font-weight: 700; font-size: .95rem;
  color: var(--lw-ink, #1E2A4A); cursor: pointer;
  min-height: var(--lw-tap-min, 44px);
  transition: transform .15s var(--lw-ease-pop, ease), background .2s, border-color .2s, opacity .2s;
}
.quiz-choice:hover:not(:disabled), .quiz-choice:focus-visible { transform: scale(1.04); border-color: var(--lw-primary, #F28B6E); }
.quiz-choice.correct { background: #F0FBF1; border-color: var(--lw-leaf, #7ED985); animation: lw-bounce-tap .5s var(--lw-ease-pop, ease); }
.quiz-choice.dim { opacity: .45; }
.quiz-encourage { min-height: 1.4em; font-weight: 600; color: #2A6E96; margin: 12px 0 0; }
.quiz-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; }
.cele-sub { color: var(--lw-ink, #1E2A4A); font-size: 1rem; margin: 0 0 16px; }

/* ---------------------------------------------------------------- error */
.story-error { max-width: 420px; margin: 60px auto; text-align: center; padding: 28px; }
.story-error h2 { font-family: var(--lw-font-display, sans-serif); }

/* ---------------------------------------------------------------- fullscreen */
#player:fullscreen, #player:-webkit-full-screen { background: var(--lw-bg, #FFFBF5); padding: 10px; overflow: auto; }
#player:fullscreen .stage, #player:-webkit-full-screen .stage { max-height: 74vh; }
body.faux-full { overflow: hidden; }
body.faux-full #player {
  position: fixed; inset: 0; z-index: 999;
  background: var(--lw-bg, #FFFBF5);
  padding: 10px; overflow: auto;
}
body.faux-full .stage { max-height: 74vh; }
body.is-full .lw-sitenav { display: none; }

/* ---------------------------------------------------------------- desktop */
@media (min-width: 760px) {
  .story-page main { padding: 14px 20px 40px; }
  .stage { max-height: 66vh; }
  .caption { font-size: 1.08rem; }
  .progress-segs i { width: 18px; }
  .buddy-bubble { font-size: .9rem; }
  .chev { width: 52px; height: 52px; }
}

/* ---------------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  .scene-layer, .scene-layer.enter.in, .scene-layer.out { transition: opacity .2s linear; transform: none !important; }
  .hotspot::before, .splash-buddy, .quiz-buddy.big, .buddy.buddy-pop img { animation: none; }
  .hotspot.active { animation: none; }
}
