/* Advanced Animations & Interactive Effects */

/* Scroll-triggered fade-up animation */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

/* Scroll-triggered animation classes */
.fade-up {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s ease;
}

.fade-up.animate {
  opacity: 1;
  transform: translateY(0);
}

.fade-in {
  opacity: 0;
  transition: opacity 0.6s ease;
}

.fade-in.animate {
  opacity: 1;
}

.slide-left {
  opacity: 0;
  transform: translateX(-30px);
  transition: all 0.6s ease;
}

.slide-left.animate {
  opacity: 1;
  transform: translateX(0);
}

.slide-right {
  opacity: 0;
  transform: translateX(30px);
  transition: all 0.6s ease;
}

.slide-right.animate {
  opacity: 1;
  transform: translateX(0);
}

.scale-in {
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.6s ease;
}

.scale-in.animate {
  opacity: 1;
  transform: scale(1);
}

/* Stagger delays for child elements */
.stagger-1 { transition-delay: 0.1s; }
.stagger-2 { transition-delay: 0.2s; }
.stagger-3 { transition-delay: 0.3s; }
.stagger-4 { transition-delay: 0.4s; }
.stagger-5 { transition-delay: 0.5s; }
.stagger-6 { transition-delay: 0.6s; }

/* Counter animation for statistics */
.counter {
  display: inline-block;
  font-variant-numeric: tabular-nums;
}

.counter.counting {
  animation: pulse 0.1s ease-in-out;
}

/* Advanced hover effects */
.hover-lift {
  transition: all var(--transition-medium);
}

.hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-xl);
}

.hover-scale {
  transition: transform var(--transition-medium);
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-glow {
  position: relative;
  transition: all var(--transition-medium);
}

.hover-glow::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, var(--color-accent), var(--color-success));
  border-radius: inherit;
  opacity: 0;
  z-index: -1;
  transition: opacity var(--transition-medium);
}

.hover-glow:hover::before {
  opacity: 0.5;
}

/* 3D Card Effects */
.card-3d {
  transform-style: preserve-3d;
  transition: transform var(--transition-medium);
}

.card-3d:hover {
  transform: rotateY(5deg) rotateX(5deg);
}

/* Loading animations */
@keyframes shimmer {
  0% {
    background-position: -200px 0;
  }
  100% {
    background-position: calc(200px + 100%) 0;
  }
}

.shimmer {
  background: linear-gradient(
    90deg,
    var(--color-bg-secondary) 0px,
    var(--color-bg-tertiary) 40px,
    var(--color-bg-secondary) 80px
  );
  background-size: 200px 100%;
  animation: shimmer 1.5s infinite;
}

/* Ripple effect */
.ripple {
  position: relative;
  overflow: hidden;
}

.ripple::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.ripple:hover::before {
  width: 300px;
  height: 300px;
}

/* Gradient border animation */
@keyframes gradientBorder {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.gradient-border {
  position: relative;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-lg);
}

.gradient-border::before {
  content: '';
  position: absolute;
  inset: -2px;
  padding: 2px;
  background: linear-gradient(45deg, var(--color-accent), var(--color-success), var(--color-accent));
  background-size: 300% 300%;
  border-radius: inherit;
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: destination-out;
  animation: gradientBorder 2s ease infinite;
}

/* Text reveal animations */
.text-reveal {
  position: relative;
  overflow: hidden;
}

.text-reveal::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--color-bg-primary);
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.text-reveal.animate::before {
  transform: translateX(100%);
}

/* Typewriter effect */
@keyframes typewriter {
  to {
    left: 100%;
  }
}

.typewriter {
  position: relative;
  overflow: hidden;
}

.typewriter::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: var(--color-bg-primary);
  animation: typewriter 2s steps(40, end) forwards;
}

/* Mouse cursor trail */
.cursor-dot {
  width: 5px;
  height: 5px;
  background-color: var(--color-accent);
  border-radius: 50%;
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  opacity: 0;
  transform: scale(0);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.cursor-dot.active {
  opacity: 1;
  transform: scale(1);
}

/* Parallax scroll effects */
.parallax {
  transform: translateZ(0);
  will-change: transform;
}

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

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

.float:nth-child(2) {
  animation-delay: 0.5s;
}

.float:nth-child(3) {
  animation-delay: 1s;
}

.float:nth-child(4) {
  animation-delay: 1.5s;
}

/* Interactive code block animations */
.code-block {
  position: relative;
  overflow: hidden;
}

.code-block::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transition: left 0.8s ease;
}

.code-block:hover::before {
  left: 100%;
}

/* Progress bar animations */
@keyframes progressFill {
  from {
    width: 0%;
  }
  to {
    width: var(--progress-width);
  }
}

.progress-animated {
  animation: progressFill 2s ease-out forwards;
}

/* Magnetic hover effect */
.magnetic {
  transition: transform 0.3s ease;
  cursor: pointer;
}

.magnetic:hover {
  transform: translate(var(--mouse-x, 0), var(--mouse-y, 0));
}

/* SVG path drawing animation */
@keyframes draw {
  to {
    stroke-dashoffset: 0;
  }
}

.draw-svg path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: draw 2s ease forwards;
}

/* Responsive animation controls */
@media (max-width: 768px) {
  .hover-lift:hover {
    transform: translateY(-4px);
  }

  .card-3d:hover {
    transform: none;
  }

  .magnetic:hover {
    transform: none;
  }
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .particle {
    display: none;
  }

  .float {
    animation: none;
  }

  .typewriter::after {
    display: none;
  }

  .shimmer {
    animation: none;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .gradient-text {
    background: none;
    -webkit-text-fill-color: unset;
    color: var(--color-text-primary);
  }

  .hover-glow::before {
    display: none;
  }
}