/* ===================================
   NineSec - Advanced Animations
   Version 1.0.0
   60 FPS Optimized Microinteractions
   =================================== */

/* ===================================
   1. LOADING & SKELETON STATES
   =================================== */

@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }
    100% {
        background-position: 468px 0;
    }
}

.skeleton {
    animation: shimmer 1.2s ease-in-out infinite;
    background: linear-gradient(
        to right,
        hsl(220, 15%, 15%) 8%,
        hsl(220, 15%, 20%) 18%,
        hsl(220, 15%, 15%) 33%
    );
    background-size: 800px 104px;
    border-radius: 0.5rem;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-heading {
    height: 2rem;
    margin-bottom: 1rem;
}

.skeleton-avatar {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
}

.skeleton-button {
    height: 2.5rem;
    width: 8rem;
}

/* ===================================
   2. SUCCESS & ERROR ANIMATIONS
   =================================== */

@keyframes checkmark-draw {
    0% {
        stroke-dashoffset: 50;
    }
    100% {
        stroke-dashoffset: 0;
    }
}

@keyframes checkmark-scale {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

.checkmark-circle {
    stroke-dasharray: 166;
    stroke-dashoffset: 166;
    stroke-width: 2;
    stroke-miterlimit: 10;
    stroke: var(--color-success);
    fill: none;
    animation: checkmark-draw 0.8s cubic-bezier(0.65, 0, 0.45, 1) forwards;
}

.checkmark-check {
    transform-origin: 50% 50%;
    stroke-dasharray: 48;
    stroke-dashoffset: 48;
    stroke: var(--color-success);
    animation: checkmark-draw 0.3s cubic-bezier(0.65, 0, 0.45, 1) 0.8s forwards;
}

.checkmark-container {
    animation: checkmark-scale 0.8s ease-in-out;
}

@keyframes error-shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

.error-shake {
    animation: error-shake 0.5s ease-in-out;
}

/* ===================================
   3. BUTTON INTERACTIONS
   =================================== */

@keyframes ripple {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    pointer-events: none;
}

.btn-ripple:active::after {
    width: 100%;
    height: 100%;
    animation: ripple 0.6s ease-out;
}

.btn-hover-lift {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.2s ease;
}

.btn-hover-lift:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.btn-hover-lift:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===================================
   4. CARD & PANEL ANIMATIONS
   =================================== */

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card-enter {
    animation: slide-up 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.card-hover-float {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease;
}

.card-hover-float:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

/* ===================================
   5. MODAL & DIALOG ANIMATIONS
   =================================== */

@keyframes modal-backdrop-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modal-slide-down {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-backdrop {
    animation: modal-backdrop-fade 0.2s ease-out;
}

.modal-content {
    animation: modal-slide-down 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===================================
   6. PAGE TRANSITIONS
   =================================== */

@keyframes page-fade {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes page-slide {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.page-transition {
    animation: page-fade 0.3s ease-out;
}

.page-transition-slide {
    animation: page-slide 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* ===================================
   7. NOTIFICATION TOASTS
   =================================== */

@keyframes toast-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes toast-slide-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-enter {
    animation: toast-slide-in 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-exit {
    animation: toast-slide-out 0.2s ease-in;
}

/* ===================================
   8. PROGRESS & LOADING BARS
   =================================== */

@keyframes progress-indeterminate {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

.progress-indeterminate {
    position: relative;
    overflow: hidden;
}

.progress-indeterminate::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 50%;
    background: linear-gradient(
        90deg,
        transparent,
        var(--color-primary),
        transparent
    );
    animation: progress-indeterminate 1.5s ease-in-out infinite;
}

/* ===================================
   9. PULSE & GLOW EFFECTS
   =================================== */

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px var(--color-accent),
                    0 0 10px var(--color-accent),
                    0 0 15px var(--color-accent);
    }
    50% {
        box-shadow: 0 0 10px var(--color-accent),
                    0 0 20px var(--color-accent),
                    0 0 30px var(--color-accent);
    }
}

.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

.glow {
    animation: glow 2s ease-in-out infinite;
}

/* ===================================
   10. SPIN & ROTATE
   =================================== */

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes spin-reverse {
    from {
        transform: rotate(360deg);
    }
    to {
        transform: rotate(0deg);
    }
}

.spin {
    animation: spin 1s linear infinite;
}

.spin-slow {
    animation: spin 3s linear infinite;
}

.spin-reverse {
    animation: spin-reverse 2s linear infinite;
}

/* ===================================
   11. BOUNCE & ELASTIC
   =================================== */

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

@keyframes elastic-spin {
    0% {
        transform: rotate(0deg) scale(1);
    }
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg) scale(1);
    }
}

.bounce {
    animation: bounce 1s ease-in-out infinite;
}

.elastic-spin {
    animation: elastic-spin 2s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
}

/* ===================================
   12. TYPING & TEXT EFFECTS
   =================================== */

@keyframes typing {
    from {
        width: 0;
    }
    to {
        width: 100%;
    }
}

@keyframes blink-caret {
    from, to {
        border-color: transparent;
    }
    50% {
        border-color: var(--color-text-primary);
    }
}

.typing-effect {
    overflow: hidden;
    border-right: 0.15em solid var(--color-text-primary);
    white-space: nowrap;
    animation: typing 3.5s steps(40, end),
               blink-caret 0.75s step-end infinite;
}

/* ===================================
   13. FOCUS & HOVER STATES
   =================================== */

.focus-ring {
    transition: box-shadow 0.2s ease;
}

.focus-ring:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.hover-scale {
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.hover-scale:hover {
    transform: scale(1.05);
}

/* ===================================
   14. GLASS MORPHISM ANIMATIONS
   =================================== */

.glass-hover {
    transition: backdrop-filter 0.3s ease,
                background 0.3s ease,
                box-shadow 0.3s ease;
}

.glass-hover:hover {
    backdrop-filter: blur(20px) saturate(180%);
    background: hsla(220, 15%, 20%, 0.8);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

/* ===================================
   15. UTILITY ANIMATIONS
   =================================== */

.fade-in {
    animation: page-fade 0.3s ease-out;
}

.slide-in-left {
    animation: slide-in-left 0.3s ease-out;
}

@keyframes slide-in-left {
    from {
        transform: translateX(-100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.slide-in-right {
    animation: slide-in-right 0.3s ease-out;
}

@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ===================================
   16. PERFORMANCE OPTIMIZATIONS
   =================================== */

/* Force GPU acceleration for smooth animations */
.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

/* Prevent layout shifts during animations */
.contain-layout {
    contain: layout;
}

.contain-paint {
    contain: paint;
}

/* ===================================
   17. REDUCED MOTION SUPPORT
   =================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
