@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500&display=swap');

:root {
    --bg-color: #000000;
    --text-color: #ffffff;
    --link-color: #649ed4; /* A slightly darker, soft purple */
    --line-color: #649ed4;
    --faded-color: #555;
    --success-color: #2e8b57; /* SeaGreen, fits the cool palette */
    --error-color: #c84b4b;   /* A softer, less jarring red */
    --font-primary: 'Montserrat', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
}

@keyframes drift {
    from {
        background-position: 0 0, 0 0, 0 0, 0 0, 0 0, 0 0;
    }
    to {
        background-position: -500px 500px, -600px 400px, -700px 300px, -450px 550px, -650px 350px, -750px 250px;
    }
}

@keyframes shooting-star-animation {
    0% {
        transform: translate(50vw, -50vh) rotate(-45deg);
        opacity: 0;
    }
    90% {
        transform: translate(50vw, -50vh) rotate(-45deg);
        opacity: 0;
    }
    90.1% {
        opacity: 1;
    }
    93% {
        transform: translate(-50vw, 50vh) rotate(-45deg);
        opacity: 0;
    }
    100% {
        transform: translate(-50vw, 50vh) rotate(-45deg);
        opacity: 0;
    }
}

body {
    font-family: var(--font-primary);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    text-align: center;
    overflow: hidden;
    position: relative;
    background-color: #000;
    background-image:
        radial-gradient(ellipse at 20% 80%, rgba(20, 80, 200, 0.3), transparent 70%),
        radial-gradient(ellipse at 80% 10%, rgba(140, 40, 180, 0.3), transparent 70%);
    transition: background-image 0.5s ease;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    background-image:
        radial-gradient(1px 1px at 10% 30%, white, transparent),
        radial-gradient(1.5px 1.5px at 80% 60%, white, transparent),
        radial-gradient(2px 2px at 40% 90%, white, transparent),
        radial-gradient(1px 1px at 55% 75%, white, transparent),
        radial-gradient(1.5px 1.5px at 20% 15%, white, transparent),
        radial-gradient(2.5px 2.5px at 90% 40%, white, transparent);
    background-repeat: repeat;
    background-size: 800px 800px, 1200px 1200px, 1600px 1600px, 800px 800px, 1200px 1200px, 1800px 1800px;
    animation: drift 120s linear infinite;
}

body::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200px;
    height: 1px;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.6), transparent);
    z-index: -1;
    animation: shooting-star-animation 97s ease-in-out infinite;
    animation-delay: 5s;
}

.container {
    max-width: 600px;
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    transition: opacity 0.2s ease;
}

.name {
    font-size: 2.5rem;
    font-weight: 400;
    letter-spacing: 5px;
    margin-bottom: 1.5rem;
    position: relative;
    padding-bottom: 1.5rem;
    transition: color 0.3s ease;
}

.name::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100px;
    height: 1px;
    background-color: var(--line-color);
    transition: background-color 0.3s ease;
}

.skills {
    font-size: 1.1rem;
    font-weight: 300;
    letter-spacing: 2px;
    margin-bottom: 2.5rem;
    color: var(--text-color);
    transition: color 0.3s ease;
}

.contact-link {
    font-size: 1.1rem;
    font-weight: 300;
    letter-spacing: 2px;
}

.contact-link a {
    font-size: 1.1rem;
    font-weight: 300;
    text-decoration: none;
    color: var(--link-color);
    /* Updated transition for a smoother bold effect */
    transition: font-weight 0.2s ease-in-out, color 0.3s ease;
}

.contact-link a:hover {
    /* Corrected hover effect */
    color: var(--text-color); /* Brighten to white on hover */
    text-decoration: none;
    font-weight: 500; /* Use a numeric value for bold */
}

/* Faded state for when the modal is open */
.container.faded {
    opacity: 0.1;
}

.container.faded .name,
.container.faded .skills,
.container.faded .contact-link a {
    color: var(--faded-color);
}

.container.faded .name::after {
    background-color: var(--faded-color);
}

/* Modal Styles */
.modal {
    position: fixed; /* Stay in place */
    z-index: 2000; /* Sit on top of everything else */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    background-color: transparent; /* No overlay dimming */
    align-items: center;
    display: flex;
    justify-content: center;
    overflow-y: auto; /* Allow scrolling on the modal container for overflow */
    /* Animation properties */
    opacity: 0;
    visibility: hidden; /* Use visibility to toggle presence */
    transition: visibility 0s linear 0.3s; /* Hide after transitions are done */
}

.modal-content {
    background-color: rgba(0, 0, 0, 0.1);
    margin: auto;
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 900px;
    position: relative;
    color: var(--text-color);
    /* Animation properties */
    opacity: 0; /* Content starts transparent */
    transform: scale(0.95);
    backdrop-filter: blur(0px); /* Start with no blur */
    transition: transform 0.3s ease, opacity 0.3s ease, backdrop-filter 0s linear 0.3s; /* Delay blur removal on close */
    max-height: 90vh;
    overflow-y: auto; /* Allow vertical scrolling if content overflows */
}

.modal.active {
    opacity: 1;
    visibility: visible; /* Show instantly */
    transition: visibility 0s linear; /* Appear instantly */
}

.modal.active .modal-content {
    opacity: 1; /* Fade in the content */
    transform: scale(1);
    backdrop-filter: blur(2px); /* Apply blur instantly */
    transition: transform 0.3s ease, opacity 0.3s ease, backdrop-filter 0s; /* No delay on open */
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 20px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    transition: color 0.2s ease-in-out;
    padding: 10px; /* Increase clickable area */
    line-height: 0; /* Prevents extra vertical space */
    transform: translate(50%, -50%); /* Center the icon within the padded area */
}

