/*
 * web/landing/shells/ReaderFlow.css - text a character reads out (web/landing/shells/ReaderFlow.js
 * documents the markup). A section imports it at the top of its own sheet:
 *   @import url('/web/landing/shells/ReaderFlow.css');
 *
 * Generic only: the registers, the lit word, the choices and the two layouts. A beat sizes,
 * places and dresses its flow in sections/<id>.css, scoped by [data-beat].
 *
 * The registers are the brand's typographic device: narration is the book voice (the
 * serif, italic, muted, set off by a rule, as the app's narration is), speech is the
 * character's own (the sans, upright), and a thought is hers unspoken (the sans, italic,
 * in the accent and set back), each as web/style.css sets it in the chat. The word being
 * said is lit as the chat lights it (web/word-lights.js): a violet tint behind the word
 * and a soft glow of its own colour, nothing that moves the text, so a line never
 * reflows under the reader.
 */

.reader-flow {
  min-width: 0;
  display: grid;
  gap: 12px;
}

.reader-flow-segments {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.reader-flow-segment {
  min-width: 0;
  overflow-wrap: break-word;
}

.reader-flow-text {
  margin: 0;
  text-wrap: pretty;
}

.reader-flow-label {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

/* ── The registers ────────────────────────────────────────────────────── */

.reader-flow-segment[data-register="narration"] .reader-flow-text,
.reader-flow-segment[data-register="narration"]:not(:has([data-segment-text])) {
  font-family: var(--serif);
  font-style: italic;
  color: var(--muted);
  border-left: 2px solid var(--line);
  padding-left: 14px;
}

.reader-flow-segment[data-register="speech"] .reader-flow-text,
.reader-flow-segment[data-register="speech"]:not(:has([data-segment-text])) {
  font-family: var(--sans);
  font-style: normal;
  color: var(--text);
}

.reader-flow-segment[data-register="thought"] .reader-flow-text,
.reader-flow-segment[data-register="thought"]:not(:has([data-segment-text])) {
  font-family: var(--sans);
  font-style: italic;
  color: var(--accent);
  opacity: .72;
}

/* ── The word being said ──────────────────────────────────────────────── */

.reader-flow .w {
  border-radius: 3px;
  transition: background-color .08s ease, box-shadow .08s ease, text-shadow .08s ease;
}

.reader-flow .w.on {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
  text-shadow: 0 0 8px color-mix(in srgb, currentColor 45%, transparent);
}

/* A word is a place to start from once its line has timings. */
.reader-flow-segment[data-seekable] .w { cursor: pointer; }

.reader-flow-segment[data-seekable] .w:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 12%, transparent);
}

.reader-flow-segment[data-seekable] .w.on:hover {
  background: color-mix(in srgb, var(--accent) 24%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent);
}

/* ── The choices ──────────────────────────────────────────────────────── */

.reader-flow-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.reader-flow-choices[hidden] { display: none; }

.reader-flow-choice {
  min-height: 36px;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
}

.reader-flow-choice:hover { border-color: var(--muted); }

/* The chosen one is the reader's own line: the accent, as the chat sets the user's bubble. */
.reader-flow-choice[aria-pressed="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* With the script running, the choices stand for the labels a reader without one needs. */
.reader-flow[data-reader-js][data-has-choices] [data-segment-label] { display: none; }

/* ── The layouts ──────────────────────────────────────────────────────── */

/* column: every segment, the one being read marked by a rule in the accent. */
.reader-flow[data-reader-js][data-layout="column"] .reader-flow-segment {
  padding-left: 12px;
  border-left: 2px solid transparent;
  transition: border-color .15s;
}

.reader-flow[data-reader-js][data-layout="column"] .reader-flow-segment[data-active] { border-left-color: var(--accent); }

/* panel: one exchange at a time - the active segment, and the chosen choice once one is. */
.reader-flow[data-reader-js][data-layout="panel"] .reader-flow-segment:not([data-active]) { display: none; }
.reader-flow[data-reader-js][data-layout="panel"][data-chosen] .reader-flow-choice:not([aria-pressed="true"]) { display: none; }
.reader-flow[data-reader-js][data-layout="panel"][data-chosen] .reader-flow-choices { justify-content: flex-end; }
