/*
 * Beat storybook-narrator: Moonpath, a storybook reader open on a spread, Pip as the
 * left page's illustration plate and the story on the right (web/landing/sections/
 * storybook-narrator.html). Linked in the page head by lib/landing.ts while the beat is
 * enabled; the shells' sheets it builds on are linked by the page itself, once each and
 * before every section sheet. Every class here starts with the beat id, and every rule
 * is scoped by [data-beat]: the frame's variant (storybook-narrator-moonpath) is styled
 * here and nowhere else.
 *
 * Layout: the copy as a header across the top (the title on the left, the body beside it),
 * the Moonpath window full width below, the book a two-page spread with a soft gutter from
 * 720 px of frame. Below that it is ONE page, no gutter: Pip's plate above the story.
 *
 * The registers are the type: narration in the serif italic (the book voice), Pip's spoken
 * line in the sans between quotes, his thought in the sans italic in parentheses, set back
 * in the accent; all of it large. The quotes and parentheses are typography drawn here, so
 * each segment's text stays its capture's transcript word for word. The moon, the stars,
 * the hedges and the gate are line drawings in the palette; nothing on the page moves but
 * Pip, and the progress line's fill.
 */

/* ── The copy, as a header ─────────────────────────────────────────────── */

.use-case[data-beat="storybook-narrator"] .use-case-copy {
  display: grid;
  grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
  grid-template-areas:
    "eyebrow eyebrow"
    "title body";
  align-items: end;
  gap: 0 clamp(28px, 5vw, 72px);
  margin: 0 0 clamp(24px, 4vh, 36px);
}

.use-case[data-beat="storybook-narrator"] .use-case-eyebrow { grid-area: eyebrow; }
.use-case[data-beat="storybook-narrator"] .use-case-title { grid-area: title; margin: 0; }
.use-case[data-beat="storybook-narrator"] .use-case-body { grid-area: body; padding-bottom: 6px; }

@media (max-width: 860px) {
  .use-case[data-beat="storybook-narrator"] .use-case-copy {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "eyebrow" "title" "body";
  }

  .use-case[data-beat="storybook-narrator"] .use-case-title { margin: 0 0 16px; }
}

/* ── The window: one slot, the book ────────────────────────────────────── */

[data-beat="storybook-narrator"] .demo-frame-body {
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "main";
}

[data-beat="storybook-narrator"] .storybook-narrator-book {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
  overflow: hidden;
}

@container demo-frame (min-width: 720px) {
  [data-beat="storybook-narrator"] .storybook-narrator-book {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    /* The gutter: the two pages meet in a soft fold. */
    background:
      linear-gradient(90deg, transparent calc(50% - 22px), rgb(0 0 0 / .22) 50%, transparent calc(50% + 22px)),
      var(--panel-2);
  }
}

[data-beat="storybook-narrator"] .storybook-narrator-page {
  position: relative;
  min-width: 0;
  padding: clamp(18px, 3.4cqi, 36px) clamp(18px, 3.6cqi, 40px) 44px;
}

/* ── The left page: Pip's plate between the sky and the garden ─────────── */

[data-beat="storybook-narrator"] .storybook-narrator-page-art {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
}

[data-beat="storybook-narrator"] .storybook-narrator-sky,
[data-beat="storybook-narrator"] .storybook-narrator-garden {
  display: block;
  width: min(100%, 340px);
  height: auto;
}

[data-beat="storybook-narrator"] .storybook-narrator-moon { fill: var(--muted); opacity: .8; }
[data-beat="storybook-narrator"] .storybook-narrator-star { fill: var(--muted); opacity: .7; }

[data-beat="storybook-narrator"] .storybook-narrator-hedge,
[data-beat="storybook-narrator"] .storybook-narrator-gate,
[data-beat="storybook-narrator"] .storybook-narrator-ground {
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: .7;
}

/* The plate: the illustration set into the page with a hairline, as a book prints it. */
[data-beat="storybook-narrator"] .storybook-narrator-plate {
  width: min(100%, 340px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

[data-beat="storybook-narrator"] .storybook-narrator-pip { border-radius: 3px; }

/* ── The right page: the story ─────────────────────────────────────────── */

[data-beat="storybook-narrator"] .storybook-narrator-page-text {
  display: grid;
  align-content: center;
  gap: 22px;
}

[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segments { gap: 18px; }
[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segment[hidden] { display: none; }

/* The book voice: the serif italic, the page's main text, so in the text colour and with
   no rule of its own (the segment being read has the column's accent rule). */
[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segment[data-register="narration"] .reader-flow-text {
  font-size: clamp(20px, 2.6cqi, 26px);
  line-height: 1.5;
  color: var(--text);
  border-left: 0;
  padding-left: 0;
}

/* Pip's line: the sans, upright, between quotes. */
[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segment[data-register="speech"] .reader-flow-text {
  font-size: clamp(19px, 2.4cqi, 23px);
  line-height: 1.5;
}

[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segment[data-register="speech"] .reader-flow-text::before { content: "\201C"; }
[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segment[data-register="speech"] .reader-flow-text::after { content: "\201D"; }

/* His thought: the sans italic, set back, in parentheses. */
[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segment[data-register="thought"] .reader-flow-text {
  font-size: clamp(17px, 2.1cqi, 20px);
  line-height: 1.5;
}

[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segment[data-register="thought"] .reader-flow-text::before { content: "("; }
[data-beat="storybook-narrator"] .storybook-narrator-flow .reader-flow-segment[data-register="thought"] .reader-flow-text::after { content: ")"; }

/* Reading progress: a hairline under the story, filled in the accent as it is read. */
[data-beat="storybook-narrator"] .storybook-narrator-progress {
  height: 2px;
  border-radius: 2px;
  background: var(--line);
  overflow: hidden;
}

[data-beat="storybook-narrator"] .storybook-narrator-progress-fill {
  display: block;
  height: 100%;
  width: calc(var(--storybook-narrator-progress, 0) * 100%);
  background: var(--accent);
}

/* Page numbers, at the outer corners. */
[data-beat="storybook-narrator"] .storybook-narrator-folio {
  position: absolute;
  bottom: 14px;
  margin: 0;
  font-family: var(--serif);
  font-size: 13px;
  color: var(--muted);
}

[data-beat="storybook-narrator"] .storybook-narrator-page-art .storybook-narrator-folio { left: 22px; }
[data-beat="storybook-narrator"] .storybook-narrator-page-text .storybook-narrator-folio { right: 22px; }

/* One page: no gutter, and the page is numbered once. */
@container demo-frame (max-width: 719px) {
  [data-beat="storybook-narrator"] .storybook-narrator-page-art { padding-bottom: 8px; }
  [data-beat="storybook-narrator"] .storybook-narrator-page-art .storybook-narrator-folio { display: none; }
  [data-beat="storybook-narrator"] .storybook-narrator-page-text { padding-top: 10px; }
}

/* ── The foot ──────────────────────────────────────────────────────────── */

[data-beat="storybook-narrator"] .storybook-narrator-icon { width: 11px; height: 11px; flex: none; }
[data-beat="storybook-narrator"] .storybook-narrator-icon[hidden] { display: none; }
[data-beat="storybook-narrator"] .storybook-narrator-status { margin-left: auto; }
