/* Decoding demos: COrAL Figure 2 replay and small multiples, LEDOM published
 * outputs, Table 4 dot plot. Flat and square-cornered. The only motion is the
 * reader-started COrAL replay (block slide and arrow fade, under 600 ms), which
 * is removed under prefers-reduced-motion. Marks are SVG shapes placed in
 * percent coordinates so labels keep their CSS size at every width.
 */
.decode-defs { position: absolute; width: 0; height: 0; overflow: hidden; }
.decode-status { margin-top: 16px; font-size: 13px; line-height: 1.7; color: var(--ink); max-width: 760px; }
.decode-note { margin-top: 16px; font-size: 12px; line-height: 1.75; color: var(--muted); max-width: 760px; }
.decode-demo .table-scroll { margin-top: 8px; }
.decode-caption { margin-top: 24px; font-size: 11px; line-height: 1.6; color: var(--muted); max-width: 760px; }
.decode-formula { white-space: nowrap; }
.decode-table { font-size: 12px; }
.decode-table th, .decode-table td { padding: 7px 10px; white-space: nowrap; }
.decode-table .num { text-align: right; }
.decode-table thead a { font-size: 10px; font-weight: 400; margin-left: 3px; }
.demo-controls svg { flex: none; }

/* Shared control rows for all three demos. */
.coral-controls, .rv-controls { flex-direction: column; align-items: flex-start; gap: 12px; }
.coral-control-row, .rv-control-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; width: 100%; }
.coral-control-label { font-size: 11px; color: var(--muted); min-width: 64px; }
.demo-controls button { display: inline-flex; align-items: center; gap: 6px; }

/* Shared transport controls (Play / Step / Reset). */
.decode-transport button { min-width: 64px; justify-content: center; }

/* COrAL: Figure 2 replay. One muted warm marks the decoding block and backward
 * dependencies; the accent marks fixed tokens and forward dependencies. */
