/* Figure 1, the replay. Everything here is scoped under #replay-root and every class starts with rp-, so this sheet
   and site.css cannot reach into each other. Colours, faces, the type scale and the spacing come from tokens.css.
   replay.js sets one layout class on the mount, from its own size and the window's:
     .rp-m-fit    the mount carries data-fit and the page has given it a height (window 987 x 620 and up): the
                  figure fills that height exactly, with the panel in its own column where there is width for one
     .rp-m-wide   natural height: the 906px canvas beside the 350px panel (page 1361px and up)
     .rp-m-stack  natural height: the canvas centred on its ground, the panel under it (987 to 1360px)
     .rp-m-list   the small-screen form: a list, no canvas (986px and under)
   plus .rp-phone at 760px and under. The canvas is never scaled. */

#replay-root { min-width: 0; }
#replay-root.rp-on {
  display: flex; flex-direction: column;
  font-family: var(--sans); font-stretch: 100%; color: var(--ink);
  font-variant-numeric: tabular-nums lining-nums;
}
#replay-root.rp-on *, #replay-root.rp-on *::before, #replay-root.rp-on *::after { box-sizing: border-box; }
/* resets at the mount's own specificity only (:where adds none), so every rule below overrides them */
#replay-root :where(h2, h3, h4, p, ol, ul) { margin: 0; padding: 0; }
#replay-root :where(ol) { list-style: none; }
#replay-root :where(svg) { display: block; flex: none; max-width: none; }
#replay-root.rp-on [hidden] { display: none !important; }
#replay-root :focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
#replay-root .rp-ld { color: var(--line); }
#replay-root .rp-nw { white-space: nowrap; }
#replay-root .rp-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; }
#replay-root .rp-msg { margin: 14px 0 4px; padding: 18px 20px; background: var(--ground); font: 400 var(--t4)/1.5 var(--sans); }

/* ---------- headline: a statement, generated from the play */
#replay-root .rp-head {
  font: 800 var(--t8)/1.05 var(--sans); font-stretch: 75%; letter-spacing: 0; word-spacing: var(--ws-75);
  text-wrap: balance; margin-top: 10px; padding-bottom: 14px; min-height: calc(var(--t8) * 1.05 + 14px);
}

/* ---------- tabs and transport share one row */
#replay-root .rp-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 0 24px; flex-wrap: wrap;
  border-top: 1px solid var(--ink); border-bottom: 1px solid var(--ink);
}
#replay-root .rp-tabs { display: flex; flex-wrap: wrap; gap: 0; align-self: stretch; }
/* one line each: the page's name. The selected tab carries a 5px ink bar on the row's top rule. */
#replay-root .rp-tabs button {
  appearance: none; border: 0; border-radius: 0; background: none; cursor: pointer;
  display: inline-flex; align-items: center; text-align: left; white-space: nowrap;
  padding: 0 26px 0 0; margin: -1px 6px 0 0; min-height: 44px;
  border-top: 5px solid transparent; border-bottom: 5px solid transparent; color: var(--ink-2);
  font: 700 var(--t4)/1.15 var(--sans); font-stretch: 88%; word-spacing: var(--ws-88);
}
#replay-root .rp-tabs button[aria-selected="true"] { border-top-color: var(--ink); color: var(--ink); }
#replay-root .rp-tabs button:hover { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }

#replay-root .rp-ctl { display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap; padding: 8px 0; min-width: 0; }
#replay-root .rp-prog {
  display: flex; align-items: center; gap: 10px; white-space: nowrap;
  font: 700 var(--t3)/1 var(--sans); font-stretch: 88%; word-spacing: var(--ws-88);
}
#replay-root .rp-transport { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
#replay-root .rp-tbtn {
  appearance: none; display: inline-flex; align-items: center; gap: 7px; height: 36px; padding: 0 12px; margin: 0;
  border: 1.5px solid var(--ink); border-radius: 2px; background: var(--paper); color: var(--ink);
  font: 600 var(--t3)/1 var(--sans); cursor: pointer; white-space: nowrap;
}
#replay-root .rp-tbtn:hover { background: var(--ground); }
#replay-root .rp-tbtn:active { background: var(--ground-2); }
#replay-root .rp-tbtn[disabled] { background: var(--ground); border-color: var(--hair); color: var(--ink-3); cursor: not-allowed; }
#replay-root .rp-speed { display: inline-flex; align-items: center; }
#replay-root .rp-seg-l { font: 500 var(--t3)/1 var(--sans); color: var(--ink-2); margin-left: 6px; }
/* The group never clips: a focused segment is raised above its neighbours so its ring is whole. */
#replay-root .rp-seg { display: inline-flex; border: 1.5px solid var(--ink); border-radius: 2px; margin-left: 8px; overflow: visible; }
#replay-root .rp-seg button {
  appearance: none; position: relative; border: 0; border-left: 1px solid var(--ink); border-radius: 0; margin: 0;
  background: var(--paper); color: var(--ink); height: 33px; min-width: 40px; padding: 0 10px;
  font: 600 var(--t3)/1 var(--sans); cursor: pointer;
}
#replay-root .rp-seg button:first-child { border-left: 0; border-radius: 1px 0 0 1px; }
#replay-root .rp-seg button:last-child { border-radius: 0 1px 1px 0; }
#replay-root .rp-seg button:hover { background: var(--ground); }
#replay-root .rp-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
#replay-root .rp-seg button:focus-visible { z-index: 1; }

