/* ============================================================
   XQCHESS – Replay page (loaded after game.css; reuses .game-player,
   .gp-*, .game-board-wrap, .game-captured-tray, .gct-*)
   ============================================================ */

.replay-page {
  display: grid;
  grid-template-columns: minmax(0, 540px) minmax(260px, 340px);
  gap: 1.5rem;
  justify-content: center;
  align-items: start;
  max-width: 920px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.replay-main {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  min-width: 0;
}

.replay-head { margin-bottom: .25rem; }
.replay-meta {
  font-size: 12px;
  color: var(--text-faint);
  margin: 0 0 2px;
}
.replay-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin: 0;
}
.replay-error {
  margin: .5rem 0 0;
  padding: .5rem .75rem;
  border: 1px solid #C06060;
  border-radius: 8px;
  color: #E59A9A;
  background: color-mix(in srgb, #C06060 10%, transparent);
  font-size: 13px;
}

.rp-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border-h);
}
.rp-dot--red   { background: #C00000; }
.rp-dot--black { background: #1C1C1C; }

.replay-main .game-board-wrap canvas { cursor: default; }

/* ── Controls ───────────────────────────────────────────── */
.rp-controls {
  display: flex;
  gap: .4rem;
  width: 100%;
  flex-wrap: wrap;
}
.rp-btn,
.rp-speed {
  background: var(--ground-2);
  border: 1px solid var(--border-h);
  border-radius: 8px;
  padding: .5rem .7rem;
  font-size: .85rem;
  font-weight: 600;
  color: var(--text-dim);
  cursor: pointer;
  min-width: 2.6rem;
  transition: border-color .15s, color .15s;
}
.rp-btn:hover:not(:disabled),
.rp-speed:hover { border-color: var(--text-dim); color: var(--text); }
.rp-btn:disabled { opacity: .4; cursor: default; }
.rp-btn:focus-visible,
.rp-speed:focus-visible { outline: 2px solid var(--jade-l); outline-offset: 2px; }
.rp-btn--play {
  flex: 1;
  color: var(--text);
  border-color: var(--jade-l);
  background: color-mix(in srgb, var(--jade-l) 12%, var(--ground-2));
}

.rp-scrub {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.rp-scrub input[type=range] {
  flex: 1;
  accent-color: var(--jade-l);
}
.rp-counter {
  font-size: 12px;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rp-toggle {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: 13px;
  color: var(--text-dim);
  cursor: pointer;
}
.rp-toggle input { accent-color: var(--jade-l); }

/* ── Move list ──────────────────────────────────────────── */
.replay-side {
  background: var(--ground-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: .75rem;
  position: sticky;
  top: calc(var(--nav-h) + 1rem);
}
.rp-moves-head h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}
.rp-move-info {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  min-height: 1.2em;
  margin-top: 2px;
}

.rp-moves {
  position: relative;
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 60vh;
  overflow-y: auto;
  border-top: 1px solid var(--border);
}
.rp-move,
.rp-event {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  padding: .35rem .5rem;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.rp-move { cursor: pointer; color: var(--text-dim); }
.rp-move:hover { background: var(--ground-3); color: var(--text); }
.rp-move.is-current {
  background: color-mix(in srgb, var(--jade-l) 16%, var(--ground-2));
  color: var(--text);
  font-weight: 600;
}
.rp-move--start { font-style: italic; }
.rp-no {
  width: 2.2rem;
  flex-shrink: 0;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.rp-move--red .rp-txt   { color: #E07A7A; }
.rp-move--black .rp-txt { color: var(--text); }
.rp-txt { flex: 1; min-width: 0; }
.rp-reveal {
  font-size: 11px;
  color: #7FD1FF;
  white-space: nowrap;
}
.rp-think {
  font-size: 11px;
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.rp-event {
  font-size: 12px;
  color: var(--gold);
  padding-left: 2.7rem;
}
.rp-event--error { color: #E59A9A; }

.rp-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.rp-link {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-decoration: none;
  background: transparent;
  border: 1px solid var(--border-h);
  border-radius: 6px;
  padding: .45rem .6rem;
  cursor: pointer;
  white-space: nowrap;
}
.rp-link:hover { color: var(--text); border-color: var(--text-dim); }

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 820px) {
  .replay-page {
    grid-template-columns: minmax(0, 1fr);
    max-width: 560px;
    padding: 1rem 1rem 3rem;
  }
  .replay-side { position: static; }
  .rp-moves { max-height: 40vh; }
}

@media (prefers-reduced-motion: reduce) {
  .rp-btn, .rp-speed { transition: none; }
}
