@import url('https://fonts.googleapis.com/css2?family=Ubuntu+Mono:wght@400;700&display=swap');

/* CSS Variables for a consistent theme */
:root {
    --primary-color: #4E9A06; /* A darker teal for contrast */
    --secondary-color: #66ad4c; /* A brighter teal for links */
    --background-color: #f4f4f4; /* Light gray background */
    --surface-color: #ffffff; /* White for surfaces */
    --text-color: #333333; /* Dark gray text */
    --border-radius: 0; /* Square corners */
    --shadow: none; /* No shadows for a flat look */
}

html.dark {
    --primary-color: #4E9A06; /* Terminal Green */
    --secondary-color: #66ad4c; /* A calm blue for links */
    --background-color: #1e1e1e; /* Dark background */
    --surface-color: #2d2d2d; /* Slightly lighter dark for surfaces */
    --text-color: #d4d4d4; /* Light gray text */
}


html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Ubuntu Mono', monospace;
    color: var(--text-color);
    background-color: var(--background-color);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 0;
}

header {
    background-color: var(--surface-color);
    box-shadow: var(--shadow);
    border-bottom: 1px solid var(--primary-color);
    padding: 1rem 5%; /* Use percentage for responsive padding */
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

h1, h2, h3, h4 {
    font-family: 'Ubuntu Mono', monospace;
    color: var(--primary-color);
    margin-top: 0;
}

h1 {
    font-size: 1.8rem;
    margin: 0;
}

h2 {
    font-size: 2.2rem;
    border-bottom: 1px solid var(--primary-color);
    padding-bottom: 0.5rem;
    margin-bottom: 2rem;
}

h3 {
    font-size: 1.5rem;
    margin-top: 2.5rem;
    margin-bottom: 1.5rem;
}

h4 {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 2rem;
}

nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 700;
    transition: color 0.3s ease;
}

nav a:hover, nav a:focus, nav a.active {
    color: var(--secondary-color);
}

main {
    flex: 1;
}

footer {
    background-color: var(--surface-color);
    color: var(--primary-color);
    text-align: center;
    padding: 1.5rem 0;
    margin-top: auto;
}

/* --- Home Page Specific Styles --- */
#hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2rem;
    flex-wrap: wrap;
    padding: 2rem 0;
}
.hero-image {
    flex: 1;
    min-width: 250px; /* Give it a minimum width */
    max-width: 300px; /* And a maximum width */
    height: auto;
    border-radius: var(--border-radius);
    object-fit: cover;
    border: 2px solid var(--primary-color);
    box-shadow: var(--shadow);
}

.hero-text {
    flex: 1;
    min-width: 30%;
}

.hero-text h2 {
    font-size: 2.5rem;
    border-bottom: none;
    margin-bottom: 1rem;
    display: inline-block;
}

/* Blinking cursor effect for the hero title */
.hero-text h2::after {
    content: '_';
    animation: blink 1s step-end infinite;
    font-weight: 700;
}

@keyframes blink {
    from, to {
        color: transparent;
    }
    50% {
        color: var(--primary-color);
    }
}

.hero-text p {
    font-size: 1.1rem;
    margin-bottom: 2rem;
}

.cta-button {
    display: inline-block;
    background-color: var(--primary-color);
    color: var(--surface-color);
    padding: 0.8rem 1.5rem;
    text-decoration: none;
    border-radius: var(--border-radius);
    font-weight: 700;
    border: 1px solid var(--primary-color);
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.cta-button:hover {
    background-color: var(--surface-color);
    color: var(--primary-color);
    transform: translateY(-2px);
}


/* --- About Page Specific Styles --- */

#about-me {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.about-container {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap; /* Allows items to wrap on smaller screens */
}

.profile-picture {
    width: 150px;
    height: 150px;
    border-radius: var(--border-radius);
    object-fit: cover;
    border: 2px solid var(--primary-color);
}

.about-text {
    flex: 1; /* Allows the text to take up remaining space */
    min-width: 300px; /* Prevents text from getting too squished */
}

.skills-grid {
    display: flex;
    gap: 1.5rem;
    justify-content: space-between;
    flex-wrap: wrap;
}

