/* GLOBAL RESETS AND TYPOGRAPHY (DEFAULT: LIGHT MODE / GREEN) */
:root {
    --primary-color: #4CAF50; /* Light Green Accent */
    --secondary-color: #388E3C; /* Dark Green for gradients */
    --background-color: #f4f7f6; /* Light Background */
    --card-background: #ffffff; /* White cards */
    --text-color: #333; /* Dark text */
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* DARK MODE OVERRIDES (Purple/Grey Theme) */
.dark-mode {
    --primary-color: #BB86FC; /* Vibrant purple */
    --secondary-color: #CF66FF; /* Lighter purple/pink */
    --background-color: #1e1e1e; /* Dark Grey Background */
    --card-background: #2c2c2c; /* Cards */
    --text-color: #f0f0f0; /* Light text color */
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

/* Base Body Styles */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Poppins', sans-serif;
    /* Use variables for colors */
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s; /* Smooth transition when toggling */
}

/* HEADER AND NAVIGATION */
header {
    background-color: var(--card-background);
    box-shadow: var(--shadow);
    padding: 15px 5%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s;
}

/* NEW UTILITY GROUP STYLING */
.utility-group {
    display: flex;
    align-items: center;
    gap: 15px; /* Spacing between the Study Room link and the toggle button */
}

.logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    /* Removed padding/border to let the button styling handle it. */
    padding: 8px 15px; 
    border-radius: 5px;
    transition: background-color 0.3s, color 0.3s;
}

.nav-link:hover {
    background-color: var(--primary-color);
    color: var(--card-background); /* Use card background for contrast text */
}

/* MODE TOGGLE BUTTON STYLING */
#mode-toggle {
    background-color: var(--primary-color);
    color: var(--card-background); /* Ensures contrast */
    border: none;
    padding: 10px 15px;
    border-radius: 5px;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s, transform 0.1s;
}

#mode-toggle:hover {
    opacity: 0.9;
}


/* MAIN CONTENT LAYOUT */
main {
    padding: 20px 5%;
    max-width: 1200px; 
    margin: 0 auto;
}

/* HERO SECTION (Uses the gradient) */
.hero {
    /* Uses the current theme's primary and secondary colors for the gradient */
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: #fff; /* White text on hero for max readability */
    padding: 40px;
    margin-bottom: 30px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.2);
}

.dark-mode .hero {
    color: #1e1e1e; /* Dark text on purple gradient for dark mode */
}
.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.hero p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* GAMES LIST STYLING */
.games-list h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

/* Category Grouping Style */
.game-category {
    margin-bottom: 35px; 
    padding: 15px 0;
    border-bottom: 2px solid var(--text-color, 0.1); 
}
.dark-mode .game-category {
    border-bottom: 2px solid #3a3a3a; /* Dark mode specific border */
}

.featured-games-section {
    padding-top: 5px; 
    margin-top: -10px; 
}

.game-category:last-child {
    border-bottom: none; 
}

.game-category h3 {
    font-size: 1.4rem;
    color: var(--text-color);
    margin-bottom: 15px;
    border-left: 4px solid var(--primary-color); 
    padding-left: 10px;
    font-weight: 600;
}

/* Grid for Tiles within a Category */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
}

.game-tile {
    background-color: var(--card-background);
    padding: 20px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    text-align: center;
    box-shadow: var(--shadow);
    transition: transform 0.3s, box-shadow 0.3s, background-color 0.3s;
    overflow: hidden; 
    white-space: nowrap;
    text-overflow: ellipsis;
}

.game-tile:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
    background-color: var(--primary-color);
    color: var(--background-color);
}
/* Ensure hover colors look good in dark mode */
.dark-mode .game-tile:hover {
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
    background-color: var(--primary-color);
    color: var(--background-color);
}


/* MISCELLANEOUS LINKS */
.misc-links {
    text-align: center;
    margin-bottom: 40px;
}

.misc-links h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
    font-weight: 600;
}

.misc-flex-container {
    display: flex;
    flex-wrap: wrap; 
    justify-content: center;
    gap: 15px;
}

.misc-item {
    flex: 1 1 auto; 
    min-width: 200px;
    background-color: var(--card-background);
    padding: 15px 25px;
    border: 2px solid var(--primary-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--primary-color);
    font-weight: 600;
    transition: background-color 0.3s, color 0.3s;
}

.misc-item:hover {
    background-color: var(--primary-color);
    color: var(--card-background);
}

/* Email link special color (orange for contrast) */
.email-link {
    border-color: #FFB74D;
    color: #FFB74D;
}
.email-link:hover {
    background-color: #FFB74D;
    color: #fff;
}
.dark-mode .email-link:hover {
    color: var(--background-color);
}


/* FOOTER */
footer {
    text-align: center;
    padding: 15px;
    background-color: #333; /* Darker footer base color */
    color: #ccc;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}
.dark-mode footer {
    background-color: #121212; /* Even darker footer in dark mode */
}

/* RESPONSIVENESS (Media Queries) */
@media (min-width: 768px) {
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    }
}
@media (min-width: 1024px) {
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
    .hero h1 {
        font-size: 3rem;
    }
}
@media (max-width: 600px) {
    /* Adjust header for small screens */
    header {
        flex-direction: column;
        align-items: flex-start; /* Align logo to the left */
        gap: 10px;
    }
    .utility-group {
        width: 100%; /* Make group full width */
        justify-content: space-around; /* Distribute items evenly */
    }
    .hero {
        padding: 30px 20px;
    }
    .hero h1 {
        font-size: 2rem;
    }
    .grid-container {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    .misc-flex-container {
        flex-direction: column;
        align-items: stretch;
    }
    .misc-item {
        min-width: unset;
    }
}