/* ---------- the body: lineage and panel */
#replay-root .rp-body {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 var(--gut); align-items: stretch;
  background: var(--ground); min-width: 0;
}
#replay-root .rp-stage { min-width: 0; position: relative; }
#replay-root .rp-canvas { display: block; width: 906px; max-width: none; margin: 0 auto; }
#replay-root .rp-list { display: none; }
#replay-root .rp-stage-msg { padding: 18px 20px; font: 400 var(--t4)/1.5 var(--sans); }
#replay-root.rp-empty .rp-canvas, #replay-root.rp-empty .rp-list, #replay-root.rp-empty .rp-side { display: none; }

#replay-root.rp-m-wide .rp-body { grid-template-columns: minmax(906px, 1fr) 350px; grid-template-rows: auto 1fr; }
#replay-root.rp-m-wide .rp-stage { grid-row: 1 / 3; grid-column: 1; }
#replay-root.rp-m-wide .rp-canvas { margin: 0; }
#replay-root.rp-m-wide .rp-side { grid-column: 2; }

#replay-root .rp-side { background: var(--paper); padding: 0 16px; min-width: 0; border-top: 1px solid var(--ink); }
#replay-root.rp-m-wide .rp-side { border-top: 0; border-left: 1px solid var(--ink); border-right: 1px solid var(--ink); }
#replay-root .rp-now { padding-top: 16px; padding-bottom: 14px; }
#replay-root .rp-standing { padding-bottom: 16px; }
#replay-root.rp-m-wide .rp-standing { border-bottom: 1px solid var(--ink); }
#replay-root.rp-m-stack .rp-standing { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--gut); border-top: 0; padding-top: 4px; }
#replay-root.rp-m-list .rp-standing { border-top: 0; }

#replay-root .rp-side h3 { font: 800 var(--t6)/1.05 var(--sans); font-stretch: 75%; word-spacing: var(--ws-75); }
#replay-root .rp-side h4 { font: 800 var(--t3)/1.2 var(--sans); font-stretch: 88%; word-spacing: var(--ws-88); margin: 0 0 8px; }

#replay-root .rp-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
#replay-root.rp-m-stack .rp-pair, #replay-root.rp-m-list .rp-pair { max-width: 560px; }
#replay-root .rp-pair > div { min-width: 0; }
#replay-root .rp-fr { border: 2px solid var(--ink); line-height: 0; }
#replay-root .rp-fr.rp-lead { outline: 4px solid var(--line); }
#replay-root .rp-fr canvas { display: block; }
#replay-root .rp-who { font: 500 var(--t2)/1.25 var(--sans); margin-top: 12px; }
#replay-root .rp-who > b:first-child { font: 800 var(--t4)/1 var(--sans); font-stretch: 75%; }
#replay-root .rp-tag { font: 800 var(--t2)/1 var(--sans); font-stretch: 88%; }
#replay-root .rp-r { font: 800 var(--t7)/1 var(--sans); font-stretch: 62%; margin-top: 3px; }
#replay-root .rp-n { font: 500 var(--t2)/1.2 var(--sans); color: var(--ink-2); margin-top: 3px; }
#replay-root .rp-pair .rp-wk { margin-top: 5px; }
#replay-root .rp-gone { color: var(--ink-3); min-height: 16px; margin-top: 5px; }
#replay-root .rp-standing > div { border-top: 1px solid var(--ink); padding-top: 12px; min-width: 0; }
#replay-root .rp-standing > div + div { margin-top: 10px; }
#replay-root.rp-m-stack .rp-standing > div + div { margin-top: 0; }
#replay-root .rp-chart { height: 178px; }
#replay-root .rp-ax { font: 500 var(--t1) var(--sans); font-stretch: 88%; fill: var(--ink-2); }
#replay-root .rp-ax-b { fill: var(--ink); font-weight: 700; }
#replay-root .rp-board { font: 500 var(--t2)/1.2 var(--sans); }
#replay-root .rp-board li {
  display: grid; grid-template-columns: 13px 30px minmax(0, 1fr) 84px 46px; gap: 6px; align-items: center;
  padding: 7px 0; border-top: 1px solid var(--hair); min-height: 46px;
}
#replay-root .rp-board li:first-child { border-top: 0; padding-top: 2px; }
#replay-root .rp-board li.rp-none { display: block; color: var(--ink-2); }
#replay-root .rp-rk { color: var(--ink-2); }
#replay-root .rp-id { font: 800 var(--t4)/1 var(--sans); font-stretch: 75%; }
#replay-root .rp-nt { min-width: 0; line-height: 1.2; overflow-wrap: anywhere; }
#replay-root .rp-rt { font: 800 var(--t4)/1 var(--sans); font-stretch: 75%; text-align: right; }
#replay-root .rp-board li.rp-lead .rp-id, #replay-root .rp-board li.rp-lead .rp-rt { color: var(--line); }
#replay-root .rp-board li.rp-orig { border-top: 1px solid var(--ink); color: var(--ink-2); }
#replay-root .rp-aa { font: 400 var(--t2)/1.35 var(--sans); color: var(--ink); border-left: 1px solid var(--ink); padding-left: 10px; margin-top: 10px; }
#replay-root .rp-aa b { font-weight: 800; }

