/* Confetti Container */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 9999;
}

/* Individual Confetti Piece */
.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #f39c12;
    will-change: transform, opacity;
    animation: confetti-fall 3s linear forwards;
}

/* Different confetti shapes */
.confetti.square {
    /* Default square shape */
}

.confetti.rectangle {
    width: 13px;
    height: 7px;
}

.confetti.circle {
    border-radius: 50%;
}

.confetti.triangle {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 10px solid;
    background: transparent !important;
}

.confetti.star {
    position: relative;
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 4px solid;
    transform: rotate(35deg);
    background: transparent !important;
}

.confetti.star:before {
    content: '';
    position: absolute;
    left: -5px;
    top: -3px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 4px solid;
    border-bottom-color: inherit;
    transform: rotate(-70deg);
}

.confetti.star:after {
    content: '';
    position: absolute;
    left: -5px;
    top: 1px;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 4px solid;
    border-bottom-color: inherit;
    transform: rotate(70deg);
}

/* Confetti colors */
.confetti.red { background-color: #E74C3C !important; border-bottom-color: #E74C3C; }
.confetti.orange { background-color: #E67E22 !important; border-bottom-color: #E67E22; }
.confetti.yellow { background-color: #F1C40F !important; border-bottom-color: #F1C40F; }
.confetti.green { background-color: #27AE60 !important; border-bottom-color: #27AE60; }
.confetti.blue { background-color: #3498DB !important; border-bottom-color: #3498DB; }
.confetti.purple { background-color: #9B59B6 !important; border-bottom-color: #9B59B6; }
.confetti.pink { background-color: #FF69B4 !important; border-bottom-color: #FF69B4; }
.confetti.turquoise { background-color: #1ABC9C !important; border-bottom-color: #1ABC9C; }
.confetti.gold { background-color: #FFD700 !important; border-bottom-color: #FFD700; }
.confetti.silver { background-color: #C0C0C0 !important; border-bottom-color: #C0C0C0; }

/* Fireworks animation - launches from bottom, arcs up, falls back down */
@keyframes confetti-fireworks {
    0% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 1;
    }
    /* Peak of trajectory - confetti explodes upward */
    40% {
        transform: translate(
            calc(var(--velocity-x) * 15px),
            calc(var(--velocity-y) * -30px)
        ) rotate(calc(var(--rotation-speed) * 0.4deg));
        opacity: 1;
    }
    /* Falling back down with gravity */
    70% {
        transform: translate(
            calc(var(--velocity-x) * 20px),
            calc(var(--velocity-y) * -15px)
        ) rotate(calc(var(--rotation-speed) * 0.7deg));
        opacity: 1;
    }
    100% {
        transform: translate(
            calc(var(--velocity-x) * 25px),
            calc(var(--velocity-y) * 5px)
        ) rotate(calc(var(--rotation-speed) * 1deg));
        opacity: 0;
    }
}

/* Legacy falling animation (kept for backward compatibility) */
@keyframes confetti-fall {
    0% {
        transform: translateY(-100vh) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotate(720deg);
        opacity: 0;
    }
}

/* Drift animations for more natural movement */
@keyframes confetti-drift-1 {
    0% {
        transform: translateY(-100vh) translateX(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) translateX(100px) rotate(360deg);
        opacity: 0;
    }
}

@keyframes confetti-drift-2 {
    0% {
        transform: translateY(-100vh) translateX(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) translateX(-100px) rotate(-360deg);
        opacity: 0;
    }
}

@keyframes confetti-float {
    0% {
        transform: translateY(-100vh) translateX(0) rotate(0deg);
        opacity: 1;
    }
    25% {
        transform: translateY(25vh) translateX(-50px) rotate(90deg);
    }
    50% {
        transform: translateY(50vh) translateX(50px) rotate(180deg);
    }
    75% {
        transform: translateY(75vh) translateX(-30px) rotate(270deg);
    }
    100% {
        transform: translateY(100vh) translateX(30px) rotate(360deg);
        opacity: 0;
    }
}

/* Fireworks effect - uses physics-based animation */
.confetti.fireworks {
    animation: confetti-fireworks 4s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* Different animation variations (legacy) */
.confetti.drift-left {
    animation: confetti-drift-1 3s linear forwards;
}

.confetti.drift-right {
    animation: confetti-drift-2 3s linear forwards;
}

.confetti.float {
    animation: confetti-float 4s linear forwards;
}

/* Trigger button styles */
.confetti-trigger {
    display: inline-block;
    padding: 10px 20px;
    background-color: #3498db;
    color: white;
    text-decoration: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s;
    user-select: none;
}

.confetti-trigger:hover {
    background-color: #2980b9;
}

.confetti-trigger.celebrating {
    animation: pulse 0.5s;
    pointer-events: none;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .confetti {
        width: 8px;
        height: 8px;
    }
    
    .confetti.rectangle {
        width: 10px;
        height: 5px;
    }
}

/* Accessibility - respect reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .confetti {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Z-index management for different contexts */
.confetti-container.in-modal {
    z-index: 10001;
}

.confetti-container.below-header {
    z-index: 999;
}
