/* Scroll Performance Optimizations */

/* Prevent flashing during stock badge updates */
.plant-card.updating-stock {
    pointer-events: none;
}

.plant-card.updating-stock .stock-badge {
    opacity: 0.8;
}

/* Optimize animations during scroll */
@media (prefers-reduced-motion: no-preference) {
    .plant-grid {
        /* Use will-change sparingly and only when needed */
        will-change: scroll-position;
    }
    
    .plant-card {
        /* Optimize paint performance */
        will-change: auto;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }
    
    .plant-card:hover {
        /* Only apply will-change on hover to improve performance */
        will-change: transform;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .plant-card,
    .plant-card *,
    .stock-badge {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Optimize scrolling performance */
.plant-grid {
    /* Create a new stacking context to isolate repaints */
    transform: translateZ(0);
    /* Use hardware acceleration for smooth scrolling */
    -webkit-transform: translateZ(0);
}

/* Reduce layout thrashing during scroll */
.stock-badge {
    /* Prevent badge updates from causing layout shifts */
    min-width: 70px;
    text-align: center;
    contain: layout style paint;
}

/* Optimize image loading performance */
.plant-image img {
    /* Improve paint performance */
    image-rendering: auto;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
}

/* Disable transitions while scrolling to prevent flashing */
body.is-scrolling * {
    /* Disable ALL transitions and animations globally during scroll */
    transition: none !important;
    animation: none !important;
    transition-duration: 0s !important;
    animation-duration: 0s !important;
}

/* Specifically target elements that commonly cause issues */
body.is-scrolling .plant-card,
body.is-scrolling .plant-image,
body.is-scrolling .plant-image img,
body.is-scrolling .skeleton-card,
body.is-scrolling .stock-badge,
body.is-scrolling .favorite-btn,
body.is-scrolling .project-indicator {
    transition: none !important;
    animation: none !important;
    will-change: auto !important;
}

/* Disable pseudo-element animations */
body.is-scrolling .skeleton-card::before,
body.is-scrolling .skeleton-card::after,
body.is-scrolling *::before,
body.is-scrolling *::after {
    animation: none !important;
    transition: none !important;
}

/* Prevent opacity changes during scroll */
body.is-scrolling .plant-card {
    opacity: 1 !important;
}

/* Disable all hover effects during scroll */
body.is-scrolling .plant-card:hover {
    transform: none !important;
    box-shadow: none !important;
}