/* ===== ANIMATION FRAMEWORK ===== */

/* CSS Custom Properties for Animations */
:root {
    --animation-duration-fast: 0.2s;
    --animation-duration-base: 0.3s;
    --animation-duration-slow: 0.5s;
    --animation-duration-slower: 0.8s;
    --animation-easing: cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --animation-easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* 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;
        scroll-behavior: auto !important;
    }
}

/* ===== UTILITY ANIMATION CLASSES ===== */
.fade-in {
    opacity: 0;
    animation: fadeIn var(--animation-duration-slow) var(--animation-easing) forwards;
}

.fade-in-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp var(--animation-duration-slow) var(--animation-easing) forwards;
}

.fade-in-down {
    opacity: 0;
    transform: translateY(-30px);
    animation: fadeInDown var(--animation-duration-slow) var(--animation-easing) forwards;
}

.fade-in-left {
    opacity: 0;
    transform: translateX(-30px);
    animation: fadeInLeft var(--animation-duration-slow) var(--animation-easing) forwards;
}

.fade-in-right {
    opacity: 0;
    transform: translateX(30px);
    animation: fadeInRight var(--animation-duration-slow) var(--animation-easing) forwards;
}

.fade-in-scale {
    opacity: 0;
    transform: scale(0.8);
    animation: fadeInScale var(--animation-duration-slow) var(--animation-easing) forwards;
}

.slide-in-up {
    transform: translateY(100%);
    animation: slideInUp var(--animation-duration-slow) var(--animation-easing) forwards;
}

.slide-in-down {
    transform: translateY(-100%);
    animation: slideInDown var(--animation-duration-slow) var(--animation-easing) forwards;
}

.bounce-in {
    opacity: 0;
    transform: scale(0.3);
    animation: bounceIn var(--animation-duration-slower) var(--animation-easing-bounce) forwards;
}

/* Animation Delays */
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
.delay-4 { animation-delay: 0.4s; }
.delay-5 { animation-delay: 0.5s; }

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

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

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

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

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

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

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

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

@keyframes slideInDown {
    from {
        transform: translateY(-100%);
    }
    to {
        transform: translateY(0);
    }
}

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
    70% {
        transform: scale(0.9);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== CONTINUOUS ANIMATIONS ===== */

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

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

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

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-5px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(5px);
    }
}

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

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(79, 70, 229, 0.2);
    }
    50% {
        box-shadow: 0 0 20px rgba(79, 70, 229, 0.6), 0 0 30px rgba(79, 70, 229, 0.4);
    }
}

/* ===== HOVER ANIMATIONS ===== */

.hover-float:hover {
    transform: translateY(-5px);
    transition: transform var(--animation-duration-base) var(--animation-easing);
}

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

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

.hover-shadow:hover {
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    transition: box-shadow var(--animation-duration-base) var(--animation-easing);
}

.hover-glow:hover {
    animation: glow 2s infinite;
}

.hover-pulse:hover {
    animation: pulse 2s infinite;
}

.hover-bounce:hover {
    animation: bounce 1s;
}

/* ===== LOADING ANIMATIONS ===== */

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

.loading-dots::after {
    content: '...';
    display: inline-block;
    width: 20px;
    text-align: left;
    animation: loadingDots 1.5s infinite;
}

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

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-bar::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: loading 2s infinite;
}

@keyframes loading {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* ===== SCROLL ANIMATIONS ===== */

.scroll-reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

.scroll-reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

.scroll-reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

.scroll-reveal-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

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

/* ===== PARTICLE EFFECTS ===== */

.particle-container {
    position: relative;
    overflow: hidden;
}

.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: rgba(79, 70, 229, 0.4);
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 8s infinite linear;
}

@keyframes particleFloat {
    0% {
        transform: translateY(100vh) translateX(0px) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateY(-10vh) translateX(100px) rotate(360deg);
        opacity: 0;
    }
}

/* ===== RIPPLE EFFECT ===== */

.ripple {
    position: relative;
    overflow: hidden;
}

.ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease-out, height 0.6s ease-out;
}

.ripple:active::before {
    width: 300px;
    height: 300px;
}

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

.typewriter {
    overflow: hidden;
    border-right: 3px solid var(--primary-color);
    white-space: nowrap;
    margin: 0 auto;
    animation: typing 3s steps(40, end), blink-caret 0.75s step-end infinite;
}

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

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--primary-color);
    }
}

.text-focus-in {
    animation: text-focus-in 1s cubic-bezier(0.550, 0.085, 0.680, 0.530) both;
}

@keyframes text-focus-in {
    0% {
        filter: blur(12px);
        opacity: 0;
    }
    100% {
        filter: blur(0px);
        opacity: 1;
    }
}

.text-shadow-pop-top {
    animation: text-shadow-pop-top 0.6s both;
}

