/* ========================================
   Linked Legends: The Chain of Destiny
   Animation Styles
   ======================================== */

/* ========================================
   Keyframe Animations
   ======================================== */

/* Node Pulse Animation */
@keyframes nodePulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 25px rgba(0, 212, 255, 0.6);
  }
}

/* Link Pulse Animation */
@keyframes linkPulse {
  0%,
  100% {
    opacity: 0.5;
    transform: scaleX(1);
  }
  50% {
    opacity: 1;
    transform: scaleX(1.1);
  }
}

/* Shimmer Effect for Logo */
@keyframes shimmer {
  0% {
    background-position: -200% center;
  }
  100% {
    background-position: 200% center;
  }
}

/* Slide In Animation */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-30px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Slide Out Animation */
@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(30px);
  }
}

/* Fade In Animation */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade Out Animation */
@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* Scale In Animation */
@keyframes scaleIn {
  from {
    transform: scale(0);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Bounce Animation */
@keyframes bounce {
  0%,
  20%,
  53%,
  80%,
  100% {
    transform: translateY(0);
  }
  40%,
  43% {
    transform: translateY(-15px);
  }
  70% {
    transform: translateY(-7px);
  }
  90% {
    transform: translateY(-3px);
  }
}

/* Shake Animation */
@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-5px);
  }
  20%,
  40%,
  60%,
  80% {
    transform: translateX(5px);
  }
}

/* Pulse Animation */
@keyframes pulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

/* Glow Animation */
@keyframes glow {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.8);
  }
}

/* Gold Glow Animation */
@keyframes goldGlow {
  0%,
  100% {
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
  }
  50% {
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
  }
}

/* Rotate Animation */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Float Animation */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Arrow Flow Animation */
@keyframes arrowFlow {
  0% {
    stroke-dashoffset: 20;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

/* Pointer Move Animation */
@keyframes pointerMove {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Confetti Animation */
@keyframes confetti {
  0% {
    transform: translateY(-100%) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Garbage Collector Fall Animation */
@keyframes garbageFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(500px) rotate(360deg);
    opacity: 0;
  }
}

/* Chain Break Animation */
@keyframes chainBreak {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px) rotate(-5deg);
  }
  50% {
    transform: translateX(5px) rotate(5deg);
  }
  75% {
    transform: translateX(-3px);
  }
  100% {
    transform: translateY(100px) rotate(45deg);
    opacity: 0;
  }
}

/* Link Reconnect Animation */
@keyframes linkReconnect {
  0% {
    stroke-dasharray: 0 100;
    opacity: 0.5;
  }
  100% {
    stroke-dasharray: 100 0;
    opacity: 1;
  }
}

/* Cycle Spin Animation */
@keyframes cycleSpin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Racer Move Animation (for Floyd's Algorithm) */
@keyframes racerSlow {
  0%,
  100% {
    transform: translateX(0);
  }
  50% {
    transform: translateX(50px);
  }
}

@keyframes racerFast {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(50px);
  }
  50% {
    transform: translateX(100px);
  }
  75% {
    transform: translateX(50px);
  }
}

/* Lightning Beam Animation (for Random Pointers) */
@keyframes lightningBeam {
  0%,
  100% {
    opacity: 0.3;
    stroke-width: 1;
  }
  50% {
    opacity: 1;
    stroke-width: 3;
  }
}

/* Type Indicator Animation */
@keyframes typeIndicator {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Success Celebration Animation */
@keyframes celebrate {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.1) rotate(-5deg);
  }
  50% {
    transform: scale(1.1) rotate(5deg);
  }
  75% {
    transform: scale(1.1) rotate(-5deg);
  }
  100% {
    transform: scale(1);
  }
}

/* ========================================
   Animation Classes
   ======================================== */

.animate-fade-in {
  animation: fadeIn 0.5s ease forwards;
}

.animate-fade-out {
  animation: fadeOut 0.5s ease forwards;
}

.animate-slide-in {
  animation: slideIn 0.3s ease forwards;
}

.animate-slide-out {
  animation: slideOut 0.3s ease forwards;
}

.animate-scale-in {
  animation: scaleIn 0.3s ease forwards;
}

.animate-bounce {
  animation: bounce 1s ease;
}

.animate-shake {
  animation: shake 0.5s ease;
}

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

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

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

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

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

.animate-celebrate {
  animation: celebrate 0.5s ease;
}

/* ========================================
   Node Animations
   ======================================== */

