/* T17 Incident Replay (replay.js). The replay has its own colour, BCP cyan, so it can't be confused with
   the sign states (teal / violet / rose / amber), the alarm (red) or training (yellow hazard tape).
   The live top bar stays as it is; the docked replay bar sits under it and a cyan frame marks
   everything below as the past. */
html{ --rp:#00a7e1; --rp-ink:#04121a; --rp-soft:rgba(0,167,225,.14); --rp-bar:#0f2333; --rp-text:#eaf7fd; --rp-dim:#a9c8d8; }
html[data-theme="light"]{ --rp:#0072a3; --rp-ink:#ffffff; --rp-soft:rgba(0,114,163,.10); --rp-bar:#e8f5fb; --rp-text:#0b0c0c; --rp-dim:#3f5560; }

/* ---------- the bar ---------- */
#replayBar{
  position:sticky; top:var(--tb-h, 64px); z-index:54;
  display:grid; gap:4px; padding:8px 28px 7px;
  background:var(--rp-bar); color:var(--rp-text);
  border-bottom:3px solid var(--rp); box-shadow:0 6px 18px rgba(0,0,0,.28);
  font-size:13px; line-height:1.3;
}
#replayBar[hidden]{ display:none; }
.rp-row{ display:flex; align-items:center; gap:8px; min-width:0; }
.rp-info{ display:flex; align-items:center; gap:12px; min-width:0; min-height:22px; }
.rp-tag{ flex:none; display:inline-flex; align-items:center; gap:7px; margin-right:6px; padding:3px 10px 3px 8px; border-radius:999px;
  background:var(--rp); color:var(--rp-ink); font-weight:800; font-size:12px; letter-spacing:.08em; text-transform:uppercase; }
.rp-dot{ width:8px; height:8px; border-radius:50%; background:currentColor; animation:rpBlink 1.2s steps(2, jump-none) infinite; }
@keyframes rpBlink{ 50%{ opacity:.25; } }

#replayBar button{ font:inherit; color:inherit; cursor:pointer; }
#replayBar button:disabled{ opacity:.35; cursor:default; }
#replayBar button:focus-visible, #rpRange:focus-visible{ outline:2px solid var(--rp); outline-offset:2px; }
#replayBar .rp-ic{ flex:none; display:inline-grid; place-items:center; width:32px; height:32px; padding:0; border-radius:4px;
  background:transparent; border:1px solid color-mix(in srgb, var(--rp) 55%, transparent); letter-spacing:0; }
#replayBar .rp-ic svg{ width:16px; height:16px; fill:currentColor; }
#replayBar .rp-ic:hover:not(:disabled){ background:var(--rp-soft); }
#replayBar .rp-big{ width:38px; height:38px; background:var(--rp); color:var(--rp-ink); border-color:var(--rp); }
#replayBar .rp-big svg{ width:20px; height:20px; }
#replayBar .rp-big:hover:not(:disabled){ background:var(--rp); filter:brightness(1.12); }
#replayBar .rp-sm{ width:24px; height:24px; font-size:16px; line-height:1; font-weight:700; }
.rp-speed{ flex:none; display:inline-flex; align-items:center; gap:6px; }
.rp-speed b{ min-width:46px; text-align:center; font-variant-numeric:tabular-nums; font-size:14px; }
#replayBar .rp-txt{ flex:none; padding:6px 11px; border-radius:4px; letter-spacing:.02em; background:transparent; border:1px solid color-mix(in srgb, var(--rp) 55%, transparent); white-space:nowrap; }
#replayBar .rp-txt:hover{ background:var(--rp-soft); }
#replayBar .rp-close{ background:var(--rp); color:var(--rp-ink); border-color:var(--rp); font-weight:700; }
#replayBar .rp-close:hover{ background:var(--rp); filter:brightness(1.12); }

