/* ============================================================================
   Replay viewer guided-tour engine — visual styles.

   Class prefix .rv-tour-* is part of the engine's public contract; do not
   rename.

   Theming reality: the popover mounts to document.body, which sits outside
   the #page-dashboard scope where the design tokens (--accent, --text-*,
   --border-strong, etc.) are defined. Every var() in this file therefore
   resolves to its hardcoded fallback at runtime. The fallback values are
   intentionally chosen to match the dashboard tokens (#56c2ff accent,
   #f4f6fa primary text, etc.) so the tour looks native to the replay
   viewer. The var() references are kept as forward-compat hooks for the
   day someone migrates the tokens to :root.

   Sole exception: --border-strong in #page-dashboard is #2f3742 (neutral
   steel). The tour deliberately wants accent-blue border to match its own
   visual language, so border-strong references are written as literals
   below — not as var(--border-strong, …) — to avoid surprise if/when the
   tokens move to :root.
   ============================================================================ */

/* Screen-reader-only utility. Used by the engine for the live-status node
   that announces each step. Standard "visually hidden" recipe. */
.rv-tour-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.rv-tour-overlay {
  position: fixed;
  inset: 0;
  /* Light dim only — the user still wants to watch the gameplay /
     overlays move behind the tour. The spotlight ring + popover do
     the heavy lifting for "where to look"; the backdrop just takes
     a touch of edge off the surrounding chrome. No blur — blur this
     wide degrades canvas readability and chews battery on mobile. */
  background: rgba(7, 10, 16, 0.32);
  pointer-events: auto;
  animation: rv-tour-fade-in 180ms ease-out;
}

/* When a clip-path cutout is applied the overlay is visually punched out
   over the spotlighted element, but clip-path does NOT affect pointer
   hit-testing — the overlay still catches clicks across its full bounds.
   The engine sets pointer-events: none on the overlay when a step opts
   into allowInteraction; otherwise clicks are absorbed and the target is
   read-only during the tour. */
.rv-tour-overlay--cutout {
  /* clip-path is set inline by the engine. */
}

.rv-tour-spotlight {
  position: fixed;
  pointer-events: none;
  box-shadow:
    0 0 0 1.5px rgba(86, 194, 255, 0.55),
    0 0 0 4px rgba(86, 194, 255, 0.18),
    0 0 24px 4px rgba(86, 194, 255, 0.28),
    inset 0 0 14px rgba(86, 194, 255, 0.12);
  border: 1px solid rgba(86, 194, 255, 0.5);
  background: transparent;
  animation: rv-tour-spotlight-in 220ms cubic-bezier(0.2, 0.8, 0.25, 1);
  transition:
    left 220ms cubic-bezier(0.2, 0.8, 0.25, 1),
    top 220ms cubic-bezier(0.2, 0.8, 0.25, 1),
    width 220ms cubic-bezier(0.2, 0.8, 0.25, 1),
    height 220ms cubic-bezier(0.2, 0.8, 0.25, 1);
}

