/* ============================================================
   ADVANCED ANIMATIONS & EFFECTS
   Magnetic interactions, parallax, micro-animations
   ============================================================ */

/* ── Magnetic Button Effect ────────────────── */
.btn-magnetic {
  position: relative;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.btn-magnetic::after {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, rgba(124, 111, 255, 0.4), rgba(245, 200, 66, 0.2));
  border-radius: inherit;
  opacity: 0;
  filter: blur(20px);
  transition: opacity 0.3s;
  z-index: -1;
}

.btn-magnetic:hover::after {
  opacity: 1;
  animation: magneticGlow 1.5s ease-in-out infinite;
}

@keyframes magneticGlow {
  0%, 100% { filter: blur(20px) brightness(1); }
  50% { filter: blur(25px) brightness(1.2); }
}

/* ── Floating Elements ─────────────────────── */
.float-slow {
  animation: floatSlow 6s ease-in-out infinite;
}

.float-medium {
  animation: floatMedium 4s ease-in-out infinite;
}

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

@keyframes floatSlow {
  0%, 100% { transform: translateY(0px) translateX(0px); }
  25% { transform: translateY(-10px) translateX(5px); }
  50% { transform: translateY(-5px) translateX(10px); }
  75% { transform: translateY(-15px) translateX(5px); }
}

@keyframes floatMedium {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  50% { transform: translateY(-12px) rotate(2deg); }
}

@keyframes floatFast {
  0%, 100% { transform: translateY(0px) scale(1); }
  50% { transform: translateY(-8px) scale(1.02); }
}

/* ── Text Gradient Animation ───────────────── */
.text-gradient-animate {
  background: linear-gradient(
    90deg,
    var(--accent),
    var(--gold),
    var(--accent-2),
    var(--accent)
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradientShift 8s ease infinite;
}

@keyframes gradientShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ── Shimmer Effect ────────────────────────── */
.shimmer {
  position: relative;
  overflow: hidden;
}

.shimmer::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: translateX(-100%);
  animation: shimmer 3s infinite;
}

@keyframes shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(200%); }
}

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

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

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

/* ── Glitch Effect ─────────────────────────── */
.glitch {
  position: relative;
  animation: glitch 5s infinite;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  opacity: 0.8;
}

.glitch::before {
  animation: glitchBefore 3s infinite;
  clip-path: polygon(0 0, 100% 0, 100% 45%, 0 45%);
  transform: translateX(-2px);
}

.glitch::after {
  animation: glitchAfter 2s infinite;
  clip-path: polygon(0 55%, 100% 55%, 100% 100%, 0 100%);
  transform: translateX(2px);
}

@keyframes glitch {
  0%, 90%, 100% { transform: none; }
  92%, 94%, 96% { transform: skew(0.5deg); }
}

@keyframes glitchBefore {
  0%, 95%, 100% { opacity: 0; }
  96%, 98% { opacity: 0.8; transform: translateX(-3px); }
}

@keyframes glitchAfter {
  0%, 93%, 100% { opacity: 0; }
  94%, 97% { opacity: 0.8; transform: translateX(3px); }
}

/* ── Staggered Fade-In ─────────────────────── */
.stagger-in > * {
  opacity: 0;
  transform: translateY(30px);
  animation: staggerFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.stagger-in > *:nth-child(1) { animation-delay: 0.05s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.15s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.2s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.25s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.3s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.35s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.4s; }

@keyframes staggerFade {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Scale Bounce ──────────────────────────── */
.scale-bounce {
  animation: scaleBounce 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

/* ── Typing Effect ─────────────────────────── */
.typing {
  overflow: hidden;
  border-right: 2px solid var(--accent);
  white-space: nowrap;
  animation: typing 3.5s steps(40) 1s both, blink 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink {
  50% { border-color: transparent; }
}

/* ── Particle Float ────────────────────────── */
.particle {
  position: absolute;
  background: var(--accent);
  border-radius: 50%;
  pointer-events: none;
  animation: particleFloat 4s ease-out forwards;
}

@keyframes particleFloat {
  0% {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(-100px) scale(0);
    opacity: 0;
  }
}

/* ── Card Tilt 3D ──────────────────────────── */
.tilt-3d {
  transform-style: preserve-3d;
  transition: transform 0.2s ease-out;
}

.tilt-3d:hover {
  transform: perspective(1000px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
}

/* ── Progress Ring Animation ───────────────── */
.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-circle {
  stroke-dasharray: 440;
  stroke-dashoffset: 440;
  animation: progressRing 2s ease-out forwards;
}

@keyframes progressRing {
  to {
    stroke-dashoffset: 0;
  }
}

/* ── Spotlight Effect ──────────────────────── */
.spotlight {
  position: relative;
}

.spotlight::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at var(--x, 50%) var(--y, 50%),
    rgba(124, 111, 255, 0.15) 0%,
    transparent 50%
  );
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.spotlight:hover::before {
  opacity: 1;
}

/* ── Border Glow Animation ─────────────────── */
.border-glow {
  position: relative;
  border: 1px solid var(--border);
}

.border-glow::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, var(--accent), var(--gold), var(--accent));
  background-size: 400% 400%;
  border-radius: inherit;
  opacity: 0;
  filter: blur(10px);
  z-index: -1;
  animation: borderGlow 3s ease infinite;
}

.border-glow:hover::before {
  opacity: 0.6;
}

@keyframes borderGlow {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ── Liquid Morphing ───────────────────────── */
.liquid-morph {
  animation: liquidMorph 8s ease-in-out infinite;
}

@keyframes liquidMorph {
  0%, 100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  25% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
  }
  50% {
    border-radius: 70% 30% 50% 50% / 30% 30% 70% 70%;
  }
  75% {
    border-radius: 40% 60% 60% 40% / 60% 50% 50% 40%;
  }
}

/* ── Breath Animation ──────────────────────── */
.breathe {
  animation: breathe 4s ease-in-out infinite;
}

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

/* ── Scroll-triggered Parallax ─────────────── */
.parallax-slow {
  transition: transform 0.1s linear;
  will-change: transform;
}

.parallax-medium {
  transition: transform 0.15s linear;
  will-change: transform;
}

.parallax-fast {
  transition: transform 0.2s linear;
  will-change: transform;
}

/* ── Loading Skeleton ──────────────────────── */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 0%,
    var(--bg-card-2) 50%,
    var(--bg-card) 100%
  );
  background-size: 200% 100%;
  animation: skeleton 1.5s ease-in-out infinite;
}

@keyframes skeleton {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Text Reveal (Clip Path) ───────────────── */
.text-reveal {
  clip-path: polygon(0 0, 100% 0, 100% 0, 0 0);
  animation: textReveal 0.8s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

@keyframes textReveal {
  to {
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
  }
}

/* ── Bounce In ─────────────────────────────── */
.bounce-in {
  animation: bounceIn 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes bounceIn {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ── Rotate In ─────────────────────────────── */
.rotate-in {
  animation: rotateIn 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes rotateIn {
  0% {
    transform: rotate(-180deg) scale(0);
    opacity: 0;
  }
  100% {
    transform: rotate(0) scale(1);
    opacity: 1;
  }
}

/* ── Slide Up ──────────────────────────────── */
.slide-up {
  animation: slideUp 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* ── Zoom Rotate ───────────────────────────── */
.zoom-rotate {
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.zoom-rotate:hover {
  transform: scale(1.1) rotate(3deg);
}

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