/* Conteneur principal des paillettes */
.paillettes-container {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    pointer-events: none !important;
    z-index: 999999 !important;
    overflow: visible !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    background: transparent !important;
    will-change: transform !important;
    transform: translateZ(0) !important;
    -webkit-transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
}

/* Style de base d'une paillette */
.sparkle {
    position: absolute !important;
    pointer-events: none !important;
    will-change: transform, opacity !important;
    transition: opacity 0.3s ease, transform 0.3s ease !important;
    background-size: contain !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    z-index: 999999 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    -webkit-backface-visibility: visible !important;
    backface-visibility: visible !important;
    -webkit-transform-style: flat !important;
    transform-style: flat !important;
    -webkit-font-smoothing: antialiased !important;
    -moz-osx-font-smoothing: grayscale !important;
    
    /* Styles de débogage */
    border: 1px solid red !important;
    background-color: rgba(255, 0, 0, 0.2) !important;
    box-shadow: 0 0 10px 5px rgba(255, 0, 0, 0.5) !important;
}

/* Animation de base */
@keyframes float {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 0.7;
    }
    25% {
        transform: translate(5px, 5px) rotate(2deg) scale(1.1);
        opacity: 1;
    }
    50% {
        transform: translate(0, 10px) rotate(0deg) scale(0.9);
        opacity: 0.5;
    }
    75% {
        transform: translate(-5px, 5px) rotate(-2deg) scale(1.05);
        opacity: 0.9;
    }
}

/* Animation de scintillement */
@keyframes twinkle {
    0%, 100% {
        opacity: 0.3;
        transform: scale(0.8);
    }
    50% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Animation de rotation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

/* Style pour les paillettes avec icônes personnalisées */
.sparkle.has-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background-color: rgba(0, 255, 0, 0.2) !important;
    border: 2px solid green !important;
}

/* Style de débogage pour les images */
.sparkle img {
    border: 2px dashed blue !important;
    background-color: rgba(0, 0, 255, 0.2) !important;
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
}

.sparkle img {
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    pointer-events: none !important;
    animation: spin 10s linear infinite !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-width: none !important;
    max-height: none !important;
    min-width: 0 !important;
    min-height: 0 !important;
    -webkit-transform: translateZ(0) !important;
    transform: translateZ(0) !important;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    transition: opacity 0.5s ease !important;
}

.sparkle img.loaded {
    opacity: 1;
}

/* Style pour les paillettes sans icônes (formes géométriques) */
.sparkle:not(.has-icon) {
    background: linear-gradient(45deg, #ffffff, rgba(255, 255, 255, 0.8));
    border-radius: 50%;
    box-shadow: 0 0 15px 2px rgba(255, 255, 255, 0.8);
    /* Effet de brillance */
    position: relative;
    overflow: hidden;
}

/* Effet de brillance sur les paillettes sans icônes */
.sparkle:not(.has-icon)::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, rgba(255,255,255,0) 60%);
    transform: rotate(45deg);
    animation: shine 3s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%) rotate(45deg); }
    100% { transform: translateX(100%) rotate(45deg); }
}

/* Effet de brillance supplémentaire */
.sparkle::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), transparent 70%);
    border-radius: inherit;
    opacity: 0.7;
    pointer-events: none;
}

/* Désactiver sur les appareils tactiles pour améliorer les performances */
@media (hover: none) and (pointer: coarse) {
    /* Réduire le nombre de paillettes sur mobile */
    .sparkle {
        /* Toutes les 3 paillettes */
        display: none !important;
    }
    
    .sparkle:nth-child(3n+1) {
        display: block !important;
    }
    
    /* Désactiver les animations complexes */
    .sparkle:not(.has-icon)::before {
        animation: none !important;
    }
    
    /* Optimiser les performances */
    .paillettes-container {
        transform: scale(0.8) !important;
        -webkit-transform: scale(0.8) !important;
    }
}

/* Réduire les animations si l'utilisateur le souhaite */
@media (prefers-reduced-motion: reduce) {
    .sparkle {
        animation: none !important;
        transition: none !important;
    }
    
    .sparkle img {
        animation: none !important;
    }
}

/* Styles spécifiques pour les différentes tailles d'écran */
@media (max-width: 782px) {
    .paillettes-container {
        /* Réduire le nombre de paillettes sur mobile */
        transform: scale(0.8);
    }
}

/* Effet de profondeur avec ombres */
.sparkle {
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.7));
}

/* Effet de brillance au survol (pour les appareils avec souris) */
@media (hover: hover) {
    .sparkle:hover {
        animation: twinkle 0.5s ease-in-out infinite;
        z-index: 1000000;
    }
}

/* Style pour les paillettes avec des couleurs aléatoires */
.sparkle.color-1 { background-color: rgba(255, 215, 0, 0.8); }
.sparkle.color-2 { background-color: rgba(255, 105, 180, 0.8); }
.sparkle.color-3 { background-color: rgba(135, 206, 235, 0.8); }
.sparkle.color-4 { background-color: rgba(255, 255, 255, 0.9); }
.sparkle.color-5 { background-color: rgba(255, 165, 0, 0.8); }

/* Animation de chute pour certaines paillettes */
.sparkle.falling {
    animation: falling linear infinite;
    animation-duration: calc(10s + (var(--fall-duration, 0) * 1s));
}

@keyframes falling {
    0% {
        transform: translateY(-10%) rotate(0deg);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 0.8;
    }
    100% {
        transform: translateY(110%) rotate(360deg);
        opacity: 0;
    }
}