.rv-tour-popover {
  position: fixed;
  width: 360px;
  max-width: calc(100vw - 32px);
  background: rgba(16, 20, 28, 0.96);
  color: var(--text-primary, #f4f6fa);
  /* Literal accent-blue — see file header re: --border-strong divergence. */
  border: 1px solid rgba(86, 194, 255, 0.35);
  border-radius: 12px;
  box-shadow:
    0 18px 40px rgba(0, 0, 0, 0.55),
    0 2px 6px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(86, 194, 255, 0.08);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.5;
  padding: 18px 18px 14px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  pointer-events: auto;
}

.rv-tour-popover.rv-tour-visible {
  opacity: 1;
  transform: translateY(0);
}

.rv-tour-popover.rv-tour-centered {
  left: 50% !important;
  top: 50% !important;
  transform: translate(-50%, -50%) translateY(4px);
}
.rv-tour-popover.rv-tour-centered.rv-tour-visible {
  transform: translate(-50%, -50%) translateY(0);
}

.rv-tour-popover-title {
  font-family: var(--font-display, 'Rajdhani', system-ui, sans-serif);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 0.01em;
  color: var(--text-primary, #f4f6fa);
  margin: 0 0 8px;
}

.rv-tour-popover-body {
  font-size: 14px;
  color: var(--text-secondary, #d8dde6);
  margin: 0 0 16px;
}

.rv-tour-popover-body p {
  margin: 0 0 8px;
}
.rv-tour-popover-body p:last-child {
  margin-bottom: 0;
}

.rv-tour-popover-body a {
  color: var(--accent, #56c2ff);
  text-decoration: none;
  border-bottom: 1px solid rgba(86, 194, 255, 0.4);
}
.rv-tour-popover-body a:hover {
  border-bottom-color: rgba(86, 194, 255, 0.9);
}

.rv-tour-popover-body code,
.rv-tour-popover-body kbd {
  font-family: var(--font-mono, 'JetBrains Mono', ui-monospace, monospace);
  font-size: 12.5px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  padding: 1px 6px;
}

.rv-tour-popover-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.rv-tour-footer-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
}

.rv-tour-footer-right {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rv-tour-progress {
  font-family: var(--font-display, 'Rajdhani', system-ui, sans-serif);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
  /* #9CA3AF clears AA against the popover bg (~6.5:1); #6B7280 was 4.0:1. */
  color: var(--text-muted, #9CA3AF);
}

.rv-tour-btn {
  appearance: none;
  -webkit-appearance: none;
  font-family: var(--font-display, 'Rajdhani', system-ui, sans-serif);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  /* 36px touch target on desktop; 40px on mobile (see media query below). */
  min-height: 36px;
  padding: 9px 14px;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  border: 1px solid transparent;
  line-height: 1;
}

/* Programmatic .focus() calls (engine focuses Next on each step) don't
   always trip :focus-visible in Chromium, so we match both. */
.rv-tour-btn:focus,
.rv-tour-btn:focus-visible {
  outline: 2px solid #56c2ff;
  outline-offset: 3px;
}

.rv-tour-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.rv-tour-btn--primary {
  background: rgba(86, 194, 255, 0.18);
  border-color: rgba(86, 194, 255, 0.55);
  color: var(--accent, #56c2ff);
}
.rv-tour-btn--primary:hover:not(:disabled) {
  background: rgba(86, 194, 255, 0.32);
  border-color: rgba(86, 194, 255, 0.85);
  color: #fff;
}

.rv-tour-btn--ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--text-secondary, #d8dde6);
}
.rv-tour-btn--ghost:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.28);
  color: var(--text-primary, #f4f6fa);
}

/* Arrow — small diamond rotated 45deg so we get a triangle pointer that
   shares the popover's border + background. Positioning is set inline by
   the engine; data-side governs which two borders show. */
.rv-tour-arrow {
  position: absolute;
  width: 14px;
  height: 14px;
  background: rgba(16, 20, 28, 0.96);
  /* Literal accent-blue — see file header re: --border-strong divergence. */
  border: 1px solid rgba(86, 194, 255, 0.35);
  transform: rotate(45deg);
  pointer-events: none;
}

.rv-tour-arrow[data-side='top'] {
  /* popover above target — arrow on bottom edge */
  border-top-color: transparent;
  border-left-color: transparent;
}
.rv-tour-arrow[data-side='bottom'] {
  /* popover below target — arrow on top edge */
  border-bottom-color: transparent;
  border-right-color: transparent;
}
.rv-tour-arrow[data-side='left'] {
  /* popover left of target — arrow on right edge */
  border-bottom-color: transparent;
  border-left-color: transparent;
}
.rv-tour-arrow[data-side='right'] {
  /* popover right of target — arrow on left edge */
  border-top-color: transparent;
  border-right-color: transparent;
}

.rv-tour-popover.rv-tour-centered .rv-tour-arrow {
  display: none;
}

@keyframes rv-tour-fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes rv-tour-spotlight-in {
  from {
    opacity: 0;
    box-shadow:
      0 0 0 0 rgba(86, 194, 255, 0),
      0 0 0 0 rgba(86, 194, 255, 0),
      0 0 0 0 rgba(86, 194, 255, 0);
  }
  to {
    opacity: 1;
  }
}

/* Mobile / narrow viewport — let the popover use almost the full width
   and stop trying to fit alongside a target horizontally. */
@media (max-width: 500px) {
  .rv-tour-popover {
    width: calc(100vw - 16px);
    max-width: calc(100vw - 16px);
    left: 8px !important;
    right: 8px;
  }
  .rv-tour-popover.rv-tour-centered {
    left: 50% !important;
  }
  /* Arrow loses meaning when the popover spans the screen — drop it on
     small screens so it doesn't appear off-target. */
  .rv-tour-popover:not(.rv-tour-centered) .rv-tour-arrow {
    display: none;
  }
  /* Larger touch target — fingers need ~40px to hit reliably. */
  .rv-tour-btn {
    min-height: 40px;
    padding: 11px 16px;
  }
  .rv-tour-footer-left {
    min-height: 40px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .rv-tour-overlay,
  .rv-tour-spotlight,
  .rv-tour-popover {
    animation: none;
    transition: none;
  }
}