/* ---------- small-screen form. Order: the pair, the lineage, the chart and the top five. */
#replay-root.rp-m-list .rp-body { display: flex; flex-direction: column; gap: 0; }
#replay-root.rp-m-list .rp-canvas { display: none; }
#replay-root.rp-m-list .rp-now { order: -1; border-top: 0; border-bottom: 1px solid var(--ink); padding: 14px 12px 14px; }
#replay-root.rp-m-list .rp-standing { padding: 0 12px 14px; }
#replay-root.rp-m-list .rp-standing > div + div { margin-top: 12px; }

#replay-root.rp-m-list .rp-list { display: block; position: relative; padding: 4px 12px 16px; }
#replay-root .rp-lg { position: relative; padding-left: 24px; }
#replay-root .rp-lh { position: relative; font: 500 var(--t2)/1.25 var(--sans); color: var(--ink-2); padding: 14px 0 10px; border-top: 1px solid var(--hair); margin: 0; }
#replay-root .rp-lg:first-of-type .rp-lh { border-top: 0; }
#replay-root .rp-lh b { display: block; font: 800 var(--t5)/1.05 var(--sans); font-stretch: 75%; word-spacing: var(--ws-75); color: var(--ink); margin-bottom: 2px; }
/* The spine: one 5px bar, 3px in from the list's left edge, from the original's node to the leader. It is a single
   element placed by script over the rows, so no hairline between rows can cut it. */
#replay-root .rp-spine { display: none; position: absolute; left: 15px; width: 5px; background: var(--line); z-index: 1; pointer-events: none; }
/* an 11px square on every ancestor's row; the leader's row gets the turn into its frame instead */
#replay-root .rp-on-line::before { content: ""; position: absolute; left: -24px; top: 20px; width: 11px; height: 11px; background: var(--line); z-index: 1; }
#replay-root .rp-lmain.rp-on-line::before { left: -21px; width: 21px; height: 5px; }

#replay-root .rp-lmain { position: relative; padding: 12px 0 14px; border-top: 1px solid var(--hair); }
#replay-root .rp-ltop > div { min-width: 0; }
#replay-root .rp-ltop { display: grid; grid-template-columns: 154px minmax(0, 1fr); gap: 14px; align-items: start; padding: 5px 0 5px 5px; }
#replay-root .rp-ltop .rp-th { border: 2px solid var(--ink); outline: 5px solid var(--line); box-sizing: content-box; }
#replay-root .rp-lid { font: 500 var(--t2)/1.15 var(--sans); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
#replay-root .rp-lid b { font: 800 var(--t5)/1 var(--sans); font-stretch: 75%; }
#replay-root .rp-lid b.rp-tag { font: 800 var(--t2)/1 var(--sans); font-stretch: 88%; }
#replay-root .rp-lid + .rp-lid { margin-top: 4px; }
#replay-root .rp-lrate { font: 800 var(--t7)/1 var(--sans); font-stretch: 62%; margin-top: 8px; }
#replay-root .rp-lmeta { font: 500 var(--t2)/1.35 var(--sans); color: var(--ink-2); margin-top: 5px; }
#replay-root .rp-ltop .rp-wk { margin-top: 6px; }
#replay-root .rp-lnote { font: 500 var(--t2)/1.35 var(--sans); font-stretch: 88%; margin-top: 8px; padding-left: 10px; border-left: 1px solid var(--ink); }
#replay-root .rp-lnote b { font-weight: 800; word-spacing: var(--ws-88); }

