/* --- THEME VARIABLES --- */
:root {
    --bg-color: #ffffff;
    --text-main: #222222;
    --text-muted: #888888;
    --text-light: #b0b0b0;
    --header-bg: rgba(255, 255, 255, 0.8);
    --border-color: rgba(0, 0, 0, 0.167); /* <--- Add this line */
    --font-main: "Helvetica Neue", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}

body.dark-mode {
    --bg-color: #121212;
    --text-main: #ffffff;
    --text-muted: #a0a0a0;
    --text-light: #777777;
    --header-bg: rgba(18, 18, 18, 0.85);
    --border-color: rgba(255, 255, 255, 0.15); /* <--- Add this line (white semi-transparent) */
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-main);
    line-height: 1.8;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    max-width: 680px;
    margin: 0 auto;
    padding: 8rem 2rem;
    transition: background-color 0.4s ease, color 0.4s ease; /* ADD THIS LINE */
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes expandStick {
    from {
        width: 0;
        left: 50%;
    }
    to {
        width: 100%;
        left: 0;
    }
}

.fade-in {
    animation: fadeIn 0.9s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    opacity: 0;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6rem;
    flex-wrap: wrap;
    gap: 2rem;
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 1rem;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 0 0 12px 12px;
    
    /* The Glassmorphism */
    background-color: var(--header-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: background-color 0.4s ease;
}

/* --- LOGO & NAV LAYOUT RESTORATION --- */
.logo-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo-group img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    image-rendering: -webkit-optimize-contrast;
}

.logo-text-group {
    display: flex;
    flex-direction: column;
}

.logo {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.alias {
    font-size: 0.85rem;
    color: var(--text-muted);
}

nav {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    align-items: center;
}

/* Ensure the link can anchor the underline */
nav a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative; /* Crucial for the underline positioning */
}

/* Color change when hovering or active */
nav a:hover, 
nav a.active { 
    color: var(--text-main); 
}

/* The expanding underline for the active link */
nav a.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    height: 2px;
    background-color: var(--text-main);
    animation: expandStick 0.5s ease forwards;
}

/* The animation that makes it grow from the center */
@keyframes expandStick {
    from {
        width: 0;
        left: 50%;
    }
    to {
        width: 100%;
        left: 0;
    }
}

h2 {
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 4rem;
}

ul { list-style-type: none; }

footer {
    margin-top: 8rem;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-color); /* <--- Updated */
    padding-top: 1.5rem;
    transition: border-color 0.4s ease; /* <--- Makes it fade nicely */
}

footer a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
    transition: color 0.3s ease;
}

/* 1. Define the header variables */
:root {
    --header-bg: rgba(255, 255, 255, 0.8); /* Light mode frosted glass */
    --header-text: #000000;
}

body.dark-mode {
    --header-bg: rgba(20, 20, 20, 0.8); /* Dark mode frosted glass */
    --header-text: #ffffff;
}


/* 3. Ensure the nav links inside the header flip colors too */
header nav a {
    color: var(--header-text);
    transition: color 0.5s ease;
}

footer a:hover { color: var(--text-main); }

@media (max-width: 600px) {
    body { padding: 4rem 1.5rem; }
    header { flex-direction: column; gap: 1.5rem; }
}

/* --- MOBILE OPTIMIZATION --- */

/* This media query kicks in ONLY when the screen width is 600px or smaller */
@media (max-width: 600px) {
    @media (max-width: 600px) {
    body {
        /* Increase the 1.2rem to 1.5rem or 2rem for more breathing room */
        padding: 3rem 1.5rem; 
    }
    
    /* Ensure the main content doesn't force a horizontal scroll */
    main {
        padding: 0 0.5rem;
        box-sizing: border-box;
    }
}

    header {
        /* Turn the horizontal layout into a clean vertical column stack */
        flex-direction: column; 
        gap: 1.2rem;
        align-items: center;
        text-align: center;
        padding: 1.2rem 1rem;
        margin-bottom: 3.5rem; /* Pull the main content up a bit higher */
    }

nav {
        gap: 0.8rem; /* Shrank from 1.2rem to make sure everything fits on one line */
        justify-content: center;
        width: 100%;
    }

    nav a {
        font-size: 0.85rem; /* Slightly smaller text for mobile fingers */
    }
    /* --- MOBILE PROJECTS STYLING --- */
    main ul {
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        align-items: flex-start; /* Centers the project list items */
    }

    main li {
        align-items: flex-start; /* Centers the items inside each project row */
        text-align: left;
        width: 100%;
        margin-bottom: 4rem; /* More breathing room between projects */
    }

    .item-image {
        width: 64px; /* Make the project icons slightly bigger and easier to see on mobile */
        height: 64px;
        margin-bottom: 0.5rem;
    }
    /* --- HOME & GENERAL LAYOUT FIXES --- */
    main {
        padding: 0 0.5rem; /* Prevents text from clipping on screen edges */
        width: 100%;
        box-sizing: border-box;
    }

    p {
        font-size: 1rem;
        line-height: 1.6;
        word-wrap: break-word; /* Ensures long text wraps cleanly */
    }

    /* --- BOOKSHELF MOBILE LAYOUT --- */
    .bookshelf-grid, .books-list { 
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .book-item {
        flex-direction: column !important; /* Stack cover image above the title text */
        text-align: center;
        gap: 1rem;
        margin-bottom: 3rem;
    }

    .book-info {
        align-items: center;
        text-align: center;
    }

    /* --- GAMING PAGE LAYOUT --- */
    .gaming-container {
        flex-direction: column !important;
        align-items: center;
        gap: 2rem;
    }

/* --- FOOTER & SOCIAL LINKS --- */
    footer, .social-links-container {
        display: flex;
        flex-direction: row; /* Forces them back into a line */
        flex-wrap: wrap;     /* Allows them to wrap gracefully if the screen is tiny */
        justify-content: center;
        align-items: center;
        gap: 1.5rem;
        margin-top: 4rem;
        padding-bottom: 2rem;
    }
}