/* ============================================================
   ANIMATIONS.CSS — Keyframes, Scroll Animations, Hover FX
   ============================================================ */

/* ---------- Entrance Animations ---------- */
.animate-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.animate-on-scroll.visible {
  opacity: 1;
  transform: translateY(0);
}

.animate-on-scroll[data-delay="100"] { transition-delay: 0.1s; }
.animate-on-scroll[data-delay="200"] { transition-delay: 0.2s; }
.animate-on-scroll[data-delay="300"] { transition-delay: 0.3s; }
.animate-on-scroll[data-delay="400"] { transition-delay: 0.4s; }
.animate-on-scroll[data-delay="500"] { transition-delay: 0.5s; }
.animate-on-scroll[data-delay="600"] { transition-delay: 0.6s; }
.animate-on-scroll[data-delay="700"] { transition-delay: 0.7s; }
.animate-on-scroll[data-delay="800"] { transition-delay: 0.8s; }

/* Fade In Up */
.fade-in-up {
  opacity: 0;
  transform: translateY(40px);
}

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

/* Fade In Down */
.fade-in-down {
  opacity: 0;
  transform: translateY(-40px);
}

.fade-in-down.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Fade In Left */
.fade-in-left {
  opacity: 0;
  transform: translateX(-40px);
}

.fade-in-left.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Fade In Right */
.fade-in-right {
  opacity: 0;
  transform: translateX(40px);
}

.fade-in-right.visible {
  opacity: 1;
  transform: translateX(0);
}

/* Scale In */
.scale-in {
  opacity: 0;
  transform: scale(0.8);
}

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

/* Rotate In */
.rotate-in {
  opacity: 0;
  transform: rotate(-10deg) scale(0.9);
}

.rotate-in.visible {
  opacity: 1;
  transform: rotate(0) scale(1);
}

/* Blur In */
.blur-in {
  opacity: 0;
  filter: blur(10px);
}

.blur-in.visible {
  opacity: 1;
  filter: blur(0);
}

/* ---------- Continuous Animations ---------- */

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

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

.float-delay-1 { animation-delay: 0.5s; }
.float-delay-2 { animation-delay: 1s; }
.float-delay-3 { animation-delay: 1.5s; }
.float-delay-4 { animation-delay: 2s; }

/* Pulse Glow */
@keyframes pulse-glow {
  0%, 100% {
    box-shadow: 0 0 5px rgba(var(--primary-rgb), 0.2),
                0 0 20px rgba(var(--primary-rgb), 0.1);
  }
  50% {
    box-shadow: 0 0 10px rgba(var(--primary-rgb), 0.4),
                0 0 40px rgba(var(--primary-rgb), 0.2),
                0 0 80px rgba(var(--primary-rgb), 0.1);
  }
}

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

/* Gradient Shift */
@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.gradient-animate {
  background-size: 200% 200%;
  animation: gradient-shift 4s ease infinite;
}

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

.rotate-slow {
  animation: rotate-slow 20s linear infinite;
}

.rotate-reverse {
  animation: rotate-slow 15s linear infinite reverse;
}

/* Orbit */
@keyframes orbit {
  0% { transform: rotate(0deg) translateX(150px) rotate(0deg); }
  100% { transform: rotate(360deg) translateX(150px) rotate(-360deg); }
}

.orbit {
  animation: orbit 12s linear infinite;
}

/* Scanning Line */
@keyframes scan-line {
  0% { top: 0; opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.scan-line {
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(var(--primary-rgb), 0.5),
    var(--primary),
    rgba(var(--primary-rgb), 0.5),
    transparent
  );
  animation: scan-line 4s ease-in-out infinite;
  pointer-events: none;
}

/* Data Stream */
@keyframes data-stream {
  0% { transform: translateY(-100%); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* Flicker */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  41% { opacity: 1; }
  42% { opacity: 0.6; }
  43% { opacity: 1; }
  45% { opacity: 0.3; }
  46% { opacity: 1; }
}

.flicker {
  animation: flicker 3s linear infinite;
}

/* Typewriter Cursor */
@keyframes blink-cursor {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.cursor-blink {
  animation: blink-cursor 0.8s step-end infinite;
}

/* ---------- Hover Animations ---------- */

/* Magnetic Hover */
.magnetic-hover {
  transition: transform var(--transition-base);
}

/* Tilt on Hover */
.tilt-hover {
  transition: transform var(--transition-base);
  transform-style: preserve-3d;
}

.tilt-hover:hover {
  transform: perspective(1000px) rotateX(5deg) rotateY(-5deg);
}

/* Shine Effect */
.shine-effect {
  position: relative;
  overflow: hidden;
}

.shine-effect::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    to right,
    transparent 0%,
    rgba(255, 255, 255, 0.05) 45%,
    rgba(255, 255, 255, 0.1) 50%,
    rgba(255, 255, 255, 0.05) 55%,
    transparent 100%
  );
  transform: rotate(25deg) translateX(-100%);
  transition: transform 0.6s ease;
}

.shine-effect:hover::after {
  transform: rotate(25deg) translateX(100%);
}

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

.ripple-effect .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(var(--primary-rgb), 0.3);
  transform: scale(0);
  animation: ripple-animation 0.6s linear;
  pointer-events: none;
}

