/* ===== MICRO-ANIMATIONS FOR SMOOTH UX ===== */
/* Version 1.0 - Performance optimized animations */

/* ===== ANIMATION VARIABLES ===== */
:root {
    --animation-fast: 0.15s;
    --animation-normal: 0.3s;
    --animation-slow: 0.6s;
    --easing-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --easing-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
    --easing-elastic: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* ===== PERFORMANCE OPTIMIZED BASE ANIMATIONS ===== */

/* Fade animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translate3d(0, -30px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(-30px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

@keyframes fadeInRight {
    from {
        opacity: 0;
        transform: translate3d(30px, 0, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Scale animations */
@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale3d(0.8, 0.8, 1);
    }
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

@keyframes scaleUp {
    from {
        transform: scale3d(1, 1, 1);
    }
    to {
        transform: scale3d(1.05, 1.05, 1);
    }
}

/* Bounce animations */
@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale3d(0.3, 0.3, 1);
    }
    50% {
        opacity: 1;
        transform: scale3d(1.05, 1.05, 1);
    }
    70% {
        transform: scale3d(0.9, 0.9, 1);
    }
    100% {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* Slide animations */
@keyframes slideInUp {
    from {
        transform: translate3d(0, 100%, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

@keyframes slideInDown {
    from {
        transform: translate3d(0, -100%, 0);
        visibility: visible;
    }
    to {
        transform: translate3d(0, 0, 0);
    }
}

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

@keyframes heartbeat {
    0% {
        transform: scale3d(1, 1, 1);
    }
    14% {
        transform: scale3d(1.3, 1.3, 1);
    }
    28% {
        transform: scale3d(1, 1, 1);
    }
    42% {
        transform: scale3d(1.3, 1.3, 1);
    }
    70% {
        transform: scale3d(1, 1, 1);
    }
}

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

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

@keyframes wobble {
    0% {
        transform: translate3d(0, 0, 0);
    }
    15% {
        transform: translate3d(-25%, 0, 0) rotate(-5deg);
    }
    30% {
        transform: translate3d(20%, 0, 0) rotate(3deg);
    }
    45% {
        transform: translate3d(-15%, 0, 0) rotate(-3deg);
    }
    60% {
        transform: translate3d(10%, 0, 0) rotate(2deg);
    }
    75% {
        transform: translate3d(-5%, 0, 0) rotate(-1deg);
    }
    100% {
        transform: translate3d(0, 0, 0);
    }
}

/* ===== COMPONENT-SPECIFIC ANIMATIONS ===== */

/* Button animations */
.btn-animate {
    transition: all var(--animation-normal) var(--easing-smooth);
    will-change: transform;
}

.btn-animate:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.btn-animate:active {
    transform: translateY(0);
    transition-duration: var(--animation-fast);
}

.btn-bounce:hover {
    animation: pulse 0.6s var(--easing-bounce);
}

.btn-shake:hover {
    animation: shake 0.5s var(--easing-smooth);
}

/* Card animations */
.card-animate {
    transition: all var(--animation-normal) var(--easing-smooth);
    will-change: transform, box-shadow;
}

.card-animate:hover {
    transform: translateY(-5px) scale3d(1.02, 1.02, 1);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
}

/* Link animations */
.link-animate {
    position: relative;
    transition: color var(--animation-normal) var(--easing-smooth);
}

.link-animate::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 0;
    height: 2px;
    background: currentColor;
    transition: width var(--animation-normal) var(--easing-smooth);
}

.link-animate:hover::after {
    width: 100%;
}

/* Input animations */
.input-animate {
    transition: all var(--animation-normal) var(--easing-smooth);
    will-change: border-color, box-shadow;
}

.input-animate:focus {
    transform: scale3d(1.02, 1.02, 1);
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

/* Image animations */
.image-animate {
    transition: all var(--animation-normal) var(--easing-smooth);
    will-change: transform, filter;
}

.image-animate:hover {
    transform: scale3d(1.05, 1.05, 1);
    filter: brightness(1.1);
}

/* Loading animations */
.loading-spinner {
    animation: rotate 1s linear infinite;
    will-change: transform;
}

.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
    will-change: transform;
}

.loading-dots::after {
    content: '';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20% {
        color: rgba(0, 0, 0, 0);
        text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0),
                     0.5em 0 0 rgba(0, 0, 0, 0);
    }
    40% {
        color: black;
        text-shadow: 0.25em 0 0 rgba(0, 0, 0, 0),
                     0.5em 0 0 rgba(0, 0, 0, 0);
    }
    60% {
        text-shadow: 0.25em 0 0 black,
                     0.5em 0 0 rgba(0, 0, 0, 0);
    }
    80%, 100% {
        text-shadow: 0.25em 0 0 black,
                     0.5em 0 0 black;
    }
}

/* ===== ENTRANCE ANIMATIONS ===== */
.animate-fade-in {
    animation: fadeIn var(--animation-slow) var(--easing-smooth) forwards;
}

.animate-fade-in-up {
    animation: fadeInUp var(--animation-slow) var(--easing-smooth) forwards;
}

.animate-fade-in-down {
    animation: fadeInDown var(--animation-slow) var(--easing-smooth) forwards;
}

.animate-fade-in-left {
    animation: fadeInLeft var(--animation-slow) var(--easing-smooth) forwards;
}

.animate-fade-in-right {
    animation: fadeInRight var(--animation-slow) var(--easing-smooth) forwards;
}

.animate-scale-in {
    animation: scaleIn var(--animation-slow) var(--easing-smooth) forwards;
}

.animate-bounce-in {
    animation: bounceIn var(--animation-slow) var(--easing-bounce) forwards;
}

.animate-slide-in-up {
    animation: slideInUp var(--animation-slow) var(--easing-smooth) forwards;
}

.animate-slide-in-down {
    animation: slideInDown var(--animation-slow) var(--easing-smooth) forwards;
}

/* ===== STAGGERED ANIMATIONS ===== */
.stagger-children > * {
    opacity: 0;
    animation: fadeInUp var(--animation-slow) var(--easing-smooth) forwards;
}

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

/* ===== SCROLL ANIMATIONS ===== */
.scroll-animate {
    opacity: 0;
    transform: translateY(30px);
    transition: all var(--animation-slow) var(--easing-smooth);
}

.scroll-animate.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* ===== HOVER EFFECTS ===== */
.hover-lift {
    transition: transform var(--animation-normal) var(--easing-smooth);
    will-change: transform;
}

.hover-lift:hover {
    transform: translateY(-5px);
}

.hover-grow {
    transition: transform var(--animation-normal) var(--easing-smooth);
    will-change: transform;
}

.hover-grow:hover {
    transform: scale3d(1.05, 1.05, 1);
}

.hover-shrink {
    transition: transform var(--animation-normal) var(--easing-smooth);
    will-change: transform;
}

.hover-shrink:hover {
    transform: scale3d(0.95, 0.95, 1);
}

.hover-rotate {
    transition: transform var(--animation-normal) var(--easing-smooth);
    will-change: transform;
}

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

.hover-wobble:hover {
    animation: wobble 0.8s var(--easing-smooth);
}

/* ===== FOCUS ANIMATIONS ===== */
.focus-ring {
    transition: box-shadow var(--animation-normal) var(--easing-smooth);
}

.focus-ring:focus {
    box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.3);
    outline: none;
}

/* ===== MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
    :root {
        --animation-fast: 0.1s;
        --animation-normal: 0.2s;
        --animation-slow: 0.4s;
    }
    
    /* Reduce animations on mobile for better performance */
    .card-animate:hover {
        transform: translateY(-2px) scale3d(1.01, 1.01, 1);
    }
    
    .btn-animate:hover {
        transform: translateY(-1px);
    }
}

/* ===== 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;
        scroll-behavior: auto !important;
    }
    
    .scroll-animate {
        opacity: 1;
        transform: none;
    }
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
    .btn-animate:hover,
    .card-animate:hover {
        outline: 2px solid;
    }
}

/* ===== PERFORMANCE HINTS ===== */
.will-animate {
    will-change: transform, opacity;
}

.gpu-accelerated {
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    perspective: 1000px;
}
