/* ============================================================================
   ANIMATIONS & MOTION EFFECTS
   Premium scroll effects, transitions, micro-interactions, visualizations
   ============================================================================ */

/* ============================================================================
   KEYFRAME ANIMATIONS
   ============================================================================ */

/* ========== FADE ANIMATIONS ========== */

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

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

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

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

/* ========== SLIDE ANIMATIONS ========== */

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

@keyframes slideDown {
  from {
    transform: translateY(-40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

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

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

/* ========== SCALE ANIMATIONS ========== */

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

@keyframes scaleUp {
  from {
    transform: scale(0.8);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========== SUBTLE ANIMATIONS ========== */

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

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

@keyframes glow {
  0%, 100% {
    box-shadow: 0 0 10px rgba(34, 211, 238, 0.2);
  }
  50% {
    box-shadow: 0 0 30px rgba(34, 211, 238, 0.4);
  }
}

@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

/* ========== ROTATION & SPIN ANIMATIONS ========== */

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes spinReverse {
  from {
    transform: rotate(360deg);
  }
  to {
    transform: rotate(0deg);
  }
}

@keyframes bounce {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* ========== TEXT ANIMATIONS ========== */

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

@keyframes characterReveal {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ========== GRADIENT ANIMATIONS ========== */

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

/* ========== LINE ANIMATIONS ========== */

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

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

/* ========== CONNECTION NETWORK ANIMATIONS ========== */

@keyframes nodeGlow {
  0%, 100% {
    r: 6px;
    opacity: 1;
  }
  50% {
    r: 8px;
    opacity: 0.7;
  }
}

@keyframes pathPulse {
  0%, 100% {
    stroke-width: 2px;
    opacity: 0.5;
  }
  50% {
    stroke-width: 3px;
    opacity: 1;
  }
}

@keyframes flowAlong {
  0% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: 1000;
  }
}

/* ============================================================================
   ANIMATION UTILITY CLASSES
   ============================================================================ */

.animate-fade-in {
  animation: fadeIn 600ms ease-out forwards;
}

.animate-fade-out {
  animation: fadeOut 600ms ease-in forwards;
}

.animate-fade-in-up {
  animation: fadeInUp 600ms ease-out forwards;
}

.animate-fade-in-down {
  animation: fadeInDown 600ms ease-out forwards;
}

.animate-fade-in-left {
  animation: fadeInLeft 600ms ease-out forwards;
}

.animate-fade-in-right {
  animation: fadeInRight 600ms ease-out forwards;
}

.animate-slide-up {
  animation: slideUp 600ms ease-out forwards;
}

.animate-slide-down {
  animation: slideDown 600ms ease-out forwards;
}

.animate-slide-left {
  animation: slideLeft 600ms ease-out forwards;
}

.animate-slide-right {
  animation: slideRight 600ms ease-out forwards;
}

.animate-scale-in {
  animation: scaleIn 600ms ease-out forwards;
}

.animate-scale-up {
  animation: scaleUp 600ms ease-out forwards;
}

.animate-pulse {
  animation: pulse 2s ease-in-out infinite;
}

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

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

.animate-spin {
  animation: spin 1s linear infinite;
}

.animate-bounce {
  animation: bounce 1s ease-in-out infinite;
}

/* Stagger animations */
.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.1s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.2s; }
.stagger-5 { animation-delay: 0.25s; }
.stagger-6 { animation-delay: 0.3s; }
.stagger-7 { animation-delay: 0.35s; }
.stagger-8 { animation-delay: 0.4s; }

/* ============================================================================
   SCROLL REVEAL ANIMATIONS (using Intersection Observer)
   ============================================================================ */

/* Elements start hidden, revealed on scroll */
[data-scroll-animate] {
  opacity: 0;
  animation: none;
}

[data-scroll-animate].in-view {
  animation: fadeInUp 600ms ease-out forwards;
}

[data-scroll-animate="fade"] {
  opacity: 0;
}

[data-scroll-animate="fade"].in-view {
  animation: fadeIn 600ms ease-out forwards;
}

[data-scroll-animate="up"] {
  opacity: 0;
  transform: translateY(30px);
}

[data-scroll-animate="up"].in-view {
  animation: fadeInUp 600ms ease-out forwards;
}

[data-scroll-animate="down"] {
  opacity: 0;
  transform: translateY(-30px);
}

[data-scroll-animate="down"].in-view {
  animation: fadeInDown 600ms ease-out forwards;
}

[data-scroll-animate="left"] {
  opacity: 0;
  transform: translateX(-30px);
}

[data-scroll-animate="left"].in-view {
  animation: fadeInLeft 600ms ease-out forwards;
}

[data-scroll-animate="right"] {
  opacity: 0;
  transform: translateX(30px);
}

[data-scroll-animate="right"].in-view {
  animation: fadeInRight 600ms ease-out forwards;
}

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

[data-scroll-animate="scale"].in-view {
  animation: scaleIn 600ms ease-out forwards;
}

/* ============================================================================
   PAGE TRANSITION ANIMATIONS
   ============================================================================ */

@keyframes pageEnter {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pageExit {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

body.page-entering {
  animation: pageEnter 400ms ease-out forwards;
}

body.page-exiting {
  animation: pageExit 300ms ease-in forwards;
}

/* ============================================================================
   HERO SECTION ANIMATIONS
   ============================================================================ */

.hero-title {
  animation: fadeInUp 800ms ease-out 0.1s forwards;
  opacity: 0;
}

.hero-subtitle {
  animation: fadeInUp 800ms ease-out 0.2s forwards;
  opacity: 0;
}

.hero-cta {
  animation: fadeInUp 800ms ease-out 0.3s forwards;
  opacity: 0;
}

.hero-visual {
  animation: fadeInDown 800ms ease-out 0.25s forwards;
  opacity: 0;
}

/* ============================================================================
   CARD & ELEMENT ANIMATIONS
   ============================================================================ */

.card {
  transition: all 300ms ease-out;
}

.card:hover {
  animation: none; /* Prevent animation loop on hover */
}

.card-grid-item {
  animation: fadeInUp 600ms ease-out forwards;
  opacity: 0;
}

.card-grid-item:nth-child(1) { animation-delay: 0.05s; }
.card-grid-item:nth-child(2) { animation-delay: 0.1s; }
.card-grid-item:nth-child(3) { animation-delay: 0.15s; }
.card-grid-item:nth-child(4) { animation-delay: 0.2s; }
.card-grid-item:nth-child(n+5) { animation-delay: 0.25s; }

/* ============================================================================
   BUTTON & INTERACTIVE ANIMATIONS
   ============================================================================ */

button, .btn {
  transition: all 200ms ease-out;
}

button:hover, .btn:hover {
  transform: translateY(-2px);
}

button:active, .btn:active {
  transform: translateY(0);
}

/* Icon rotation on hover */
.btn-icon-rotate:hover::after {
  animation: spin 400ms ease-out;
}

/* ============================================================================
   INPUT FIELD ANIMATIONS
   ============================================================================ */

input, textarea, select {
  transition: all 200ms ease-out;
}

input:focus, textarea:focus, select:focus {
  transform: translateY(-2px);
}

label {
  transition: color 200ms ease-out;
}

input:focus ~ label, textarea:focus ~ label {
  color: var(--accent-primary);
}

/* ============================================================================
   LOADING STATES
   ============================================================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-secondary) 25%,
    var(--bg-tertiary) 50%,
    var(--bg-secondary) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 2s infinite;
}

.loader {
  width: 40px;
  height: 40px;
  border: 4px solid var(--bg-tertiary);
  border-top-color: var(--accent-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ============================================================================
   TOOLTIP ANIMATIONS
   ============================================================================ */

.tooltip {
  opacity: 0;
  visibility: hidden;
  transform: translateY(8px);
  transition: all 200ms ease-out;
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
}

.tooltip-trigger:hover .tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-8px);
}

/* ============================================================================
   MODAL ANIMATIONS
   ============================================================================ */

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

@keyframes modalScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal {
  animation: modalScaleIn 300ms ease-out;
}

.modal-overlay {
  animation: modalFadeIn 300ms ease-out;
}

.modal.closing {
  animation: modalScaleIn 300ms ease-in reverse;
}

/* ============================================================================
   OVERFLOW HIDDEN FOR ANIMATIONS
   ============================================================================ */

.overflow-hidden {
  overflow: hidden;
}

/* ============================================================================
   RESPECT USER PREFERENCES
   ============================================================================ */

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

/* ============================================================================
   PERFORMANCE OPTIMIZATION
   ============================================================================ */

/* Use will-change sparingly for high-performance animations */
.will-animate {
  will-change: transform, opacity;
}

/* Disable animations on low-performance devices */
@media (prefers-reduced-motion: reduce) {
  .will-animate {
    will-change: auto;
  }
}
