:root {
    --day-sky-color: #e0f7ff; /* Clear Sky Light Blue */
    --bg-color: var(--day-sky-color);
    --dot-color: #c0d9e6; /* Adjusted dot color for better contrast */
    --text-color: #1d1d1f;
    --card-pattern-color: #ff572244; /* Used in projects.html */
}

[data-theme="dark"] {
    --bg-color: #0c1445; /* Midnight Blue */
    --dot-color: #2a3a8a; /* Lighter blue for dots */
    --text-color: #e0e0e0; /* Light grey for text */
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
    background-color: var(--bg-color); /* Fallback for older browsers */
    /* Dotted canvas background */
    background-image: radial-gradient(var(--dot-color) 1px, transparent 1px);
    background-size: 25px 25px;
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scrolling site-wide */
    transition: background-color 3s ease;
}

#theme-toggle {
    position: fixed;
    top: 10%; /* 10% from the top edge */
    right: 10%; /* 10% from the right edge */
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 50%;
    z-index: 1003; /* Ensure this is the topmost element on the page */
    line-height: 1;
    transition: transform 0.3s ease;
    /* Ensure the container is a square based on its font size */
    width: 1em;
    height: 1em;
}

#theme-toggle.disabled {
    cursor: default;
}

/* --- Origami Symbol Styles --- */
.origami-sun, .origami-moon {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none; /* Children should never capture clicks */
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Sun Styles */
.origami-sun {
    background-color: #f9d71c; /* Sun color */
    border-radius: 50%;
    box-shadow: 0 0 0.5em #f9d71c;
}

/* Moon Styles */
.origami-moon {
    /* New textured moon background */
    background-color: #F5F3E5; /* Base yellowish moon color */
    background-image:
        radial-gradient(circle at 25% 30%, #D1CFC0 4%, transparent 4.5%),
        radial-gradient(circle at 60% 70%, #D1CFC0 7%, transparent 7.5%),
        radial-gradient(circle at 40% 80%, #D1CFC0 2%, transparent 2.5%);
    border-radius: 50%;
    box-shadow: -0.2em 0.1em 0 -0.05em #0c1445; /* Creates the crescent shape */
    filter: drop-shadow(0 0 0.2em #f1f1f1);
}

/* Visibility Logic */
[data-theme="light"] .origami-sun {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

[data-theme="light"] .origami-moon {
    opacity: 0;
    transform: scale(0.8) rotate(90deg);
}

[data-theme="dark"] .origami-sun {
    opacity: 0;
    transform: scale(0.8) rotate(-90deg);
}

[data-theme="dark"] .origami-moon {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}


/* --- General Layout --- */
.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    box-sizing: border-box;
}

/* --- Animated Sky Background Elements --- */
.sky-elements {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1; /* Place behind all other content */
    overflow: hidden; /* CRITICAL: Prevents animated children from causing horizontal scroll */
}

/* New container for clouds to manage their stacking order */
.clouds-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2; /* In front of theme toggle, behind main content */
    overflow: hidden;
    pointer-events: none; /* Allow clicks to pass through to content below */
}

/* --- Origami Clouds --- */
.cloud {
    position: absolute;
    background: #fff;
    border-radius: 50%;
    opacity: 0.8;
    filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.1));
    /* Two animations: one for vertical bobbing, one for horizontal drift */
    animation: hover 10s infinite ease-in-out, drift var(--drift-duration, 60s) linear infinite;
}
.cloud::before, .cloud::after {
    content: '';
    position: absolute;
    background: #fff;
    border-radius: 50%;
}
.cloud-1 {
    width: 120px; height: 35px;
    top: 15%; left: 10%;
    --parallax-factor: 0.4;
    --drift-duration: 75s;
    animation-delay: -2s;
}
.cloud-1::before { width: 60px; height: 60px; top: -25px; left: 15px; }
.cloud-1::after { width: 70px; height: 70px; top: -35px; right: 10px; }

.cloud-2 {
    width: 180px; height: 50px;
    top: 25%; left: 75%;
    --parallax-factor: 0.5;
    --drift-duration: 90s;
    animation-delay: -5s;
}
.cloud-2::before { width: 90px; height: 90px; top: -35px; left: 25px; }
.cloud-2::after { width: 110px; height: 110px; top: -50px; right: 15px; }

.cloud-3 {
    width: 100px; height: 30px;
    top: 50%; left: 5%;
    --parallax-factor: 0.3;
    --drift-duration: 110s;
    animation-delay: -8s;
}
.cloud-3::before { width: 50px; height: 50px; top: -20px; left: 10px; }
.cloud-3::after { width: 60px; height: 60px; top: -30px; right: 5px; }

.cloud-4 {
    width: 160px; height: 45px;
    top: 65%; left: 80%;
    --parallax-factor: 0.45;
    --drift-duration: 80s;
    animation-delay: -3s;
}
.cloud-4::before { width: 80px; height: 80px; top: -30px; left: 20px; }
.cloud-4::after { width: 90px; height: 90px; top: -40px; right: 15px; }

.cloud-5 {
    width: 140px; height: 40px;
    top: 80%; left: 30%;
    --parallax-factor: 0.35;
    --drift-duration: 100s;
    animation-delay: -6s;
}
.cloud-5::before { width: 70px; height: 70px; top: -25px; left: 15px; }
.cloud-5::after { width: 80px; height: 80px; top: -35px; right: 10px; }

.cloud-6 {
    width: 110px; height: 30px;
    top: 40%; left: 60%;
    --parallax-factor: 0.25;
    --drift-duration: 120s;
    animation-delay: -12s;
    transition: opacity 3s ease; /* For smooth fade-out in dark mode */
}
.cloud-6::before { width: 55px; height: 55px; top: -20px; left: 10px; }
.cloud-6::after { width: 65px; height: 65px; top: -30px; right: 5px; }

/* --- Origami Birds --- */
.bird-flock {
    position: absolute;
    top: 20%;
    left: 40%;
    transform: scale(0.8) translateY(var(--parallax-y, 0));
    transition: opacity 3s ease;
    --parallax-factor: 0.2;
}
.bird {
    position: absolute;
    width: 20px; height: 20px;
    background-color: var(--text-color);
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
    animation: bird-hover 3s infinite ease-in-out;
}
.bird-1 { top: 0; left: 0; animation-delay: -0.5s; }
.bird-2 { top: 15px; left: -30px; transform: scale(0.8); animation-delay: -1s; }
.bird-3 { top: 10px; left: 30px; transform: scale(0.9); animation-delay: -2s; }

@keyframes bird-hover {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

[data-theme="dark"] .bird-flock {
    opacity: 0.2;
}

[data-theme="dark"] .cloud-6 {
    /* Hide the extra cloud at night */
    opacity: 0;
}

@keyframes hover {
    0%, 100% { margin-top: 0; }
    50% { margin-top: -10px; }
}

@keyframes drift {
    from { transform: translateX(-200px) translateY(var(--parallax-y, 0)); }
    to { transform: translateX(100vw) translateY(var(--parallax-y, 0)); }
}

/* --- Origami Stars --- */
.stars {
    position: absolute;
    width: 100%; height: 100%;
    opacity: 0;
    transform: translateY(var(--parallax-y, 0));
    --parallax-factor: 0.1;
    transition: opacity 3s ease 1s; /* Fade in stars for night mode */
}
.star {
    position: absolute;
    background-color: #f5f5f5; /* Slightly off-white for a softer look */
    clip-path: polygon(50% 0%, 60% 40%, 100% 50%, 60% 60%, 50% 100%, 40% 60%, 0% 50%, 40% 40%);
    /* Animation properties are now more dynamic */
    animation-name: twinkle;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

[data-theme="dark"] .stars {
    opacity: 1;
}

@keyframes twinkle {
    0%, 100% {
        opacity: var(--twinkle-start-opacity, 0.4);
        box-shadow: 0 0 2px #fff;
    }
    50% {
        opacity: var(--twinkle-end-opacity, 1);
        box-shadow: 0 0 5px #fff;
    }
}

/* --- Shooting Stars --- */
.shooting-stars {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden; /* Ensure stars don't appear outside the container */
}

.shooting-star {
    position: absolute;
    width: 3px;
    height: 3px;
    background-color: #fff;
    border-radius: 50%;
    box-shadow: 0 0 8px #fff, 0 0 12px #fff;
    /* Animation will be set by JS */
    animation: shoot 3s ease-out;
    opacity: 0; /* Start invisible, animation will fade it in */
}

@keyframes shoot {
    0% {
        transform: translate(0, 0);
        opacity: 1;
    }
    80% {
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx, 300px), var(--ty, 300px));
        opacity: 0;
    }
}