/**
 * Celebration Animations CSS 🎉
 * Dramatic effects for task completion
 * 
 * Effects included:
 * - Confetti 🎊
 * - Nyan Cat 🐱🌈
 * - Magic Sparkles ✨
 * - Fireworks 🎆
 * - Emoji Rain 🌧️😀
 * - Rocket Launch 🚀
 * - Trophy 🏆
 * - Balloons 🎈
 * - Shooting Stars 🌠
 * - Screen Flash ⚡
 */

/* ============================================================================
   CELEBRATION OVERLAY - Base container
   ============================================================================ */

.celebration-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 99999;
    overflow: hidden;
}

/* ============================================================================
   CONFETTI 🎊
   ============================================================================ */

.confetti-container {
    perspective: 1000px;
}

.confetti-piece {
    position: absolute;
    opacity: 1;
    animation: confetti-burst 3s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
    transform-style: preserve-3d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

@keyframes confetti-burst {
    0% {
        opacity: 1;
        transform: translate(0, 0) rotate(0deg) scale(0);
    }

    10% {
        transform: translate(0, 0) rotate(0deg) scale(1.2);
    }

    20% {
        transform: translate(calc(var(--end-x) * 0.3), calc(var(--end-y) * 0.1)) rotate(calc(var(--rotation) * 0.3)) scale(1);
    }

    100% {
        opacity: 0;
        transform: translate(var(--end-x), var(--end-y)) rotate(var(--rotation)) scale(0.6);
    }
}

/* ============================================================================
   NYAN CAT 🐱🌈
   ============================================================================ */

.nyancat-container {
    background: linear-gradient(180deg,
            #003366 0%,
            #0a1a33 50%,
            #000011 100%);
    animation: fade-in-out 3.5s ease-in-out;
}

@keyframes fade-in-out {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    85% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.nyan-cat-wrapper {
    position: absolute;
    top: 50%;
    left: -200px;
    transform: translateY(-50%);
    animation: fly-across 2.8s ease-in-out forwards;
    display: flex;
    align-items: center;
}

@keyframes fly-across {
    0% {
        left: -200px;
        top: 60%;
    }

    25% {
        top: 35%;
    }

    50% {
        top: 55%;
    }

    75% {
        top: 40%;
    }

    100% {
        left: calc(100% + 200px);
        top: 50%;
    }
}

.rainbow-trail {
    display: flex;
    flex-direction: column;
    width: 500px;
    margin-right: -10px;
}

.rainbow-stripe {
    height: 12px;
    animation: rainbow-wave 0.2s ease-in-out infinite alternate;
}

@keyframes rainbow-wave {
    0% {
        opacity: 0.8;
        transform: scaleX(0.95);
    }

    100% {
        opacity: 1;
        transform: scaleX(1);
    }
}

.nyan-cat {
    position: relative;
    animation: nyan-bounce 0.12s ease-in-out infinite alternate;
}

@keyframes nyan-bounce {
    0% {
        transform: translateY(-3px);
    }

    100% {
        transform: translateY(3px);
    }
}

.nyan-body {
    position: relative;
    width: 100px;
    height: 70px;
}

.poptart {
    position: absolute;
    width: 70px;
    height: 55px;
    background: #fc9;
    border-radius: 8px;
    top: 8px;
    left: 15px;
    border: 4px solid #c96;
    overflow: hidden;
}

.poptart::after {
    content: '';
    position: absolute;
    top: 5px;
    left: 5px;
    right: 5px;
    bottom: 5px;
    background: #f9a;
    border-radius: 4px;
}

.sprinkle {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    z-index: 1;
    animation: sprinkle-twinkle 0.3s ease-in-out infinite alternate;
}

.sprinkle:nth-child(1) {
    background: #f00;
    top: 10px;
    left: 12px;
}

.sprinkle:nth-child(2) {
    background: #0f0;
    top: 25px;
    left: 8px;
}

.sprinkle:nth-child(3) {
    background: #00f;
    top: 15px;
    left: 35px;
}

.sprinkle:nth-child(4) {
    background: #ff0;
    top: 35px;
    left: 20px;
}

.sprinkle:nth-child(5) {
    background: #f0f;
    top: 8px;
    left: 50px;
}

.sprinkle:nth-child(6) {
    background: #0ff;
    top: 30px;
    left: 45px;
}

.sprinkle:nth-child(7) {
    background: #f60;
    top: 40px;
    left: 35px;
}

@keyframes sprinkle-twinkle {
    0% {
        transform: scale(1);
    }

    100% {
        transform: scale(1.3);
    }
}

.cat-head {
    position: absolute;
    right: -5px;
    top: 12px;
    width: 35px;
    height: 30px;
    background: #999;
    border-radius: 6px;
}

.cat-ear {
    position: absolute;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 12px solid #999;
    top: -10px;
}

.cat-ear.left {
    left: 2px;
}

.cat-ear.right {
    right: 2px;
}

.cat-ear::after {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 8px solid #f9a;
    left: -5px;
    top: 4px;
}

.cat-face {
    position: relative;
    top: 5px;
}

.cat-eye {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #000;
    border-radius: 50%;
    top: 5px;
}

.cat-eye.left {
    left: 6px;
}

.cat-eye.right {
    right: 6px;
}

.cat-eye::after {
    content: '';
    position: absolute;
    width: 3px;
    height: 3px;
    background: #fff;
    border-radius: 50%;
    top: 1px;
    left: 1px;
}

.cat-cheek {
    position: absolute;
    width: 6px;
    height: 4px;
    background: #f99;
    border-radius: 50%;
    top: 15px;
}

.cat-cheek.left {
    left: 3px;
}

.cat-cheek.right {
    right: 3px;
}

.cat-mouth {
    position: absolute;
    width: 4px;
    height: 4px;
    border: 2px solid #000;
    border-top: none;
    border-left: none;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 3px 3px;
}

.cat-tail {
    position: absolute;
    left: 0;
    top: 25px;
    width: 15px;
    height: 10px;
    background: #999;
    border-radius: 10px 0 0 10px;
    animation: tail-wag 0.15s ease-in-out infinite alternate;
}

@keyframes tail-wag {
    0% {
        transform: rotate(-10deg);
    }

    100% {
        transform: rotate(10deg);
    }
}

.cat-legs {
    position: absolute;
    bottom: -8px;
    left: 20px;
    display: flex;
    gap: 10px;
}

.leg {
    width: 8px;
    height: 10px;
    background: #999;
    border-radius: 0 0 4px 4px;
}

.leg:nth-child(1),
.leg:nth-child(3) {
    animation: leg-run 0.12s ease-in-out infinite;
}

.leg:nth-child(2),
.leg:nth-child(4) {
    animation: leg-run 0.12s ease-in-out infinite reverse;
}

@keyframes leg-run {
    0% {
        height: 6px;
    }

    100% {
        height: 12px;
    }
}

.nyan-star {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: star-twinkle 0.3s ease-in-out infinite alternate,
        star-move 2.5s linear forwards;
}

.nyan-star::before,
.nyan-star::after {
    content: '';
    position: absolute;
    background: #fff;
}

.nyan-star::before {
    width: 10px;
    height: 3px;
    top: 3.5px;
    left: 0;
    border-radius: 2px;
}

.nyan-star::after {
    width: 3px;
    height: 10px;
    top: 0;
    left: 3.5px;
    border-radius: 2px;
}

@keyframes star-twinkle {
    0% {
        opacity: 0.5;
        transform: scale(0.8) rotate(0deg);
    }

    100% {
        opacity: 1;
        transform: scale(1.2) rotate(45deg);
    }
}

@keyframes star-move {
    0% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(-150vw);
    }
}

/* ============================================================================
   MAGIC SPARKLES ✨ (Harry Potter style)
   ============================================================================ */

.magic-container {
    background: radial-gradient(circle at center,
            rgba(255, 215, 0, 0.1) 0%,
            transparent 50%);
    animation: magic-glow 0.5s ease-out;
}

@keyframes magic-glow {
    0% {
        background: radial-gradient(circle at center, rgba(255, 215, 0, 0.4) 0%, transparent 30%);
    }

    100% {
        background: radial-gradient(circle at center, rgba(255, 215, 0, 0) 0%, transparent 50%);
    }
}

.magic-sparkle {
    position: absolute;
    background: radial-gradient(circle at 30% 30%,
            #fff 0%, #ffd700 40%, #ff8c00 70%, transparent 100%);
    border-radius: 50%;
    animation: sparkle-burst 2s ease-out forwards;
    box-shadow: 0 0 10px #ffd700, 0 0 20px #ffa500, 0 0 30px #ff8c00;
}

.magic-sparkle.secondary {
    background: radial-gradient(circle at 30% 30%,
            #fff 0%, #fffacd 50%, transparent 100%);
    box-shadow: 0 0 5px #ffd700, 0 0 10px #ffa500;
}

@keyframes sparkle-burst {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0);
    }

    20% {
        opacity: 1;
        transform: translate(calc(var(--end-x) * 0.2), calc(var(--end-y) * 0.2)) scale(1.5);
    }

    100% {
        opacity: 0;
        transform: translate(var(--end-x), var(--end-y)) scale(0.3);
    }
}

.magic-trail {
    position: absolute;
    width: 100px;
    height: 100px;
    transform: translate(-50%, -50%);
    animation: trail-pulse 0.8s ease-out forwards;
}

.magic-trail::before,
.magic-trail::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    border: 3px solid #ffd700;
    animation: ring-expand 0.8s ease-out forwards;
}

.magic-trail::before {
    width: 20px;
    height: 20px;
}

.magic-trail::after {
    width: 10px;
    height: 10px;
    animation-delay: 0.1s;
}

@keyframes ring-expand {
    0% {
        opacity: 1;
        width: 10px;
        height: 10px;
        border-width: 4px;
    }

    100% {
        opacity: 0;
        width: 300px;
        height: 300px;
        border-width: 1px;
    }
}

@keyframes trail-pulse {
    0% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* ============================================================================
   FIREWORKS 🎆
   ============================================================================ */

.fireworks-container {
    background: rgba(0, 0, 20, 0.8);
    animation: fade-in-out 4s ease-in-out;
}

.firework-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    animation: firework-explode 1.5s ease-out forwards;
}

@keyframes firework-explode {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0);
    }

    20% {
        opacity: 1;
        transform: translate(calc(var(--end-x) * 0.4), calc(var(--end-y) * 0.4)) scale(1.5);
    }

    100% {
        opacity: 0;
        transform: translate(var(--end-x), calc(var(--end-y) + 50px)) scale(0.2);
    }
}

