/* ---------- Page Fade ---------- */
body {
    opacity: 0;
    transition: opacity 0.5s ease-in-out, background 0.5s ease, color 0.5s ease;
}

.loaded {
    opacity: 1;
}

/* ---------- Body Dark Mode ---------- */
body {
    margin: 0;
    font-family: Arial, sans-serif;
    background-color: #0a021a;
    color: #e8d9ff;
    padding: 20px;
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* ---------- Subtle Animated Stars ---------- */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 2px;
    height: 2px;
    background: white;
    border-radius: 50%;
    box-shadow:
        10vw 15vh white,
        50vw 10vh white,
        70vw 80vh white,
        30vw 60vh white,
        90vw 40vh white,
        20vw 75vh white,
        60vw 50vh white,
        80vw 15vh white;
    z-index: 0;
    pointer-events: none;
    animation: starDrift 30s linear infinite;
}

@keyframes starDrift {
    0%   { transform: translate(0,0); }
    100% { transform: translate(-80px,-60px); }
}

/* ---------- Moon/Sun ---------- */
body::after {
    content: '🌙';
    position: fixed;
    top: 10vh;
    right: 10vw;
    font-size: 50px;
    z-index: 0;
    pointer-events: none;
    animation: moonFloat 20s ease-in-out infinite alternate;
}

@keyframes moonFloat {
    0% { transform: translateY(0px); }
    100% { transform: translateY(15px); }
}

/* ---------- Light Mode ---------- */
.light-mode {
    background: linear-gradient(to bottom, #cfe9ff, #a0dfff);
    color: #002240;
}

/* Hide stars in light mode */
.light-mode::before {
    display: none;
}

/* Sun in light mode */
.light-mode::after {
    content: '☀️';
    animation: sunFloat 20s ease-in-out infinite alternate;
}

@keyframes sunFloat {
    0% { transform: translateY(0px); }
    100% { transform: translateY(-15px); }
}

/* ---------- Ensure content above stars/moon/sun ---------- */
nav, h1, h3, p {
    position: relative;
    z-index: 1;
}

/* ---------- Navigation ---------- */
nav {
    background-color: #14042d;
    padding: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border-bottom: 1px solid #a070ff;
    position: relative;
    z-index: 1;
}

.light-mode nav {
    background-color: #e3f4ff;
    border-bottom: 1px solid #ffcc33;
}

nav a {
    color: #f7eaff;
    text-decoration: none;
    font-size: 18px;
    padding: 6px 10px;
    border-radius: 6px;
    transition: all 0.3s ease;
}

.light-mode nav a {
    color: #003a66;
}

nav a:hover {
    background-color: #a070ff;
    color: black;
    box-shadow: 0 0 10px #a070ff;
}

.light-mode nav a:hover {
    background-color: #ffcc33;
    box-shadow: 0 0 10px #ffcc33;
}

/* ---------- Toggle Button ---------- */
.toggle-btn {
    margin-left: auto;
    background-color: #a070ff;
    border: none;
    color: black;
    padding: 6px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 17px;
    display: flex;
    align-items: center;
    transition: all 0.3s ease;
}

.light-mode .toggle-btn {
    background-color: #ffcc33;
}

.toggle-btn:hover {
    filter: brightness(1.2);
    box-shadow: 0 0 8px #a070ff;
}

.light-mode .toggle-btn:hover {
    box-shadow: 0 0 8px #ffcc33;
}

.toggle-btn .icon {
    font-size: 20px;
}

/* ---------- Responsive ---------- */
@media (max-width: 600px) {
    nav {
        justify-content: center;
    }
    nav a {
        font-size: 16px;
    }
}

