* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: linear-gradient(180deg, #07101f 0%, #0d1d34 40%, #13233b 100%);
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
}
.story { width: 100%; }

/* LSQS-P0-STORYBOOK-QUALITY-001/C2: image-dominant storybook layout.
   The pre-C1 rules pinned `min-height: 100vh` + `justify-content: center`
   on every panel and capped the image at `max-height: 80vh` /
   `width: auto`, which made the illustrations feel small on a
   1280x633 viewport (the first image rendered at 1178x483 with ~150px
   of dead space above and below). The C1 fix — landed on
   `stories/template/t_styles.css` (b8b6c19) and on the
   `lucca-and-the-tidepool-friend` per-story stylesheet — drops the
   100vh cap, switches the image to `width: 100%; max-width: 1200px`,
   and adds a soft opacity/translate fade-in tied to the existing
   `.panel.visible` IntersectionObserver hook.

   This block is the source of truth: any future `build_publish_folder`
   call writes THIS stylesheet (not the historical Flask template),
   so newly packaged stories inherit the picture-book reading flow
   without a manual template-paste step. The selector names
   (`.panel`, `.panel img`, `.panel.end`, `.end-text`,
   `.panel.visible`) match the elements `_render_panels` emits, so
   the packager HTML remains a drop-in consumer. */
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 4vh 4vw;
  max-width: 1400px;
  margin: 0 auto;
}
.panel img {
  display: block;
  width: 100%;
  max-width: 1200px;
  /* LSQS-LAYOUT-FIX-001: page-N.png assets are 1024x1536 portrait (2:3)
     with ~13% cream sky/ground padding baked into the top and bottom of
     every illustration. At natural aspect, those padding bands render
     as large empty horizontal stripes flanking the character. Force
     the image element to a 3:2 landscape box and let object-fit: cover
     crop the empty sky/ground symmetrically (keeping the middle ~75%
     of the source). This is the standard picture-book reader pattern
     (Kindle / Apple Books) and the cheapest way to remove the dead
     space without re-rendering the underlying PNGs. */
  aspect-ratio: 3 / 2;
  object-fit: cover;
  object-position: center;
  border-radius: 18px;
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.35),
    0 4px 18px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transform: translateY(32px) scale(0.985);
  transition: opacity 1000ms ease, transform 1000ms ease;
}
.panel.visible img {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.panel.end {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
  font-weight: 700;
  text-align: center;
}
.end-text {
  background: rgba(255, 255, 255, 0.08);
  padding: 1.5rem 2.5rem;
  border-radius: 16px;
  opacity: 0;
  transform: translateY(20px) scale(0.99);
  transition: opacity 1000ms ease, transform 1000ms ease;
}
.panel.visible .end-text {
  opacity: 1;
  transform: translateY(0) scale(1);
}

@media (max-width: 768px) {
  .panel {
    padding: 3vh 1.5vw;
    gap: 1rem;
  }
  .panel img {
    max-width: 100%;
    border-radius: 12px;
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .panel img,
  .end-text {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* LSQS-STORY-TEXT-001: per-page narrative caption.
   When the story spec carries a per-page `text` field, the
   packager emits a <p class="page-text"> beneath the image.
   The caption is age-appropriate (large, calm, high-contrast on a
   translucent backdrop) and reads aloud well. The default font
   (Arial) is the parent body's font — no extra asset is loaded.
   The block is optional: stories without per-page text do not
   render the element, so legacy / audio-only stories are
   visually unchanged. */
.page-text {
  margin: 1.5rem auto 0;
  max-width: 38rem;
  padding: 1rem 1.5rem;
  background: rgba(255, 255, 255, 0.10);
  border-radius: 14px;
  font-size: clamp(1.05rem, 2.4vw, 1.4rem);
  line-height: 1.5;
  text-align: center;
  color: #fff;
  font-weight: 500;
  letter-spacing: 0.01em;
  text-wrap: balance;
  /* Soften the caption's backdrop so the image behind it stays
     the focal element on small screens. */
  backdrop-filter: blur(2px);
}
.page-text--missing {
  /* Defensive fallback for legacy stories that previously
     published page text into the prompt bundle but whose new
     run dropped the field. The packager itself NEVER emits
     .page-text--missing; only a downstream consumer (manual
     fix-up, future gate) should inject it. */
  font-style: italic;
  color: rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.04);
}

/* LSQS-094 / LSQS-VOICE-002b AC4: per-page narration controls. */
.audio-control {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.5rem 0.75rem;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  backdrop-filter: blur(4px);
}
.audio-control audio { display: none; }
.audio-control .audio-play {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}
.audio-control .audio-play:hover {
  background: rgba(255, 255, 255, 0.32);
}
.audio-control .audio-volume {
  width: 8rem;
  accent-color: #fff;
  cursor: pointer;
}
.audio-control--missing {
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.55);
  font-size: 0.85rem;
  font-style: italic;
}
.audio-control--missing .audio-missing-label {
  padding: 0 0.25rem;
}
