/* ═══════════════════════════════════════════════════
   Animations - Scroll reveals, hover effects, etc.
   ═══════════════════════════════════════════════════ */

/* ── Scroll Reveal Animations ─────────────────── */
[data-animate] {
  opacity: 0;
  transition: opacity 0.8s ease, transform 0.8s ease;
  /* Fallback animation: even if the IntersectionObserver in animations.js
     never fires (JS error, observer unsupported, slow Render cold-start),
     content reveals itself after 3 seconds so the page is never stuck
     blank. animations.js + the .animated class take over instantly when
     they run; this is just a safety net. */
  animation: animateFallback 0.6s ease 3s forwards;
}

@keyframes animateFallback {
  to { opacity: 1; transform: translate(0) scale(1); }
}

[data-animate="fade-up"] {
  transform: translateY(40px);
}

[data-animate="fade-down"] {
  transform: translateY(-40px);
}

[data-animate="fade-left"] {
  transform: translateX(40px);
}

[data-animate="fade-right"] {
  transform: translateX(-40px);
}

[data-animate="scale-up"] {
  transform: scale(0.9);
}

[data-animate].animated {
  opacity: 1;
  transform: translate(0) scale(1);
  /* JS-driven reveal beats the CSS fallback */
  animation: none;
}

/* If JS is disabled entirely, show all data-animate elements immediately */
@media (scripting: none) {
  [data-animate] {
    opacity: 1 !important;
    transform: none !important;
    animation: none;
  }
}

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

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

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

.floating-card {
  animation: float 6s ease-in-out infinite;
  position: absolute;
  padding: var(--space-md) var(--space-lg);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: var(--fs-sm);
  font-weight: var(--fw-medium);
  z-index: var(--z-base);
}

.floating-card i {
  width: 18px;
  height: 18px;
  color: var(--primary-light);
}

.floating-card-1 {
  top: 10%;
  right: -20px;
  animation-delay: 0s;
}

.floating-card-2 {
  bottom: 30%;
  left: -30px;
  animation: floatSlow 7s ease-in-out infinite;
  animation-delay: 1s;
}

.floating-card-3 {
  bottom: 10%;
  right: 10%;
  animation: floatReverse 5s ease-in-out infinite;
  animation-delay: 2s;
}

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

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

/* ── Glow Pulse ───────────────────────────────── */
@keyframes glowPulse {
  0%, 100% { box-shadow: 0 0 20px rgba(108, 92, 231, 0.2); }
  50% { box-shadow: 0 0 40px rgba(108, 92, 231, 0.4); }
}

.glow-pulse {
  animation: glowPulse 3s ease-in-out infinite;
}

/* ── Hero Particles ───────────────────────────── */
@keyframes particleFloat {
  0%, 100% {
    transform: translate(0, 0) scale(1);
    opacity: 0.3;
  }
  25% {
    transform: translate(20px, -30px) scale(1.2);
    opacity: 0.6;
  }
  50% {
    transform: translate(-10px, -60px) scale(0.8);
    opacity: 0.4;
  }
  75% {
    transform: translate(15px, -40px) scale(1.1);
    opacity: 0.5;
  }
}

/* ── Gradient Text Animation ──────────────────── */
@keyframes gradientFlow {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.text-gradient-animated {
  background: linear-gradient(
    270deg,
    #6c5ce7,
    #a855f7,
    #ec4899,
    #a855f7,
    #6c5ce7
  );
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientFlow 6s ease infinite;
}

/* ── Scroll Indicator ─────────────────────────── */
.hero-scroll-indicator {
  position: absolute;
  bottom: var(--space-2xl);
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.hero-scroll-indicator a {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-sm);
  color: var(--text-tertiary);
  font-size: var(--fs-xs);
  transition: color var(--transition-fast);
}

.hero-scroll-indicator a:hover {
  color: var(--text-secondary);
}

.scroll-mouse {
  width: 24px;
  height: 38px;
  border: 2px solid var(--text-tertiary);
  border-radius: var(--radius-xl);
  position: relative;
}

.scroll-wheel {
  width: 3px;
  height: 8px;
  background: var(--primary-light);
  border-radius: var(--radius-full);
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  animation: scrollWheel 2s ease-in-out infinite;
}

@keyframes scrollWheel {
  0% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(16px); }
}

/* ── Card Tilt on Hover ───────────────────────── */
.tilt-card {
  transform-style: preserve-3d;
  perspective: 1000px;
}

/* ── Stagger animation delays ─────────────────── */
[data-delay="100"] { transition-delay: 100ms; }
[data-delay="200"] { transition-delay: 200ms; }
[data-delay="300"] { transition-delay: 300ms; }
[data-delay="400"] { transition-delay: 400ms; }
[data-delay="500"] { transition-delay: 500ms; }
[data-delay="600"] { transition-delay: 600ms; }
[data-delay="700"] { transition-delay: 700ms; }
[data-delay="800"] { transition-delay: 800ms; }

/* ── Counter Animation ────────────────────────── */
@keyframes countUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Typewriter ───────────────────────────────── */
@keyframes typewriter {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink {
  0%, 50% { border-color: var(--primary); }
  51%, 100% { border-color: transparent; }
}

/* ── Ripple Effect ────────────────────────────── */
@keyframes ripple {
  0% { transform: scale(0); opacity: 1; }
  100% { transform: scale(4); opacity: 0; }
}

.btn .ripple {
  position: absolute;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  pointer-events: none;
  animation: ripple 0.6s linear;
}

/* ── Portfolio card hover effects ─────────────── */
.portfolio-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-base);
  z-index: 0;
  border-radius: inherit;
}

.portfolio-card:hover::before {
  opacity: 0.03;
}

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

  [data-animate] {
    opacity: 1;
    transform: none;
  }

  .floating-card {
    animation: none;
  }
}
