/* ============================================
   WebCraft Studio - Animations
   Advanced Animation System
   ============================================ */

/* ---------- Keyframe Animations ---------- */

/* Fade 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);
    }
}

/* Scale Animations */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

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

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

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

@keyframes floatSlow {
    0%, 100% {
        transform: translateY(0) rotate(0deg);
    }
    25% {
        transform: translateY(-10px) rotate(2deg);
    }
    50% {
        transform: translateY(-20px) rotate(0deg);
    }
    75% {
        transform: translateY(-10px) rotate(-2deg);
    }
}

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

@keyframes pulseGlow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(99, 102, 241, 0);
    }
}

/* Rotate Animation */
@keyframes rotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

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

/* Shimmer Effect */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Wave Animation */
@keyframes wave {
    0%, 100% {
        transform: rotate(0deg);
    }
    10% {
        transform: rotate(14deg);
    }
    20% {
        transform: rotate(-8deg);
    }
    30% {
        transform: rotate(14deg);
    }
    40% {
        transform: rotate(-4deg);
    }
    50% {
        transform: rotate(10deg);
    }
    60% {
        transform: rotate(0deg);
    }
}

/* Bounce Animation */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-15px);
    }
    60% {
        transform: translateY(-7px);
    }
}

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

/* Gradient Animation */
@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

/* Text Gradient Animation */
@keyframes textGradient {
    0%, 100% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
}

/* Glow Animation */
@keyframes glow {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(99, 102, 241, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(99, 102, 241, 0.8));
    }
}

/* Draw Line Animation */
@keyframes drawLine {
    from {
        stroke-dashoffset: 1000;
    }
    to {
        stroke-dashoffset: 0;
    }
}

/* Typing Animation */
@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink {
    0%, 100% {
        border-color: transparent;
    }
    50% {
        border-color: var(--primary-500);
    }
}

/* Morph Animation */
@keyframes morph {
    0%, 100% {
        border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%;
    }
    50% {
        border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%;
    }
}

/* Parallax Layer Animation */
@keyframes parallaxFloat {
    0%, 100% {
        transform: translateY(0) translateX(0);
    }
    25% {
        transform: translateY(-15px) translateX(10px);
    }
    50% {
        transform: translateY(-25px) translateX(-5px);
    }
    75% {
        transform: translateY(-10px) translateX(-15px);
    }
}

/* ---------- Animation Classes ---------- */

/* Fade Classes */
.animate-fade-in {
    opacity: 0;
    animation: fadeIn 0.6s ease forwards;
}

.animate-fade-in-up {
    opacity: 0;
    animation: fadeInUp 0.6s ease forwards;
}

.animate-fade-in-down {
    opacity: 0;
    animation: fadeInDown 0.6s ease forwards;
}

.animate-fade-in-left {
    opacity: 0;
    animation: fadeInLeft 0.6s ease forwards;
}

.animate-fade-in-right {
    opacity: 0;
    animation: fadeInRight 0.6s ease forwards;
}

/* Slide Classes */
.animate-slide-up {
    opacity: 0;
    transform: translateY(30px);
    animation: fadeInUp 0.8s ease forwards;
}

.animate-slide-down {
    opacity: 0;
    transform: translateY(-30px);
    animation: fadeInDown 0.8s ease forwards;
}

/* Scale Classes */
.animate-scale-in {
    opacity: 0;
    animation: scaleIn 0.5s ease forwards;
}

.animate-scale-bounce {
    opacity: 0;
    animation: scaleInBounce 0.8s ease forwards;
}

/* Float Class */
.animate-float {
    animation: float 6s ease-in-out infinite;
}

.animate-float-slow {
    animation: floatSlow 8s ease-in-out infinite;
}

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

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

/* Rotate Class */
.animate-rotate {
    animation: rotate 10s linear infinite;
}

.animate-rotate-slow {
    animation: rotateSlow 20s linear infinite;
}

/* Bounce Class */
.animate-bounce {
    animation: bounce 2s ease infinite;
}

/* Shake Class */
.animate-shake {
    animation: shake 0.5s ease;
}

/* Wave Class */
.animate-wave {
    animation: wave 2.5s ease-in-out infinite;
    transform-origin: 70% 70%;
}

/* Shimmer Effect */
.animate-shimmer {
    background: linear-gradient(90deg, 
        transparent 0%,
        rgba(255, 255, 255, 0.2) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmer 2s infinite;
}

/* Gradient Shift */
.animate-gradient {
    background-size: 200% 200%;
    animation: gradientShift 3s ease infinite;
}

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

/* Delay Classes */
.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; }

/* Duration Classes */
.duration-fast { animation-duration: 0.3s; }
.duration-normal { animation-duration: 0.6s; }
.duration-slow { animation-duration: 1s; }
.duration-slower { animation-duration: 2s; }

/* ---------- Scroll-Triggered Animations ---------- */
[data-aos] {
    opacity: 0;
    transition: all 0.6s ease;
}

[data-aos="fade-up"] {
    transform: translateY(40px);
}

[data-aos="fade-down"] {
    transform: translateY(-40px);
}