.skill-category {
    background-color: var(--background-color);
    padding: 1.5rem;
    border-radius: var(--border-radius);
    flex: 1;
    min-width: 200px; /* Ensures categories don't get too narrow */
}

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

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

#about-me article {
    border-left: 2px solid var(--primary-color);
    padding-left: 1.5rem;
    margin-bottom: 2rem;
}

#about-me article p {
    margin: 0 0 1rem 0;
}

/* --- Work Page Specific Styles --- */

#work {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

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

.project-card {
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: transform 0.3s ease;
}

.project-card:hover {
    transform: translateY(-5px);
}

.project-iframe {
    display: block; /* Treat the iframe as a block element */
    margin: 0 auto; /* Apply automatic left and right margins */
    max-width: 100%; /* Ensure the iframe is responsive */
    border: none; /* Remove the default border */
    margin-bottom: 18px;
}

.project-image-gallery {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap; /* Allows images to stack on smaller screens */
}

.project-image {
    width: 100%;
    border-radius: var(--border-radius);
    object-fit: cover;
}

.project-description {
    margin-top: 1rem;
    color: var(--text-color);
}

.project-link {
    display: inline-block;
    text-decoration: underline;
    color: var(--text-color);
    font-weight: 700;
    transition: color 0.3s ease;
}

.project-link:hover {
    color: var(--primary-color);
}

/* --- 404 Page Specific Styles --- */
.error-code {
    font-size: 10rem;
    font-weight: 700;
    color: var(--secondary-color);
    opacity: 0.5;
    margin-bottom: 0;
}

/* --- Contact Page Specific Styles --- */

#contact {
    background-color: var(--surface-color);
    padding: 2rem;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.contact-form label {
    font-weight: 700;
    color: var(--primary-color);
}

.contact-form input, .contact-form textarea {
    font-family: 'Ubuntu Mono', monospace;
    padding: 1rem;
    border: 1px solid var(--primary-color);
    border-radius: var(--border-radius);
    width: 100%;
    background-color: var(--background-color);
    box-sizing: border-box; /* Ensures padding doesn't add to the width */
    color: var(--text-color);
    max-width: 600px;
}

.contact-form button {
    padding: 1rem;
    background-color: var(--primary-color);
    color: var(--surface-color);
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.contact-form button:hover {
    background-color: var(--surface-color);
    color: var(--primary-color);
}


/* --- General Utility Classes --- */

.text-center {
    text-align: center;
}

.mb-1 {
    margin-bottom: 1rem;
}

.mb-2 {
    margin-bottom: 2rem;
}

.mt-2 {
    margin-top: 2rem;
}

.pt-2 {
    padding-top: 2rem;
}

.pb-2 {
    padding-bottom: 2rem;
}

.flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.align-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.gap-1 {
    gap: 1rem;
}

.gap-2 {
    gap: 2rem;
}

.rounded {
    border-radius: var(--border-radius);
}

.shadow {
    box-shadow: var(--shadow);
}

/* --- Theme Switcher --- */
.theme-switch-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-switch {
    position: relative;
    display: flex;
    width: 50px;
    height: 24px;
}

.theme-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--background-color);
    border: 1px solid var(--primary-color);
    transition: .4s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: var(--primary-color);
    transition: .4s;
}

input:not(:checked) + .slider {
    background-color: var(--background-color);
}

input:not(:checked) + .slider:before {
    transform: translateX(26px);
}

.slider.round { border-radius: 34px; }
.slider.round:before { border-radius: 50%; }

.theme-switcher {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    color: var(--primary-color);
}

.theme-icon {
    width: 24px;
    height: 24px;
}

/* Icon transition styles */
.sun-and-moon > .sun {
    transform-origin: center center;
    transition: transform 0.5s cubic-bezier(0.5, 1.5, 0.5, 1.5);
}

.sun-and-moon > .moon {
    transform-origin: center center;
    transition: transform 0.5s cubic-bezier(0.5, 1.5, 0.5, 1.5);
    fill: var(--primary-color);
}

html:not(.dark) .sun-and-moon > .sun {
    transform: scale(1.75);
}

