/* Keyframes + small interactive animations. */

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

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.94) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes guess-in {
  from { opacity: 0; transform: translateX(-12px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes clue-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}
.shake { animation: shake 0.42s ease-in-out; }

@keyframes pulse-green {
  0%   { filter: drop-shadow(0 0 6px var(--track-glow)); }
  50%  { filter: drop-shadow(0 0 18px rgba(180, 227, 61, 0.8)); }
  100% { filter: drop-shadow(0 0 6px var(--track-glow)); }
}
#track-svg.win .track-line {
  stroke: var(--success);
  animation: pulse-green 1.2s ease-in-out 2;
}

@keyframes pulse-red {
  0%   { filter: drop-shadow(0 0 6px var(--track-glow)); }
  50%  { filter: drop-shadow(0 0 14px rgba(239, 71, 111, 0.8)); }
  100% { filter: drop-shadow(0 0 6px var(--track-glow)); }
}
#track-svg.lose .track-line {
  stroke: var(--danger);
  animation: pulse-red 0.9s ease-in-out 2;
}

/* Track reveal: line draws itself */
@keyframes draw-track {
  from { stroke-dashoffset: var(--track-length); }
  to   { stroke-dashoffset: 0; }
}
.track-line.drawing {
  stroke-dasharray: var(--track-length);
  stroke-dashoffset: var(--track-length);
  animation: draw-track 1.4s cubic-bezier(.22,.7,.3,1) forwards;
}

/* Starting lights intro overlay */
.lights {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--bg-deep);
  z-index: 9000;
  animation: fade-in 0.2s ease;
}
.lights.done {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.lights-row { display: flex; gap: 14px; }
.light {
  width: 28px;
  height: 42px;
  background: #301018;
  border: 3px solid #0b0510;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.04);
  transition: background 0.08s ease, box-shadow 0.08s ease;
}
.light.on {
  background: #ff2833;
  box-shadow:
    inset 0 0 6px rgba(255,255,255,0.5),
    0 0 18px rgba(255, 40, 51, 0.7);
}
.lights-go {
  font-family: var(--font-pixel);
  font-size: 28px;
  color: var(--success);
  letter-spacing: 0.2em;
  opacity: 0;
  transform: scale(0.8);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.lights.go .lights-go {
  opacity: 1;
  transform: scale(1.2);
}

.lights-prompt {
  font-family: var(--font-pixel);
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 0.18em;
  margin-top: 10px;
  opacity: 0.9;
  animation: prompt-pulse 1.4s ease-in-out infinite;
}
.lights.armed .lights-prompt,
.lights.go   .lights-prompt,
.lights.done .lights-prompt {
  display: none;
}
@keyframes prompt-pulse {
  0%, 100% { opacity: 0.9; }
  50%      { opacity: 0.35; }
}
.lights.armed { cursor: default; }
.lights { cursor: pointer; }

/* Header mini car: slight blinking checkered flag animation on streak */
@keyframes blink {
  0%, 80%, 100% { opacity: 1; }
  85%, 95% { opacity: 0.4; }
}

/* Reduced motion respect */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .track-line.drawing { stroke-dashoffset: 0 !important; }
}