/* the scrubber: what the signs showed overall, alarms in red, presses and comms losses as ticks */
.rp-scrub{ position:relative; flex:1 1 auto; min-width:120px; height:42px; margin:0 6px; --p:0%; }
.rp-ribbon, .rp-marks{ position:absolute; left:0; right:0; top:9px; height:12px; border-radius:3px; pointer-events:none; }
.rp-ribbon{ background:rgba(150,160,190,.28); }
.rp-ribbon::after{ content:""; position:absolute; top:0; bottom:0; left:var(--p); right:0; background:rgba(5,10,20,.4); border-radius:0 3px 3px 0; }
html[data-theme="light"] .rp-ribbon::after{ background:rgba(255,255,255,.62); }
.rp-marks{ top:5px; height:20px; }
.rp-m-alarm{ position:absolute; top:0; height:4px; background:#ff3b50; border-radius:2px; }
.rp-m{ position:absolute; bottom:0; width:2px; height:20px; margin-left:-1px; border-radius:1px; }
.rp-m-press{ background:var(--rp-text); }
.rp-m-comms{ height:9px; bottom:-5px; background:#9aa3b8; }
#rpRange{ position:absolute; left:0; right:0; top:0; width:100%; height:30px; margin:0; background:transparent; -webkit-appearance:none; appearance:none; cursor:pointer; }
#rpRange::-webkit-slider-runnable-track{ height:30px; background:transparent; }
#rpRange::-moz-range-track{ height:30px; background:transparent; }
#rpRange::-webkit-slider-thumb{ -webkit-appearance:none; appearance:none; width:6px; height:28px; margin-top:1px; border-radius:3px;
  background:#fff; border:0; box-shadow:0 0 0 2px var(--rp), 0 0 10px var(--rp); }
#rpRange::-moz-range-thumb{ width:6px; height:28px; border-radius:3px; background:#fff; border:0; box-shadow:0 0 0 2px var(--rp), 0 0 10px var(--rp); }
.rp-ends{ position:absolute; left:0; right:0; bottom:0; display:flex; justify-content:space-between; font-size:11px; color:var(--rp-dim); pointer-events:none; }

.rp-when{ flex:none; font-weight:800; font-size:14px; font-variant-numeric:tabular-nums; }
.rp-alarm{ flex:none; padding:2px 9px; border-radius:999px; background:#d4182f; color:#fff; font-weight:700; font-size:12px; }
.rp-alarm[hidden]{ display:none; }
.rp-feed{ flex:1 1 auto; display:flex; gap:16px; min-width:0; margin:0; padding:0; list-style:none; overflow:hidden; white-space:nowrap;
  -webkit-mask-image:linear-gradient(to right, #000 85%, transparent); mask-image:linear-gradient(to right, #000 85%, transparent); }
.rp-ev{ flex:none; display:inline-flex; align-items:center; gap:6px; padding:1px 8px 1px 6px; border-radius:4px; }
.rp-ev:nth-child(2){ opacity:.8; } .rp-ev:nth-child(3){ opacity:.62; } .rp-ev:nth-child(4){ opacity:.45; }
.rp-ev time{ font-variant-numeric:tabular-nums; color:var(--rp-dim); }
.rp-ev::before{ content:""; flex:none; width:8px; height:8px; border-radius:50%; background:#9aa3b8; }
.rp-ev-press::before{ background:var(--rp-text); border-radius:2px; }
.rp-ev-sign[data-state="BOTH"]::before{ background:var(--teal); }
.rp-ev-sign[data-state="POOLE"]::before{ background:var(--violet); }
.rp-ev-sign[data-state="TWIN"]::before{ background:var(--rose); }
.rp-ev-sign::before{ background:var(--amber); }
.rp-ev-alert::before{ background:#ff3b50; box-shadow:0 0 6px #ff3b50; }
.rp-ev-clear::before, .rp-ev-back::before{ background:var(--teal); }
.rp-ev-none{ color:var(--rp-dim); } .rp-ev-none::before{ display:none; }
.rp-ev .op-init{ font-size:11px; }
.rp-ev.fresh{ animation:rpFresh 1.6s ease-out; }
@keyframes rpFresh{ 0%{ background:var(--rp); color:var(--rp-ink); transform:translateY(-3px); } 100%{ background:transparent; transform:none; } }
.rp-note{ flex:0 1 auto; min-width:0; font-size:11px; color:var(--rp-dim); text-align:right; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* ---------- the frame, and the scene played like a tape ---------- */
#rpFrame{ display:none; }
html.replaying #rpFrame{ display:block; position:fixed; z-index:50; left:0; right:0; bottom:0; top:var(--tb-h, 64px); pointer-events:none;
  box-shadow:inset 0 0 0 3px var(--rp); }
html.replaying #sceneBand{ position:relative; }
html.replaying #sceneBand::after{ content:""; position:absolute; inset:0; z-index:4; pointer-events:none;
  background:repeating-linear-gradient(to bottom, rgba(255,255,255,.045) 0 1px, transparent 1px 3px); }
.rp-osd{ display:none; }
html.replaying .rp-osd{ display:grid; gap:2px; position:absolute; z-index:5; left:18px; bottom:12px; pointer-events:none;
  font:700 15px/1.2 ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace; letter-spacing:.08em; color:#fff;
  text-shadow:0 0 6px rgba(0,0,0,.85), 0 0 2px rgba(0,0,0,.9); }
.rp-osd-mode{ color:#7fdcff; }
html.replaying #hero .hero-text::before{ content:"\25B6  Replay \00B7  not live"; display:block; width:fit-content; margin-bottom:6px; padding:2px 9px; border-radius:4px;
  background:var(--rp); color:var(--rp-ink); font-size:12px; font-weight:800; letter-spacing:.08em; text-transform:uppercase; }
/* no presses from a picture of the past (the controls are also inert) */
html.replaying .cp-hero{ opacity:.35; filter:grayscale(1); }
html.replaying .cp-hero::after{ content:"Bridge controls are off during a replay"; display:block; margin-top:6px; font-size:12px; font-weight:700; }

/* ---------- ways in: a play button on shift-log and history rows, Replay on the timeline ---------- */
html[data-view] button.rp-btn, html[data-view][data-theme] button.rp-btn{ display:inline-grid; place-items:center; width:20px; height:20px; padding:0; margin:-2px 7px 0 0; vertical-align:middle; cursor:pointer;
  border-radius:50%; border:1px solid var(--rp); background:transparent; color:var(--rp); opacity:.6; letter-spacing:0; box-shadow:none; }
.rp-btn::before{ content:""; margin-left:2px; border-left:7px solid currentColor; border-top:4.5px solid transparent; border-bottom:4.5px solid transparent; }
tr:hover .rp-btn, .rp-btn:focus-visible{ opacity:1; }
html[data-view][data-theme] button.rp-btn:hover{ background:var(--rp); color:var(--rp-ink); opacity:1; box-shadow:none; }
.rp-btn:focus-visible{ outline:2px solid var(--rp); outline-offset:2px; }
.tl-controls button.rp-tl{ border-color:var(--rp); color:var(--rp); font-weight:700; }
.tl-controls button.rp-tl:hover{ background:var(--rp); color:var(--rp-ink); }
html.training .rp-btn, html.training .rp-tl{ display:none !important; }
.tl-rp{ position:absolute; top:0; bottom:0; pointer-events:none; z-index:3; }
.tl-rp[hidden]{ display:none; }
.tl-rp-win{ background:var(--rp-soft); border-left:1px dashed var(--rp); border-right:1px dashed var(--rp); }
.tl-rp-head{ width:2px !important; margin-left:-1px; background:var(--rp); box-shadow:0 0 8px var(--rp); }
.tl-rp-head::after{ content:"\25B6  " attr(data-t); position:absolute; bottom:-20px; left:50%; transform:translateX(-50%);
  padding:1px 7px; border-radius:6px; font-size:11px; font-weight:700; white-space:nowrap; background:var(--rp); color:var(--rp-ink); }

#rpNotice{ position:fixed; z-index:60; left:50%; bottom:28px; transform:translateX(-50%); max-width:calc(100vw - 32px); padding:10px 16px; border-radius:6px;
  background:var(--panel, #211631); color:var(--text, #fff); border:2px solid var(--rp); box-shadow:0 8px 24px rgba(0,0,0,.4); font-size:14px; }
#rpNotice[hidden]{ display:none; }
.rp-short{ display:none; }

@media (prefers-reduced-motion: reduce){
  .rp-dot{ animation:none; }
  .rp-ev.fresh{ animation:none; }
}
/* laptops: drop the long note before anything else */
@media (max-width:1180px){ .rp-note{ display:none; } }
/* phones: the scrubber gets its own line, the feed shows the latest event only */
@media (max-width:720px){
  #replayBar{ padding:8px 12px 7px; }
  .rp-row{ flex-wrap:wrap; row-gap:6px; }
  .rp-scrub{ order:9; flex-basis:100%; margin:0; }
  .rp-tag, #rpLink, .rp-long{ display:none; }
  .rp-short{ display:inline; }
  .rp-speed{ margin-left:auto; }
  .rp-info{ flex-wrap:wrap; gap:2px 8px; }
  .rp-feed{ flex-basis:100%; }
  .rp-ev ~ .rp-ev{ display:none; }
  #rpNotice{ bottom:80px; }
  html.replaying .rp-osd{ left:10px; bottom:8px; font-size:12px; }
}
