/*
 * Play: the stage and what stands around it. The stage is the design's fifth
 * figure frame, the one that holds a world and not a scene. It is as wide as
 * its column and never taller than a screen, a hairline around it because
 * the world inside it is clipped. Everything on it is a glyph of `draw.js`
 * placed in space, so no colour is set here but through a slot.
 *
 * The words around it are the library's own: `.qs-kicker`, the steps of
 * `figures.css`, `.qs-action`, `.qs-code`. This file adds only their places.
 */

/* `.qs-play-room` is the room the parts ask about. Where it is wide, the
   words stand beside the stage, so a step is read while it plays. Where it
   is narrow they stand under it, and a film shows its playing step alone. */
.qs-play-room {
  container: qs-play / inline-size;
}

.qs-play {
  display: grid;
  gap: var(--nv-space-5, 1.5rem);
}

@container qs-play (min-width: 60rem) {
  .qs-play {
    grid-template-columns: minmax(0, 1.9fr) minmax(19rem, 1fr);
    column-gap: var(--nv-space-6, 2rem);
    align-items: start;
  }
}

@container qs-play (max-width: 40rem) {
  .qs-play[data-playing] .qs-scene-steps li:not([data-now]) {
    display: none;
  }
}

/* ---- the frame ---- */

.qs-play-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  max-height: 82vh;
  overflow: hidden;
  border: 1px solid var(--nv-color-border);
  border-radius: var(--nv-radius-lg);
  background: var(--nv-color-bg);
  perspective: 1400px;
  touch-action: none;
  cursor: grab;
}

@container qs-play (min-width: 40rem) {
  .qs-play-frame {
    aspect-ratio: 16 / 10;
  }
}

/* An empty world: its one sentence and its one act at the stage's centre,
   so the frame is never a blank box. */
.qs-play-begin {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: var(--nv-space-4, 1rem);
  padding: var(--nv-space-5, 1.5rem);
  text-align: center;
  cursor: default;
}

.qs-play-begin[hidden] {
  display: none;
}

.qs-play-begin p {
  max-width: 24rem;
  margin: 0;
  font-family: var(--nv-font-sans);
  font-size: var(--nv-text-base, 1rem);
  color: var(--nv-color-fg-muted);
}

@container qs-play (min-width: 60rem) {
  .qs-play-frame {
    aspect-ratio: 4 / 3;
  }
}

.qs-play-frame[data-locked] {
  cursor: default;
}

/* ---- the world, and what stands in it ---- */

.qp-world {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 0;
  height: 0;
  transform-style: preserve-3d;
  will-change: transform;
}

.qp-world[hidden] {
  display: none;
}

.qp-house,
.qp-span,
.qp-token {
  position: absolute;
  left: 0;
  top: 0;
}

.qp-span,
.qp-token {
  pointer-events: none;
}

