/* Mechanism replay player + shared primitives. Case modules add only their own layout. */
.replay {
  --rp-line: rgba(var(--brass-rgb),.25);
  --rp-soft: rgba(var(--cream-rgb),.05);
  --rp-panel: #101522;
  --rp-sunk: #0b0f1a;
  --rp-ok: #9cc8a4;
  --rp-bad: #e39a86;
  --rp-warn: #fac251;
  --rp-ease: cubic-bezier(.22,.68,0,1);
  color: var(--cream, #f1ebe0);
  background: var(--rp-panel);
  border: 1px solid var(--rp-line);
  border-radius: 14px;
  padding: clamp(18px, 3vw, 32px);
  font: 400 14px/1.5 var(--font-body, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif);
}
.replay *, .replay *::before, .replay *::after { box-sizing: border-box; }
.replay-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.replay-head:has(.replay-tabs:empty):has(.replay-actions:empty) { display: none; }
.replay-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.replay-tab, .replay-action, .replay-play, .replay-step {
  font: inherit; font-size: 13px; color: var(--muted, #a9b1c2); background: transparent;
  border: 1px solid rgba(var(--muted-rgb),.3); border-radius: 999px; padding: 7px 14px; cursor: pointer; line-height: 1.2;
  transition: color .2s, border-color .2s, background .2s;
}
.replay-tab:hover, .replay-action:hover, .replay-play:hover, .replay-step:hover:not(:disabled) { color: var(--cream, #f1ebe0); border-color: var(--brass, #e9b46c); }
.replay-tab[aria-pressed="true"] { color: var(--bg); background: var(--brass, #e9b46c); border-color: var(--brass, #e9b46c); }
.replay-action { color: var(--brass, #e9b46c); border-color: rgba(var(--brass-rgb),.55); }
.replay-action:active { transform: translateY(1px); }
.replay-stage { position: relative; min-height: 260px; }
.replay-narration { min-height: 3.2em; margin: 18px 0 14px; font-size: 15px; line-height: 1.6; color: #e0d8c9; }
.replay-controls { display: flex; align-items: center; gap: 8px; }
.replay-play { min-width: 72px; color: var(--cream, #f1ebe0); }
.replay-step { width: 34px; height: 34px; padding: 0; display: grid; place-items: center; font-size: 18px; }
.replay-step:disabled { opacity: .35; cursor: default; }
.replay-ticks { flex: 1; display: flex; gap: 4px; min-width: 0; }
.replay-tick { flex: 1; min-width: 6px; height: 22px; padding: 0; border: 0; background: none; cursor: pointer; position: relative; }
.replay-tick::before { content: ""; position: absolute; left: 0; right: 0; top: 9px; height: 4px; border-radius: 2px; background: rgba(var(--cream-rgb),.14); transition: background .3s; }
.replay-tick.is-done::before { background: rgba(var(--brass-rgb),.55); }
.replay-tick[aria-current="step"]::before { background: var(--brass, #e9b46c); box-shadow: 0 0 0 3px rgba(var(--brass-rgb),.18); }
.replay-tick:focus-visible { outline: 2px solid var(--sky, #8fb3d9); outline-offset: 2px; border-radius: 3px; }
.replay-counter { font-size: 12px; color: var(--muted, #a9b1c2); font-variant-numeric: tabular-nums; min-width: 40px; text-align: right; }

/* Shared primitives for case modules. */
.rp-card { background: var(--rp-sunk); border: 1px solid rgba(var(--cream-rgb),.1); border-radius: 8px; padding: 12px 14px; transition: border-color .4s var(--rp-ease), opacity .4s var(--rp-ease), transform .5s var(--rp-ease), background .4s; }
.rp-card.is-active { border-color: var(--brass, #e9b46c); }
.rp-card.is-dim { opacity: .38; }
.rp-label { display: block; font-size: 12px; color: var(--muted, #a9b1c2); margin-bottom: 4px; }
.rp-value { font-size: 15px; color: var(--cream, #f1ebe0); font-variant-numeric: tabular-nums; }
.rp-mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12px; }
.rp-tag { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 9px; border-radius: 999px; border: 1px solid currentColor; line-height: 1.4; white-space: nowrap; }
.rp-tag.ok { color: var(--rp-ok); }
.rp-tag.bad { color: var(--rp-bad); }
.rp-tag.warn { color: var(--rp-warn); }
.rp-tag.muted { color: var(--muted, #a9b1c2); }
.rp-pop { animation: rp-pop .5s var(--rp-ease); }
.rp-shake { animation: rp-shake .45s ease-in-out; }
.rp-meter { height: 8px; border-radius: 4px; background: rgba(var(--cream-rgb),.1); overflow: hidden; }
.rp-meter > i { display: block; height: 100%; width: calc(var(--fill, 0) * 100%); background: var(--brass, #e9b46c); border-radius: inherit; transition: width .9s var(--rp-ease); }
@keyframes rp-pop { from { transform: scale(.92); opacity: .2; } to { transform: none; opacity: 1; } }
@keyframes rp-shake { 0%,100% { transform: none; } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

@media (max-width: 520px) {
  .replay { padding: 16px 14px; border-radius: 10px; }
  .replay-narration { font-size: 14px; min-height: 4.8em; }
  .replay-tab, .replay-action { font-size: 12px; padding: 6px 11px; }
  .replay-counter { display: none; }
  .replay-stage { min-height: 240px; }
}
@media (prefers-reduced-motion: reduce) {
  .replay *, .replay *::before, .replay *::after { transition: none !important; animation: none !important; }
}
