/* ========================================
   Animation Keyframes & Effects
   ======================================== */

/* ========================================
   Page Reveal Animations
   ======================================== */
.reveal-up {
    opacity: 0;
    transform: translateY(50px);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

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

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

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

.reveal-scale {
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Stagger children animation */
.stagger-children > * {
    opacity: 0;
    transform: translateY(30px);
}

.stagger-children.active > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.active > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.active > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.active > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.active > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children.active > *:nth-child(6) { transition-delay: 0.6s; }

.stagger-children.active > * {
    opacity: 1;
    transform: translateY(0);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

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

/* Split text reveal */
.split-text .char {
    display: inline-block;
    opacity: 0;
    transform: translateY(100%);
    transition: all 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.split-text.active .char {
    opacity: 1;
    transform: translateY(0);
}

/* Text gradient animation */
.text-gradient-animate {
    background: linear-gradient(
        90deg,
        var(--color-primary),
        var(--color-secondary),
        var(--color-accent),
        var(--color-primary)
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: gradientMove 8s ease infinite;
}

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

/* Typewriter effect */
.typewriter {
    overflow: hidden;
    white-space: nowrap;
    animation: typewriter 3s steps(40) 1s forwards;
}

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

/* ========================================
   Button & Interactive Animations
   ======================================== */

/* Magnetic button effect */
.magnetic {
    position: relative;
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Button ripple effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    top: 50%;
    left: 50%;
    pointer-events: none;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.3) 0%, transparent 70%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s ease;
}

.btn-ripple:active::after {
    transform: translate(-50%, -50%) scale(2);
    opacity: 0;
    transition: transform 0.5s ease, opacity 0.3s ease 0.2s;
}

/* Button shine effect */
.btn-shine {
    position: relative;
    overflow: hidden;
}

.btn-shine::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.2),
        transparent
    );
    transition: left 0.5s ease;
}

.btn-shine:hover::before {
    left: 100%;
}

/* ========================================
   Card Animations
   ======================================== */

/* Card 3D tilt effect */
.card-tilt {
    transform-style: preserve-3d;
    transition: transform 0.3s ease;
}

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

/* Card glow effect */
.card-glow {
    position: relative;
}

.card-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: inherit;
    background: var(--gradient-primary);
    opacity: 0;
    filter: blur(20px);
    z-index: -1;
    transition: opacity 0.3s ease;
}

.card-glow:hover::before {
    opacity: 0.3;
}

/* Card lift effect */
.card-lift {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
                box-shadow 0.3s ease;
}

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

/* ========================================
   Loading & Spinner Animations
   ======================================== */

/* Pulse loader */
.pulse-loader {
    width: 40px;
    height: 40px;
    background: var(--color-primary);
    border-radius: 50%;
    animation: pulse-scale 1s ease-in-out infinite;
}

@keyframes pulse-scale {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.5); opacity: 0.5; }
}

/* Dot loader */
.dot-loader {
    display: flex;
    gap: 8px;
}

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

.dot-loader span:nth-child(2) { animation-delay: 0.2s; }
.dot-loader span:nth-child(3) { animation-delay: 0.4s; }

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

/* Spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ========================================
   Background Animations
   ======================================== */

/* Floating particles */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-primary);
    border-radius: 50%;
    opacity: 0.5;
    animation: particle-float 10s ease-in-out infinite;
}

@keyframes particle-float {
    0%, 100% {
        transform: translate(0, 0);
        opacity: 0.5;
    }
    25% {
        transform: translate(100px, -100px);
        opacity: 0.8;
    }
    50% {
        transform: translate(-50px, -200px);
        opacity: 0.3;
    }
    75% {
        transform: translate(50px, -100px);
        opacity: 0.6;
    }
}

/* Gradient background animation */
.gradient-bg {
    background: linear-gradient(
        -45deg,
        var(--color-bg),
        var(--color-bg-secondary),
        var(--color-bg-tertiary),
        var(--color-bg)
    );
    background-size: 400% 400%;
    animation: gradient-shift 15s ease infinite;
}

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

/* Aurora effect */
.aurora {
    position: absolute;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 30% 30%, rgba(99, 102, 241, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 70% 70%, rgba(34, 211, 238, 0.2) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(244, 114, 182, 0.1) 0%, transparent 50%);
    filter: blur(60px);
    animation: aurora-move 20s ease-in-out infinite;
}

