/* ==========================================================================
   Animations — @keyframes + Animation Utilities for Dcodz Theme
   ========================================================================== */

/* -----------------------------------------------------------------------
   @keyframes Definitions
   ----------------------------------------------------------------------- */

/* Fade Up — Elements sliding up into view */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

/* Slide In Left */
@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide In Right */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In — Pop-in effect */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Float — Gentle Y oscillation for blobs/decorative elements */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-20px);
  }
}

/* Pulse — Glowing elements */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.7;
    transform: scale(1.05);
  }
}

/* Pulse Glow — Box shadow pulsing */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(1, 112, 185, 0.3);
  }
  50% {
    box-shadow: 0 0 20px rgba(1, 112, 185, 0.6), 0 0 40px rgba(1, 112, 185, 0.2);
  }
}

/* Morph Blob — Clip-path morphing for organic shapes */
@keyframes morphBlob {
  0% {
    clip-path: polygon(50% 0%, 80% 10%, 100% 35%, 95% 65%, 75% 90%, 40% 100%, 10% 80%, 0% 50%, 15% 20%);
  }
  25% {
    clip-path: polygon(40% 5%, 75% 0%, 95% 30%, 100% 60%, 80% 95%, 50% 100%, 15% 85%, 5% 55%, 20% 15%);
  }
  50% {
    clip-path: polygon(55% 5%, 90% 15%, 100% 45%, 90% 75%, 70% 100%, 35% 95%, 5% 75%, 0% 40%, 25% 10%);
  }
  75% {
    clip-path: polygon(45% 0%, 85% 5%, 100% 40%, 95% 70%, 75% 95%, 45% 100%, 10% 85%, 0% 50%, 10% 15%);
  }
  100% {
    clip-path: polygon(50% 0%, 80% 10%, 100% 35%, 95% 65%, 75% 90%, 40% 100%, 10% 80%, 0% 50%, 15% 20%);
  }
}

/* Draw Stroke — SVG stroke animation */
@keyframes drawStroke {
  from {
    stroke-dashoffset: 1000;
  }
  to {
    stroke-dashoffset: 0;
  }
}

/* Bounce — For floating action buttons */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-8px);
  }
  60% {
    transform: translateY(-4px);
  }
}