.qp-house .fig,
.qp-span .fig,
.qp-token .fig {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* The fold of a booth, from its red half to its purple half: the edge of
   the graph. It is never thinner than a pixel and a half on the screen,
   however far the camera stands, and it is said quietly where the door
   stopped holding the relation. */
.qp-arc path {
  stroke-width: max(2.5px, calc(1.5px / var(--qp-zoom, 1)));
  opacity: 0.85;
}

.qp-arc[data-faded] path {
  opacity: 0.3;
}

/* While a visit plays, its two houses are read alone. Every other house
   and every fold is said quietly, and a house that stands on the line
   between the two doors draws back, so the one booth is never drawn
   through a third room. */
.qp-house,
.qp-arc path {
  transition: opacity 0.6s;
}

.qp-world[data-visit] .qp-house[data-aside] {
  opacity: 0.4;
}

.qp-world[data-visit] .qp-house[data-aside='way'] {
  opacity: 0.07;
}

.qp-world[data-visit] .qp-arc path {
  opacity: 0.2;
}

@media (prefers-reduced-motion: reduce) {
  .qp-house,
  .qp-arc path {
    transition: none;
  }
}

/* A house: the mark's own ring, three hundred units across with its name
   under it. The name is a label, in mono, and its key is said quietly. */
.qp-house {
  width: 300px;
  height: 300px;
  margin: -150px 0 0 -150px;
  border-radius: 50%;
  cursor: pointer;
}

.qs-play-frame[data-locked] .qp-house {
  pointer-events: none;
}

.qp-name {
  position: absolute;
  left: 50%;
  top: calc(100% - 1.25rem);
  margin: 0;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: var(--nv-font-mono);
  /* Twenty units in the world, and never under twelve pixels on the
     screen, however far the camera stands. */
  font-size: max(20px, calc(12px / var(--qp-zoom, 1)));
  line-height: 1;
  color: var(--nv-color-fg-subtle);
}

.qp-name b {
  font-weight: 500;
  color: var(--nv-color-fg);
}

.qp-world[data-far] .qp-name span {
  display: none;
}

/* The house the reader chose: its name in the red, which is where a reader
   looks. */
.qp-house[data-selected] .qp-name b {
  color: var(--nv-color-accent);
  text-decoration: underline;
  text-underline-offset: 0.3em;
}

.qp-house:focus-visible {
  outline: 3px solid var(--nv-color-border-focus);
  outline-offset: 6px;
}

/* ---- what is said beside it ---- */

.qs-play-beside {
  display: grid;
  gap: var(--nv-space-5, 1.5rem);
  min-width: 0;
}

.qs-play-say {
  display: grid;
  gap: var(--nv-space-2, 0.5rem);
  min-width: 0;
}

.qs-play-caption {
  max-width: 58ch;
  min-height: 1.5em;
  margin: 0;
  font-size: var(--nv-text-lg, 1.125rem);
  line-height: var(--nv-leading-normal, 1.5);
  color: var(--nv-color-fg);
}

/* A showcase's steps: the one playing hangs from the red, the rest are
   said quietly until their turn. */
.qs-play .qs-scene-steps li {
  color: var(--nv-color-fg-muted);
}

.qs-play .qs-scene-steps li[data-now] {
  border-inline-start-color: var(--nv-color-accent);
  color: var(--nv-color-fg);
}

.qs-play-controls {
  display: grid;
  gap: var(--nv-space-4, 1rem);
  min-width: 0;
}

.qs-play button.qs-action {
  cursor: pointer;
}

.qs-play button.qs-action:disabled {
  opacity: 0.45;
  cursor: default;
}

.qs-play button.qs-action[aria-pressed='true'] {
  border-color: var(--nv-color-accent);
  color: var(--nv-color-accent);
}

/* The showcases: ruled rows, each a number in the red and a name. What else
   may happen at a house is the same rows with no number. While a film plays
   the lists give way, so its steps stand beside the stage. */
.qs-play-films ol {
  margin: var(--nv-space-2, 0.5rem) 0 0;
  padding: 0;
  list-style: none;
  border-block-end: 1px solid var(--nv-color-border-subtle);
}

.qs-play-film {
  display: flex;
  gap: var(--nv-space-3, 0.75rem);
  align-items: baseline;
  width: 100%;
  min-height: 2.75rem;
  padding: var(--nv-space-2, 0.5rem) 0;
  border: 0;
  border-block-start: 1px solid var(--nv-color-border-subtle);
  background: none;
  font-family: var(--nv-font-sans);
  font-size: var(--nv-text-base, 1rem);
  text-align: start;
  color: var(--nv-color-fg);
  cursor: pointer;
}

.qs-play-film .qs-no {
  font-family: var(--nv-font-mono);
  font-size: var(--nv-text-xs, 0.8125rem);
  color: var(--nv-color-accent);
}

.qs-play-film:hover:not(:disabled),
.qs-play-film[aria-pressed='true'] {
  color: var(--nv-color-accent);
}

.qs-play-film:disabled {
  opacity: 0.45;
  cursor: default;
}

.qs-play-film:focus-visible {
  outline: 2px solid var(--nv-color-border-focus);
  outline-offset: 2px;
}

.qs-play[data-playing] .qs-play-films,
.qs-play[data-playing] .qs-play-keeps {
  display: none;
}

.qs-play-keeps .qs-code {
  max-height: 22rem;
  margin-top: var(--nv-space-2, 0.5rem);
  overflow: auto;
  font-size: var(--nv-text-xs, 0.8125rem);
}