@keyframes ripple-animation {
  to {
    transform: scale(4);
    opacity: 0;
  }
}

/* Glitch Effect */
.glitch-hover {
  position: relative;
}

.glitch-hover:hover {
  animation: glitch-text 0.3s ease;
}

@keyframes glitch-text {
  0% { transform: translate(0); }
  20% { transform: translate(-2px, 2px); }
  40% { transform: translate(-2px, -2px); }
  60% { transform: translate(2px, 2px); }
  80% { transform: translate(2px, -2px); }
  100% { transform: translate(0); }
}

/* Border Glow on Hover */
.border-glow-hover {
  transition: all var(--transition-base);
}

.border-glow-hover:hover {
  border-color: var(--primary);
  box-shadow: 0 0 15px rgba(var(--primary-rgb), 0.3),
              inset 0 0 15px rgba(var(--primary-rgb), 0.05);
}

/* ---------- Particle Effects ---------- */
@keyframes particle-float-1 {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translate(100px, -200px) scale(0); opacity: 0; }
}

@keyframes particle-float-2 {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  10% { opacity: 0.8; }
  90% { opacity: 0.8; }
  100% { transform: translate(-80px, -250px) scale(0); opacity: 0; }
}

@keyframes particle-float-3 {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  10% { opacity: 0.6; }
  90% { opacity: 0.6; }
  100% { transform: translate(50px, -180px) scale(0); opacity: 0; }
}

/* ---------- Text Animations ---------- */

/* Wave Text */
@keyframes wave-text {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-5px); }
  75% { transform: translateY(5px); }
}

/* Letter Spacing Animation */
@keyframes letter-space {
  0%, 100% { letter-spacing: 0.05em; }
  50% { letter-spacing: 0.15em; }
}

.letter-space-animate:hover {
  animation: letter-space 1s ease;
}

/* ---------- Loading Animations ---------- */

/* Dots Loading */
@keyframes dot-bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

.loading-dots {
  display: inline-flex;
  gap: 6px;
}

.loading-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--primary);
  animation: dot-bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: -0.32s; }
.loading-dots span:nth-child(2) { animation-delay: -0.16s; }

/* Bar Loading */
@keyframes bar-loading {
  0% { transform: scaleX(0); transform-origin: left; }
  50% { transform: scaleX(1); transform-origin: left; }
  51% { transform-origin: right; }
  100% { transform: scaleX(0); transform-origin: right; }
}

.loading-bar {
  width: 100%;
  height: 2px;
  background: rgba(var(--primary-rgb), 0.1);
  overflow: hidden;
}

.loading-bar::after {
  content: '';
  display: block;
  width: 100%;
  height: 100%;
  background: var(--primary);
  animation: bar-loading 1.5s ease infinite;
}

/* ---------- Stagger Animation Helper ---------- */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-children.visible > *:nth-child(1) { transition-delay: 0.05s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.1s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.15s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.2s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.25s; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.3s; }
.stagger-children.visible > *:nth-child(7) { transition-delay: 0.35s; }
.stagger-children.visible > *:nth-child(8) { transition-delay: 0.4s; }
.stagger-children.visible > *:nth-child(9) { transition-delay: 0.45s; }
.stagger-children.visible > *:nth-child(10) { transition-delay: 0.5s; }
.stagger-children.visible > *:nth-child(11) { transition-delay: 0.55s; }
.stagger-children.visible > *:nth-child(12) { transition-delay: 0.6s; }

.stagger-children.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Counter Animation ---------- */
.counter-animate {
  display: inline-block;
}

/* ---------- Parallax Layers ---------- */
.parallax-container {
  position: relative;
  overflow: hidden;
}

.parallax-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 120%;
  will-change: transform;
}

/* ---------- Marquee ---------- */
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.marquee-container {
  overflow: hidden;
  white-space: nowrap;
}

.marquee-content {
  display: inline-flex;
  animation: marquee 30s linear infinite;
}

.marquee-content:hover {
  animation-play-state: paused;
}