@keyframes aurora-move {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(5%, -5%) scale(1.1); }
    50% { transform: translate(-5%, 5%) scale(0.9); }
    75% { transform: translate(5%, 5%) scale(1.05); }
}

/* ========================================
   Icon Animations
   ======================================== */

/* Icon bounce */
.icon-bounce {
    animation: icon-bounce 2s ease infinite;
}

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

/* Icon shake */
.icon-shake:hover {
    animation: icon-shake 0.5s ease;
}

@keyframes icon-shake {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

/* Icon pulse */
.icon-pulse {
    animation: icon-pulse 2s ease infinite;
}

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

/* ========================================
   Scroll Progress Indicator
   ======================================== */
.scroll-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--gradient-primary);
    z-index: 9999;
    transition: width 0.1s ease;
}

/* ========================================
   Page Transition Overlay
   ======================================== */
.page-transition {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-bg);
    z-index: 10001;
    transform: scaleY(0);
    transform-origin: bottom;
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.page-transition.active {
    transform: scaleY(1);
    transform-origin: top;
}

/* ========================================
   Form Input Animations
   ======================================== */

/* Input focus effect */
.input-effect {
    position: relative;
}

.input-effect input {
    position: relative;
    z-index: 1;
}

.input-effect::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--gradient-primary);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.input-effect:focus-within::after {
    width: 100%;
}

/* ========================================
   Success/Error Animations
   ======================================== */

/* Success checkmark */
.success-check {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-success);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: success-pop 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.success-check svg {
    stroke: white;
    stroke-dasharray: 100;
    stroke-dashoffset: 100;
    animation: success-draw 0.5s ease 0.3s forwards;
}

@keyframes success-pop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

@keyframes success-draw {
    to { stroke-dashoffset: 0; }
}

/* Error shake */
.error-shake {
    animation: error-shake 0.5s ease;
}

@keyframes error-shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-10px); }
    40%, 80% { transform: translateX(10px); }
}

/* ========================================
   Counter Animation
   ======================================== */
.counter {
    transition: all 0.5s ease;
}

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

/* Image zoom on hover */
.img-zoom {
    overflow: hidden;
}

.img-zoom img {
    transition: transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

.img-zoom:hover img {
    transform: scale(1.1);
}

/* Image reveal */
.img-reveal {
    position: relative;
    overflow: hidden;
}

.img-reveal::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--color-primary);
    transform: scaleX(1);
    transform-origin: right;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.img-reveal.active::after {
    transform: scaleX(0);
}

/* ========================================
   Mobile Menu Animations
   ======================================== */
.mobile-menu {
    position: fixed;
    top: 0;
    right: -100%;
    width: 80%;
    max-width: 400px;
    height: 100vh;
    background: var(--color-bg-secondary);
    transition: right 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 999;
}

.mobile-menu.active {
    right: 0;
}

.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 998;
}

.mobile-menu-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ========================================
   Tooltip Animation
   ======================================== */
.tooltip {
    position: relative;
}

.tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(-10px);
    padding: 8px 12px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.tooltip:hover::after {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ========================================
   Marquee Animation
   ======================================== */
.marquee {
    display: flex;
    overflow: hidden;
    width: 100%;
}

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

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

/* ========================================
   Skeleton Loading
   ======================================== */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-bg-tertiary) 25%,
        var(--color-bg-secondary) 50%,
        var(--color-bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ========================================
   Enhanced 3D Animations
   ======================================== */

/* 3D Rotate on Hover */
.rotate-3d {
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.rotate-3d:hover {
    transform: perspective(1000px) rotateY(15deg) rotateX(5deg);
}

/* Flip Card */
.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    transform-style: preserve-3d;
    transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.flip-card:hover .flip-card-inner {
    transform: rotateY(180deg);
}

.flip-card-front, .flip-card-back {
    backface-visibility: hidden;
}

.flip-card-back {
    transform: rotateY(180deg);
}

/* Floating Animation */
.float-animation {
    animation: float-updown 4s ease-in-out infinite;
}

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

.float-animation-delayed {
    animation: float-updown 4s ease-in-out 0.5s infinite;
}

/* Rotate Animation */
.rotate-slow {
    animation: rotate-360 20s linear infinite;
}

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

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

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

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

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

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

@keyframes glow-pulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(99, 102, 241, 0.3);
    }
    50% {
        box-shadow: 0 0 40px rgba(99, 102, 241, 0.6),
                    0 0 60px rgba(34, 211, 238, 0.4);
    }
}

