body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
    transition: background-color 0.3s ease, color 0.3s ease;
}

@media (min-width: 768px) {
    body {
        background: radial-gradient(circle at var(--x) var(--y), transparent 10%, rgba(0, 0, 0, 0.95) 20%),
                    linear-gradient(-45deg, #ee7752, #e73c7e, #23a6d5, #23d5ab);
        background-size: 100% 100%, 400% 400%;
        animation: gradientAnimation 15s ease infinite;
    }
}

@keyframes gradientAnimation {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.container {
    max-width: 960px;
    margin: 2rem auto;
    padding: 2rem;
    background-color: #fff;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    transition: background-color 0.3s ease, box-shadow 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

@keyframes turn-out {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(0.8);
        opacity: 0;
    }
}

@keyframes turn-in {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.container.turning-out {
    animation: turn-out 0.3s ease-out forwards;
}

.container.turning-in {
    animation: turn-in 0.3s ease-in forwards;
}

header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 1rem;
    position: relative; /* For dark mode toggle positioning */
    transition: border-bottom-color 0.3s ease;
}

.profile-img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin-right: 2rem;
}

.header-text h1 {
    margin: 0;
    font-size: 2.5rem;
    color: #007bff;
}

.header-text p {
    margin: 0.2rem 0;
    font-size: 1.2rem;
}

.contact-info p {
    font-size: 1rem;
    margin: 0.5rem 0;
}

.contact-info a {
    text-decoration: none;
    color: #007bff;
    transition: color 0.3s ease;
}

.contact-info a:hover {
    text-decoration: underline;
}

main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

section {
    padding: 1.5rem;
    border-radius: 8px;
    background-color: #f9f9f9;
    transition: background-color 0.3s ease;
}

section h2 {
    margin-top: 0;
    color: #007bff;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
    transition: color 0.3s ease, border-bottom-color 0.3s ease;
}

article {
    margin-bottom: 1.5rem;
}

article:last-child {
    margin-bottom: 0;
}

article h3 {
    margin-bottom: 0.3rem;
}

article p {
    margin: 0.2rem 0;
}

article ul {
    padding-left: 1.5rem;
    margin-top: 0.5rem;
}

.skills {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.skill-category h3 {
    color: #007bff;
}

.skill-category ul {
    list-style: none;
    padding: 0;
}

.skill-category li {
    margin-bottom: 0.5rem;
}

@media (max-width: 768px) {
    .container {
        margin: 1rem;
        padding: 1rem;
    }

    header {
        flex-direction: column;
        text-align: center;
    }

    .profile-img {
        margin-right: 0;
        margin-bottom: 1rem;
    }

    .header-text h1 {
        font-size: 2rem;
    }
}

/* Loading Overlay Styles */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f4f4f4; /* Light mode default */
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.5s ease-out, background-color 0.3s ease;
}

body.dark-mode #loading-overlay {
    background-color: #1a1a1a; /* Dark mode */
}

#loading-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.loading-pulse {
    position: relative;
    width: 100px;
    height: 100px;
}

.loading-circle {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: #007bff; /* Light mode default */
    opacity: 0;
    animation: pulse-scale 2s infinite ease-out, pulse-opacity 2s infinite ease-out;
}

body.dark-mode .loading-circle {
    background-color: #8ab4f8; /* Dark mode */
}

.loading-circle:nth-child(1) {
    animation-delay: 0s;
}

.loading-circle:nth-child(2) {
    animation-delay: 0.5s;
}

.loading-circle:nth-child(3) {
    animation-delay: 1s;
}

@keyframes pulse-scale {
    0% { transform: scale(0); }
    50% { transform: scale(1); }
    100% { transform: scale(1); }
}

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

/* Dark Mode Toggle Button */
#dark-mode-toggle {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 5px;
    transition: background-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
    transform-style: preserve-3d;
    perspective: 1000px;
}

#dark-mode-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

#dark-mode-toggle.flipped {
    transform: rotateY(180deg);
}

/* Dark Mode Styles */
body.dark-mode {
    background-color: #1a1a1a;
    color: #e0e0e0;
}

body.dark-mode .container {
    background-color: #2a2a2a;
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

body.dark-mode header {
    border-bottom-color: #444;
}

body.dark-mode .header-text h1,
body.dark-mode .contact-info a,
body.dark-mode section h2,
body.dark-mode .skill-category h3 {
    color: #8ab4f8; /* Lighter blue for dark mode */
}

body.dark-mode section {
    background-color: #3a3a3a;
}

body.dark-mode section h2 {
    border-bottom-color: #555;
}

body.dark-mode .contact-info a {
    color: #8ab4f8;
}

body.dark-mode #dark-mode-toggle {
    background-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode #dark-mode-toggle:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

@media (min-width: 768px) {
    body.dark-mode {
        background: radial-gradient(circle at var(--x) var(--y), transparent 10%, rgba(0, 0, 0, 0.9) 20%),
                    linear-gradient(-45deg, #2c3e50, #34495e, #4a698c, #5e81a8);
        background-size: 100% 100%, 400% 400%;
        animation: gradientAnimation 15s ease infinite;
    }
}