/* Gradient Shift — Background position animation */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Typewriter Cursor — Blink */
@keyframes typewriterCursor {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* Spin — Loading / rotation */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

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

/* Counter Up — Number counting effect helper */
@keyframes countUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Ripple — Button click effect */
@keyframes ripple {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* -----------------------------------------------------------------------
   Reveal System — Scroll-triggered Animations
   ----------------------------------------------------------------------- */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition:
    opacity 0.6s var(--ease-out-expo),
    transform 0.6s var(--ease-out-expo);
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

/* Reveal variants */
.reveal--left {
  opacity: 0;
  transform: translateX(-40px);
  transition:
    opacity 0.6s var(--ease-out-expo),
    transform 0.6s var(--ease-out-expo);
}

.reveal--left.active {
  opacity: 1;
  transform: translateX(0);
}

.reveal--right {
  opacity: 0;
  transform: translateX(40px);
  transition:
    opacity 0.6s var(--ease-out-expo),
    transform 0.6s var(--ease-out-expo);
}

.reveal--right.active {
  opacity: 1;
  transform: translateX(0);
}

.reveal--scale {
  opacity: 0;
  transform: scale(0.9);
  transition:
    opacity 0.6s var(--ease-out-expo),
    transform 0.6s var(--ease-out-expo);
}

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

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

/* -----------------------------------------------------------------------
   Animation Utility Classes
   ----------------------------------------------------------------------- */
.animate-fadeUp { animation: fadeUp 0.6s var(--ease-out-expo) forwards; }
.animate-fadeIn { animation: fadeIn 0.6s ease forwards; }
.animate-slideInLeft { animation: slideInLeft 0.6s var(--ease-out-expo) forwards; }
.animate-slideInRight { animation: slideInRight 0.6s var(--ease-out-expo) forwards; }
.animate-scaleIn { animation: scaleIn 0.5s var(--ease-out-expo) forwards; }
.animate-float { animation: float 6s ease-in-out infinite; }
.animate-pulse { animation: pulse 2s ease-in-out infinite; }
.animate-pulseGlow { animation: pulseGlow 2s ease-in-out infinite; }
.animate-bounce { animation: bounce 2s ease-in-out infinite; }
.animate-spin { animation: spin 1s linear infinite; }
.animate-gradientShift {
  background-size: 200% 200%;
  animation: gradientShift 20s ease infinite;
}

/* -----------------------------------------------------------------------
   Cursor Spotlight — Mouse-following radial glow on dark sections
   ----------------------------------------------------------------------- */
.cursor-spotlight {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    circle 300px at var(--mx, 50%) var(--my, 50%),
    rgba(1, 112, 185, 0.12) 0%,
    rgba(57, 9, 119, 0.08) 40%,
    transparent 70%
  );
  transition: opacity 0.4s ease;
}

.cursor-spotlight.active {
  opacity: 1;
}

/* Mobile: ambient pulsing glow instead of cursor-following */
@media (hover: none) {
  .cursor-spotlight {
    background: radial-gradient(
      ellipse 60% 40% at 50% 50%,
      rgba(1, 112, 185, 0.08) 0%,
      rgba(57, 9, 119, 0.05) 50%,
      transparent 80%
    );
    animation: mobileGlow 6s ease-in-out infinite;
  }

  .cursor-spotlight.active {
    opacity: 0.8;
  }
}

@keyframes mobileGlow {
  0%, 100% {
    background-position: 30% 40%;
    opacity: 0.5;
  }
  33% {
    background-position: 70% 30%;
    opacity: 0.8;
  }
  66% {
    background-position: 40% 70%;
    opacity: 0.6;
  }
}

/* -----------------------------------------------------------------------
   Gradient Border — Animated border on card hover
   ----------------------------------------------------------------------- */
@keyframes gradientBorder {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Service card — ::before gradient border (no conflict) */
.service-card {
  position: relative;
  transform-style: preserve-3d;
}

.service-card::before {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: inherit;
  background: linear-gradient(
    135deg,
    #0170B9,
    #390977,
    #ffbe00,
    #0170B9
  );
  background-size: 300% 300%;
  opacity: 0;
  transition: opacity 0.4s ease;
}

.service-card:hover::before {
  opacity: 1;
  animation: gradientBorder 4s ease infinite;
}

/* AI card — box-shadow gradient border (avoids ::before conflict + overflow clip) */
.ai-card {
  transform-style: preserve-3d;
}

.ai-card:hover {
  box-shadow:
    0 0 0 1px rgba(1, 112, 185, 0.6),
    0 0 15px rgba(1, 112, 185, 0.3),
    0 0 30px rgba(57, 9, 119, 0.2),
    0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Mobile: activate gradient border on tap and when card is in view */
@media (hover: none) {
  .service-card:active::before,
  .service-card:focus-within::before {
    opacity: 1;
    animation: gradientBorder 4s ease infinite;
  }

  /* Subtle always-on shimmer for service cards in viewport (toggled by JS) */
  .service-card.in-view::before {
    opacity: 0.5;
    animation: gradientBorder 6s ease infinite;
  }

  /* AI card in-view glow */
  .ai-card.in-view {
    box-shadow:
      0 0 0 1px rgba(1, 112, 185, 0.3),
      0 0 10px rgba(1, 112, 185, 0.15),
      0 0 20px rgba(57, 9, 119, 0.1);
  }
}

/* -----------------------------------------------------------------------
   Parallax — GPU hints for scrub-animated elements
   ----------------------------------------------------------------------- */
.ai-automations__neural-bg,
.hero__blob,
.data-particle {
  will-change: transform;
}

/* -----------------------------------------------------------------------
   Prefers Reduced Motion — Disable ALL animations
   ----------------------------------------------------------------------- */
@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;
  }

  .reveal,
  .reveal--left,
  .reveal--right,
  .reveal--scale {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .hero__blob {
    animation: none;
  }

  .cursor-spotlight {
    display: none;
  }

  .service-card::before {
    display: none;
  }

  .ai-card {
    box-shadow: none !important;
  }
}