.node-created {
  animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.node-deleted {
  animation: garbageFall 0.8s ease-in forwards;
}

.node-selected {
  animation: glow 1s ease-in-out infinite;
}

.node-highlight {
  animation: nodePulse 1s ease-in-out infinite;
}

.node-error {
  animation: shake 0.5s ease;
  border-color: var(--accent-red) !important;
}

.node-success {
  animation: celebrate 0.5s ease;
  border-color: var(--accent-green) !important;
}

/* ========================================
   Pointer Animations
   ======================================== */

.pointer-slow {
  animation: racerSlow 2s ease-in-out infinite;
}

.pointer-fast {
  animation: racerFast 1s ease-in-out infinite;
}

.pointer-traverse {
  animation: pointerMove 1s ease;
}

/* ========================================
   Link Animations
   ======================================== */

.link-created {
  animation: linkReconnect 0.5s ease forwards;
}

.link-broken {
  animation: chainBreak 0.8s ease-in forwards;
}

.link-flow {
  animation: arrowFlow 1s linear infinite;
}

.link-random {
  animation: lightningBeam 1s ease-in-out infinite;
}

/* ========================================
   Floating Background Nodes
   ======================================== */

.floating-node {
  position: absolute;
  width: 60px;
  height: 60px;
  background: var(--node-bg);
  border: 2px solid var(--node-border);
  border-radius: 12px;
  opacity: 0.2;
  animation: float 6s ease-in-out infinite;
}

.floating-node:nth-child(1) {
  top: 10%;
  left: 10%;
  animation-delay: 0s;
}

.floating-node:nth-child(2) {
  top: 20%;
  right: 15%;
  animation-delay: 1s;
}

.floating-node:nth-child(3) {
  bottom: 30%;
  left: 20%;
  animation-delay: 2s;
}

.floating-node:nth-child(4) {
  bottom: 15%;
  right: 25%;
  animation-delay: 3s;
}

.floating-node:nth-child(5) {
  top: 50%;
  left: 5%;
  animation-delay: 4s;
}

.floating-link {
  position: absolute;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-blue), transparent);
  opacity: 0.15;
  animation: linkPulse 4s ease-in-out infinite;
}

/* ========================================
   Confetti Effect
   ======================================== */

.confetti {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confetti 3s ease-in-out forwards;
}

.confetti-piece:nth-child(odd) {
  background: var(--accent-gold);
}

.confetti-piece:nth-child(even) {
  background: var(--accent-blue);
}

/* ========================================
   Garbage Collector Animation
   ======================================== */

.garbage-collector {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  width: 200px;
  height: 100px;
  background: linear-gradient(180deg, var(--accent-red), #8b0000);
  border-radius: 20px 20px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  transition: bottom 0.5s ease;
}

.garbage-collector.active {
  bottom: 0;
}

.garbage-collector::before {
  content: '🗑️';
  font-size: 3rem;
}

/* ========================================
   Cycle Track Animation
   ======================================== */

.cycle-track {
  stroke-dasharray: 5 5;
  animation: arrowFlow 2s linear infinite;
}

.cycle-indicator {
  position: absolute;
  width: 30px;
  height: 30px;
  border: 3px solid var(--accent-purple);
  border-radius: 50%;
  animation: cycleSpin 4s linear infinite;
}

.cycle-indicator::after {
  content: '🌀';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1.2rem;
}

/* ========================================
   LRU Cache Animations
   ======================================== */

.cache-evict {
  animation: garbageFall 0.5s ease-in forwards;
}

.cache-move-to-tail {
  transition: transform 0.5s ease;
}

.cache-highlight {
  animation: goldGlow 0.5s ease;
}

/* ========================================
   Clone Animation
   ======================================== */

.clone-node {
  opacity: 0.5;
  animation: fadeIn 0.5s ease forwards;
  animation-delay: 0.3s;
}

.clone-link {
  stroke-dasharray: 5 5;
  animation: linkReconnect 0.5s ease forwards;
}

/* ========================================
   Intersection Animation
   ======================================== */

.intersection-point {
  animation: goldGlow 1s ease-in-out infinite;
}

.path-a {
  stroke: var(--accent-blue);
}

.path-b {
  stroke: var(--accent-green);
}

/* ========================================
   Tutorial Animations
   ======================================== */

.tutorial-highlight {
  position: relative;
}

.tutorial-highlight::after {
  content: '';
  position: absolute;
  top: -5px;
  left: -5px;
  right: -5px;
  bottom: -5px;
  border: 2px solid var(--accent-gold);
  border-radius: inherit;
  animation: pulse 1s ease-in-out infinite;
  pointer-events: none;
}

.tutorial-arrow {
  position: absolute;
  font-size: 2rem;
  animation: bounce 1s ease-in-out infinite;
  color: var(--accent-gold);
}

/* ========================================
   Progress Animations
   ======================================== */

.progress-fill {
  transition: width 0.5s ease;
}

.progress-complete {
  animation: celebrate 0.5s ease;
}

/* ========================================
   Transition Classes
   ======================================== */

.transition-all {
  transition: all var(--transition-normal);
}

.transition-fast {
  transition: all var(--transition-fast);
}

.transition-slow {
  transition: all var(--transition-slow);
}

/* ========================================
   Special Effects
   ======================================== */

.magic-sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--accent-gold);
  border-radius: 50%;
  animation: fadeOut 1s ease forwards;
  pointer-events: none;
}

.energy-trail {
  position: absolute;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    var(--accent-blue),
    transparent
  );
  animation: pointerMove 0.5s ease;
  pointer-events: none;
}

/* ========================================
   Loading States
   ======================================== */

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--bg-tertiary);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: rotate 1s linear infinite;
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-tertiary) 25%,
    var(--bg-card) 50%,
    var(--bg-tertiary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
}
