/* Provenance replay player (P6) — src/app/provenance/replay/.
 *
 * Loaded with <link rel="stylesheet" href="/replay.css"> AFTER
 * /tokens.css, which is where every value below comes from. This file
 * declares NO custom properties: tokens.css is the only place a design
 * token is written down (its own banner states the rule), so everything
 * here reads var(--…) and nothing here defines one.
 *
 * Both presets (.rp-adjudicator, .rp-writer) share this sheet. Preset
 * differences are copy, set in player.ts — the only rules keyed to a
 * preset here are the two accent lines at the bottom, which tint the
 * frame so a writer never mistakes their own record for a review
 * surface.
 *
 * --chrome-fade appears only on borders and fills below. It is 3.46:1
 * on --paper and check-contrast.mjs fails the build if it ever carries
 * text; text uses --ink-muted.
 */

/* ── Overlay chrome (open.ts) ─────────────────────────────────────── */

.rp-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(26, 24, 21, 0.55);
  backdrop-filter: blur(2px);
  overflow: auto;
}

.rp-shell {
  position: relative;
  width: min(920px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--hair-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
}

.rp-close {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  width: 30px;
  height: 30px;
  padding: 0;
  font: inherit;
  font-size: 15px;
  line-height: 1;
  color: var(--ink-muted);
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 6px;
  cursor: pointer;
}

.rp-close:hover { color: var(--ink); background: var(--paper-3); }
.rp-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Player frame ─────────────────────────────────────────────────── */

.rp {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 20px 22px 22px;
  font-family: var(--sans);
  color: var(--ink);
}

.rp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-right: 34px;
}

.rp-head-text { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }

.rp-title {
  font-family: var(--display);
  font-size: 20px;
  font-weight: 600;
  color: var(--ink);
}

.rp-subject { font-size: 13px; color: var(--ink-muted); }

.rp-clock {
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
  white-space: nowrap;
}

.rp-framing {
  margin: 0;
  max-width: 66ch;
  font-size: 13px;
  line-height: 1.55;
  color: var(--ink-muted);
}

/* ── Stage / trail ────────────────────────────────────────────────── */

.rp-stage {
  border: 1px solid var(--hair);
  border-radius: 8px;
  background: var(--paper-2);
  overflow: hidden;
}

.rp-stage-label {
  padding: 7px 12px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
  background: var(--paper-3);
  border-bottom: 1px solid var(--hair);
}

.rp-trail {
  height: clamp(180px, 34vh, 340px);
  overflow: auto;
  padding: 16px 18px;
  font-family: var(--prose);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--paper);
}

.rp-trail:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.rp-trail-elide {
  display: block;
  padding: 4px 0;
  font-family: var(--sans);
  font-size: 11.5px;
  font-style: italic;
  color: var(--ink-muted);
}

.rp-caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin: 0 -1px;
  vertical-align: text-bottom;
  background: var(--red);
}

.rp.is-playing .rp-caret { animation: rp-blink 1s steps(2, start) infinite; }

@keyframes rp-blink { to { opacity: 0.25; } }

@media (prefers-reduced-motion: reduce) {
  .rp.is-playing .rp-caret { animation: none; }
}

.rp-seg {
  padding: 0.05em 0;
  color: var(--ink);
  border-radius: 2px;
}

.rp-seg-paste { background: var(--tone-warn-wash); box-shadow: inset 0 -1px 0 var(--tone-warn); }
.rp-seg-composed { background: var(--tone-info-wash); box-shadow: inset 0 -1px 0 var(--tone-info); }
.rp-seg-injected { background: var(--tone-danger-wash); box-shadow: inset 0 -1px 0 var(--tone-danger); }

.rp-caption {
  min-height: 1.4em;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--ink-soft);
}

/* ── Track: density · away · marks · progress · scrubber ──────────── */

.rp-track {
  position: relative;
  height: 46px;
  border: 1px solid var(--hair);
  border-radius: 6px;
  background: var(--paper-2);
  overflow: hidden;
}

.rp-density {
  position: absolute;
  inset: 0 0 6px;
  display: grid;
  align-items: end;
  gap: 0;
}

.rp-col { display: block; width: 100%; min-height: 0; }
.rp-col-typing { background: var(--ink-soft); opacity: 0.5; }
.rp-col-revision { background: var(--accent); opacity: 0.55; }
.rp-col-paste { background: var(--tone-warn); opacity: 0.7; }
.rp-col-away { background: var(--chrome-fade); opacity: 0.35; }

.rp-away-layer, .rp-marks, .rp-progress { position: absolute; inset: 0; pointer-events: none; }

.rp-away {
  position: absolute;
  top: 0;
  bottom: 6px;
  background: repeating-linear-gradient(
    45deg,
    rgba(138, 133, 122, 0.16) 0 4px,
    rgba(138, 133, 122, 0.04) 4px 8px
  );
  border-left: 1px solid var(--chrome-fade);
  border-right: 1px solid var(--chrome-fade);
}

