/* Particle container */

#stardust {
    position: fixed;
    inset: 0;
    z-index: -1;

    overflow: hidden;
    pointer-events: none;
}

#stardust .particle {
    position: absolute;
    top: -30px;

    display: block;
    pointer-events: none;
    user-select: none;

    will-change: transform;
}

/* Stardust */

.stardust-particle {
    color: white;
    opacity: var(--opacity);

    text-shadow:
        0 0 3px currentColor,
        0 0 7px currentColor;

    animation:
        stardust-fall
        var(--duration)
        linear
        var(--delay)
        infinite;
}

@keyframes stardust-fall {
    from {
        transform:
            translate3d(0, -10vh, 0)
            rotate(0deg);
    }

    to {
        transform:
            translate3d(var(--drift), 115vh, 0)
            rotate(300deg);
    }
}

/* --------------------------------
   Aaron Rickle-inspired rain
-------------------------------- */

#stardust {
    /*
     * These assume your root variables are named exactly
     * --aged-gold and --ivory.
     */
    --rain-gold: var(--aged-gold, #c7a765);
    --rain-ivory: var(--ivory, #f3ecd8);
}

/* Front and back rain layers */

#stardust .rain-layer {
    position: absolute;
    inset: 0;

    width: 100%;
    height: 100%;

    overflow: hidden;
    pointer-events: none;
}

#stardust .rain-layer.front-row {
    z-index: 2;
}

#stardust .rain-layer.back-row {
    /*
     * Always displayed—there is no back-row toggle.
     */
    z-index: 1;
    bottom: 45px;

    opacity: 0.42;
}

/* Individual drop wrapper */

#stardust .rain-drop {
    position: absolute;
    bottom: 100%;

    display: block;

    width: 15px;
    height: var(--drop-length);

    pointer-events: none;
    will-change: transform;

    animation:
        luna-rain-drop
        var(--rain-duration)
        steps(32, end)
        var(--rain-delay)
        infinite;
}

/* Falling golden stem */

#stardust .rain-stem {
    display: block;

    width: 2px;
    height: 62%;

    margin-left: 7px;

    
    background-color: var(--rain-gold, #c7a765);

    background-image: repeating-linear-gradient(
        to bottom,
        transparent 0,
        transparent 2px,
        var(--rain-ivory, #f3ecd8) 2px,
        var(--rain-ivory, #f3ecd8) 4px,
        transparent 4px,
        transparent 7px
    );

    border-radius: 0;
    opacity: 1;

    animation:
        luna-rain-stem
        var(--rain-duration)
        steps(32, end)
        var(--rain-delay)
        infinite;
}

/* Ground splat */

#stardust .rain-splat {
    display: block;

    width: var(--splat-size);
    height: calc(var(--splat-size) * 0.6);

    opacity: 0;

    color: var(--rain-gold);

    border-top:
        2px dotted
        currentColor;

    border-radius: 50%;

    transform: scale(0);

    animation:
        luna-rain-splat
        var(--rain-duration)
        linear
        var(--rain-delay)
        infinite;
}

/*
 * Tiny upward droplets produced by each splat.
 */

#stardust .rain-splat::before,
#stardust .rain-splat::after {
    content: "";

    position: absolute;
    left: 50%;
    top: 0;

    width: 2px;
    height: 3px;

    opacity: 0;

    border-radius: 50%;

    background: var(--rain-ivory);

    animation:
        luna-rain-spark
        var(--rain-duration)
        linear
        var(--rain-delay)
        infinite;
}

#stardust .rain-splat::before {
    --spark-x: -8px;
}

#stardust .rain-splat::after {
    --spark-x: 8px;
}

/* Animations */

@keyframes luna-rain-drop {
    0% {
        transform: translate3d(0, 0, 0);
    }

    75% {
        transform: translate3d(0, 90vh, 0);
    }

    100% {
        transform: translate3d(0, 90vh, 0);
    }
}

