/* Spatial rooms 39, 70: inside the machine (owner: the spatial designer).
   html[data-grammar="spatial-machine"] (39) · html[data-grammar="spatial-weights"] (70).
   A sticky stage over a tall track; captions scroll natively over it. */

/* While the reader is inside the figure, the instruments step aside. */
html[data-grammar^="spatial-"] #dash { transition: opacity 0.6s ease, visibility 0s linear 0s; }
html.sp-inside #dash { opacity: 0; visibility: hidden; transition: opacity 0.6s ease, visibility 0s linear 0.6s; }

.sp-track {
  position: relative;
  height: var(--sp-h, 760vh);
  width: var(--sp-w, 100%);
  margin: 44px 0 30px var(--sp-l, 0px);
}
.sp-stage {
  position: sticky;
  top: 0;
  z-index: 1;
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background: var(--paper);
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  pointer-events: none;
}
.sp-r70 .sp-stage { background: #0d0c0b; }
.sp-gl { display: block; width: 100%; height: 100%; }

/* labels fastened to things in the figure */
.sp-labels { position: absolute; inset: 0; pointer-events: none; }
.sp-lab {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 7px 3px;
  border: 1.2px solid var(--ink);
  background: var(--paper);
  color: var(--ink);
  font: 700 10.5px/14px var(--mono);
  letter-spacing: 0.08em;
  white-space: nowrap;
  visibility: hidden;
  will-change: transform, opacity;
}
.sp-lab.is-hot { border-color: var(--accent); color: var(--accent); }
.sp-stage.is-dark .sp-lab { background: #0d0c0b; border-color: #ebe5d4; color: #ebe5d4; }
.sp-stage.is-dark .sp-lab.is-hot { border-color: #ff4433; color: #ff4433; }

/* captions: report cards that scroll past the stage */
.sp-steps { position: absolute; inset: 0; pointer-events: none; }
.sp-step {
  position: absolute;
  z-index: 2;
  top: calc(var(--at) * (100% - 100vh) + 62vh);
  left: var(--sp-ml, 18px);
  width: min(430px, calc(100% - 36px));
  margin: 0;
  padding: 12px 16px 13px;
  border: 1.5px solid var(--ink);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font-size: 18px;
  line-height: 26px;
}
.sp-step:first-child { font-size: 15px; line-height: 21px; }

/* 70: the next-token distribution, set in the figure's last frame */
.sp-dist { position: absolute; inset: 0; pointer-events: none; visibility: hidden; }
.sp-dist.is-on { visibility: visible; }
.sp-dist-cap,
.sp-tok {
  position: absolute;
  left: 0;
  top: 0;
  margin: 0;
  will-change: transform;
}
.sp-dist-cap {
  width: max-content;
  max-width: min(520px, 86vw);
  font: italic 17px/23px var(--serif);
  color: var(--ink);
  text-align: center;
}
.sp-tok {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: max-content;
  max-width: min(30vw, var(--sp-gap, 30vw));
  text-align: center;
  font-size: 18px;
  line-height: 24px;
}
.sp-tok .plan-in { pointer-events: auto; }
.sp-pr { font: 11px/14px var(--mono); letter-spacing: 0.06em; color: #444; font-variant-numeric: lining-nums tabular-nums; }

/* reduced motion: the stills, and the distribution as a plain figure */
.sp-stills { margin: 34px 0 30px; display: grid; gap: 26px; }
.sp-still { margin: 0; }
.sp-still img { display: block; width: 100%; height: auto; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink); background: var(--paper); }
.sp-still figcaption { margin-top: 8px; font: 11.5px/17px var(--mono); color: #333; letter-spacing: 0.02em; }
.sp-dist.is-static {
  position: static;
  visibility: visible;
  pointer-events: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px 14px;
  padding: 4px 0 0;
}
.sp-dist.is-static .sp-dist-cap { position: static; grid-column: 1 / -1; max-width: none; text-align: left; transform: none; }
.sp-dist.is-static .sp-tok { position: static; max-width: none; width: auto; transform: none; }

.sp-pinned:empty { display: none; }
.sp-pinned { margin: 0 0 24px; padding: 10px 12px; border: 1.4px dashed var(--ink); }
.sp-coda { margin-top: 0; }

@media (max-width: 860px) {
  .sp-step { font-size: 16px; line-height: 23px; padding: 10px 13px 11px; top: calc(var(--at) * (100% - 100vh) + 58vh); }
  .sp-step:first-child { font-size: 14px; line-height: 20px; }
  .sp-tok { font-size: 15px; line-height: 20px; max-width: min(33vw, var(--sp-gap, 33vw)); }
  .sp-dist-cap { font-size: 15px; line-height: 20px; }
}