html:not(.dark) .sun-and-moon > .moon {
    transform: scale(0);
    fill: transparent;
}

html.dark .sun-and-moon > .sun {
    transform: rotate(360deg) scale(0);
}

html.dark .sun-and-moon > .moon {
    transform: rotate(0deg);
}

/* Hide the checkbox visually but keep it accessible */
#checkbox {
    display: none;
}

/* --- Media Queries for Responsiveness --- */

.nav-toggle {
    display: none; /* Hidden by default on larger screens */
    padding: 0.5em;
    background: transparent;
    border: 0;
    cursor: pointer;
    position: absolute;
    right: 1em;
    top: 1.5rem; /* Adjust to vertically center with title */
    z-index: 1000;
}

.hamburger {
    display: block;
    position: relative;
}

.hamburger,
.hamburger::before,
.hamburger::after {
    background: var(--primary-color);
    width: 2em;
    height: 3px;
    border-radius: 1em;
    transition: transform 250ms ease-in-out;
}

.hamburger::before,
.hamburger::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
}

.hamburger::before { top: 6px; }
.hamburger::after { bottom: 6px; }

/* Animate hamburger to X */
.nav-toggle.is-active .hamburger {
    transform: rotate(45deg);
}

.nav-toggle.is-active .hamburger::before {
    transform: rotate(90deg);
    top: 0;
}

.nav-toggle.is-active .hamburger::after {
    opacity: 0;
}

@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .header-content-left {
        display: flex;
        justify-content: space-between;
        width: 100%;
    }

    #hero {
        justify-content: center;
        text-align: center;
    }

    .hero-text h2 {
        font-size: 2rem;
    }

    .nav-toggle {
        display: block;
    }

    nav ul {
        flex-direction: column;
        width: 100%;
        display: none; /* Hide nav links by default on mobile */
        position: absolute;
        background: var(--surface-color);
        left: 0;
        right: 0;
        top: 100%; /* Position below the header */
        box-shadow: var(--shadow);
        border-bottom: 1px solid var(--primary-color);
        text-align: center;
    }

    nav ul.active {
        display: flex; /* Show the nav when it has the .active class */
    }

    nav a {
        padding: 1rem;
        display: block;
        background-color: var(--surface-color);
        border: 1px solid #4E9A06;
    }

    nav li:last-child a {
        border-bottom: none;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.8rem;
    }

    .about-container {
        flex-direction: column;
        align-items: center;
    }

    .profile-picture {
        width: 120px;
        height: 120px;
    }

    .skills-grid {
        flex-direction: column;
        align-items: center;
    }

    .skill-category {
        width: 100%;
        box-sizing: border-box; /* Ensures padding is included in the width */
    }

    #work .project-card {
        flex-direction: column;
    }

    #work .project-image {
        height: 200px;
        object-fit: cover;
    }

    .project-image-gallery .project-image {
        flex-basis: 100%; /* Make each image take full width on smaller screens */
        width: 100%;
    }

    #contact .contact-form {
        width: 100%;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.2rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.2rem;
    }

    nav ul {
        flex-direction: column;
        gap: 1rem;
    }

    .about-container {
        flex-direction: column;
        align-items: center;
    }

    .profile-picture {
        width: 100px;
        height: 100px;
    }

    .skills-grid {
        flex-direction: column;
        align-items: center;
    }

    .skill-category {
        width: 100%;
        box-sizing: border-box; /* Ensures padding is included in the width */
    }

    #work .project-card {
        flex-direction: column;
    }

    #work .project-image {
        height: 150px;
        object-fit: cover;
    }

    .project-image-gallery .project-image {
        flex-basis: 100%; /* Ensure stacking on very small screens too */
        width: 100%;
    }

    #contact .contact-form input,
    #contact .contact-form textarea {
        font-size: 0.9rem;
    }

    #contact .contact-form button {
        font-size: 0.9rem;
    }
}

@media (max-width: 768px) {
    #hero {
        flex-direction: column; /* Stack items vertically */
        text-align: center;    /* Center-align the text for a better mobile look */
    }

    .hero-image {
        margin-top: 2rem; /* Add some space between the text and the image */
    }
}