/**
 * Animations - Animazioni scroll-triggered e micro-interazioni
 */

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

/* Fade Up */
.animate-on-scroll[data-animation="fade-up"] {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll[data-animation="fade-up"].is-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Fade In */
.animate-on-scroll[data-animation="fade-in"] {
    opacity: 0;
    transition: opacity 0.6s ease;
}

.animate-on-scroll[data-animation="fade-in"].is-visible {
    opacity: 1;
}

/* Scale Up */
.animate-on-scroll[data-animation="scale-up"] {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.animate-on-scroll[data-animation="scale-up"].is-visible {
    opacity: 1;
    transform: scale(1);
}

/* Slide Left */
.animate-on-scroll[data-animation="slide-left"] {
    opacity: 0;
    transform: translateX(-60px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll[data-animation="slide-left"].is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Slide Right */
.animate-on-scroll[data-animation="slide-right"] {
    opacity: 0;
    transform: translateX(60px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.animate-on-scroll[data-animation="slide-right"].is-visible {
    opacity: 1;
    transform: translateX(0);
}

/* Blur In */
.animate-on-scroll[data-animation="blur-in"] {
    opacity: 0;
    filter: blur(10px);
    transition: opacity 0.6s ease, filter 0.6s ease;
}

.animate-on-scroll[data-animation="blur-in"].is-visible {
    opacity: 1;
    filter: blur(0);
}

/* ========================================
   STAGGER ANIMATIONS
   ======================================== */
.animate-on-scroll[data-animation="stagger"] > * {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.animate-on-scroll[data-animation="stagger"].is-visible > *:nth-child(1) { transition-delay: 0ms; }
.animate-on-scroll[data-animation="stagger"].is-visible > *:nth-child(2) { transition-delay: 100ms; }
.animate-on-scroll[data-animation="stagger"].is-visible > *:nth-child(3) { transition-delay: 200ms; }
.animate-on-scroll[data-animation="stagger"].is-visible > *:nth-child(4) { transition-delay: 300ms; }
.animate-on-scroll[data-animation="stagger"].is-visible > *:nth-child(5) { transition-delay: 400ms; }
.animate-on-scroll[data-animation="stagger"].is-visible > *:nth-child(6) { transition-delay: 500ms; }
.animate-on-scroll[data-animation="stagger"].is-visible > *:nth-child(7) { transition-delay: 600ms; }
.animate-on-scroll[data-animation="stagger"].is-visible > *:nth-child(8) { transition-delay: 700ms; }

.animate-on-scroll[data-animation="stagger"].is-visible > * {
    opacity: 1;
    transform: translateY(0);
}

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

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

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

/* Pulse */
@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 var(--color-secondary);
    }
    50% {
        box-shadow: 0 0 0 20px rgba(49, 130, 206, 0);
    }
}

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

/* Shimmer (loading effect) */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.shimmer {
    background: linear-gradient(
        90deg,
        var(--color-surface-alt) 25%,
        var(--color-surface) 50%,
        var(--color-surface-alt) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Gradient Shift */
@keyframes gradient-shift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.animated-gradient {
    background: linear-gradient(
        -45deg,
        var(--color-primary),
        var(--color-secondary),
        var(--color-primary-dark),
        var(--color-accent)
    );
    background-size: 400% 400%;
    animation: gradient-shift 15s ease infinite;
}

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

.spin {
    animation: spin 1s linear infinite;
}

/* Bounce */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
        animation-timing-function: cubic-bezier(0.8, 0, 1, 1);
    }
    50% {
        transform: translateY(-25%);
        animation-timing-function: cubic-bezier(0, 0, 0.2, 1);
    }
}

.bounce {
    animation: bounce 1s infinite;
}

/* Text Reveal */
@keyframes text-reveal {
    from {
        clip-path: inset(0 100% 0 0);
    }
    to {
        clip-path: inset(0 0 0 0);
    }
}

.text-reveal {
    animation: text-reveal 0.8s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

/* Counter */
@keyframes count-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.count-up {
    animation: count-up 0.5s ease forwards;
}

/* ========================================
   MICRO-INTERACTIONS
   ======================================== */

/* Link Underline Effect */
.link-hover {
    position: relative;
    text-decoration: none;
}

.link-hover::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: currentColor;
    transform: scaleX(0);
    transform-origin: right;
    transition: transform 0.3s ease;
}

.link-hover:hover::after {
    transform: scaleX(1);
    transform-origin: left;
}

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

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

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

/* Card Tilt on Hover */
.card-tilt {
    transition: transform 0.3s ease;
}

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

/* Icon Bounce on Hover */
.icon-bounce:hover svg,
.icon-bounce:hover i {
    animation: bounce 0.5s ease;
}

/* Glow Effect */
.glow {
    transition: box-shadow 0.3s ease;
}

.glow:hover {
    box-shadow: 0 0 30px rgba(49, 130, 206, 0.4);
}

/* ========================================
   LOADING STATES
   ======================================== */

/* Skeleton Loader */
.skeleton {
    background: linear-gradient(
        90deg,
        var(--color-surface-alt) 25%,
        var(--color-surface) 50%,
        var(--color-surface-alt) 75%
    );
    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%;
}

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

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

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

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

    .animate-on-scroll,
    .animate-on-scroll[data-animation] {
        opacity: 1 !important;
        transform: none !important;
        filter: none !important;
    }

    .animate-on-scroll[data-animation="stagger"] > * {
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ========================================
   PAGE TRANSITIONS
   ======================================== */
.page-enter {
    opacity: 0;
    transform: translateY(20px);
}

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

.page-exit {
    opacity: 1;
}

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