/* ============================================================================
   EMOJI RAIN 🌧️😀
   ============================================================================ */

.emoji-rain-container {
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.1) 100%);
}

.falling-emoji {
    position: absolute;
    top: -60px;
    animation: emoji-fall 3s ease-in forwards;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

@keyframes emoji-fall {
    0% {
        opacity: 1;
        transform: translateY(0) rotate(0deg);
    }

    100% {
        opacity: 0;
        transform: translateY(110vh) rotate(var(--rotation));
    }
}

/* ============================================================================
   ROCKET LAUNCH 🚀
   ============================================================================ */

.rocket-container {
    background: linear-gradient(180deg,
            #000022 0%,
            #000044 50%,
            #000066 100%);
    animation: fade-in-out 3s ease-in-out;
}

.rocket {
    position: absolute;
    bottom: -100px;
    left: 50%;
    transform: translateX(-50%);
    animation: rocket-launch 2.5s ease-in forwards;
    font-size: 80px;
    text-align: center;
}

@keyframes rocket-launch {
    0% {
        bottom: -100px;
        transform: translateX(-50%) rotate(0deg);
    }

    20% {
        bottom: 20%;
        transform: translateX(-50%) rotate(-5deg);
    }

    40% {
        transform: translateX(-50%) rotate(5deg);
    }

    60% {
        transform: translateX(-50%) rotate(-3deg);
    }

    100% {
        bottom: 120%;
        transform: translateX(-50%) rotate(0deg);
    }
}

.rocket-body {
    filter: drop-shadow(0 0 20px rgba(255, 150, 0, 0.8));
}

.rocket-flame {
    position: absolute;
    bottom: -30px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 60px;
    background: linear-gradient(180deg,
            #ff6600 0%,
            #ff9900 30%,
            #ffcc00 60%,
            transparent 100%);
    border-radius: 50% 50% 50% 50% / 20% 20% 80% 80%;
    animation: flame-flicker 0.1s ease-in-out infinite alternate;
}

@keyframes flame-flicker {
    0% {
        transform: translateX(-50%) scaleY(1) scaleX(1);
    }

    100% {
        transform: translateX(-50%) scaleY(1.2) scaleX(0.9);
    }
}

.rocket-smoke {
    position: absolute;
    bottom: 0;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.6);
    border-radius: 50%;
    animation: smoke-rise 1.5s ease-out forwards;
}

@keyframes smoke-rise {
    0% {
        opacity: 0.8;
        transform: translateY(0) scale(1);
        bottom: 0;
    }

    100% {
        opacity: 0;
        transform: translateY(-100px) scale(3);
        bottom: 0;
    }
}

.rocket-star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    animation: rocket-star-fall 1s linear infinite;
}

