/* ============================================
   ROCKET LAUNCH ANIMATION
   Post-lesson reward visualization combining
   accuracy (trajectory smoothness) and
   speed (rocket velocity + particle intensity)
   ============================================ */

/* Full-screen overlay */
.rocket-overlay {
  position: fixed;
  inset: 0;
  z-index: 6000;
  overflow: hidden;
  background-color: #000010;
  background-image: radial-gradient(ellipse at 50% 100%, #0a0a2e 0%, #000010 70%);
}

.rocket-overlay.fade-out {
  animation: rocket-fade-out 0.6s ease forwards;
}

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

/* Starfield background */
.rocket-starfield {
  position: absolute;
  inset: 0;
}

.rocket-star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
}

.rocket-star.twinkle {
  animation: rocket-twinkle var(--twinkle-dur, 2s) ease-in-out infinite alternate;
  animation-delay: var(--twinkle-delay, 0s);
}

@keyframes rocket-twinkle {
  0% { opacity: 0.3; transform: scale(0.8); }
  100% { opacity: 1; transform: scale(1.2); }
}

/* The rocket */
.rocket-ship {
  position: absolute;
  bottom: -80px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 4rem;
  filter: drop-shadow(0 0 20px rgba(255, 150, 0, 0.6));
  z-index: 10;
  will-change: transform, bottom;
}

.rocket-ship.launched {
  transition: bottom var(--launch-dur, 3s) cubic-bezier(0.2, 0.8, 0.3, 1),
              transform var(--launch-dur, 3s) cubic-bezier(0.2, 0.8, 0.3, 1);
}

.rocket-ship.wobble {
  animation: rocket-wobble var(--launch-dur, 3s) ease-in-out;
}

@keyframes rocket-wobble {
  0% { transform: translateX(-50%) rotate(0deg); }
  10% { transform: translateX(-50%) rotate(var(--wobble-deg, 0deg)); }
  20% { transform: translateX(-50%) rotate(calc(var(--wobble-deg, 0deg) * -0.8)); }
  30% { transform: translateX(-50%) rotate(calc(var(--wobble-deg, 0deg) * 0.6)); }
  40% { transform: translateX(-50%) rotate(calc(var(--wobble-deg, 0deg) * -0.4)); }
  50% { transform: translateX(-50%) rotate(calc(var(--wobble-deg, 0deg) * 0.2)); }
  100% { transform: translateX(-50%) rotate(0deg); }
}

/* Engine flame */
.rocket-flame {
  position: absolute;
  bottom: -40px;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 60px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: linear-gradient(180deg,
    rgba(255, 200, 50, 1) 0%,
    rgba(255, 120, 0, 0.9) 40%,
    rgba(255, 50, 0, 0.6) 70%,
    transparent 100%
  );
  animation: flame-flicker 0.1s ease-in-out infinite alternate;
  z-index: 9;
}

@keyframes flame-flicker {
  0% { transform: translateX(-50%) scaleY(1) scaleX(1); opacity: 0.9; }
  100% { transform: translateX(-50%) scaleY(1.15) scaleX(0.85); opacity: 1; }
}

/* Exhaust particles */
.rocket-exhaust {
  position: absolute;
  z-index: 8;
  pointer-events: none;
}

.exhaust-particle {
  position: absolute;
  border-radius: 50%;
  will-change: transform, opacity;
  animation: exhaust-drift var(--exhaust-dur, 1s) ease-out forwards;
}

@keyframes exhaust-drift {
  0% {
    transform: translate(0, 0) scale(1);
    opacity: 0.8;
  }
  100% {
    transform: translate(var(--drift-x, 0px), var(--drift-y, 80px)) scale(var(--drift-scale, 2));
    opacity: 0;
  }
}

/* Speed lines (streaking past during launch) */
.speed-line {
  position: absolute;
  width: 2px;
  border-radius: 1px;
  background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: speed-streak var(--streak-dur, 0.4s) linear forwards;
  animation-delay: var(--streak-delay, 0s);
  will-change: transform;
}

@keyframes speed-streak {
  0% { transform: translateY(-100%); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(120vh); opacity: 0; }
}

/* Launch pad */
.rocket-launchpad {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 8px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  border-radius: 4px;
}

/* Destination planets/objects */
.rocket-destination {
  position: absolute;
  font-size: 3rem;
  opacity: 0;
  z-index: 5;
  filter: drop-shadow(0 0 15px var(--planet-glow, rgba(255, 200, 0, 0.5)));
  transition: opacity 0.8s ease, transform 0.8s ease;
}

.rocket-destination.visible {
  opacity: 1;
  animation: planet-float 3s ease-in-out infinite;
}

@keyframes planet-float {
  0%, 100% { transform: translate(var(--planet-x, 0), var(--planet-y, 0)); }
  50% { transform: translate(var(--planet-x, 0), calc(var(--planet-y, 0px) - 8px)); }
}

/* Score display that appears after landing */
.rocket-score-display {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  text-align: center;
  z-index: 20;
  pointer-events: none;
}

.rocket-score-display.visible {
  animation: score-reveal 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes score-reveal {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); }
  60% { transform: translate(-50%, -50%) scale(1.1) rotate(2deg); }
  100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
}

.rocket-score-value {
  font-size: 4rem;
  font-weight: 900;
  background: linear-gradient(135deg, #FFD700, #FF8C00);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
}

.rocket-score-label {
  font-size: 1.2rem;
  color: rgba(255, 255, 255, 0.8);
  margin-top: 4px;
}

.rocket-destination-label {
  font-size: 1.4rem;
  color: #FFD700;
  margin-top: 8px;
  font-weight: 700;
}

/* Screen shake on launch */
.rocket-overlay.shake {
  animation: screen-shake 0.5s ease;
}

@keyframes screen-shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-3px, -2px); }
  20% { transform: translate(3px, 1px); }
  30% { transform: translate(-2px, 3px); }
  40% { transform: translate(2px, -2px); }
  50% { transform: translate(-1px, 2px); }
  60% { transform: translate(1px, -1px); }
}

/* Explosion ring on reaching destination */
.arrival-ring {
  position: absolute;
  border-radius: 50%;
  border: 3px solid rgba(255, 215, 0, 0.8);
  width: 20px;
  height: 20px;
  animation: ring-expand 1s ease-out forwards;
  z-index: 15;
}

@keyframes ring-expand {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(8); opacity: 0; }
}

/* Countdown text before launch */
.rocket-countdown {
  position: absolute;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 5rem;
  font-weight: 900;
  color: #FFD700;
  opacity: 0;
  z-index: 20;
  text-shadow: 0 0 30px rgba(255, 215, 0, 0.5);
}

.rocket-countdown.pop {
  animation: countdown-pop 0.7s ease forwards;
}

@keyframes countdown-pop {
  0% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  80% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
}

/* Skip button */
.rocket-skip {
  position: absolute;
  bottom: 20px;
  right: 20px;
  z-index: 25;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.5);
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.rocket-skip:hover {
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
}
