/* Incident 10s frame ring-buffer & scrubbing timeline styles.
   Matches SkySentry's monochrome Geist aesthetic across Tower/App (app.css) and Landing/Site (site.css).
   All transitions and keyframes are strictly compositor/paint-only and respect prefers-reduced-motion. */

#detail > .incident-replay {
  grid-column: 1 / -1;
}

.incident-replay {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 12px;
  background: var(--card, #111);
  border: 1px solid var(--line, var(--line-s, #262626));
  color: var(--ink, var(--ink-s, #fafafa));
  min-width: 0;
  box-sizing: border-box;
}

.incident-replay[hidden],
.incident-replay [hidden] {
  display: none !important;
}

/* ---------- Viewport, responsive frame canvas, and HUD badge ---------- */
.incident-replay-viewport {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  background: #0a0a0a;
  border: 1px solid var(--line, var(--line-s, #262626));
  isolation: isolate;
  min-width: 0;
}

.incident-replay-canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  object-fit: contain;
}

.incident-replay-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  padding: 3px 8px;
  border-radius: 6px;
  font: 600 0.75rem/1.2 var(--mono, var(--mono-s, "Geist Mono", ui-monospace, monospace));
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(10, 10, 10, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: #fafafa;
  border: 1px solid rgba(255, 255, 255, 0.16);
  pointer-events: none;
}

.incident-replay-badge::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a1a1aa;
}

.incident-replay-badge[data-alert="true"] {
  border-color: color-mix(in srgb, var(--stop, #ef4444) 68%, transparent);
  background: rgba(28, 10, 10, 0.86);
  color: #fff;
}

.incident-replay-badge[data-alert="true"]::before {
  background: var(--stop, #ef4444);
}

/* ---------- Transport controls & tabular-numeral buttons ---------- */
.incident-replay-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.incident-replay-btn,
.incident-replay-play,
.incident-replay-prev,
.incident-replay-next,
.incident-replay-speed {
  appearance: none;
  -webkit-appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  box-sizing: border-box;
  border: 1px solid var(--line, var(--line-s, #e5e7eb));
  background: var(--paper-2, #f4f4f5);
  color: var(--ink, var(--ink-s, #0a0a0a));
  border-radius: 8px;
  padding: 5px 10px;
  font: 500 0.78rem/1.2 var(--mono, var(--mono-s, "Geist Mono", ui-monospace, monospace));
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
  transition:
    background-color 0.14s ease,
    border-color 0.14s ease,
    color 0.14s ease,
    transform 0.1s ease,
    opacity 0.14s ease;
}

.incident-replay-play {
  min-width: 58px;
  justify-content: center;
}

.incident-replay-prev,
.incident-replay-next {
  min-width: 32px;
  padding: 5px 8px;
  justify-content: center;
}

.incident-replay-speed {
  min-width: 44px;
  text-align: center;
  justify-content: center;
}

.incident-replay-btn:hover:not(:disabled),
.incident-replay-play:hover:not(:disabled),
.incident-replay-prev:hover:not(:disabled),
.incident-replay-next:hover:not(:disabled),
.incident-replay-speed:hover:not(:disabled) {
  background-color: var(--hover, #e4e4e7);
  border-color: var(--line-2, #d4d4d8);
  color: var(--ink, var(--ink-s, #0a0a0a));
  opacity: 1;
}

.incident-replay-btn:active:not(:disabled),
.incident-replay-play:active:not(:disabled),
.incident-replay-prev:active:not(:disabled),
.incident-replay-next:active:not(:disabled),
.incident-replay-speed:active:not(:disabled) {
  transform: scale(0.97);
}

.incident-replay-btn:focus-visible,
.incident-replay-play:focus-visible,
.incident-replay-prev:focus-visible,
.incident-replay-next:focus-visible,
.incident-replay-speed:focus-visible {
  outline: 2px solid var(--ink, var(--ink-s, #0a0a0a));
  outline-offset: 2px;
}

.incident-replay-btn:disabled,
.incident-replay-play:disabled,
.incident-replay-prev:disabled,
.incident-replay-next:disabled,
.incident-replay-speed:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.incident-replay-play[aria-pressed="true"],
.incident-replay-btn.incident-replay-play[aria-pressed="true"] {
  background: var(--accent, #0a0a0a);
  color: var(--on-accent, #fff);
  border-color: var(--accent, #0a0a0a);
}

.incident-replay-play[aria-pressed="true"]:hover:not(:disabled),
.incident-replay-btn.incident-replay-play[aria-pressed="true"]:hover:not(:disabled) {
  background-color: var(--accent, #0a0a0a);
  color: var(--on-accent, #fff);
  border-color: var(--accent, #0a0a0a);
  opacity: 0.88;
}

/* ---------- Timeline range scrubber ---------- */
.incident-replay-scrubber {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 auto;
  min-width: 96px;
  height: 24px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  accent-color: var(--accent, #0a0a0a);
  cursor: pointer;
}

.incident-replay-scrubber:hover {
  border-color: transparent;
}

.incident-replay-scrubber:focus-visible {
  outline: 2px solid var(--ink, var(--ink-s, #0a0a0a));
  outline-offset: 2px;
}

.incident-replay-scrubber:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.incident-replay-scrubber::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background-color: var(--line-2, var(--line, var(--line-s, #d4d4d8)));
}

.incident-replay-scrubber::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -5px;
  border-radius: 50%;
  border: 2px solid var(--card, #111);
  background-color: var(--accent, var(--ink, var(--ink-s, #0a0a0a)));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition:
    transform 0.12s ease,
    background-color 0.14s ease,
    box-shadow 0.14s ease;
}

.incident-replay-scrubber::-moz-range-track {
  height: 4px;
  border: 0;
  border-radius: 999px;
  background-color: var(--line-2, var(--line, var(--line-s, #d4d4d8)));
}

.incident-replay-scrubber::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--card, #111);
  box-sizing: border-box;
  background-color: var(--accent, var(--ink, var(--ink-s, #0a0a0a)));
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.28);
  transition:
    transform 0.12s ease,
    background-color 0.14s ease,
    box-shadow 0.14s ease;
}

/* ---------- Empty-state banner for pre-session historical incidents ---------- */
.incident-replay-empty {
  margin: 0;
  padding: 14px 12px;
  border-radius: 8px;
  background: var(--paper-2, #f4f4f5);
  border: 1px dashed var(--line-2, var(--line, var(--line-s, #d4d4d8)));
  color: var(--mute, var(--mute-s, #6b7280));
  font: 400 0.84rem/1.45 var(--sans, "Geist", system-ui, sans-serif);
}

@media (max-width: 380px) {
  .incident-replay-controls {
    flex-wrap: wrap;
  }

  .incident-replay-scrubber {
    order: -1;
    flex-basis: 100%;
  }
}

/* ---------- Motion & accessibility (strictly gated) ---------- */
@keyframes incident-replay-alert-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.45;
    transform: scale(1.22);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .incident-replay-badge[data-alert="true"]::before {
    animation: incident-replay-alert-pulse 1.4s ease-in-out infinite;
  }

  .incident-replay-scrubber:not(:disabled):hover::-webkit-slider-thumb {
    transform: scale(1.12);
  }

  .incident-replay-scrubber:not(:disabled):hover::-moz-range-thumb {
    transform: scale(1.12);
  }
}

@media (prefers-reduced-motion: reduce) {
  .incident-replay,
  .incident-replay *,
  .incident-replay *::before,
  .incident-replay *::after,
  .incident-replay-btn,
  .incident-replay-play,
  .incident-replay-prev,
  .incident-replay-next,
  .incident-replay-speed,
  .incident-replay-badge,
  .incident-replay-badge::before,
  .incident-replay-badge[data-alert="true"]::before,
  .incident-replay-scrubber {
    animation: none !important;
    transition-duration: 0.01ms !important;
  }

  .incident-replay-btn:active:not(:disabled),
  .incident-replay-play:active:not(:disabled),
  .incident-replay-prev:active:not(:disabled),
  .incident-replay-next:active:not(:disabled),
  .incident-replay-speed:active:not(:disabled) {
    transform: none !important;
  }

  .incident-replay-scrubber::-webkit-slider-thumb {
    animation: none !important;
    transition-duration: 0.01ms !important;
    transform: none !important;
  }

  .incident-replay-scrubber::-moz-range-thumb {
    animation: none !important;
    transition-duration: 0.01ms !important;
    transform: none !important;
  }
}