@keyframes rocket-star-fall {
    0% {
        transform: translateY(0);
        opacity: 1;
    }

    100% {
        transform: translateY(100vh);
        opacity: 0;
    }
}

/* ============================================================================
   TROPHY 🏆
   ============================================================================ */

.trophy-container {
    background: radial-gradient(circle at center,
            rgba(255, 215, 0, 0.2) 0%,
            transparent 60%);
    animation: fade-in-out 3s ease-in-out;
}

.trophy {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    animation: trophy-appear 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes trophy-appear {
    0% {
        transform: translate(-50%, -50%) scale(0) rotate(-20deg);
    }

    60% {
        transform: translate(-50%, -50%) scale(1.2) rotate(10deg);
    }

    100% {
        transform: translate(-50%, -50%) scale(1) rotate(0deg);
    }
}

.trophy-icon {
    font-size: 120px;
    filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.8));
    animation: trophy-glow 1s ease-in-out infinite alternate;
}

@keyframes trophy-glow {
    0% {
        filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.6));
    }

    100% {
        filter: drop-shadow(0 0 40px rgba(255, 215, 0, 1));
    }
}

.trophy-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200px;
    height: 200px;
    transform: translate(-50%, -50%);
    background: radial-gradient(circle, rgba(255, 215, 0, 0.4) 0%, transparent 70%);
    animation: pulse-glow 1s ease-in-out infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 0.5;
    }

    50% {
        transform: translate(-50%, -50%) scale(1.3);
        opacity: 0.8;
    }
}

