/*
 * Confettis (app/components/confetti.js). Le JS ne crée que des <div class="confetti"> :
 * position, couleur, rotation, durée et délai viennent d'ici, par :nth-child sur des
 * cycles de longueurs différentes (20, 11, 7, 5, 3) pour éviter tout motif visible.
 * Les rangs se comptent dans la rafale (.confetti-burst), qui couvre tout son conteneur.
 */

.confetti-burst {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.confetti {
    position: absolute;
    top: -2rem;
    width: 1rem;
    height: 0.5rem;
    background-color: #FF7992;
    pointer-events: none;
    /* backwards : caché au-dessus de l'écran pendant le délai, sans rester figé en bas à la fin */
    animation: fall 4s linear 2 backwards;
}

/* Jusque sous le bas de l'écran (top: -2rem + 100vh + marge) : le confetti en sort */
@keyframes fall {
    to {
        transform: translateY(calc(100vh + 4rem)) rotate(360deg);
    }
}

/* Position horizontale (20) */
.confetti:nth-child(20n+1) { left: 37.5%; }
.confetti:nth-child(20n+2) { left: 77.5%; }
.confetti:nth-child(20n+3) { left: 12.5%; }
.confetti:nth-child(20n+4) { left: 57.5%; }
.confetti:nth-child(20n+5) { left: 92.5%; }
.confetti:nth-child(20n+6) { left: 22.5%; }
.confetti:nth-child(20n+7) { left: 67.5%; }
.confetti:nth-child(20n+8) { left: 2.5%; }
.confetti:nth-child(20n+9) { left: 47.5%; }
.confetti:nth-child(20n+10) { left: 82.5%; }
.confetti:nth-child(20n+11) { left: 27.5%; }
.confetti:nth-child(20n+12) { left: 97.5%; }
.confetti:nth-child(20n+13) { left: 7.5%; }
.confetti:nth-child(20n+14) { left: 62.5%; }
.confetti:nth-child(20n+15) { left: 42.5%; }
.confetti:nth-child(20n+16) { left: 87.5%; }
.confetti:nth-child(20n+17) { left: 17.5%; }
.confetti:nth-child(20n+18) { left: 72.5%; }
.confetti:nth-child(20n+19) { left: 32.5%; }
.confetti:nth-child(20n+20) { left: 52.5%; }

/* Délai d'apparition (11) */
.confetti:nth-child(11n+1) { animation-delay: 1.80s; }
.confetti:nth-child(11n+2) { animation-delay: 3.60s; }
.confetti:nth-child(11n+3) { animation-delay: 0.45s; }
.confetti:nth-child(11n+4) { animation-delay: 2.25s; }
.confetti:nth-child(11n+5) { animation-delay: 4.05s; }
.confetti:nth-child(11n+6) { animation-delay: 0.90s; }
.confetti:nth-child(11n+7) { animation-delay: 2.70s; }
.confetti:nth-child(11n+8) { animation-delay: 4.50s; }
.confetti:nth-child(11n+9) { animation-delay: 1.35s; }
.confetti:nth-child(11n+10) { animation-delay: 3.15s; }
.confetti:nth-child(11n+11) { animation-delay: 0.00s; }

/* Rotation de départ (7) */
.confetti:nth-child(7n+1) { transform: rotate(153deg); }
.confetti:nth-child(7n+2) { transform: rotate(306deg); }
.confetti:nth-child(7n+3) { transform: rotate(102deg); }
.confetti:nth-child(7n+4) { transform: rotate(255deg); }
.confetti:nth-child(7n+5) { transform: rotate(51deg); }
.confetti:nth-child(7n+6) { transform: rotate(204deg); }
.confetti:nth-child(7n+7) { transform: rotate(0deg); }

/* Durée de chute (5) */
.confetti:nth-child(5n+1) { animation-duration: 3.8s; }
.confetti:nth-child(5n+2) { animation-duration: 4.6s; }
.confetti:nth-child(5n+3) { animation-duration: 3.4s; }
.confetti:nth-child(5n+4) { animation-duration: 4.2s; }
.confetti:nth-child(5n+5) { animation-duration: 3.0s; }

/* Couleur (3) */
.confetti:nth-child(3n+1) { background-color: #FF7992; }
.confetti:nth-child(3n+2) { background-color: #FFC500; }
.confetti:nth-child(3n+3) { background-color: #FFA242; }

@media (prefers-reduced-motion: reduce) {
    .confetti {
        display: none;
    }
}
