/* Replay page for dba-post-0007: where the log piles up in a distributed availability group.
   Site chrome and brand tokens come from /assets/css/site.css. This file adds the wide layout,
   the scenario picker and the replay panels. The four stage colours are data colours, checked
   for colour-blind separation on both surfaces; they are not brand colours. */

body.replay {
  --measure: 80rem;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --track: #e9f1ef;
  --ink3: #6b7280;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --rate: #14897f; --good: #2f7a45; --crit: #c0362c;
  --deep: #0b2725; --mint: #5eead4;
  /* names used by the lab page's drawing code */
  --ink: var(--text); --ink2: var(--muted); --line: var(--border);
}
@media (prefers-color-scheme: dark) {
  body.replay {
    --track: #0b2725;
    --ink3: #86a39e;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500;
    --rate: #5eead4; --good: #9be59a; --crit: #f87171;
  }
}

body.replay h1, body.replay h2, body.replay h3 { font-family: var(--font-head); }
.rp-intro { max-width: 52rem; }
.rp-eyebrow { font: 600 0.75rem/1.2 var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--amber); }
@media (prefers-color-scheme: dark) { .rp-eyebrow { color: #f2b45a; } }
.rp-intro h1 { font-size: clamp(1.9rem, 4.2vw, 2.7rem); line-height: 1.15; margin: 0.4rem 0 0.6rem; }
.rp-tested { font: 0.78rem var(--font-mono); color: var(--muted); }
.rp-section { font-size: clamp(1.3rem, 3vw, 1.6rem); margin: 2.2rem 0 0.8rem; }

/* how to read it */
.rp-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0.75rem; margin: 1rem 0; padding: 0; list-style: none; }
.rp-facts li { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--sw, var(--teal)); border-radius: var(--radius); padding: 0.6rem 0.8rem; font-size: 0.92rem; line-height: 1.45; }
.rp-facts b { display: block; font-family: var(--font-head); }

