/**
 * Performance Optimizations CSS
 * 
 * Styles pour:
 * - Lazy loading des images
 * - Virtual scrolling
 * - Animations optimisées
 * 
 * @module assets/css/components/performance
 * @version 1.0.0
 */

/* Lazy Loading Images */
img.lazy-load {
    opacity: 0;
    transition: opacity 0.3s ease-in;
    background: linear-gradient(90deg, #334155 0%, #475569 50%, #334155 100%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

img.lazy-loaded {
    opacity: 1;
    animation: none;
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Virtual Scrolling */
.virtual-scroll-sentinel {
    height: 1px;
    width: 100%;
    margin-top: 20px;
    visibility: hidden;
}

/* Optimisation des animations */
.track-card,
.artist-card,
.album-card {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* Optimisation du hover */
.track-card:hover,
.artist-card:hover,
.album-card:hover {
    transform: translateY(-4px) translateZ(0);
}

/* Skeleton loading pour les images */
.track-cover.lazy-load::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        rgba(51, 65, 85, 0.1) 0%,
        rgba(71, 85, 105, 0.2) 50%,
        rgba(51, 65, 85, 0.1) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

/* Performance: Réduire les repaints */
.tracks-grid,
.artists-grid,
.albums-grid {
    contain: layout style paint;
}

/* Performance: GPU acceleration pour les transitions */
.track-card,
.track-action-btn,
.sidebar-link {
    transform: translateZ(0);
    will-change: transform, opacity;
}

/* Optimisation du scroll */
.music-main {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Indicateur de chargement pour virtual scrolling */
.virtual-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: var(--text-secondary);
}

.virtual-loading::after {
    content: '';
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Optimisation des images de couverture */
.track-cover,
.album-cover-large {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

/* Performance: Limiter les effets sur mobile */
@media (max-width: 768px) {
    .track-card:hover,
    .artist-card:hover,
    .album-card:hover {
        transform: none;
    }
    
    img.lazy-load {
        animation: none;
    }
}

/* Optimisation de la mémoire: Limiter les ombres */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    img.lazy-load {
        opacity: 1;
        animation: none;
    }
}