/* ---------- Morph Shape ---------- */
@keyframes morph {
  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: 50% 60% 30% 60% / 30% 60% 70% 40%; }
  75% { border-radius: 60% 40% 60% 30% / 70% 30% 50% 60%; }
}

.morph-shape {
  animation: morph 8s ease-in-out infinite;
}

/* ---------- Draw Line ---------- */
@keyframes draw-line {
  0% { stroke-dashoffset: 1000; }
  100% { stroke-dashoffset: 0; }
}

.draw-line {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
}

.draw-line.visible {
  animation: draw-line 2s ease forwards;
}

/* ---------- Neon Pulse ---------- */
@keyframes neon-pulse {
  0%, 100% {
    text-shadow:
      0 0 4px rgba(var(--primary-rgb), 0.5),
      0 0 11px rgba(var(--primary-rgb), 0.3),
      0 0 19px rgba(var(--primary-rgb), 0.2);
  }
  50% {
    text-shadow:
      0 0 4px rgba(var(--primary-rgb), 0.8),
      0 0 11px rgba(var(--primary-rgb), 0.6),
      0 0 19px rgba(var(--primary-rgb), 0.4),
      0 0 40px rgba(var(--primary-rgb), 0.2),
      0 0 80px rgba(var(--primary-rgb), 0.1);
  }
}

.neon-pulse {
  animation: neon-pulse 2.5s ease-in-out infinite;
}

/* ---------- Matrix Rain (optional) ---------- */
@keyframes matrix-drop {
  0% { transform: translateY(-100%); opacity: 1; }
  100% { transform: translateY(100vh); opacity: 0; }
}

/* ---------- Reveal Clip ---------- */
@keyframes reveal-clip {
  0% { clip-path: inset(0 100% 0 0); }
  100% { clip-path: inset(0 0 0 0); }
}

.reveal-clip {
  clip-path: inset(0 100% 0 0);
}

.reveal-clip.visible {
  animation: reveal-clip 1s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

/* ---------- Reduced Motion ---------- */
@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;
  }

  .animate-on-scroll,
  .fade-in-up,
  .fade-in-down,
  .fade-in-left,
  .fade-in-right,
  .scale-in,
  .rotate-in,
  .blur-in {
    opacity: 1;
    transform: none;
    filter: none;
  }
}

/* ==================== CARD HOVER EFFECTS ==================== */
.card-hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.card-hover-lift:hover {
  transform: translateY(-8px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3), 0 0 20px rgba(var(--primary-rgb), 0.1);
}

.card-hover-glow {
  transition: box-shadow var(--transition-base), border-color var(--transition-base);
}

.card-hover-glow:hover {
  box-shadow: 0 0 30px rgba(var(--primary-rgb), 0.2), 0 0 60px rgba(var(--primary-rgb), 0.1);
  border-color: rgba(var(--primary-rgb), 0.5);
}

/* ==================== TEXT CLIP ANIMATION ==================== */
@keyframes text-clip-reveal {
  0% {
    clip-path: polygon(0% 100%, 100% 100%, 100% 100%, 0% 100%);
  }
  100% {
    clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
  }
}

.text-clip-reveal {
  animation: text-clip-reveal 0.8s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

/* ==================== WAVE ANIMATION ==================== */
@keyframes wave {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-8px); }
  50% { transform: translateY(0); }
  75% { transform: translateY(4px); }
}

.wave-text span {
  display: inline-block;
  animation: wave 2s ease-in-out infinite;
}

.wave-text span:nth-child(1) { animation-delay: 0s; }
.wave-text span:nth-child(2) { animation-delay: 0.1s; }
.wave-text span:nth-child(3) { animation-delay: 0.2s; }
.wave-text span:nth-child(4) { animation-delay: 0.3s; }
.wave-text span:nth-child(5) { animation-delay: 0.4s; }
.wave-text span:nth-child(6) { animation-delay: 0.5s; }
.wave-text span:nth-child(7) { animation-delay: 0.6s; }
.wave-text span:nth-child(8) { animation-delay: 0.7s; }
.wave-text span:nth-child(9) { animation-delay: 0.8s; }
.wave-text span:nth-child(10) { animation-delay: 0.9s; }

/* ==================== MORPHING BLOB ==================== */
@keyframes morph-blob {
  0% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
  25% {
    border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
  }
  50% {
    border-radius: 40% 60% 30% 70% / 40% 40% 60% 50%;
  }
  75% {
    border-radius: 60% 40% 60% 30% / 30% 50% 40% 70%;
  }
  100% {
    border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
  }
}

.morph-blob {
  animation: morph-blob 8s ease-in-out infinite;
}