/* scenario picker */
.rp-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 0.6rem; }
.rp-tabs button { font: inherit; text-align: left; cursor: pointer; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.6rem 0.8rem; line-height: 1.3; }
.rp-tabs button b { display: block; font: 600 0.72rem var(--font-mono); letter-spacing: 0.1em; color: var(--muted); }
.rp-tabs button:hover { border-color: var(--accent); }
.rp-tabs button[aria-pressed="true"] { background: var(--deep); border-color: var(--deep); color: #e6f2ef; box-shadow: inset 0 -3px 0 var(--mint); }
.rp-tabs button[aria-pressed="true"] b { color: var(--mint); }
@media (prefers-color-scheme: dark) { .rp-tabs button[aria-pressed="true"] { border-color: var(--mint); } }
.rp-about { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; margin: 0.75rem 0 1rem; }
.rp-about > div { background: var(--surface); border: 1px solid var(--border); border-top: 3px solid #14897f; border-radius: var(--radius); padding: 0.7rem 0.9rem; font-size: 0.95rem; line-height: 1.5; }
.rp-about > div + div { border-top-color: #f2b45a; }
.rp-about h3 { font: 600 0.72rem var(--font-mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); margin: 0 0 0.35rem; }
.rp-about p { margin: 0; } .rp-about ul { margin: 0; padding-left: 1.1rem; }
@media (max-width: 46rem) { .rp-about { grid-template-columns: 1fr; } }

/* player */
.rp { display: grid; gap: 0.75rem; font-size: 0.875rem; line-height: 1.4; }
.rp .card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 0.85rem 1rem; min-width: 0; }
.rp h2 { font: 600 0.72rem var(--font-mono); margin: 0 0 0.6rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.rp .num { font-variant-numeric: tabular-nums; }
.rp .muted { color: var(--ink3); }
.rp-status { display: flex; flex-wrap: wrap; gap: 0.4rem 0.6rem; align-items: center; }
.chip { display: inline-flex; gap: 6px; align-items: center; padding: 2px 10px; border: 1px solid var(--border); border-radius: 999px; font-size: 0.78rem; color: var(--muted); }
.chip b { color: var(--text); font-weight: 600; }
.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; top: 0; z-index: 5; }
.rp button, .rp select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 5px 10px; cursor: pointer; min-height: 2.1rem; }
.rp button:hover, .rp select:hover { border-color: var(--accent); }
.rp button[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.rp #bPlay { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); min-width: 5.2rem; font-weight: 600; }
.seg { display: inline-flex; } .seg button { border-radius: 0; margin-left: -1px; }
.seg button:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; } .seg button:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.sep { width: 1px; height: 22px; background: var(--border); margin: 0 4px; }
.grow { flex: 1; }
@media (max-width: 46rem) { .controls { position: static; } .sep, .controls .grow { display: none; } }
#callout { border-left: 5px solid var(--ink3); font-size: 1rem; }
#callout.hot { border-left-color: var(--crit); } #callout.calm { border-left-color: var(--good); }
#callout small { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 4px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 0.78rem; color: var(--muted); margin-bottom: 10px; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }

/* flow strip: scrolls inside its own box on narrow screens */
.flowbox { overflow-x: auto; }
.flowbox > div { min-width: 44rem; }
.flow { display: grid; gap: 8px; }
.frow, .fhead { display: grid; grid-template-columns: 9rem repeat(4, minmax(5.5rem, 1fr)) 9.5rem; gap: 6px; }
.frow { align-items: stretch; cursor: pointer; border-radius: 8px; padding: 4px; border: 1px solid transparent; }
.frow.sel { border-color: var(--accent); }
.fhead { padding: 0 4px 4px; font: 0.68rem var(--font-mono); color: var(--ink3); text-transform: uppercase; letter-spacing: 0.06em; }
.node { border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; font-size: 0.75rem; background: var(--bg); }
.node b { display: block; font-size: 0.82rem; } .node.down { border-color: var(--crit); }
.tank { position: relative; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; min-height: 58px; background: var(--track); }
.tank .fill { position: absolute; left: 0; right: 0; bottom: 0; transition: height 0.25s; }
.tank .txt { position: relative; padding: 5px 8px; font-size: 0.7rem; color: var(--muted); }
.tank .txt b { display: block; font-size: 0.875rem; color: var(--text); }
.tank .txt span { background: color-mix(in srgb, var(--surface) 80%, transparent); border-radius: 4px; padding: 0 3px; }
@media (prefers-reduced-motion: reduce) { .tank .fill { transition: none; } }

.two { display: grid; grid-template-columns: 1.5fr 1fr; gap: 0.75rem; }
@media (max-width: 56rem) { .two { grid-template-columns: 1fr; } }
.brow { display: grid; grid-template-columns: 9rem 1fr 6.5rem; gap: 10px; align-items: center; margin: 7px 0; }
@media (max-width: 30rem) { .brow { grid-template-columns: 5.2rem 1fr 4.6rem; gap: 6px; } }
.blabel { font-size: 0.75rem; color: var(--muted); } .blabel b { color: var(--text); }
.btrack { display: flex; gap: 2px; height: 20px; }
.bseg { height: 100%; min-width: 0; } .bseg:first-child { border-radius: 4px 0 0 4px; } .bseg:last-child { border-radius: 0 4px 4px 0; }
.bval { text-align: right; font-size: 0.82rem; }
.rgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(11.5rem, 1fr)); gap: 14px; }
.rrow { display: grid; grid-template-columns: 4.4rem 1fr 3.4rem; gap: 6px; align-items: center; font-size: 0.7rem; color: var(--muted); margin: 3px 0; }
.rbar { height: 8px; border-radius: 0 4px 4px 0; background: var(--rate); min-width: 1px; }
.rrow.low .rbar { background: var(--crit); }
.rp svg text { fill: var(--muted); font: 11px var(--font-sans); }
.rp svg text.big { fill: var(--text); font: 600 20px var(--font-head); }
.tblbox { overflow-x: auto; }
.rp table { border-collapse: collapse; width: 100%; font-size: 0.75rem; margin: 0; }
.rp th, .rp td { text-align: right; padding: 5px 8px; border: 0; border-bottom: 1px solid var(--border); white-space: nowrap; background: none; }
.rp th { color: var(--ink3); font-weight: 600; } .rp th:first-child, .rp td:first-child { text-align: left; }
#tip { position: fixed; pointer-events: none; background: var(--deep); color: #e6f2ef; border: 1px solid #1b4540; padding: 6px 9px; border-radius: 6px; font-size: 0.75rem; line-height: 1.4; z-index: 9; display: none; max-width: 320px; white-space: pre-line; }
#timeline { width: 100%; height: 170px; display: block; cursor: crosshair; }
#events { max-height: 190px; overflow: auto; font-size: 0.78rem; }
#events div { padding: 4px 0; border-bottom: 1px solid var(--border); cursor: pointer; }
#events div:hover { color: var(--accent); }
#events div.past { color: var(--ink3); }
.tag { font: 0.62rem var(--font-mono); text-transform: uppercase; border: 1px solid var(--border); border-radius: 4px; padding: 0 5px; margin-right: 6px; color: var(--muted); }
.hidden { display: none !important; }
.rp-notes { max-width: 52rem; }
.rp-notes li { margin: 0.3rem 0; }