/* The change against the parent, as terminal output: a solid ink block, mono throughout, a prompt, then the removed
   line in grey and the added line in yellow. No window chrome, no red and green. The canvas draws the same slab. */
#replay-root .rp-term { background: var(--ink); color: var(--paper); font: 400 var(--t1)/1.5 var(--mono); padding: 7px 10px 8px; margin-top: 10px; min-width: 0; }
#replay-root .rp-term p { white-space: pre-wrap; overflow-wrap: anywhere; padding-left: 2ch; text-indent: -2ch; }
#replay-root .rp-term .rp-t-prompt, #replay-root .rp-term .rp-t-hunk { font-weight: 600; }
#replay-root .rp-term .rp-t-del, #replay-root .rp-term .rp-t-dim, #replay-root .rp-term .rp-t-tail { color: #9A9A94; }
#replay-root .rp-term .rp-t-add { color: var(--mark); }
#replay-root .rp-term .rp-sw { display: inline-block; width: 9px; height: 9px; border: 1px solid var(--paper); margin-right: 5px; vertical-align: -1px; text-indent: 0; }
/* a retired variant's change is set back: no yellow, which is for what is live */
#replay-root .rp-term.rp-term-ret { background: var(--ink-3); }
#replay-root .rp-term.rp-term-ret p, #replay-root .rp-term.rp-term-ret .rp-t-tail { color: var(--ground); }

#replay-root .rp-lrow {
  position: relative; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto;
  grid-template-areas: "th id r" "th key r" "term term term" "note note note";
  gap: 3px 10px; align-items: start; padding: 10px 0 12px; border-top: 1px solid var(--hair);
}
#replay-root .rp-lrow > .rp-th { grid-area: th; border: 1px solid var(--ink); box-sizing: content-box; }
#replay-root .rp-lrow .rp-lid { grid-area: id; }
#replay-root .rp-lrow .rp-lid span { flex-basis: 100%; }
#replay-root .rp-lrow .rp-lid b { font-size: var(--t4); }
#replay-root .rp-lkey { grid-area: key; font: 500 var(--t2)/1.4 var(--sans); color: var(--ink-2); min-width: 0; }
#replay-root .rp-lrow .rp-term { grid-area: term; margin-top: 5px; }
#replay-root .rp-lr { grid-area: r; text-align: right; font: 800 var(--t4)/1 var(--sans); font-stretch: 75%; }
#replay-root .rp-lr small { display: block; font: 500 var(--t2)/1 var(--sans); font-stretch: 88%; color: var(--ink-2); margin-top: 5px; }
#replay-root .rp-lr .rp-wk { margin-top: 6px; margin-left: auto; }
#replay-root .rp-lrow .rp-lnote { grid-area: note; margin-top: 4px; }
#replay-root .rp-lrow.rp-ret > .rp-th { border-color: var(--ink-3); }
#replay-root .rp-lrow.rp-ret .rp-lid, #replay-root .rp-lrow.rp-ret .rp-lr { color: var(--ink-3); }
#replay-root .rp-lrow.rp-ret .rp-lid b { text-decoration: line-through; text-decoration-thickness: 1.5px; }
#replay-root .rp-lrow.rp-ret .rp-lr small { color: var(--ink-3); }

/* ---------- phones: type steps down, 2 x 2 tabs, 44px controls */
#replay-root.rp-phone .rp-head { font-size: var(--t7); min-height: 0; }
#replay-root.rp-phone .rp-tabs { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
#replay-root.rp-phone .rp-tabs button { padding: 0 8px 0 0; margin: 0; border-bottom: 1px solid var(--hair); min-height: 48px; }
#replay-root.rp-phone .rp-ctl { width: 100%; padding: 10px 0; }
#replay-root.rp-phone .rp-transport { width: 100%; }
#replay-root.rp-phone .rp-tbtn, #replay-root.rp-phone .rp-seg button { height: 44px; }
#replay-root.rp-phone .rp-speed { margin-left: auto; }
#replay-root.rp-phone .rp-seg-l { margin-left: 0; }
#replay-root.rp-phone .rp-prog { white-space: normal; }

