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

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

@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 scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideInLeft {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

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

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

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

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

.animate-on-scroll {
    opacity: 0;
    transition: all 0.6s ease-out;
}

.animate-on-scroll.animated {
    opacity: 1;
}

/* Fade Animations */
.fade-in {
    animation: fadeIn 0.8s ease-out forwards;
}

.fade-in-up {
    animation: fadeInUp 0.8s ease-out forwards;
}

.fade-in-down {
    animation: fadeInDown 0.8s ease-out forwards;
}

.fade-in-left {
    animation: fadeInLeft 0.8s ease-out forwards;
}

.fade-in-right {
    animation: fadeInRight 0.8s ease-out forwards;
}

/* Scale Animation */
.scale-in {
    animation: scaleIn 0.6s ease-out forwards;
}

/* Slide Animations */
.slide-in-right {
    animation: slideInRight 0.8s ease-out forwards;
}

.slide-in-left {
    animation: slideInLeft 0.8s ease-out forwards;
}

/* Pulse Animation */
.pulse {
    animation: pulse 2s ease-in-out infinite;
}

/* Bounce Animation */
.bounce {
    animation: bounce 1s ease-in-out;
}

/* ========================================
   Stagger Delays for Sequential Animations
   ======================================== */

.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; }
.delay-6 { animation-delay: 0.6s; }
.delay-7 { animation-delay: 0.7s; }
.delay-8 { animation-delay: 0.8s; }
.delay-9 { animation-delay: 0.9s; }
.delay-10 { animation-delay: 1s; }

/* ========================================
   Metric Counter Animations
   ======================================== */

.metric-value {
    transition: all 0.3s ease-out;
}

.metric-value.counting {
    animation: countUp 0.5s ease-out;
}

.metric-card {
    transition: all 0.3s ease-out;
}

.metric-card.animating {
    animation: pulse 0.6s ease-in-out;
}

/* ========================================
   Hover Effects
   ======================================== */

.hover-lift {
    transition: transform 0.3s ease-out, box-shadow 0.3s ease-out;
}

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

.hover-grow {
    transition: transform 0.3s ease-out;
}

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

.hover-glow {
    transition: box-shadow 0.3s ease-out;
}

.hover-glow:hover {
    box-shadow: 0 0 20px rgba(107, 70, 193, 0.5);
}

/* ========================================
   Loading & Skeleton Animations
   ======================================== */

.skeleton {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 50%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.loading-spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #6B46C1;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

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

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

.gradient-text {
    background: linear-gradient(
        135deg,
        #6B46C1 0%,
        #3B82F6 100%
    );
    background-size: 200% 200%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientShift 3s ease infinite;
}

.typewriter {
    overflow: hidden;
    border-right: 0.15em solid #6B46C1;
    white-space: nowrap;
    margin: 0 auto;
    letter-spacing: 0.05em;
    animation: typing 3.5s 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: #6B46C1; }
}

/* ========================================
   Scroll Progress Indicator
   ======================================== */

.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    background: linear-gradient(90deg, #6B46C1 0%, #3B82F6 100%);
    z-index: 9999;
    transition: width 0.2s ease-out;
}

/* ========================================
   Section Entrance Animations
   ======================================== */

section {
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

section.visible {
    opacity: 1;
    transform: translateY(0);
}

/* ========================================
   Card Stack Effect
   ======================================== */

.card-stack {
    position: relative;
}

.card-stack::before,
.card-stack::after {
    content: '';
    position: absolute;
    background: inherit;
    border-radius: inherit;
    opacity: 0.8;
    transition: all 0.3s ease-out;
}

.card-stack::before {
    top: -5px;
    left: -5px;
    right: 5px;
    bottom: 5px;
    z-index: -1;
}

.card-stack::after {
    top: -10px;
    left: -10px;
    right: 10px;
    bottom: 10px;
    z-index: -2;
    opacity: 0.6;
}

.card-stack:hover::before {
    top: -8px;
    left: -8px;
}

.card-stack:hover::after {
    top: -15px;
    left: -15px;
}

/* ========================================
   Ripple Effect
   ======================================== */

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

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

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

/* ========================================
   Parallax Effect
   ======================================== */

.parallax {
    transition: transform 0.5s ease-out;
}

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

/* ========================================
   Smooth Reveal on Scroll
   ======================================== */

.reveal {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reveal-left {
    opacity: 0;
    transform: translateX(-50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.reveal-right {
    opacity: 0;
    transform: translateX(50px);
    transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ========================================
   Code Block Animations
   ======================================== */

.code-block {
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.5s ease-out;
}

.code-block.visible {
    opacity: 1;
    transform: translateY(0);
}

pre code {
    display: block;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 0.3s forwards;
}

/* ========================================
   Chat Bubble Animations
   ======================================== */

.chat-message {
    opacity: 0;
    transform: translateX(-30px);
    animation: slideInLeft 0.5s ease-out forwards;
}

.chat-message.ai {
    transform: translateX(30px);
    animation: slideInRight 0.5s ease-out forwards;
}

.chat-message:nth-child(1) { animation-delay: 0.1s; }
.chat-message:nth-child(2) { animation-delay: 0.3s; }
.chat-message:nth-child(3) { animation-delay: 0.5s; }
.chat-message:nth-child(4) { animation-delay: 0.7s; }
.chat-message:nth-child(5) { animation-delay: 0.9s; }

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

.progress-bar {
    position: relative;
    height: 8px;
    background-color: #e0e0e0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6B46C1 0%, #3B82F6 100%);
    border-radius: 10px;
    transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   Floating Animation
   ======================================== */

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

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

/* ========================================
   Glow Effect
   ======================================== */

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(107, 70, 193, 0.5),
                    0 0 10px rgba(107, 70, 193, 0.3),
                    0 0 15px rgba(107, 70, 193, 0.2);
    }
    50% {
        box-shadow: 0 0 10px rgba(107, 70, 193, 0.8),
                    0 0 20px rgba(107, 70, 193, 0.6),
                    0 0 30px rgba(107, 70, 193, 0.4);
    }
}

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

/* ========================================
   Accessibility: 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;
    }

    .parallax,
    .floating,
    .pulse,
    .bounce {
        animation: none !important;
    }
}
