/* Background Animation */
#background-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-color: var(--bg-color);
    overflow: hidden;
}

.light-mode #background-animation {
    opacity: 1.0;
    /* Full Visibility */
}

#bg-canvas {
    position: fixed;
    /* Fix canvas position */
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    z-index: 0;
    /* Ensure visibility */
}

#background-animation::before,
#background-animation::after {
    content: '';
    position: absolute;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    filter: blur(100px);
    /* Softer blur */
    opacity: 0.2;
    /* Very subtle glow, not a wash */
    animation: drift 20s infinite alternate;
}

#background-animation::before {
    background: var(--atmosphere-glow-1);
    /* RED */
    top: -10%;
    left: -10%;
}

#background-animation::after {
    background: var(--atmosphere-glow-2);
    /* DARK RED */
    bottom: -10%;
    right: -10%;
    animation-delay: -10s;
}

@keyframes drift {
    0% {
        transform: translate(0, 0) scale(1);
    }

    100% {
        transform: translate(50px, 50px) scale(1.1);
    }
}

/* Planet Animation System */
.planet-system {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.orbit {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 280px;
    height: 280px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    transform: translate(-50%, -50%) rotate(45deg) scaleY(0.25);
    pointer-events: none;
}

.planet.large {
    width: 150px;
    height: 150px;
    position: relative;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, var(--atmosphere-glow-1), #0a0a0a);
    box-shadow:
        inset -10px -10px 20px rgba(0, 0, 0, 0.8),
        inset 10px 10px 20px rgba(255, 255, 255, 0.2),
        0 0 30px rgba(56, 189, 248, 0.4);
    z-index: 10;
}

.orbit-container {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 280px;
    height: 280px;
    border-radius: 50%;
    transform: translate(-50%, -50%) rotate(45deg) scaleY(0.25);
    transform-style: preserve-3d;
    pointer-events: none;
    /* Z-Index swap on the CONTAINER to work with Stacking Contexts */
    animation: orbit-z-swap 8s steps(1) infinite;
}

@keyframes orbit-z-swap {
    0% {
        z-index: 12;
    }

    /* Right -> Bottom -> Left (Front) */
    49% {
        z-index: 12;
    }

    50% {
        z-index: 5;
    }

    /* Left -> Top -> Right (Back) */
    99% {
        z-index: 5;
    }

    100% {
        z-index: 12;
    }
}

.planet-driver {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    animation: driver-spin 8s linear infinite;
}

@keyframes driver-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.planet.small {
    position: absolute;
    top: 50%;
    left: 100%;
    /* Start at Edge (0 deg) */
    margin-top: 0;
    margin-left: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff, #555);
    box-shadow: 0 0 15px var(--secondary-accent);

    /* Counter-Rotate + Un-Scale */
    transform: translate(-50%, -50%) scaleY(4.0);
    animation: counter-spin 8s linear infinite;
}

@keyframes counter-spin {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scaleY(4.0);
    }

    100% {
        transform: translate(-50%, -50%) rotate(-360deg) scaleY(4.0);
    }
}

/* Scroll Reveal Animation Classes */
.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: all 0.8s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}