* { 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-UX-003: centered title block (visual hierarchy fix).
   The language toggle, hero image, and audio controls are all
   visually centered, but the story title / subtitle / feature-note
   were left-aligned by default — making the header feel disconnected
   from the rest of the hero. This block constrains the header to the
   same content width as the panels (.panel { max-width: 1400px }) and
   centers its text, so the title block aligns with the hero image and
   audio column. Pure CSS — no HTML structural changes. */
.story-header {
  text-align: center;
  max-width: 1400px;
  margin: 0 auto;
  padding: 5vh 4vw 2vh;
}
.story-title {
  font-size: clamp(1.8rem, 4.5vw, 3.2rem);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: -0.01em;
  /* width:fit-content + margin:0 auto shrinks the H1 box to the
     actual text width, then centers that box within .story-header
     so the title's left/right margins match the viewport center
     exactly. Without this, the H1 fills the parent and `margin:
     auto` resolves to 0, leaving centering to the parent's
     text-align: center alone — which renders correctly per the DOM
     but reads as "left of center" to the eye when the title is
     wider than the page-1 image below it. fit-content makes the
     centering visually unambiguous at every viewport width.
     LSQS-WATERFALL-EN-PUBLISH-READY-001 / LSQS-UX-003 v2. */
  width: fit-content;
  max-width: 100%;
  margin: 0 auto 0.6rem;
  text-wrap: balance;
  /* Inherits text-align:center from .story-header so the H1's
     internal text-align is correct on the rare browser that
     doesn't pick up the parent's text-align when the H1 is
     fit-content-sized. Belt-and-braces for the LSQS-UX-003 v2
     follow-up. */
  text-align: center;
}
.story-subtitle {
  font-size: clamp(1.05rem, 2.2vw, 1.4rem);
  font-weight: 400;
  line-height: 1.45;
  width: fit-content;
  max-width: 48ch;
  margin: 0 auto 1rem;
  opacity: 0.85;
  text-wrap: balance;
  text-align: center;
}
.feature-note {
  font-size: clamp(0.9rem, 1.8vw, 1.05rem);
  line-height: 1.5;
  width: fit-content;
  max-width: 48ch;
  margin: 0 auto;
  opacity: 0.7;
  font-style: italic;
  text-align: center;
}
@media (max-width: 768px) {
  .story-header {
    padding: 3vh 1.5vw 1.5vh;
  }
  .story-title {
    max-width: 100%;
  }
  .story-subtitle,
  .feature-note {
    max-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;
  height: auto;
  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;
}
