/*
 * Beat branching-dialogue: Lantern Gate, an adventure game's dialogue screen with Mika
 * answering the player's choice (web/landing/sections/branching-dialogue.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 (branching-dialogue-lantern) is styled here and nowhere else.
 *
 * Layout: the copy on the left, the Lantern Gate window on the right (guided-onboarding's
 * mirror); one column below 1024 px. In the window, top to bottom: the game's bar (the
 * chapter, the route map, the save slot), Mika in her scene band, the dialogue box, the
 * two choices (side by side from 560 px of frame, full width and stacked below it).
 *
 * The warmth is typographic, in the palette: the chapter and the dialogue in the serif
 * (upright, weight 500: the game's book voice, never bold), the speaker's name and the
 * choices in the sans, the save slot in mono. The route map is two hairlines from a gate;
 * the chosen path is lit in the accent. Nothing moves but the character.
 */

/* ── The section: the copy beside the window ───────────────────────────── */

@media (min-width: 1024px) {
  .use-case[data-beat="branching-dialogue"] {
    display: grid;
    grid-template-columns: minmax(0, 4fr) minmax(0, 8fr);
    grid-template-areas: "copy frame";
    align-items: center;
    gap: 28px clamp(28px, 4vw, 56px);
  }

  .use-case[data-beat="branching-dialogue"] .use-case-copy { grid-area: copy; }
  .use-case[data-beat="branching-dialogue"] .use-case-mount { grid-area: frame; min-width: 0; }
}

@media (max-width: 1023px) {
  .use-case[data-beat="branching-dialogue"] .use-case-copy { margin-bottom: 24px; }
}

/* ── The window: one slot, the game's screen ───────────────────────────── */

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

[data-beat="branching-dialogue"] .branching-dialogue-screen {
  display: grid;
  gap: 12px;
  min-width: 0;
}

/* The game's bar: chapter, route map, save slot. */
[data-beat="branching-dialogue"] .branching-dialogue-hud {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-areas: "chapter route slot";
  align-items: center;
  gap: 6px 14px;
  min-width: 0;
  padding: 2px 4px 10px;
  border-bottom: 1px solid var(--line);
}

[data-beat="branching-dialogue"] .branching-dialogue-chapter {
  grid-area: chapter;
  margin: 0;
  font-family: var(--serif);
  font-weight: 500;
  font-size: 16px;
  letter-spacing: .02em;
}

[data-beat="branching-dialogue"] .branching-dialogue-route {
  grid-area: route;
  display: block;
  width: 132px;
  height: 40px;
}

[data-beat="branching-dialogue"] .branching-dialogue-route-path {
  fill: none;
  stroke: var(--line);
  stroke-width: 2;
  stroke-linecap: round;
  transition: stroke .15s;
}

[data-beat="branching-dialogue"] .branching-dialogue-route-gate { fill: var(--muted); }
[data-beat="branching-dialogue"] .branching-dialogue-route-end { fill: var(--line); transition: fill .15s; }

[data-beat="branching-dialogue"] [data-route="bridge"] [data-route-path="bridge"],
[data-beat="branching-dialogue"] [data-route="forest"] [data-route-path="forest"] { stroke: var(--accent); }

[data-beat="branching-dialogue"] [data-route="bridge"] [data-route-end="bridge"],
[data-beat="branching-dialogue"] [data-route="forest"] [data-route-end="forest"] { fill: var(--accent); }

[data-beat="branching-dialogue"] .branching-dialogue-slot {
  grid-area: slot;
  justify-self: end;
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
}

@container demo-frame (max-width: 479px) {
  [data-beat="branching-dialogue"] .branching-dialogue-hud {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "chapter slot" "route route";
  }

  [data-beat="branching-dialogue"] .branching-dialogue-route { justify-self: center; }
}

/* Mika in her scene band. */
[data-beat="branching-dialogue"] .branching-dialogue-portrait {
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel-2), var(--ink));
}

[data-beat="branching-dialogue"] .branching-dialogue-mika { width: min(100%, 288px); }

/* ── The dialogue box and the choices ──────────────────────────────────── */

[data-beat="branching-dialogue"] .branching-dialogue-flow { gap: 10px; }

[data-beat="branching-dialogue"] .branching-dialogue-box {
  min-width: 0;
  min-height: 96px;
  padding: 12px 16px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel-2);
}

[data-beat="branching-dialogue"] .branching-dialogue-speaker {
  margin: 0 0 6px;
  min-height: 1.4em;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
}

/* Her line: the game's book voice, upright. */
[data-beat="branching-dialogue"] .branching-dialogue-flow .reader-flow-segment[data-register="speech"] .reader-flow-text {
  font-family: var(--serif);
  font-weight: 500;
  font-size: clamp(17px, 2.2cqi, 20px);
  line-height: 1.5;
}

/* Before a choice the box waits: three quiet dots, and nothing in it moves. */
[data-beat="branching-dialogue"] .branching-dialogue-waiting {
  display: flex;
  gap: 6px;
  padding: 10px 0 4px;
}

[data-beat="branching-dialogue"] .branching-dialogue-waiting i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted);
  opacity: .55;
}

[data-beat="branching-dialogue"] .branching-dialogue-flow:not([data-reader-js]) .branching-dialogue-waiting,
[data-beat="branching-dialogue"] .branching-dialogue-flow[data-active] .branching-dialogue-waiting { display: none; }

/* With no script each line stands under its choice's name. */
[data-beat="branching-dialogue"] .branching-dialogue-flow:not([data-reader-js]) .reader-flow-segments { gap: 14px; }

/* The choices: full width, stacked; side by side once the frame is wide. The chosen one is
   the player's line (the shell hides the other), in the accent, under its route's side. */
[data-beat="branching-dialogue"] .branching-dialogue-choices {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

[data-beat="branching-dialogue"] .branching-dialogue-choices[hidden] { display: none; }

@container demo-frame (min-width: 560px) {
  [data-beat="branching-dialogue"] .branching-dialogue-choices { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  [data-beat="branching-dialogue"] .branching-dialogue-flow[data-chosen="forest"] .branching-dialogue-choice[data-choice="forest"] { grid-column: 2; }
}

[data-beat="branching-dialogue"] .branching-dialogue-choice {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--panel);
  font-size: 14.5px;
}

[data-beat="branching-dialogue"] .branching-dialogue-choice-mark {
  flex: none;
  width: 7px;
  height: 7px;
  background: var(--muted);
  transform: rotate(45deg);
}

[data-beat="branching-dialogue"] .branching-dialogue-choice[aria-pressed="true"] .branching-dialogue-choice-mark { background: var(--accent-ink); }

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

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