/* ==================== MAGNETIC EFFECT ==================== */
.magnetic-hover {
  transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ==================== NUMBER COUNTER ==================== */
@keyframes count-up-glow {
  0% { text-shadow: 0 0 5px rgba(var(--primary-rgb), 0); }
  50% { text-shadow: 0 0 20px rgba(var(--primary-rgb), 0.5); }
  100% { text-shadow: 0 0 5px rgba(var(--primary-rgb), 0); }
}

.count-glow {
  animation: count-up-glow 1.5s ease-in-out;
}

/* ==================== SKELETON LOADING ==================== */
@keyframes skeleton-shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: calc(200px + 100%) 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-card) 25%,
    rgba(var(--primary-rgb), 0.05) 50%,
    var(--bg-card) 75%
  );
  background-size: 200px 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--border-radius-sm);
}

.skeleton-text {
  height: 16px;
  margin-bottom: 8px;
  border-radius: 4px;
}

.skeleton-text:last-child {
  width: 70%;
}

.skeleton-circle {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

.skeleton-rect {
  height: 200px;
  border-radius: var(--border-radius-md);
}

/* ==================== TYPEWRITER CURSOR ==================== */
@keyframes typewriter-cursor {
  0%, 100% { border-right-color: var(--primary); }
  50% { border-right-color: transparent; }
}

.typewriter-line {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--primary);
  animation: typewriter-cursor 0.8s step-end infinite;
}

/* ==================== PARALLAX LAYER ==================== */
.parallax-container {
  position: relative;
  overflow: hidden;
}

.parallax-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 120%;
  will-change: transform;
}

/* ==================== STAGGER SYSTEM (Extended) ==================== */
.stagger-children > *:nth-child(1) { transition-delay: 0.05s; }
.stagger-children > *:nth-child(2) { transition-delay: 0.1s; }
.stagger-children > *:nth-child(3) { transition-delay: 0.15s; }
.stagger-children > *:nth-child(4) { transition-delay: 0.2s; }
.stagger-children > *:nth-child(5) { transition-delay: 0.25s; }
.stagger-children > *:nth-child(6) { transition-delay: 0.3s; }
.stagger-children > *:nth-child(7) { transition-delay: 0.35s; }
.stagger-children > *:nth-child(8) { transition-delay: 0.4s; }
.stagger-children > *:nth-child(9) { transition-delay: 0.45s; }
.stagger-children > *:nth-child(10) { transition-delay: 0.5s; }
.stagger-children > *:nth-child(11) { transition-delay: 0.55s; }
.stagger-children > *:nth-child(12) { transition-delay: 0.6s; }
.stagger-children > *:nth-child(13) { transition-delay: 0.65s; }
.stagger-children > *:nth-child(14) { transition-delay: 0.7s; }
.stagger-children > *:nth-child(15) { transition-delay: 0.75s; }
.stagger-children > *:nth-child(16) { transition-delay: 0.8s; }

.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.stagger-children.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* ==================== UNDERLINE ANIMATION ==================== */
.animated-underline {
  position: relative;
  display: inline-block;
}

.animated-underline::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.3s ease;
}

.animated-underline:hover::after {
  width: 100%;
}

/* ==================== BORDER ANIMATION ==================== */
@keyframes border-spin {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.animated-border {
  position: relative;
  overflow: hidden;
}

.animated-border::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  right: -2px;
  bottom: -2px;
  background: linear-gradient(
    45deg,
    var(--primary),
    var(--secondary),
    var(--accent),
    var(--primary)
  );
  background-size: 400% 400%;
  animation: border-spin 6s ease infinite;
  z-index: -1;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--transition-base);
}

.animated-border:hover::before {
  opacity: 1;
}

.animated-border::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  right: 1px;
  bottom: 1px;
  background: var(--bg-card);
  border-radius: inherit;
  z-index: -1;
}

/* ==================== PAGE TRANSITION VARIANTS ==================== */
@keyframes page-slide-in {
  0% {
    opacity: 0;
    transform: translateX(30px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes page-fade-up {
  0% {
    opacity: 0;
    transform: translateY(40px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-enter {
  animation: page-fade-up 0.6s ease forwards;
}

.page-enter-slide {
  animation: page-slide-in 0.5s ease forwards;
}

/* ==================== ACCESSIBILITY ==================== */
@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;
  }

  .hero-profile-ring,
  .hero-profile-ring-2,
  .hero-gradient-orb,
  .float-element,
  .morph-blob,
  .wave-text span {
    animation: none !important;
  }

  .stagger-children > * {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }

  .animate-on-scroll,
  .fade-in-up,
  .fade-in-down,
  .fade-in-left,
  .fade-in-right,
  .scale-in,
  .blur-in {
    opacity: 1 !important;
    transform: none !important;
  }
}