/* Border Animation */
.border-animation {
    position: relative;
}

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

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

/* Neon Flicker */
.neon-flicker {
    animation: neon-flicker 2s ease-in-out infinite;
}

@keyframes neon-flicker {
    0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% {
        text-shadow:
            0 0 5px var(--color-primary),
            0 0 10px var(--color-primary),
            0 0 20px var(--color-primary),
            0 0 40px var(--color-secondary);
    }
    20%, 24%, 55% {
        text-shadow: none;
    }
}

/* Wave Animation for Text */
.wave-text span {
    display: inline-block;
    animation: wave-bounce 1s 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; }

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

/* Morph Background */
.morph-bg {
    animation: morph 8s ease-in-out infinite;
}

@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% 30% 60% 40% / 70% 40% 50% 60%; }
}

/* Slide In Animations */
.slide-in-left {
    animation: slide-in-left 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-right {
    animation: slide-in-right 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in-up {
    animation: slide-in-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slide-in-up {
    from {
        opacity: 0;
        transform: translateY(100px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Parallax Layer */
.parallax-layer {
    will-change: transform;
    transition: transform 0.1s ease-out;
}

/* Blur Reveal */
.blur-reveal {
    filter: blur(20px);
    opacity: 0;
    animation: blur-reveal 1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes blur-reveal {
    to {
        filter: blur(0);
        opacity: 1;
    }
}

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

.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.glitch::before {
    left: 2px;
    text-shadow: -2px 0 var(--color-secondary);
    animation: glitch-1 2s infinite linear alternate-reverse;
}

.glitch::after {
    left: -2px;
    text-shadow: 2px 0 var(--color-accent);
    animation: glitch-2 3s infinite linear alternate-reverse;
}

@keyframes glitch-1 {
    0%, 20%, 40%, 60%, 80%, 100% { clip-path: inset(0 0 100% 0); }
    10% { clip-path: inset(20% 0 60% 0); }
    30% { clip-path: inset(40% 0 40% 0); }
    50% { clip-path: inset(60% 0 20% 0); }
    70% { clip-path: inset(80% 0 10% 0); }
    90% { clip-path: inset(10% 0 70% 0); }
}

@keyframes glitch-2 {
    0%, 20%, 40%, 60%, 80%, 100% { clip-path: inset(100% 0 0 0); }
    10% { clip-path: inset(60% 0 20% 0); }
    30% { clip-path: inset(40% 0 40% 0); }
    50% { clip-path: inset(20% 0 60% 0); }
    70% { clip-path: inset(10% 0 80% 0); }
    90% { clip-path: inset(70% 0 10% 0); }
}

/* Orbit Glow */
.orbit-glow {
    box-shadow:
        0 0 10px rgba(99, 102, 241, 0.5),
        0 0 20px rgba(99, 102, 241, 0.3),
        0 0 30px rgba(99, 102, 241, 0.1);
    animation: orbit-glow-pulse 3s ease-in-out infinite;
}

@keyframes orbit-glow-pulse {
    0%, 100% {
        box-shadow:
            0 0 10px rgba(99, 102, 241, 0.5),
            0 0 20px rgba(99, 102, 241, 0.3),
            0 0 30px rgba(99, 102, 241, 0.1);
    }
    50% {
        box-shadow:
            0 0 20px rgba(34, 211, 238, 0.6),
            0 0 40px rgba(34, 211, 238, 0.4),
            0 0 60px rgba(34, 211, 238, 0.2);
    }
}

/* Shooting Star */
.shooting-star {
    position: absolute;
    width: 100px;
    height: 2px;
    background: linear-gradient(90deg, var(--color-secondary), transparent);
    animation: shooting-star 3s ease-in-out infinite;
}

@keyframes shooting-star {
    0% {
        transform: translateX(-100%) translateY(0) rotate(-45deg);
        opacity: 1;
    }
    70% {
        opacity: 1;
    }
    100% {
        transform: translateX(200vw) translateY(200px) rotate(-45deg);
        opacity: 0;
    }
}

/* 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.2);
    transform: translate(-50%, -50%);
    animation: ripple-expand 1s ease-out infinite;
}

@keyframes ripple-expand {
    0% {
        width: 0;
        height: 0;
        opacity: 0.5;
    }
    100% {
        width: 200%;
        height: 200%;
        opacity: 0;
    }
}