/* ---------- fitted to the window. The page gives the mount a height (flex: 1 1 0; min-height: 0) and the figure
   fills exactly that: a one-line headline, one row of controls, and a body that takes what is left. The canvas is
   placed over the stage, so the stage's size comes from the page and never from what is drawn in it. */
#replay-root.rp-m-fit { min-height: 0; }
#replay-root.rp-m-fit .rp-head {
  flex: none; margin-top: 6px; padding-bottom: 8px; min-height: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-wrap: nowrap; line-height: 1.05;
}
#replay-root.rp-h38 .rp-head { font-size: var(--t8); }
#replay-root.rp-h30 .rp-head { font-size: var(--t7); }
#replay-root.rp-h24 .rp-head { font-size: var(--t6); margin-top: 4px; padding-bottom: 6px; }
#replay-root.rp-h20 .rp-head { font-size: var(--t5); margin-top: 4px; padding-bottom: 6px; }
#replay-root.rp-m-fit .rp-bar { flex: none; flex-wrap: nowrap; gap: 0 20px; }
#replay-root.rp-m-fit .rp-tabs { flex: none; flex-wrap: nowrap; }
#replay-root.rp-m-fit .rp-tabs button { min-height: 40px; padding-right: 22px; margin-right: 4px; }
#replay-root.rp-m-fit .rp-ctl { flex: none; flex-wrap: nowrap; padding: 4px 0; gap: 0 16px; }
#replay-root.rp-m-fit .rp-transport { flex-wrap: nowrap; }
#replay-root.rp-c1 .rp-prog svg { display: none; }
#replay-root.rp-c2 .rp-seg-l { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
#replay-root.rp-c2 .rp-tabs button { padding-right: 14px; }
#replay-root.rp-c2 .rp-seg { margin-left: 0; }
#replay-root.rp-c3 .rp-pg-w { display: none; }
#replay-root.rp-c3 .rp-tabs button { padding-right: 10px; }

#replay-root.rp-m-fit .rp-body {
  flex: 1 1 0; min-height: 0;
  grid-template-columns: minmax(0, 1fr) var(--rp-panel, 350px); grid-template-rows: auto minmax(0, 1fr);
}
#replay-root.rp-m-fit.rp-nopanel .rp-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
#replay-root.rp-m-fit .rp-stage { grid-row: 1 / 3; grid-column: 1; min-height: 0; overflow: hidden; }
#replay-root.rp-m-fit.rp-nopanel .rp-stage { grid-row: 1; }
#replay-root.rp-m-fit .rp-canvas { position: absolute; top: 0; left: 0; margin: 0; }
#replay-root.rp-m-fit .rp-side { grid-column: 2; border-top: 0; border-left: 1px solid var(--ink); border-right: 1px solid var(--ink); padding: 0 14px; }
#replay-root.rp-m-fit.rp-nopanel .rp-side { display: none; }
#replay-root.rp-m-fit .rp-now { padding-top: 12px; padding-bottom: 10px; }
#replay-root.rp-m-fit .rp-standing { min-height: 0; overflow: hidden; padding-bottom: 0; border-bottom: 1px solid var(--ink); }
#replay-root.rp-m-fit .rp-side h3 { font-size: var(--t5); }
#replay-root.rp-m-fit .rp-pair { gap: 14px; margin-top: 8px; }
#replay-root.rp-m-fit .rp-who { margin-top: 10px; min-height: 2.5em; }
#replay-root.rp-m-fit .rp-r { font-size: var(--t6); }
#replay-root.rp-m-fit .rp-standing > div { padding-top: 9px; padding-bottom: 8px; }
#replay-root.rp-m-fit .rp-standing > div + div { margin-top: 0; }
#replay-root.rp-m-fit .rp-side h4 { margin-bottom: 4px; }
#replay-root.rp-m-fit .rp-chart { overflow: hidden; }
/* five rows, one line each, and room kept for all five from the first frame so nothing below them moves */
#replay-root.rp-m-fit .rp-board { min-height: 140px; }
#replay-root.rp-m-fit .rp-board li { min-height: 28px; padding: 3px 0; grid-template-columns: 11px 30px minmax(0, 1fr) 84px 46px; }
#replay-root.rp-m-fit .rp-board li:first-child { padding-top: 3px; }
#replay-root.rp-m-fit .rp-nt { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#replay-root.rp-m-fit .rp-aa { display: none; }
#replay-root .rp-standing.rp-no-board .rp-b-board, #replay-root .rp-standing.rp-no-chart .rp-b-chart { display: none; }

@media (prefers-reduced-motion: reduce) {
  #replay-root *, #replay-root *::before, #replay-root *::after { transition: none !important; animation: none !important; }
}