.trophy-text {
    font-size: 32px;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.8), 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-top: 10px;
    animation: text-bounce 0.5s ease-out 0.3s forwards;
    opacity: 0;
    transform: translateY(20px);
}

@keyframes text-bounce {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    60% {
        transform: translateY(-5px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.trophy-sparkle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ffd700;
    border-radius: 50%;
    animation: trophy-sparkle-burst 1.5s ease-out forwards;
    box-shadow: 0 0 10px #ffd700;
}

@keyframes trophy-sparkle-burst {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(0);
    }

    30% {
        opacity: 1;
        transform: translate(calc(var(--end-x) * 0.3), calc(var(--end-y) * 0.3)) scale(1.5);
    }

    100% {
        opacity: 0;
        transform: translate(var(--end-x), var(--end-y)) scale(0.5);
    }
}

/* ============================================================================
   BALLOONS 🎈
   ============================================================================ */

.balloon-container {
    background: linear-gradient(180deg, transparent 0%, rgba(135, 206, 235, 0.2) 100%);
}

.balloon {
    position: absolute;
    bottom: -100px;
    border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
    animation: balloon-rise 3s ease-out forwards;
    box-shadow: inset -10px -10px 20px rgba(0, 0, 0, 0.1),
        inset 10px 10px 20px rgba(255, 255, 255, 0.3);
}

.balloon::before {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 12px solid inherit;
}

.balloon-string {
    position: absolute;
    bottom: -50px;
    left: 50%;
    width: 2px;
    height: 40px;
    background: #999;
    transform-origin: top center;
    animation: string-sway 0.5s ease-in-out infinite alternate;
}

@keyframes string-sway {
    0% {
        transform: translateX(-50%) rotate(-5deg);
    }

    100% {
        transform: translateX(-50%) rotate(5deg);
    }
}

@keyframes balloon-rise {
    0% {
        bottom: -100px;
        opacity: 1;
        transform: translateX(0);
    }

    100% {
        bottom: 120%;
        opacity: 0.8;
        transform: translateX(var(--wobble));
    }
}

/* ============================================================================
   SHOOTING STARS 🌠
   ============================================================================ */

.shooting-stars-container {
    background: linear-gradient(180deg,
            #0a0a2e 0%,
            #16213e 50%,
            #1a1a4e 100%);
    animation: fade-in-out 3.5s ease-in-out;
}

.shooting-star {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #fff;
    border-radius: 50%;
    animation: shooting-star-fly 1s ease-out forwards;
    box-shadow: 0 0 10px #fff, 0 0 20px #fff;
}

.shooting-star::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: var(--length);
    height: 2px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.8) 0%, transparent 100%);
    transform-origin: right center;
    transform: rotate(calc(var(--angle) * -1));
}