[data-aos="fade-left"] {
    transform: translateX(40px);
}

[data-aos="fade-right"] {
    transform: translateX(-40px);
}

[data-aos="zoom-in"] {
    transform: scale(0.9);
}

[data-aos="zoom-out"] {
    transform: scale(1.1);
}

[data-aos="flip-up"] {
    transform: perspective(2500px) rotateX(-100deg);
}

[data-aos="flip-down"] {
    transform: perspective(2500px) rotateX(100deg);
}

[data-aos].aos-animate {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1) rotateX(0);
}

/* AOS Delays */
[data-aos-delay="100"] { transition-delay: 100ms; }
[data-aos-delay="200"] { transition-delay: 200ms; }
[data-aos-delay="300"] { transition-delay: 300ms; }
[data-aos-delay="400"] { transition-delay: 400ms; }
[data-aos-delay="500"] { transition-delay: 500ms; }
[data-aos-delay="600"] { transition-delay: 600ms; }

/* ---------- Hover Animations ---------- */
.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

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

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

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

.hover-rotate:hover {
    transform: rotate(5deg);
}

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

.hover-glow:hover {
    box-shadow: 0 0 30px rgba(99, 102, 241, 0.4);
}

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

.hover-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;
}

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

/* ---------- Loading States ---------- */
.skeleton {
    background: linear-gradient(90deg, 
        var(--gray-200) 0%,
        var(--gray-100) 50%,
        var(--gray-200) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-title {
    height: 1.5em;
    width: 60%;
    margin-bottom: 1em;
}

.skeleton-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.skeleton-image {
    width: 100%;
    aspect-ratio: 16/9;
}

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

.spinner-small {
    width: 20px;
    height: 20px;
    border-width: 2px;
}

.spinner-large {
    width: 60px;
    height: 60px;
    border-width: 4px;
}

/* Dots Loading */
.loading-dots {
    display: flex;
    gap: 8px;
}

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

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 4px;
    background: var(--gray-200);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

.progress-bar-indeterminate .progress-bar-fill {
    width: 30%;
    animation: loading 1.5s ease-in-out infinite;
}

/* ---------- Page Transitions ---------- */
.page-transition-enter {
    opacity: 0;
    transform: translateY(20px);
}

.page-transition-enter-active {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.page-transition-exit {
    opacity: 1;
}

.page-transition-exit-active {
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* ---------- Particle Effects ---------- */
.particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--primary-400);
    border-radius: 50%;
    pointer-events: none;
}

.particle-glow {
    box-shadow: 0 0 10px var(--primary-400);
}

/* ---------- Text Effects ---------- */
.text-reveal {
    overflow: hidden;
}

.text-reveal span {
    display: inline-block;
    transform: translateY(100%);
    animation: slideInUp 0.6s ease forwards;
}

.text-gradient-animated {
    background: linear-gradient(
        90deg,
        var(--primary-400),
        var(--secondary-500),
        var(--accent-500),
        var(--primary-400)
    );
    background-size: 300% 100%;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: textGradient 4s ease infinite;
}

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

/* ---------- 3D Effects ---------- */
.perspective-container {
    perspective: 1000px;
}

.card-3d {
    transform-style: preserve-3d;
    transition: transform 0.6s ease;
}

.card-3d:hover {
    transform: rotateY(10deg) rotateX(5deg);
}

.card-3d-content {
    transform: translateZ(50px);
}

/* ---------- Magnetic Effect Styles ---------- */
.magnetic {
    transition: transform 0.3s ease;
}

/* ---------- Ripple Effect ---------- */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-effect {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: ripple 0.6s linear;
    pointer-events: none;
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ---------- Tilt Effect Container ---------- */
.tilt-container {
    transform-style: preserve-3d;
    perspective: 1000px;
}

.tilt-element {
    transition: transform 0.1s ease;
}

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

/* ---------- Marquee Animation ---------- */
.marquee {
    overflow: hidden;
    white-space: nowrap;
}

.marquee-content {
    display: inline-block;
    animation: marquee 20s linear infinite;
}

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

/* ---------- Stagger Children Animation ---------- */
.stagger-children > * {
    opacity: 0;
    transform: translateY(20px);
}

.stagger-children.animate > *:nth-child(1) { animation: fadeInUp 0.5s ease 0.1s forwards; }
.stagger-children.animate > *:nth-child(2) { animation: fadeInUp 0.5s ease 0.2s forwards; }
.stagger-children.animate > *:nth-child(3) { animation: fadeInUp 0.5s ease 0.3s forwards; }
.stagger-children.animate > *:nth-child(4) { animation: fadeInUp 0.5s ease 0.4s forwards; }
.stagger-children.animate > *:nth-child(5) { animation: fadeInUp 0.5s ease 0.5s forwards; }
.stagger-children.animate > *:nth-child(6) { animation: fadeInUp 0.5s ease 0.6s forwards; }

/* ---------- Reduced Motion ---------- */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .animate-float,
    .animate-pulse,
    .animate-rotate,
    .animate-bounce {
        animation: none;
    }
}
