/* ============================================================
   PISTAR — Animations
   Subtle, performant micro-animations
   ============================================================ */

/* ---- KEYFRAMES ---- */

@keyframes pi-fade-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pi-fade-in-up {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: none; }
}

@keyframes pi-fade-in-down {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pi-fade-in-left {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pi-fade-in-right {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes pi-scale-in {
    from { opacity: 0; transform: scale(0.95); }
    to { opacity: 1; transform: scale(1); }
}

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

@keyframes pi-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes pi-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

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

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

@keyframes pi-slide-down {
    from { transform: translateY(-100%); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ---- ANIMATION UTILITIES ---- */

.pi-animate-fade-in { animation: pi-fade-in 0.5s ease-out both; }
.pi-animate-fade-in-up { animation: pi-fade-in-up 0.5s ease-out both; }
.pi-animate-fade-in-down { animation: pi-fade-in-down 0.5s ease-out both; }
.pi-animate-fade-in-left { animation: pi-fade-in-left 0.5s ease-out both; }
.pi-animate-fade-in-right { animation: pi-fade-in-right 0.5s ease-out both; }
.pi-animate-scale-in { animation: pi-scale-in 0.4s ease-out both; }
.pi-animate-bounce { animation: pi-bounce 1s ease both; }

/* Staggered delays */
.pi-delay-1 { animation-delay: 0.1s; }
.pi-delay-2 { animation-delay: 0.2s; }
.pi-delay-3 { animation-delay: 0.3s; }
.pi-delay-4 { animation-delay: 0.4s; }
.pi-delay-5 { animation-delay: 0.5s; }
.pi-delay-6 { animation-delay: 0.6s; }

/* ---- SKELETON LOADER ---- */

.pi-skeleton {
    background: linear-gradient(
        90deg,
        var(--pi-skeleton-base) 25%,
        var(--pi-skeleton-shine) 50%,
        var(--pi-skeleton-base) 75%
    );
    background-size: 200% 100%;
    animation: pi-shimmer 1.5s ease-in-out infinite;
    border-radius: var(--pi-radius-sm);
}

.pi-skeleton-text {
    height: 14px;
    margin-bottom: var(--pi-space-2);
    border-radius: var(--pi-radius-sm);
}

.pi-skeleton-text.short { width: 60%; }
.pi-skeleton-text.medium { width: 80%; }

.pi-skeleton-image {
    aspect-ratio: 4/3;
    border-radius: var(--pi-radius-md);
}

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

.pi-skeleton-button {
    height: 40px;
    width: 120px;
    border-radius: var(--pi-radius-md);
}

.pi-skeleton-card {
    border-radius: var(--pi-radius-lg);
    overflow: hidden;
}

/* ---- LOADING SPINNER ---- */

.pi-spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 3px solid var(--pi-border-color);
    border-top-color: var(--pi-primary);
    border-radius: 50%;
    animation: pi-spin 0.8s linear infinite;
}

.pi-spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.pi-spinner-lg { width: 40px; height: 40px; border-width: 4px; }

/* Button loading state */
.btn.loading {
    pointer-events: none;
    opacity: 0.8;
    position: relative;
}

.btn.loading .btn-text { opacity: 0; }

.btn.loading::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #FFFFFF;
    border-radius: 50%;
    animation: pi-spin 0.8s linear infinite;
}

/* ---- PAGE TRANSITION ---- */

.pi-page-enter {
    animation: pi-fade-in-up 0.4s ease-out both;
}

/* ---- SCROLL REVEAL ---- */

.pi-reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

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

/* ---- TOAST NOTIFICATION ---- */

.pi-toast {
    position: fixed;
    top: calc(var(--pi-navbar-height) + var(--pi-space-4));
    right: var(--pi-space-4);
    z-index: var(--pi-z-toast);
    animation: pi-slide-down 0.3s ease-out both;
    min-width: 320px;
    max-width: 450px;
}

.pi-toast.hiding {
    animation: pi-fade-in-right 0.3s ease-in both reverse;
}

/* ---- MODAL ANIMATION ---- */

.modal.pi-modal-animated .modal-dialog {
    animation: pi-scale-in 0.3s ease-out both;
}

/* ---- HOVER EFFECTS ---- */

.pi-hover-lift {
    transition: transform var(--pi-transition-base), box-shadow var(--pi-transition-base);
}

.pi-hover-lift:hover {
    transform: translateY(-4px);
    box-shadow: var(--pi-shadow-lg);
}

.pi-hover-glow:hover {
    box-shadow: var(--pi-shadow-glow);
}

.pi-hover-scale {
    transition: transform var(--pi-transition-base);
}

.pi-hover-scale:hover {
    transform: scale(1.02);
}

/* ---- REDUCE MOTION ---- */

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .pi-reveal {
        opacity: 1;
        transform: none;
    }
}
