/* BLITZ Мотошкола — CSS Animations */

/* Sparkle animation for particles */
@keyframes sparkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Float animation for decorative elements */
@keyframes float {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-20px);
  }
}

@keyframes floatSlow {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
  }
  33% {
    transform: translateY(-15px) rotate(2deg);
  }
  66% {
    transform: translateY(-8px) rotate(-1deg);
  }
}

/* Flying cone animation variant 1 */
@keyframes coneFly0 {
  0%, 100% {
    transform: rotate(-25deg) translate(0, 0);
  }
  50% {
    transform: rotate(-15deg) translate(15px, -20px);
  }
}

/* Flying cone animation variant 2 */
@keyframes coneFly1 {
  0%, 100% {
    transform: rotate(35deg) translate(0, 0);
  }
  50% {
    transform: rotate(25deg) translate(-10px, 15px);
  }
}

/* Flying cone animation variant 3 */
@keyframes coneFly2 {
  0%, 100% {
    transform: rotate(-15deg) translate(0, 0);
  }
  50% {
    transform: rotate(-30deg) translate(-15px, 15px);
  }
}

/* Flying cone animation variant 4 */
@keyframes coneFly3 {
  0%, 100% {
    transform: rotate(20deg) translate(0, 0);
  }
  50% {
    transform: rotate(10deg) translate(20px, -15px);
  }
}

/* Smoke animation for exhaust */
@keyframes smoke {
  0% {
    opacity: 0.3;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-40px, -20px) scale(2.5);
  }
}

/* Bounce animation for scroll indicator */
@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(8px);
  }
}

/* Scroll dot animation for mouse indicator */
@keyframes scrollDot {
  0% {
    top: 8px;
    opacity: 1;
  }
  100% {
    top: 24px;
    opacity: 0;
  }
}

/* Fade in up animation for scroll reveal */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Glow pulse animation for highlighted elements */
@keyframes glowPulse {
  0%, 100% {
    box-shadow: 0 0 20px rgba(182, 255, 62, 0.2);
  }
  50% {
    box-shadow: 0 0 40px rgba(182, 255, 62, 0.33);
  }
}

/* Shimmer animation for loading states */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* Rotate animation for decorative elements */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Pulse scale animation */
@keyframes pulseScale {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Slide in from left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide in from right */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Utility classes for applying animations */
.animate-sparkle {
  animation: sparkle 2s ease-in-out infinite;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

.animate-fadeInUp {
  animation: fadeInUp 0.6s ease-out forwards;
}

.animate-glow {
  animation: glowPulse 2s ease-in-out infinite;
}

.animate-shimmer {
  animation: shimmer 2s linear infinite;
}

.animate-rotate {
  animation: rotate 20s linear infinite;
}

.animate-pulse {
  animation: pulseScale 2s ease-in-out infinite;
}

.animate-slideInLeft {
  animation: slideInLeft 0.6s ease-out forwards;
}

.animate-slideInRight {
  animation: slideInRight 0.6s ease-out forwards;
}

/* Delay utility classes for staggered animations */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }

/* Cursor trail (P14c-3): singleton main bike + N ghost copies. Both
   are position:fixed and updated each frame via transform — never
   recreated, never animated by CSS keyframes. JS owns transform &
   opacity; CSS only declares look. */
.cursor-moto {
  position: fixed;
  top: 0;
  left: 0;
  width: 34px;
  height: 22px;
  color: #B6FF3E;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  will-change: transform, opacity;
  transform: translate(-9999px, -9999px);
  filter: drop-shadow(0 0 8px rgba(182, 255, 62, 0.55));
  transition: opacity 0.18s linear;
}

.cursor-moto--ghost {
  /* Motion-blur trail: progressively wider blur per ghost so the streak
     softens into the cursor's wake. --ghost-i is set by JS (0..N-1). */
  filter: blur(calc(1px + var(--ghost-i, 0) * 1.4px))
          drop-shadow(0 0 6px rgba(182, 255, 62, 0.45));
  z-index: 9998;
}

.cursor-moto svg {
  display: block;
  width: 100%;
  height: 100%;
}

.cursor-tire-track {
  position: absolute;
  height: 8px;
  pointer-events: none;
  z-index: 9998;
  transform-origin: left center;
  animation: tireTrackFade 0.9s ease-out forwards;
}

.cursor-tire-track::before,
.cursor-tire-track::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: repeating-linear-gradient(90deg, rgba(182, 255, 62, 0.55) 0 5px, transparent 5px 9px);
  border-radius: 999px;
}

.cursor-tire-track::before {
  top: 1px;
}

.cursor-tire-track::after {
  bottom: 1px;
}

.click-particle {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #B6FF3E;
  pointer-events: none;
  z-index: 9999;
  animation: clickBurst 0.5s forwards;
}