.close-button:hover,
.close-button:focus {
    color: var(--text-color);
    text-decoration: none;
    cursor: pointer;
}

.modal-title {
    font-size: 2rem;
    font-weight: 400;
    letter-spacing: 4px;
    text-align: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    position: relative;
}

.modal-title::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 80px;
    height: 1px;
    background-color: var(--line-color);
}

.projects-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
}

.project img {
    width: 100%;
    border-radius: 5px;
    margin-bottom: 1rem;
    border: 1px solid #333;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.project a:hover img {
    transform: scale(1.02);
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.4);
}

.project-title {
    font-size: 1.2rem;
    font-weight: 500;
    letter-spacing: 1px;
    margin-bottom: 0.5rem;
}

.project-title a {
    color: var(--text-color);
    text-decoration: none;
    transition: color 0.2s ease;
}

.project-title a:hover {
    color: var(--line-color);
}

.project-description {
    font-size: 0.9rem;
    font-weight: 300;
    line-height: 1.6;
    color: #ccc;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .name {
        font-size: 2rem;
        letter-spacing: 4px;
        margin-bottom: 1rem;
        padding-bottom: 1rem;
    }

    .name::after {
        width: 80px;
    }

    .skills {
        font-size: 1rem;
        letter-spacing: 1.5px;
        margin-bottom: 2rem;
    }

    .contact-link a {
        font-size: 1rem;
    }

    .modal-content {
        width: 95%;
        padding: 20px;
    }

    .projects-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .name {
        font-size: 1.8rem;
        letter-spacing: 3px;
    }

    .name::after {
        width: 60px;
    }

    .skills {
        font-size: 0.9rem;
        letter-spacing: 1px;
    }

    .contact-link a {
        font-size: 0.9rem;
    }
}

/* --- THEME ADDITIONS --- */

/* Theme Switcher Button */
#theme-switcher {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    cursor: pointer;
    z-index: 1000; /* Sit below the modal */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s ease;
    overflow: hidden;
}

#theme-switcher:hover {
    background: rgba(255, 255, 255, 0.2);
}

#theme-switcher svg {
    width: 24px;
    height: 24px;
    fill: var(--text-color);
    position: absolute;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Default Theme (Space) Icon Logic */
.icon-ocean {
    opacity: 0;
    transform: scale(0);
}
.icon-space {
    opacity: 1;
    transform: scale(1);
}

/* Ocean Theme Icon Logic */
body.ocean-theme .icon-space {
    opacity: 0;
    transform: scale(0);
}
body.ocean-theme .icon-ocean {
    opacity: 1;
    transform: scale(1);
}

/* --- Ocean Theme Definitions --- */
body.ocean-theme {
    /* Override colors */
    --link-color: #00aaff;
    --line-color: #00aaff;
    --faded-color: #3d5f7a;

    /* Override status colors for the Ocean theme */
    --success-color: #48d1cc; /* MediumTurquoise, fits the vibrant blue */
    --error-color: #ff7f50;   /* Coral, for a warmer contrast */
    
    /* Override background to look like underwater light */
    background-image:
        radial-gradient(ellipse at 10% 90%, rgba(20, 100, 200, 0.4), transparent 70%),
        radial-gradient(ellipse at 80% 20%, rgba(0, 150, 180, 0.3), transparent 70%);
}

/* --- Contact Form Styles --- */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    text-align: left;
}

.form-group-poohbear {
    opacity: 0;
    position: absolute;
    top: 0;
    left: 0;
    height: 0;
    width: 0;
    z-index: -1;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 0.5rem;
    font-weight: 300;
    letter-spacing: 1px;
    color: #ccc;
}

.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
    background-color: rgba(255, 255, 255, 0.05);
    border: 1px solid #444;
    border-radius: 5px;
    padding: 12px;
    font-family: var(--font-primary);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

.contact-form input[type="text"]:focus,
.contact-form input[type="email"]:focus,
.contact-form textarea:focus {
    outline: none;
    border-color: var(--line-color);
    background-color: rgba(0, 0, 0, 0.1);
}

.contact-form textarea {
    resize: vertical;
}

.submit-btn {
    padding: 12px 20px;
    background-color: transparent;
    border: 1px solid var(--line-color);
    color: var(--line-color);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 400;
    letter-spacing: 2px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease, color 0.3s ease;
    margin-top: 1rem;
    display: flex; /* Use flexbox for alignment */
    align-items: center;
    justify-content: center;
}

.submit-btn:hover {
    background-color: var(--line-color);
    color: var(--bg-color);
}

.submit-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}


/* --- Form Message Styles --- */
.form-messages {
    padding: 15px;
    margin-bottom: 1.5rem;
    border-radius: 5px;
    text-align: center;
    font-weight: 400;
    display: none; /* Hidden by default */
}

.form-messages.success {
    background-color: rgba(var(--success-color-rgb), 0.15);
    border: 1px solid var(--success-color);
    color: var(--success-color);
}

.form-messages.error {
    background-color: rgba(var(--error-color-rgb), 0.15);
    border: 1px solid var(--error-color);
    color: var(--error-color);
}

/* --- Spinner for Submit Button --- */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.spinner {
    display: none; /* Hidden by default */
    width: 18px;
    height: 18px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin .75s linear infinite;
}

.submit-btn.loading .spinner {
    display: inline-block;
}