@keyframes luna-rain-stem {
    0%,
    74% {
        opacity: 1;
    }

    75%,
    100% {
        opacity: 0;
    }
}

@keyframes luna-rain-splat {
    0%,
    78% {
        opacity: 0;
        transform: scale(0);
    }

    82% {
        opacity: 0.8;
        transform: scale(0.25);
    }

    92% {
        opacity: 0.5;
        transform: scale(1);
    }

    100% {
        opacity: 0;
        transform: scale(1.55);
    }
}

@keyframes luna-rain-spark {
    0%,
    80% {
        opacity: 0;

        transform:
            translate3d(-50%, 0, 0)
            scale(0.4);
    }

    84% {
        opacity: 0.8;
    }

    100% {
        opacity: 0;

        transform:
            translate3d(
                calc(-50% + var(--spark-x)),
                -13px,
                0
            )
            scale(0.15);
    }
}

/* Weather selector */

#weather-control {
    position: fixed;
    right: 8px;
    bottom: 8px;
    z-index: 9999;

    display: flex;
    align-items: center;
    gap: 5px;

    padding: 4px 6px;

    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 3px;

    background: rgba(15, 12, 25, 0.85);
    color: white;

    font-family: monospace;
    font-size: 10px;
    line-height: 1;
}

#weather-control label {
    white-space: nowrap;
}

#weather-select {
    max-width: 95px;
    padding: 1px 2px;

    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 2px;

    background: #17121f;
    color: white;

    font: inherit;
    cursor: pointer;
}

#weather-select:focus-visible {
    outline: 1px solid white;
    outline-offset: 2px;
}

/* Fireflies */

#stardust .firefly-particle {
    width: var(--size);
    height: var(--size);
    border-radius: 50%;

    background: rgba(255, 244, 140, 0.95);
    opacity: var(--opacity);

    box-shadow:
        0 0 4px rgba(255, 244, 140, 0.6),
        0 0 8px rgba(255, 244, 140, 0.45),
        0 0 14px rgba(255, 244, 140, 0.3);

    animation:
        firefly-drift var(--move-duration) ease-in-out var(--delay) infinite alternate,
        firefly-glow var(--glow-duration) ease-in-out var(--delay) infinite;
}

@keyframes firefly-drift {
    0% {
        transform: translate3d(0, 0, 0);
    }

    25% {
        transform: translate3d(
            calc(var(--float-x) * 0.35),
            calc(var(--float-y) * -0.3),
            0
        );
    }

    50% {
        transform: translate3d(
            calc(var(--float-x) * 0.75),
            calc(var(--float-y) * 0.45),
            0
        );
    }

    75% {
        transform: translate3d(
            calc(var(--float-x) * -0.25),
            calc(var(--float-y) * 0.8),
            0
        );
    }

    100% {
        transform: translate3d(
            var(--float-x),
            var(--float-y),
            0
        );
    }
}

@keyframes firefly-glow {
    0%,
    100% {
        opacity: 0.18;
        box-shadow:
            0 0 2px rgba(255, 244, 140, 0.18),
            0 0 5px rgba(255, 244, 140, 0.12),
            0 0 8px rgba(255, 244, 140, 0.08);
    }

    20% {
        opacity: 0.35;
        box-shadow:
            0 0 3px rgba(255, 244, 140, 0.3),
            0 0 8px rgba(255, 244, 140, 0.22),
            0 0 12px rgba(255, 244, 140, 0.15);
    }

    45% {
        opacity: 0.95;
        box-shadow:
            0 0 5px rgba(255, 244, 140, 0.8),
            0 0 12px rgba(255, 244, 140, 0.55),
            0 0 20px rgba(255, 244, 140, 0.35);
    }

    70% {
        opacity: 0.28;
        box-shadow:
            0 0 3px rgba(255, 244, 140, 0.22),
            0 0 6px rgba(255, 244, 140, 0.16),
            0 0 10px rgba(255, 244, 140, 0.1);
    }
}