/*
* Advanced Animations - Complex CSS animations and transitions
* Provides smooth animations, particle effects, and micro-interactions
* Version: 1.0
* Last Modified: August 26, 2025
*/

/* ============================================
   Animation Variables
============================================ */

:root {
    --animation-duration-fast: 0.2s;
    --animation-duration-normal: 0.4s;
    --animation-duration-slow: 0.8s;
    --animation-easing: cubic-bezier(0.4, 0, 0.2, 1);
    --animation-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --animation-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ============================================
   Keyframes
============================================ */

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(-30px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translate3d(30px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

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

@keyframes rotateIn {
    from {
        opacity: 0;
        transform: rotate(-180deg) scale(0.8);
    }
    to {
        opacity: 1;
        transform: rotate(0deg) scale(1);
    }
}

@keyframes slideInUp {
    from {
        transform: translate3d(0, 100%, 0);
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes bounce {
    0%, 20%, 53%, 80%, 100% {
        transform: translate3d(0, 0, 0);
    }
    40%, 43% {
        transform: translate3d(0, -30px, 0);
    }
    70% {
        transform: translate3d(0, -15px, 0);
    }
    90% {
        transform: translate3d(0, -4px, 0);
    }
}

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

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

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 20px rgba(106, 125, 254, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(106, 125, 254, 0.6);
    }
}

@keyframes social-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 10px rgba(255, 255, 255, 0.2);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(255, 255, 255, 0.4);
    }
}

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

@keyframes morphing {
    0%, 100% {
        border-radius: 63% 37% 54% 46% / 55% 48% 52% 45%;
    }
    14% {
        border-radius: 40% 60% 54% 46% / 49% 60% 40% 51%;
    }
    28% {
        border-radius: 54% 46% 38% 62% / 49% 70% 30% 51%;
    }
    42% {
        border-radius: 61% 39% 55% 45% / 61% 38% 62% 39%;
    }
    56% {
        border-radius: 61% 39% 67% 33% / 70% 50% 50% 30%;
    }
    70% {
        border-radius: 50% 50% 34% 66% / 56% 68% 32% 44%;
    }
    84% {
        border-radius: 46% 54% 50% 50% / 35% 61% 39% 65%;
    }
}

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

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

@keyframes particleFloat {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    33% {
        transform: translateY(-30px) rotate(120deg);
    }
    66% {
        transform: translateY(20px) rotate(240deg);
    }
}

@keyframes colorShift {
    0%, 100% {
        filter: hue-rotate(0deg);
    }
    50% {
        filter: hue-rotate(180deg);
    }
}

/* ============================================
   Animation Classes
============================================ */

.animate-fade-in-up {
    animation: fadeInUp var(--animation-duration-normal) var(--animation-easing) forwards;
}

.animate-fade-in-down {
    animation: fadeInDown var(--animation-duration-normal) var(--animation-easing) forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft var(--animation-duration-normal) var(--animation-easing) forwards;
}

.animate-fade-in-right {
    animation: fadeInRight var(--animation-duration-normal) var(--animation-easing) forwards;
}

.animate-scale-in {
    animation: scaleIn var(--animation-duration-normal) var(--animation-bounce) forwards;
}

.animate-rotate-in {
    animation: rotateIn var(--animation-duration-slow) var(--animation-elastic) forwards;
}

.animate-slide-up {
    animation: slideInUp var(--animation-duration-normal) var(--animation-easing) forwards;
}

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

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

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

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

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

.animate-morphing {
    animation: morphing 8s ease-in-out infinite;
}

.animate-typing {
    overflow: hidden;
    border-right: 2px solid var(--color-accent);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink 0.75s step-end infinite;
}

.animate-particle {
    animation: particleFloat 4s ease-in-out infinite;
}

.animate-color-shift {
    animation: colorShift 3s ease-in-out infinite;
}

/* ============================================
   Hover Animations
============================================ */

.hover-lift {
    transition: transform var(--animation-duration-fast) var(--animation-easing),
                box-shadow var(--animation-duration-fast) var(--animation-easing);
}

.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.hover-tilt {
    transition: transform var(--animation-duration-fast) var(--animation-easing);
}

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

.hover-scale {
    transition: transform var(--animation-duration-fast) var(--animation-easing);
}

.hover-scale:hover {
    transform: scale(1.05);
}

.hover-glow {
    transition: box-shadow var(--animation-duration-fast) var(--animation-easing);
}

.hover-glow:hover {
    box-shadow: 0 0 30px var(--color-accent);
}

.hover-shimmer {
    position: relative;
    overflow: hidden;
}

.hover-shimmer::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    transition: left var(--animation-duration-slow) var(--animation-easing);
}

.hover-shimmer:hover::before {
    left: 100%;
}

/* ============================================
   Scroll Animations
============================================ */

.scroll-fade-in {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity var(--animation-duration-slow) var(--animation-easing),
                transform var(--animation-duration-slow) var(--animation-easing);
}

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

.scroll-slide-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: opacity var(--animation-duration-slow) var(--animation-easing),
                transform var(--animation-duration-slow) var(--animation-easing);
}

.scroll-slide-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-slide-right {
    opacity: 0;
    transform: translateX(50px);
    transition: opacity var(--animation-duration-slow) var(--animation-easing),
                transform var(--animation-duration-slow) var(--animation-easing);
}

.scroll-slide-right.visible {
    opacity: 1;
    transform: translateX(0);
}

.scroll-scale-in {
    opacity: 0;
    transform: scale(0.8);
    transition: opacity var(--animation-duration-slow) var(--animation-easing),
                transform var(--animation-duration-slow) var(--animation-easing);
}

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

/* ============================================
   Progress Animations
============================================ */

.progress-bar {
    position: relative;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    height: 8px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
    border-radius: 10px;
    width: 0%;
    transition: width 2s var(--animation-easing);
    position: relative;
}

.progress-fill::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmer 2s ease-in-out infinite;
}

/* ============================================
   Loading Animations
============================================ */

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--color-accent);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.loading-dots {
    display: inline-block;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%, 20% {
        content: '';
    }
    40% {
        content: '.';
    }
    60% {
        content: '..';
    }
    90%, 100% {
        content: '...';
    }
}

/* ============================================
   Particle Effects
============================================ */

.particle-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-accent);
    border-radius: 50%;
    animation: particleFloat 6s linear infinite;
}

.particle:nth-child(odd) {
    animation-duration: 8s;
    animation-delay: -2s;
}

.particle:nth-child(even) {
    animation-duration: 10s;
    animation-delay: -4s;
}

/* ============================================
   Text Animations
============================================ */

.text-reveal {
    position: relative;
    overflow: hidden;
}

.text-reveal::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-accent);
    transform: translateX(-100%);
    transition: transform 0.6s var(--animation-easing);
}

.text-reveal.animate::before {
    transform: translateX(100%);
}

.typewriter {
    display: inline-block;
    overflow: hidden;
    border-right: 2px solid var(--color-accent);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end), blink 0.75s step-end infinite;
}

/* ============================================
   Performance Optimizations
============================================ */

.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.will-change-auto {
    will-change: auto;
}

/* Enable hardware acceleration for animations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

/* ============================================
   Reduced Motion Support
============================================ */

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

/* ============================================
   Animation Delays
============================================ */

.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }
.delay-500 { animation-delay: 0.5s; }
.delay-600 { animation-delay: 0.6s; }
.delay-700 { animation-delay: 0.7s; }
.delay-800 { animation-delay: 0.8s; }
.delay-900 { animation-delay: 0.9s; }
.delay-1000 { animation-delay: 1s; }