@keyframes text-shadow-pop-top {
    0% {
        text-shadow: 0 0 #555555, 0 0 #555555, 0 0 #555555, 0 0 #555555;
        transform: translateY(0);
    }
    100% {
        text-shadow: 0 -1px #555555, 0 -2px #555555, 0 -3px #555555, 0 -4px #555555;
        transform: translateY(-4px);
    }
}

/* ===== MORPHING ANIMATIONS ===== */

.morph-container {
    position: relative;
    overflow: hidden;
}

.morph-shape {
    position: absolute;
    background: var(--primary-color);
    border-radius: 50%;
    animation: morph 8s ease-in-out infinite;
}

@keyframes morph {
    0%, 100% {
        border-radius: 50% 50% 50% 50%;
        transform: rotate(0deg);
    }
    25% {
        border-radius: 60% 40% 30% 70%;
        transform: rotate(90deg);
    }
    50% {
        border-radius: 30% 60% 70% 40%;
        transform: rotate(180deg);
    }
    75% {
        border-radius: 40% 70% 60% 30%;
        transform: rotate(270deg);
    }
}

/* ===== STAGGER ANIMATIONS ===== */

.stagger-container .stagger-item {
    opacity: 0;
    transform: translateY(20px);
    animation: fadeInUp 0.6s ease-out forwards;
}

.stagger-container .stagger-item:nth-child(1) { animation-delay: 0.1s; }
.stagger-container .stagger-item:nth-child(2) { animation-delay: 0.2s; }
.stagger-container .stagger-item:nth-child(3) { animation-delay: 0.3s; }
.stagger-container .stagger-item:nth-child(4) { animation-delay: 0.4s; }
.stagger-container .stagger-item:nth-child(5) { animation-delay: 0.5s; }
.stagger-container .stagger-item:nth-child(6) { animation-delay: 0.6s; }

/* ===== ENTRANCE ANIMATIONS ===== */

.entrance-left {
    animation: entranceLeft 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes entranceLeft {
    0% {
        transform: translateX(-100px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

.entrance-right {
    animation: entranceRight 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

@keyframes entranceRight {
    0% {
        transform: translateX(100px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

.entrance-bottom {
    animation: entranceBottom 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

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

/* ===== SPECIAL EFFECTS ===== */

.neon-glow {
    text-shadow: 
        0 0 5px var(--primary-color),
        0 0 10px var(--primary-color),
        0 0 15px var(--primary-color),
        0 0 20px var(--primary-color);
    animation: neonFlicker 2s infinite alternate;
}

@keyframes neonFlicker {
    0%, 18%, 22%, 25%, 53%, 57%, 100% {
        text-shadow: 
            0 0 5px var(--primary-color),
            0 0 10px var(--primary-color),
            0 0 15px var(--primary-color),
            0 0 20px var(--primary-color);
    }
    20%, 24%, 55% {
        text-shadow: none;
    }
}

.gradient-animation {
    background: linear-gradient(-45deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
}

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

/* ===== INTERACTIVE ANIMATIONS ===== */

.interactive-card {
    transition: all var(--animation-duration-base) var(--animation-easing);
    transform-style: preserve-3d;
}

.interactive-card:hover {
    transform: translateY(-10px) rotateX(5deg) rotateY(5deg);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.tilt-card {
    transition: transform var(--animation-duration-base) var(--animation-easing);
}

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

/* ===== PERFORMANCE OPTIMIZATIONS ===== */

.hardware-accelerated {
    transform: translateZ(0);
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.smooth-animation {
    animation-fill-mode: both;
    animation-timing-function: cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* ===== VIEWPORT SPECIFIC ANIMATIONS ===== */

@media (max-width: 768px) {
    .fade-in-up {
        transform: translateY(20px);
    }
    
    .fade-in-left,
    .fade-in-right {
        transform: translateY(20px);
    }
    
    .bounce-in {
        animation-duration: 0.6s;
    }
    
    .interactive-card:hover {
        transform: translateY(-5px);
    }
    
    .tilt-card:hover {
        transform: translateY(-5px);
    }
}

/* ===== ACCESSIBILITY ===== */

@media (prefers-reduced-motion: reduce) {
    .fade-in,
    .fade-in-up,
    .fade-in-down,
    .fade-in-left,
    .fade-in-right,
    .fade-in-scale,
    .slide-in-up,
    .slide-in-down,
    .bounce-in {
        animation: none;
        opacity: 1;
        transform: none;
    }
    
    .scroll-reveal,
    .scroll-reveal-left,
    .scroll-reveal-right,
    .scroll-reveal-scale {
        opacity: 1;
        transform: none;
        transition: none;
    }
    
    .hover-float:hover,
    .hover-scale:hover,
    .hover-grow:hover,
    .interactive-card:hover,
    .tilt-card:hover {
        transform: none;
    }
}