/* the stage: the island picture with couriers on its roads */
.stage { position: relative; margin: 0 0 18px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--room); }
.stage .stw { overflow-x: auto; }
.stage .stg { position: relative; min-width: 620px; }
.stage img { display: block; width: 100%; height: auto; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage text { font: 600 15px/1 var(--sans); fill: #fff; paint-order: stroke; stroke: #06131a; stroke-width: 4px; stroke-linejoin: round; }
.stage .pl.me text { fill: #ffe9a8; }
.stage .dec { stroke: #fff; stroke-width: 2.5; fill: #888; } .stage .dec.dred { fill: #c0281c; } .stage .dec.dblue { fill: #1d4fc4; }
.stage .stv { position: relative; } .stage .stv > * { min-width: 0; } .stage .stw { max-width: 100%; contain: inline-size; } .stepbar, .stepbar .sgs { min-width: 0; }      /* the wide picture scrolls inside its frame; it must not widen the page */      /* the picture's frame: a corner close-up sits on it, not on the scrolling picture or the caption */

@media (max-width: 640px) {
  .stage .stv { display: flex; flex-direction: column; }
}/* the stepper: pinned to the top of the screen while its scene's timeline is on screen */
.stepbar { position: sticky; top: 52px; z-index: 6; margin: 0 0 var(--s4); display: flex; align-items: center; gap: var(--s3) var(--s4); flex-wrap: wrap; padding: var(--s3); border: 1px solid var(--line); }
.stepbar .sgs { flex: 1; min-width: 0; }
.stepbar .arrow { flex: none; width: 36px; height: 36px; padding: 0; display: grid; place-items: center; line-height: 0; }
.stepbar .arrow svg { display: block; }
.stepbar .arrow[disabled] { opacity: .35; }
.stepbar .sctl { flex: 1 1 100%; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s4); }
.stepbar .sfoot { flex: 1 1 100%; display: flex; align-items: center; flex-wrap: wrap; gap: 6px 14px; padding-left: 48px; }
.stepbar .skey { flex: 1 1 auto; }
/* the picture rides at the top of the stepper box; the stepper sits below it, in reach of a thumb, on one scrolling line */
.stepbar .pict { flex: 1 1 100%; min-width: 0; }
.stepbar .stage { margin: 0; }
.stepbar .stv { max-width: calc(40vh * var(--ar, 2)); margin-inline: auto; }      /* capped by width, so the box never outgrows the screen */

.stage { margin-bottom: 12px; }
/* the Abstraction register's diagram: the island's layout without the island */
.stage.abs .stg { min-width: 520px; }
.stage.abs svg { position: static; display: block; width: 100%; height: auto; }
.stage.abs text { font: 600 14px/1 var(--mono); fill: var(--ink); stroke: var(--room); stroke-width: 4px; paint-order: stroke; stroke-linejoin: round; }

/* the city stage: the picture is the svg itself, cropped by its viewBox; sizes are in em of the svg's font-size, which scales with the crop */
.stage.city .stg { min-width: 0; }      /* the whole picture, sized to the room left on screen; its labels scale up when it is small */
.stage.city svg { position: static; display: block; width: 100%; height: auto; cursor: pointer; }
.stage.city .baked > svg { position: absolute; inset: 0; width: 100%; height: 100%; will-change: transform; }      /* the messengers on a layer of their own, so moving them never repaints the picture beneath */
.stage.city .baked { cursor: pointer; }
.stage.city text { font: 600 1em/1 var(--sans); stroke-width: .28em; }
.stage.city .cpl .pin { fill: #fff; stroke: #06131a; stroke-width: .14em; }
.stage.city .cpl.me .pin { fill: #ffd34d; } .stage.city .cpl.me text { fill: #ffe9a8; }
.stage.city .way { fill: none; stroke: #fff; stroke-width: .16em; stroke-dasharray: .05em .55em; stroke-linecap: round; opacity: .8; }
.stage.city .trail { fill: none; stroke-width: .42em; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.stage.city .in .trail { stroke: #1f77b4; } .stage.city .out .trail { stroke: #e39a12; } .stage.city .lost .trail { stroke: #d6336c; }
.stage.city .mx circle { stroke: #fff; stroke-width: 2.2; } .stage.city .in .mx circle { fill: #1f77b4; } .stage.city .out .mx circle { fill: #e39a12; } .stage.city .lost .mx circle { fill: #d6336c; }
.stage.city .mx .sh { fill: rgba(0,0,0,.28); }
.stage.city .mx rect.scroll { fill: #f6ecd2; stroke: #5a4630; stroke-width: 1; } .stage.city .mx path.scroll { fill: none; stroke: #5a4630; stroke-width: 1.1; }
.stage.city .xx { font-size: 1.6em; fill: #ff7aa8; }
.stage.city .pulse { fill: none; stroke: #ffd34d; stroke-width: .3em; }
.stage .replay { position: absolute; right: 10px; top: 10px; z-index: 3; display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: var(--room); color: var(--ink); font: 600 var(--t-xs)/1 var(--sans); cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.stage .replay svg, .stage.city .replay svg { position: static; display: block; width: 15px; height: 15px; cursor: inherit; }
.stage .replay:hover { background: var(--line); }

/* the player: the stepper and picture are the scene's main view, and the panel under them shows the chosen step */
.player { display: grid; gap: var(--s4); }
.player .stepbar { position: static; margin: 0; }
.player .panel .band.core.solo { border-radius: 0 0 10px 10px; }
.player .panel .band.core, .player .panel .band.end { animation: panel-in .25s ease-out; }
@keyframes panel-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) { .player .panel .band.core, .player .panel .band.end { animation: none; } }
.sd.fin { border-color: var(--node); color: var(--node); }
.sd.fin svg { display: block; }
.stepbar .panel { flex: 1 1 100%; min-width: 0; }
/* in the panel the step's own text takes the width; what arrives and what leaves take only what they need */
@container (min-width: 721px) { .panel .tl { grid-template-columns: fit-content(32%) minmax(0, 1fr) fit-content(32%); } }
.stepbar .panel { padding-inline: 4px; }
.panel .band { background: none; border-top: 0; border-radius: 0; }
.panel .band.ph { background: var(--node-wash); border-radius: 6px; }
.panel .in { padding-right: 4px; } .panel .outb { padding-left: 4px; }
/* the panel: the step in words across the width, then a strip that reads arrives, then what is kept, then leaves */
.panel .sp { display: grid; gap: var(--s3); padding: var(--s2) var(--s2) var(--s1); animation: panel-in .25s ease-out; }
@media (prefers-reduced-motion: reduce) { .panel .sp { animation: none; } }
.panel .sp-ph { font: 500 var(--t-xs)/1.35 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--soft); }
.panel .sp-ph b { font-weight: 500; }
.panel .sp-ph i { font: var(--t-sm)/1.4 var(--sans); letter-spacing: 0; text-transform: none; margin-left: var(--s2); }
.panel .fst .state { margin-top: 0; }
.panel .end { padding: var(--s2) var(--s2) var(--s1); } .panel .end::before, .panel .end .tm { display: none; }
.stepbar .panel { container-type: inline-size; }
/* always three columns, so what arrives and what leaves are always in the same place; stacked on a narrow screen */
.panel .flow { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2.2fr) minmax(0, 1fr); border-radius: 8px; background: var(--ground); }      /* the kept state is the widest: its names and values need room; a courier line is short */
.panel .fcol { display: grid; gap: var(--s2); align-content: start; min-width: 0; padding: var(--s3) var(--s4) var(--s4); }
.panel .fcol + .fcol { border-left: 1px solid var(--line); }
.panel .fcol .none { font: var(--t-sm)/1.45 var(--sans); color: var(--soft); }
.panel .fin .m { justify-content: space-between; }
@container (max-width: 600px) {
  .panel .flow { grid-template-columns: minmax(0, 1fr); }
  .panel .fcol + .fcol { border-left: 0; border-top: 1px solid var(--line); }
  .panel .flow .wire { display: none; }      /* stacked, the arrows would point at nothing */
}

/* the city stage in the Abstraction register: the same geometry and messengers, on a plain ground with nodes as solid blocks */
.stage.city.abs .gnd { fill: var(--room); }
.stage.city.abs .rdn { fill: none; stroke: var(--line); stroke-linecap: round; stroke-linejoin: round; }
.stage.city.abs .rdn.road { stroke-width: 7; } .stage.city.abs .rdn.street { stroke-width: 4; opacity: .7; }
.stage.city.abs .blk .ft { fill: var(--room); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.stage.city.abs .blk .fs { fill: var(--line); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.stage.city.abs .blk .fe { fill: var(--soft); stroke: var(--ink); stroke-width: 2.5; stroke-linejoin: round; }
.stage.city.abs .blk.me .ft { fill: var(--node); } .stage.city.abs .blk.me .bl { fill: var(--on-node); }
.stage.city.abs .blk.cl .ft, .stage.city.abs .blk.cl .fs, .stage.city.abs .blk.cl .fe { stroke-dasharray: 6 5; }
.stage.city.abs .blk .bl { font: 700 1.25em/1 var(--mono); fill: var(--ink); stroke: none; }
.stage.city.abs text { fill: var(--ink); stroke: var(--room); }
.stage.city.abs .cpl.me text:not(.bl) { fill: var(--node); }

/* the whole box, stepper, picture and the step's panel, should fit on one screen: the picture takes the height the rest leaves */
.player .stepbar .stv { max-width: max(260px * var(--ar, 2), calc((100svh - 560px) * var(--ar, 2))); }
/* in the box the picture carries its own rounded corners, so a picture narrower than the box sits in it without a frame */
.stepbar .stage { border: 0; background: none; overflow: visible; }
.stepbar .stv { border-radius: 8px; overflow: hidden; }
/* the step groups already name the phase; the panel repeats it only where it has the reason to add, or on a phone, where the groups lose their names */
@media (min-width: 641px) { .panel .sp-ph:not(:has(i)) { display: none; } }
@media (max-width: 640px) {
  :root:not([data-theater]) .stepbar .skey { display: none; }                      /* the dots carry the same marks; the key costs three lines on a phone */
  :root:not([data-theater]) .stepbar .sfoot { padding-left: 0; justify-content: flex-end; }
  .stepbar .sd:not(.skey .sd) { width: 24px; height: 24px; }      /* smaller dots, so a scene's steps fit on one row */
  .stepbar .sd.r::before, .stepbar .sd.s::after { width: 5px; }
  .stepbar .dots { gap: 7px; }
  :root:not([data-theater]) .stepbar .sg > .label { display: none; }      /* the panel names the current phase, so the groups can share one row */
  .stepbar .sgs { gap: 8px 12px; }
  .stepbar .arrow { width: 30px; height: 30px; }
  .stepbar, .stepbar .sctl { gap: 8px 8px; }
  .player .stepbar .stage.city .stv { max-width: 100%; }
  .panel .sp { gap: 8px; padding-inline: 0; }
  .panel .say { font-size: var(--t-md); }
  .panel .fcol { padding: 8px 12px 10px; gap: 6px; }
}

/* at night the messengers and their trails glow brighter, to stand out on the moonlit ground */
.stage.city.night .in .trail { stroke: #59b4ff; } .stage.city.night .out .trail { stroke: #ffb340; } .stage.city.night .lost .trail { stroke: #ff6f9f; }
.stage.city.night .in .mx circle { fill: #59b4ff; } .stage.city.night .out .mx circle { fill: #ffb340; } .stage.city.night .lost .mx circle { fill: #ff6f9f; }
.stage.city.night .trail { opacity: .95; } .stage.city.night .way { opacity: .9; }

.stepbar .sgs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-block: 4px; position: relative; }
.stepbar .sgs::-webkit-scrollbar { display: none; }
.stepbar .sg, .stepbar .dots { flex: none; flex-wrap: nowrap; }
.stepbar .sfoot { display: none; }
@media (min-width: 641px) { .stepbar .sfoot { display: flex; } }
/* the step groups and the key sit in the middle, the arrows stay at the ends; auto margins centre the row
   but fall back to nothing when the steps overflow, so a long scene still scrolls from its first step */
.stepbar .sgs > .sg:first-child { margin-left: auto; }
.stepbar .sgs > .sg:last-child { margin-right: auto; }
.stepbar .sfoot { justify-content: center; padding-inline: 48px; }
.stepbar .skey { flex: 0 1 auto; justify-content: center; }

/* the picture's labels. A place wears a dark plate that leads with its node's chip, the same letter or name the step panel uses,
   then says where it is; yours is gold. A message's tag is a slip of parchment in the machine's type, edged in its trail's colour.
   stage.js sizes them and finds each a spot inside the frame, clear of the others. */
.stage.city .lb text, .stage.city .tg text { stroke: none; }
.stage.city .lb .bg { fill: rgba(8, 18, 27, .8); }
.stage.city .lb .chip { fill: #fbfcfe; }
.stage.city .lb .ct { font: 600 .8em/1 var(--mono); fill: #131a2e; text-anchor: middle; }
.stage.city .lb .nm { font: 500 .84em/1 var(--sans); fill: #fff; }
.stage.city .lb .sub { font: 500 .74em/1 var(--sans); fill: #fff; }
.stage.city .lb .dec { stroke: #fff; stroke-width: .07em; }
.stage.city .cpl.me .chip { fill: #ffd34d; } .stage.city .cpl.me .ct { fill: #131a2e; } .stage.city .cpl.me .nm, .stage.city .cpl.me .sub { fill: #fff; } .stage.city .cpl.me .yo { fill: #ffd34d; font-weight: 600; }
.stage.city .cpl.cl .chip { fill: none; stroke: rgba(255, 255, 255, .75); stroke-width: .07em; stroke-dasharray: .24em .18em; }
.stage.city .cpl.cl .ct { fill: #fff; font-weight: 500; }
.stage.city .tg .bg { fill: #f8f0db; stroke: rgba(40, 28, 12, .45); stroke-width: .05em; }
.stage.city .tg text { font: 500 .8em/1 var(--mono); fill: #2a2118; }
.stage.city .tg.in .bar { fill: #1f77b4; } .stage.city .tg.out .bar { fill: #e39a12; } .stage.city .tg.lost .bar { fill: #d6336c; } .stage.city .tg.here .bar { fill: #c9a227; }
.stage.city .tg .bar { clip-path: inset(0 round .2em 0 0 .2em); }
.stage.city.abs .lb .bg { fill: var(--room); opacity: .88; }
.stage.city.abs .lb .nm, .stage.city.abs .lb .sub, .stage.city.abs .cpl.me .nm, .stage.city.abs .cpl.me .sub { fill: var(--soft); } .stage.city.abs .cpl.me .yo { fill: var(--node); }
.stage.city.abs .lb .dec { stroke: var(--ink); }
.stage.city.abs .tg .bg { fill: var(--room); stroke: var(--line); stroke-width: .07em; }
.stage.city.abs .tg text { fill: var(--ink); }