.cr-replay { --cr-warm: #96682f; --cr-warm-tint: #f6ecd8; --cr-fixed: #dbe9e0; --cr-prompt: #e8eae6; }
.cr-controls { flex-direction: column; align-items: flex-start; gap: 10px; }
.cr-chips button { min-width: 46px; justify-content: center; }
.cr-scroll { overflow-x: auto; margin-top: 4px; padding-bottom: 4px; }
.cr-scroll:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cr-stage { display: grid; grid-template-columns: 62px minmax(0, 1fr); column-gap: 10px; min-width: 760px; }
.cr-row { position: relative; display: grid; grid-template-columns: var(--cr-columns); min-height: 34px; }
.cr-row-label { align-self: center; margin: 0; font-size: 11px; line-height: 1.3; color: var(--muted); text-align: right; }
.cr-cell { display: flex; align-items: center; justify-content: center; min-width: 0; padding: 0 1px; border-left: 2px solid #fff;
  font-size: 12px; line-height: 1; white-space: nowrap; overflow: hidden; color: var(--ink); background: transparent;
  transition: background-color .3s, color .3s; }
.cr-cell.is-prompt { background: var(--cr-prompt); font-weight: 600; }
.cr-cell.is-fixed { background: var(--cr-fixed); }
.cr-cell.is-block { background: var(--cr-warm-tint); }
.cr-cell.is-accepted { box-shadow: inset 0 -2px 0 var(--accent); }
.cr-cell.is-revised { box-shadow: inset 0 -3px 0 var(--cr-warm); font-weight: 600; }
.cr-cell.is-draft { color: #a88a63; font-style: italic; }
.cr-cell.is-pending { color: transparent; }
.cr-block { position: absolute; top: -3px; bottom: -3px; border: 2px solid var(--cr-warm); pointer-events: none;
  transition: left .45s ease, width .45s ease; }
.cr-link { position: relative; height: 54px; }
.cr-arrows { display: block; overflow: visible; }
.cr-forward { stroke: var(--accent); stroke-width: 1.4; }
.cr-backward { stroke: var(--cr-warm); stroke-width: 1.6; stroke-dasharray: 4 2.5; }
.cr-head-forward path { fill: var(--accent); }
.cr-head-backward path { fill: var(--cr-warm); }
.cr-replay.is-enhanced [data-cr-arrows] { opacity: 0; transition: opacity .35s; }
.cr-replay.is-enhanced [data-cr-arrows].is-shown { opacity: 1; }
.cr-gap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0;
  font-size: 12px; letter-spacing: .04em; color: var(--muted); }
.cr-gap[hidden] { display: none; }
.cr-index { min-height: 0; margin-top: 5px; }
.cr-index span { font-size: 10px; line-height: 1; color: #8a948d; text-align: center; font-variant-numeric: tabular-nums; }
.cr-index-label { font-size: 10px; align-self: start; margin-top: 4px; }
.cr-key { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 11px; color: var(--muted); }
.cr-key > span { display: inline-flex; align-items: center; gap: 6px; }
.cr-swatch { display: inline-block; width: 14px; height: 12px; background: var(--cr-prompt); }
.cr-swatch.is-fixed { background: var(--cr-fixed); }
.cr-swatch.is-block { background: var(--cr-warm-tint); }
.cr-swatch.is-revised { background: var(--cr-warm-tint); box-shadow: inset 0 -3px 0 var(--cr-warm); }
.cr-line { display: inline-block; width: 20px; border-top: 1.5px solid var(--accent); }
.cr-line.is-backward { border-top: 1.6px dashed var(--cr-warm); }
.cr-status { min-height: 4.5em; }
.cr-log-details { margin-top: 18px; }
.cr-log-details summary { padding: 12px 0; font-size: 13px; }
.cr-log-details .table-scroll { margin-bottom: 14px; }
.cr-log-details .decode-caption { margin-top: 10px; }
.cr-log td, .cr-log th { white-space: normal; vertical-align: top; }
.cr-log th[scope="row"] { white-space: nowrap; }
.cr-log td:nth-child(2) { min-width: 150px; }
.cr-log td:nth-child(5) { min-width: 210px; }
.cr-log tr.is-current { background: #f8f1e3; }
.cr-log tr.is-current th { font-weight: 600; }
@media (prefers-reduced-motion: reduce) {
  .cr-cell, .cr-block, .cr-replay.is-enhanced [data-cr-arrows] { transition: none; }
}

/* COrAL: measured small multiples */
.coral-swatch use { fill: #fff; stroke: var(--ink); stroke-width: 1.3; }
.demo-controls button[aria-pressed="true"] .coral-swatch use { fill: #fff; stroke: #fff; }
.coral-key { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; font-size: 11px; color: var(--muted); }
.coral-key > span { display: inline-flex; align-items: center; gap: 5px; }
.coral-key .coral-key-note { width: 100%; }
.coral-grid-panels { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 24px 18px; margin-top: 16px; }
.coral-panel { margin: 0; min-width: 0; }
.coral-panel-head { display: flex; flex-direction: column; gap: 1px; font-size: 11px; color: var(--muted); }
.coral-panel-head strong { font-size: 13px; font-weight: 600; color: var(--ink); }
.coral-plot { position: relative; height: 128px; margin: 12px 6px 22px 26px; }
.coral-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: block; }
.coral-grid { stroke: #e8ece7; stroke-width: 1; }
.coral-axis { stroke: #98a39b; stroke-width: 1; }
.coral-y, .coral-x { position: absolute; font-size: 10px; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.coral-y { right: calc(100% + 5px); transform: translateY(-50%); }
.coral-x { top: calc(100% + 6px); transform: translateX(-50%); }
.coral-x-start { transform: none; }
.coral-x-end { transform: translateX(-100%); }
.coral-mark { cursor: pointer; }
.coral-mark use { stroke-width: 1.3; }
.coral-mark.is-other use { fill: #fff; stroke: #9aa59d; }
.coral-mark.is-reference use { fill: var(--ink); stroke: #fff; }
.coral-mark.is-highlight use { fill: var(--accent); stroke: #173d31; stroke-width: 1.5; }
.coral-arrow { stroke: var(--accent); stroke-width: 1.5; }
.coral-arrowhead path { fill: var(--accent); }
.coral-change { margin: 0; display: grid; gap: 3px; font-size: 11px; line-height: 1.45; }
.coral-change dt { color: var(--muted); }
.coral-change dd { margin: 0; font-variant-numeric: tabular-nums; }
.coral-change dd.is-large { font-weight: 700; }
.coral-axes-note { margin-top: 18px; font-size: 11px; line-height: 1.7; color: var(--muted); max-width: 760px; }
.coral-table tbody th { display: flex; align-items: center; gap: 7px; }
.coral-table tbody tr { cursor: pointer; }
.coral-table tr.is-highlight { background: #edf3ec; }
.coral-table tr.is-highlight th, .coral-table tr.is-highlight td { font-weight: 600; }
.coral-table tr.is-highlight .coral-swatch use { fill: var(--accent); stroke: #173d31; }
.coral-table tr.is-reference .coral-swatch use { fill: var(--ink); stroke: var(--ink); }
.coral-table thead tr:first-child th { border-bottom: 0; }
.coral-table thead th[colspan] { text-align: right; }

/* LEDOM: published examples */
.rv-range { display: flex; align-items: center; gap: 10px; flex: 1 1 280px; font-size: 12px; }
.rv-range input { flex: 1; min-width: 100px; accent-color: var(--accent); }
.rv-range output { min-width: 64px; font-variant-numeric: tabular-nums; color: var(--muted); }
.rv-examples { display: grid; gap: 30px; }
.rv-example { min-width: 0; }
.ledom-examples:not(.is-enhanced) .rv-example + .rv-example { border-top: 1px solid var(--line); padding-top: 26px; }
.ledom-examples:not(.is-enhanced) .rv-examples { margin-top: 24px; }
.rv-meta h4 { font: 400 19px/1.35 Georgia, serif; margin: 0; }
.rv-meta p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.rv-rows { display: flex; flex-direction: column; margin-top: 14px; border: 1px solid var(--line); border-top: 0; }
.rv-row { padding: 13px 16px 15px; border-top: 1px solid var(--line); }
.rv-row-given { background: var(--wash); }
.rv-rows.is-model-order .rv-row-given { order: -1; }
.rv-row-label { font-size: 10px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.rv-text { font: 17px/1.75 Georgia, serif; color: var(--ink); overflow-wrap: anywhere; }
.rv-text.rv-symbols { letter-spacing: .06em; }
.rv-text .is-pending { color: transparent; text-decoration: underline dotted #aab5ad; text-underline-offset: 5px; }
.rv-text .is-frontier { color: var(--accent); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
.rv-elision { font: italic 14px/1.7 Georgia, serif; color: var(--muted); }
.rv-note { margin-top: 12px; font-size: 13px; line-height: 1.7; color: #424e47; max-width: 760px; }
.rv-status { margin-top: 8px; font-size: 12px; color: var(--muted); }

/* LEDOM: Table 4 dot plot */
.rr-key { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 11px; color: var(--muted); }
.rr-key-item { display: inline-flex; align-items: center; gap: 5px; }
.rr-chart { margin-top: 14px; max-width: 760px; }
.rr-row { display: grid; grid-template-columns: 104px minmax(0, 1fr) 76px; align-items: center; column-gap: 12px; height: 26px; }
.rr-head { height: auto; font-size: 11px; color: var(--muted); margin-bottom: 6px; align-items: end; }
.rr-head .rr-axis-title { text-align: center; }
.rr-head .rr-value { font-weight: 400; color: var(--muted); font-size: 11px; line-height: 1.3; }
.rr-head .rr-value span { white-space: nowrap; }
.rr-group { border-top: 1px solid var(--line); padding: 5px 0 3px; }
.rr-bench { font-size: 12px; font-weight: 600; margin: 2px 0; }
.rr-model { font-size: 12px; color: #424e47; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rr-track { display: block; height: 26px; min-width: 0; }
.rr-track svg { display: block; width: 100%; height: 26px; overflow: visible; }
.rr-tick { stroke: #edf0ec; stroke-width: 1; }
.rr-zero { stroke: #7f8b83; stroke-width: 1; }
.rr-mark-greedy { fill: #fff; stroke: var(--ink); stroke-width: 1.4; }
.rr-mark-random { fill: #fff; stroke: #8e9990; stroke-width: 1.4; }
.rr-mark-rr { fill: var(--accent); stroke: #fff; stroke-width: 1.2; }
.rr-mark-beam { fill: #a9c4b9; stroke: var(--accent); stroke-width: 1.2; }
.rr-value { text-align: right; font-size: 12px; font-weight: 600; color: var(--accent); font-variant-numeric: tabular-nums; }
.rr-ticks-row { height: 22px; border-top: 1px solid var(--line); }
.rr-ticks { position: relative; display: block; height: 100%; }
.rr-ticks span { position: absolute; top: 5px; transform: translateX(-50%); font-size: 10px; line-height: 1; color: var(--muted); font-variant-numeric: tabular-nums; }
.rr-status p { font-weight: 600; font-size: 12px; }
.rr-status ul { margin: 4px 0 0; padding-left: 18px; }
.rr-status li + li { margin-top: 3px; }
.rr-table .rr-model-row th { font-weight: 600; padding-top: 12px; }
.rr-table tbody th[scope="row"] { padding-left: 18px; }
.rr-table tr.is-baseline { background: var(--wash); }
.rr-table .is-best { font-weight: 700; }

@media (max-width: 700px) {
  .cr-chips { flex-wrap: nowrap; overflow-x: auto; max-width: 100%; padding-bottom: 2px; }
  .cr-chips button { flex: none; }
  .cr-stage { grid-template-columns: 48px minmax(0, 1fr); column-gap: 6px; min-width: 780px; }
  .cr-cell { font-size: 11px; }
  .cr-link { height: 46px; }
  .cr-status { min-height: 0; }
  .coral-grid-panels { gap: 22px 14px; }
  .rv-text { font-size: 16px; }
  .rv-row { padding: 12px 13px 13px; }
  .rr-row { grid-template-columns: 86px minmax(0, 1fr) 46px; column-gap: 8px; }
  .rr-model { font-size: 11px; }
  .rr-head .rr-value { font-size: 10px; }
  .rr-table th, .rr-table td { padding: 7px 6px; }
  .rr-table tbody th[scope="row"] { white-space: normal; padding-left: 10px; min-width: 104px; }
  .rr-table thead th { white-space: normal; }
}