.click-moto-particle {
  position: absolute;
  width: 20px;
  height: 12px;
  color: #B6FF3E;
  pointer-events: none;
  z-index: 9999;
  filter: drop-shadow(0 0 6px rgba(182, 255, 62, 0.55));
  animation: clickMotoBurst 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.click-moto-particle svg {
  display: block;
  width: 100%;
  height: 100%;
}

@keyframes clickBurst {
  0% {
    transform: translate(0, 0);
    opacity: 1;
  }
  100% {
    transform: translate(var(--dx), var(--dy));
    opacity: 0;
  }
}

@keyframes clickMotoBurst {
  0% {
    transform: translate(-50%, -50%) rotate(var(--rot)) scale(0.55);
    opacity: 1;
  }
  55% {
    transform: translate(calc(var(--dx) * 0.65), calc(var(--dy) * 0.35 - 12px)) rotate(calc(var(--rot) + 24deg)) scale(1);
    opacity: 0.95;
  }
  100% {
    transform: translate(var(--dx), var(--dy)) rotate(calc(var(--rot) - 18deg)) scale(0.75);
    opacity: 0;
  }
}

.htmx-indicator {
  display: none;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
  display: block;
}

.flying-cone,
.moto-particle {
  will-change: transform;
}

.flying-cone > *,
.moto-particle > * {
  transform-origin: center;
  will-change: transform;
}

@keyframes tireTrackFade {
  0% {
    opacity: 0.75;
  }
  100% {
    opacity: 0;
  }
}

@media (pointer: coarse) {
  .cursor-moto,
  .cursor-moto--main,
  .cursor-moto--ghost,
  .cursor-tire-track {
    display: none;
  }
}

.tilt-card {
  transition: transform 0.5s ease;
  transform-style: preserve-3d;
}

/* ===========================================================
   Arc speedometer (P14c-1) — overshoot needle + smooth fill
   -----------------------------------------------------------
   Needle: 3-phase keyframe — punch past target, recoil, settle.
   Phase 1 (0 → 56.25%): 0% → target+8%, cubic-bezier(.34,1.56,.64,1)
   Phase 2 (56.25 → 81.25%): target+8% → target-4%, ease-out
   Phase 3 (81.25 → 100%): target-4% → target, ease-in-out
   Total 1.6s. +8%/-4% of 180° arc = +14.4°/-7.2° of rotation.

   Arc fill: separate transition on stroke-dashoffset, same 1.6s,
   smooth cubic-bezier — lands on final position synchronously with
   the needle. No overshoot on fill (a kicking arc looks broken).
   =========================================================== */

.arc-speedometer .arc-fill {
  stroke-dashoffset: 219.91;
  transition: stroke-dashoffset 1.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.arc-speedometer .arc-fill.is-visible {
  stroke-dashoffset: var(--arc-target-offset);
}

.arc-speedometer .arc-needle {
  transform: rotate(-90deg);
  transform-box: view-box;
  transform-origin: 90px 90px;
}

.arc-speedometer .arc-needle.is-animating {
  animation: arcNeedleOvershoot 1.6s forwards;
}

@keyframes arcNeedleOvershoot {
  0% {
    transform: rotate(-90deg);
    animation-timing-function: cubic-bezier(0.34, 1.56, 0.64, 1);
  }
  56.25% {
    /* +8% of arc past target — the "punch" */
    transform: rotate(calc(var(--arc-target-rot) + 14.4deg));
    animation-timing-function: ease-out;
  }
  81.25% {
    /* -4% of arc below target — the "recoil" */
    transform: rotate(calc(var(--arc-target-rot) - 7.2deg));
    animation-timing-function: ease-in-out;
  }
  100% {
    /* settle on target */
    transform: rotate(var(--arc-target-rot));
  }
}

@media (prefers-reduced-motion: reduce) {
  .arc-speedometer .arc-needle,
  .arc-speedometer .arc-needle.is-animating {
    animation: none;
    transform: rotate(var(--arc-target-rot));
  }
  .arc-speedometer .arc-fill {
    transition: none;
  }
}

/* ===========================================================
   Floating bikes chaos keyframes (P14c-2)
   ----------------------------------------------------------- 
   5 distinct trajectories so the swarm never reads as a single
   synchronised wave. Each is a 4-control-point loop using
   translate + small rotate. JS picks one of these per particle
   and randomises duration (18-35s) + negative delay so phases
   are scrambled across the swarm.

   prefers-reduced-motion: handled in JS (animation simply not
   assigned). On (pointer: coarse) particles use the legacy
   floatSlow keyframe with longer duration to spare CPU.
   =========================================================== */

@keyframes floatChaos1 {
  0%   { transform: translate(0, 0) rotate(0deg); }
  25%  { transform: translate(-22px, -14px) rotate(-2deg); }
  50%  { transform: translate(8px, -28px) rotate(3deg); }
  75%  { transform: translate(18px, -6px) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes floatChaos2 {
  0%   { transform: translate(0, 0) rotate(0deg); }
  20%  { transform: translate(14px, -10px) rotate(2deg); }
  45%  { transform: translate(-10px, -22px) rotate(-3deg); }
  70%  { transform: translate(-26px, 8px) rotate(1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes floatChaos3 {
  0%   { transform: translate(0, 0) rotate(0deg); }
  30%  { transform: translate(20px, 18px) rotate(-2deg); }
  60%  { transform: translate(-12px, 10px) rotate(3deg); }
  85%  { transform: translate(-22px, -16px) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes floatChaos4 {
  0%   { transform: translate(0, 0) rotate(0deg); }
  18%  { transform: translate(-16px, 12px) rotate(1deg); }
  42%  { transform: translate(-6px, -20px) rotate(-2deg); }
  68%  { transform: translate(24px, -8px) rotate(2deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@keyframes floatChaos5 {
  0%   { transform: translate(0, 0) rotate(0deg); }
  22%  { transform: translate(8px, 18px) rotate(-3deg); }
  48%  { transform: translate(-18px, 4px) rotate(2deg); }
  74%  { transform: translate(12px, -22px) rotate(-1deg); }
  100% { transform: translate(0, 0) rotate(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .moto-particle { animation: none !important; }
}