.rp-mark {
  position: absolute;
  top: 0;
  bottom: 6px;
  width: 2px;
  margin-left: -1px;
  background: var(--tone-warn);
}

.rp-mark-medium { background: var(--tone-warn); }
.rp-mark-high { background: var(--tone-danger); width: 3px; }
.rp-mark-low { background: var(--tone-info); }

.rp-progress {
  right: auto;
  width: 0;
  background: var(--red-wash);
  border-right: 2px solid var(--red);
}

.rp-scrub {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: 0;
  appearance: none;
  cursor: pointer;
}

.rp-scrub::-webkit-slider-thumb {
  appearance: none;
  width: 12px;
  height: 44px;
  background: transparent;
  border: 0;
  cursor: ew-resize;
}

.rp-scrub::-moz-range-thumb {
  width: 12px;
  height: 44px;
  background: transparent;
  border: 0;
  cursor: ew-resize;
}

.rp-scrub:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Controls ─────────────────────────────────────────────────────── */

.rp-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-soft);
}

.rp-btn {
  padding: 6px 12px;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--hair-strong);
  border-radius: 6px;
  cursor: pointer;
}

.rp-btn:hover:not(:disabled) { background: var(--paper-3); color: var(--ink); }
.rp-btn:disabled { opacity: 0.45; cursor: default; }
.rp-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.rp-btn.is-primary {
  min-width: 92px;
  color: var(--paper);
  background: var(--ink-2);
  border-color: var(--ink-2);
}

.rp-btn.is-primary:hover:not(:disabled) { background: var(--ink); color: var(--paper); }

.rp-speed-label, .rp-condense-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--ink-muted);
  cursor: pointer;
}

.rp-speed {
  font: inherit;
  font-size: 12px;
  padding: 4px 6px;
  color: var(--ink-2);
  background: var(--paper);
  border: 1px solid var(--hair-strong);
  border-radius: 5px;
}

.rp-moment-counter {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--ink-muted);
}

/* ── Moment list ──────────────────────────────────────────────────── */

.rp-moments { display: flex; flex-direction: column; gap: 6px; }

.rp-moments-label, .rp-fidelity-label, .rp-stage-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.rp-moments-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 168px;
  overflow: auto;
}

.rp-moments-empty { margin: 0; font-size: 12.5px; color: var(--ink-muted); }

.rp-moment {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  font: inherit;
  text-align: left;
  color: var(--ink-2);
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-left: 3px solid var(--tone-warn);
  border-radius: 5px;
  cursor: pointer;
}

.rp-moment-low { border-left-color: var(--tone-info); }
.rp-moment-high { border-left-color: var(--tone-danger); }
.rp-moment:hover:not(:disabled) { background: var(--paper-3); }
.rp-moment:disabled { cursor: default; opacity: 0.7; }
.rp-moment.is-current { background: var(--paper-3); border-color: var(--hair-strong); }
.rp-moment:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.rp-moment-stamp {
  flex: 0 0 auto;
  font-family: var(--mono);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--ink-muted);
  padding-top: 1px;
}

.rp-moment-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.rp-moment-cat { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.rp-moment-reason { font-size: 11.5px; line-height: 1.45; color: var(--ink-muted); }

/* ── Legend + fidelity ────────────────────────────────────────────── */

.rp-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 11px;
  color: var(--ink-muted);
}

.rp-legend-item { display: inline-flex; align-items: center; gap: 5px; }

.rp-swatch {
  display: inline-block;
  width: 22px;
  height: 10px;
  border-radius: 2px;
}

.rp-legend code {
  font-family: var(--mono);
  padding: 0 4px;
  background: var(--paper-3);
  border-radius: 3px;
}

.rp-fidelity {
  padding: 10px 12px;
  background: var(--paper-2);
  border: 1px solid var(--hair);
  border-radius: 6px;
}

.rp-fidelity-note {
  margin: 5px 0 0;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--ink-muted);
}

.rp-fidelity-clean { margin-top: 0; }

/* ── Loading ──────────────────────────────────────────────────────── */

.rp.is-loading .rp-track, .rp.is-loading .rp-controls { opacity: 0.5; }

/* ── Preset accents — the only preset-keyed rules in this file ─────── */

.rp-adjudicator .rp-title { border-bottom: 2px solid var(--red); padding-bottom: 2px; }
.rp-writer .rp-title { border-bottom: 2px solid var(--tone-good); padding-bottom: 2px; }

/* ── Narrow viewports ─────────────────────────────────────────────── */

@media (max-width: 620px) {
  .rp-overlay { padding: 0; }
  .rp-shell { width: 100%; height: 100%; max-height: 100%; border: 0; border-radius: 0; }
  .rp { padding: 16px 14px 20px; }
  .rp-moment-counter { margin-left: 0; }
}
