/* ============================================
   MICROINTERACTIONS - Gen Z Optimized
   Subtle animations for engaging UX
   ============================================ */

/* ===========================================
   STAGGERED CARD ENTRANCE
   =========================================== */

/* Animation for cards appearing */
@keyframes card-entrance {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Apply to project cards */
.projects-grid .project-card {
    animation: card-entrance var(--ds-duration-normal, 250ms) var(--ds-ease-out, cubic-bezier(0, 0, 0.2, 1)) backwards;
}

/* Stagger entrance for first 12 cards */
.projects-grid .project-card:nth-child(1) { animation-delay: 0ms; }
.projects-grid .project-card:nth-child(2) { animation-delay: 50ms; }
.projects-grid .project-card:nth-child(3) { animation-delay: 100ms; }
.projects-grid .project-card:nth-child(4) { animation-delay: 150ms; }
.projects-grid .project-card:nth-child(5) { animation-delay: 200ms; }
.projects-grid .project-card:nth-child(6) { animation-delay: 250ms; }
.projects-grid .project-card:nth-child(7) { animation-delay: 300ms; }
.projects-grid .project-card:nth-child(8) { animation-delay: 350ms; }
.projects-grid .project-card:nth-child(9) { animation-delay: 400ms; }
.projects-grid .project-card:nth-child(10) { animation-delay: 450ms; }
.projects-grid .project-card:nth-child(11) { animation-delay: 500ms; }
.projects-grid .project-card:nth-child(12) { animation-delay: 550ms; }

/* ===========================================
   BUTTON MICROINTERACTIONS
   =========================================== */

/* Scale on press (active state) */
.btn,
button:not([disabled]),
[role="button"] {
    transition:
        transform var(--ds-duration-fast, 150ms) var(--ds-ease-out, cubic-bezier(0, 0, 0.2, 1)),
        box-shadow var(--ds-duration-fast, 150ms) var(--ds-ease-out, cubic-bezier(0, 0, 0.2, 1)),
        background-color var(--ds-duration-fast, 150ms) var(--ds-ease-out, cubic-bezier(0, 0, 0.2, 1));
}

.btn:active:not([disabled]),
button:active:not([disabled]) {
    transform: scale(0.97);
}

/* Icon bounce on button click */
@keyframes icon-bounce {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

.btn:active i,
button:active i {
    animation: icon-bounce 200ms ease-out;
}

/* ===========================================
   CARD HOVER LIFT
   =========================================== */

.project-card,
.template-card,
.deck-card {
    transition:
        transform var(--ds-duration-fast, 150ms) var(--ds-ease-out, cubic-bezier(0, 0, 0.2, 1)),
        box-shadow var(--ds-duration-fast, 150ms) var(--ds-ease-out, cubic-bezier(0, 0, 0.2, 1));
}

.project-card:hover,
.template-card:hover,
.deck-card:hover {
    transform: translateY(-4px);
    box-shadow:
        0 12px 40px rgba(0, 0, 0, 0.25),
        0 0 0 1px rgba(139, 92, 246, 0.15);
}

/* Focus ring for keyboard navigation */
.project-card:focus-visible,
.template-card:focus-visible,
.deck-card:focus-visible {
    outline: 2px solid var(--ds-accent-primary, #8b5cf6);
    outline-offset: 2px;
}

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

/* Pulse animation for loading elements */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.is-loading {
    pointer-events: none;
}

.is-loading::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 50%,
        transparent 100%
    );
    animation: shimmer-overlay 1.5s infinite;
}

@keyframes shimmer-overlay {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* ===========================================
   SPINNER ANIMATION
   =========================================== */

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

.loading-spinner,
.spinner,
.fa-spinner {
    animation: spin 1s linear infinite;
}

/* ===========================================
   TOAST/NOTIFICATION ENTRANCE
   =========================================== */

@keyframes toast-slide-in {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes toast-slide-out {
    from {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
    to {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
}

/* ===========================================
   MODAL ENTRANCE
   =========================================== */

@keyframes modal-backdrop-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modal-content-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===========================================
   DROPDOWN ANIMATION
   =========================================== */

@keyframes dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.project-dropdown-menu.show,
.dropdown-menu.show {
    animation: dropdown-in var(--ds-duration-fast, 150ms) var(--ds-ease-spring, cubic-bezier(0.175, 0.885, 0.32, 1.275));
}

/* ===========================================
   FOCUS INDICATOR
   =========================================== */

/* Ripple effect placeholder for future implementation */
.ripple {
    position: relative;
    overflow: hidden;
}

/* ===========================================
   PAGE TRANSITIONS (if using AJAX navigation)
   =========================================== */

@keyframes page-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.page-transition-enter {
    animation: page-fade-in 200ms ease-out;
}

/* ===========================================
   SUCCESS/ERROR STATE ANIMATIONS
   =========================================== */

@keyframes success-check {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

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

.success-animation i,
.success-animation svg {
    animation: success-check 400ms var(--ds-ease-spring, cubic-bezier(0.175, 0.885, 0.32, 1.275));
}

.error-shake {
    animation: error-shake 400ms ease-out;
}

/* ===========================================
   PROGRESS BAR
   =========================================== */

@keyframes progress-indeterminate {
    0% {
        left: -40%;
        width: 40%;
    }
    50% {
        left: 20%;
        width: 80%;
    }
    100% {
        left: 100%;
        width: 40%;
    }
}

.progress-indeterminate .progress-bar {
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

/* ===========================================
   BADGE PULSE
   =========================================== */

@keyframes badge-pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.5);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(239, 68, 68, 0);
    }
}

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

/* ===========================================
   REDUCED MOTION
   =========================================== */

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

    .projects-grid .project-card {
        animation: none;
    }

    .project-card:hover,
    .template-card:hover,
    .deck-card:hover {
        transform: none;
    }
}