@keyframes shooting-star-fly {
    0% {
        opacity: 1;
        transform: translate(0, 0);
    }

    100% {
        opacity: 0;
        transform: translate(calc(var(--length) * 2), calc(var(--length) * 1.5));
    }
}

/* ============================================================================
   SCREEN FLASH ⚡
   ============================================================================ */

.flash-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.screen-flash {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #fff;
    animation: flash-effect 0.5s ease-out forwards;
}

@keyframes flash-effect {
    0% {
        opacity: 0.9;
    }

    100% {
        opacity: 0;
    }
}

.flash-text {
    position: relative;
    z-index: 1;
    font-size: 200px;
    font-weight: 900;
    color: #10b981;
    animation: flash-text-appear 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
    text-shadow: 0 0 40px rgba(16, 185, 129, 0.6);
}

@keyframes flash-text-appear {
    0% {
        opacity: 0;
        transform: scale(3);
    }

    50% {
        opacity: 1;
        transform: scale(0.9);
    }

    70% {
        transform: scale(1.1);
    }

    100% {
        opacity: 0;
        transform: scale(1);
    }
}

/* ============================================================================
   CELEBRATION TOGGLE UI
   ============================================================================ */

.celebration-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f0fdf4;
    border-radius: 8px;
    border: 2px solid #bbf7d0;
}

.celebration-toggle .toggle-label {
    font-size: 13px;
    font-weight: 600;
    color: #166534;
    white-space: nowrap;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #d1d5db;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background: linear-gradient(135deg, #10b981 0%, #34d399 100%);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
}

.toggle-switch input:focus+.toggle-slider {
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 768px) {
    .nyan-cat-wrapper {
        transform: translateY(-50%) scale(0.7);
    }

    .rainbow-trail {
        width: 300px;
    }

    .celebration-toggle {
        padding: 6px 10px;
    }

    .celebration-toggle .toggle-label {
        font-size: 12px;
    }

    .trophy-icon {
        font-size: 80px;
    }

    .rocket {
        font-size: 60px;
    }

    .flash-text {
        font-size: 120px;
    }
}

/* ============================================================================
   REDUCED MOTION
   ============================================================================ */

@media (prefers-reduced-motion: reduce) {

    .confetti-piece,
    .nyan-cat-wrapper,
    .magic-sparkle,
    .nyan-cat,
    .nyan-star,
    .firework-particle,
    .falling-emoji,
    .rocket,
    .trophy,
    .balloon,
    .shooting-star,
    .screen-flash {
        animation: none !important;
    }

    .celebration-overlay {
        display: none;
    }
}