/* ---------------- the speech boxes ----------------
   Styles for host/dialogue.js. Brief: docs/tv-scene-phases-spec.md

   Above the drawing (z-index 19) and the researcher's panel (20) — they never share the
   screen, and the overlay earns its inset the same way #survey does: transparent, over
   everything, so a tap during the dialogue cannot fall through into the prototype. */

#dialogue { position: fixed; inset: 0; z-index: 21; }
#dialogue[hidden] { display: none; }
/* Over the open programme (28) instead, and only the box takes a press: the booklet's
   moments must stay clickable through the layer, and its backdrop reads on for us. */
#dialogue.dlg-over { z-index: 29; pointer-events: none; }
#dialogue.dlg-over .dlg-box { pointer-events: auto; }

/* max-content until it reaches the max-width script measures against the drawing, and
   then it wraps — dialogue.js's sizeToFull() measures the finished line this way once
   and locks the result as an explicit width/height, so typing it out doesn't reflow the
   box underneath itself. Anchored by its bottom-right corner, so a longer line grows up
   and to the left and leaves the placed corner where it was put — the speaker stands to
   the right of the box and the gap to them never changes. */
.dlg-box {
  --dlg-scale: 1;
  position: absolute;
  width: max-content;
  padding: calc(10px * var(--dlg-scale)) calc(14px * var(--dlg-scale));
  background: #000;
  border: 1px solid #fff;
  color: #fff;
  font-size: calc(15px * var(--dlg-scale));
  line-height: 1.45;
  cursor: pointer;
  user-select: none;
}
/* The developer speaks out of the fiction: orange, apart from everyone in it. */
.dlg-box[data-who="developer"] { color: #ff9d3d; }

/* A stack (dialogue.js stack()): lines up together, each placed on its own page by its
   top-left corner. The live box goes where the line it is saying stands. Already said
   lingers in place, faint, the booklet showing through; not yet said is not there at
   all — except while placing them (the editor), when it is faint too. */
.dlg-stack { position: absolute; inset: 0; pointer-events: none; }
.dlg-stack .dlg-box { pointer-events: auto; }
.dlg-box[hidden], .dlg-slot[hidden] { display: none; }
.dlg-slot.dlg-past { opacity: .35; }
.dlg-slot.dlg-ahead { display: none; }
#dialogue.dlg-placing .dlg-slot.dlg-ahead { display: block; opacity: .35; }
/* The part of a stacked line not typed yet: its dim text, which the typing brightens. */
.dlg-rest { opacity: .35; }

/* The block that says there is more. A hard blink rather than a fade — it is a terminal
   cursor, not a glow. Only once the line has fully typed out (dialogue.js removes
   dlg-typing on settle()) — while it's still being typed, the blink itself would read
   as another kind of "more to come" and fight the one the typing already gives. */
.dlg-caret {
  display: inline-block;
  width: .55em; height: 1em;
  margin-left: .35em;
  vertical-align: -.15em;
  background: #fff;
  animation: dlg-blink 1s steps(1, end) infinite;
}
.dlg-box.dlg-typing .dlg-caret, .dlg-box.dlg-held .dlg-caret { animation: none; opacity: 0; }
/* CARET_ARROW in dialogue.js: the block's off beat is the Enter key's return arrow,
   drawn to the block's own box so the two trade places without anything moving. The
   whole element blinks between them, rather than on and off. crispEdges and square caps
   keep the arrow as blocky as the block. */
.dlg-caret.dlg-caret-arrow { animation: dlg-blink-arrow 1s steps(1, end) infinite; }
.dlg-caret svg { display: none; }
.dlg-caret-arrow svg { display: block; width: 100%; height: 100%; opacity: 0;
  animation: dlg-blink-arrow-svg 1s steps(1, end) infinite; }
.dlg-caret-arrow path { fill: none; stroke: #fff; stroke-width: 2.5; stroke-linecap: square;
  stroke-linejoin: miter; shape-rendering: crispEdges; }
.dlg-box.dlg-typing .dlg-caret-arrow svg, .dlg-box.dlg-held .dlg-caret-arrow svg { animation: none; }
@keyframes dlg-blink-arrow { 0%, 50% { background: #fff } 50.01%, 100% { background: transparent } }
@keyframes dlg-blink-arrow-svg { 0%, 50% { opacity: 0 } 50.01%, 100% { opacity: 1 } }
@keyframes dlg-blink { 0%, 50% { opacity: 1 } 50.01%, 100% { opacity: 0 } }

/* ---------- placing ----------
   Only while the tv-scene editor's dialogue tab is up. Nothing here reaches a player. */

#dialogue.dlg-placing .dlg-box { cursor: move; }
