:root {
    /* Default Theme (Dark/Teal) */
    --primary-color: #009688;
    --secondary-color: #004d40;
    --background-color: #121212;
    --surface-color: rgba(255, 255, 255, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #b0b0b0;
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 4px 30px rgba(0, 0, 0, 0.5);
    --nav-bg: rgba(18, 18, 18, 0.8);
    --card-bg: rgba(30, 30, 30, 0.6);
    --card-hover: rgba(255, 255, 255, 0.1);
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Roboto', sans-serif;
}

/* Light Theme */
[data-theme="light"] {
    --primary-color: #00796b;
    --secondary-color: #b2dfdb;
    --background-color: #f5f5f5;
    --surface-color: rgba(255, 255, 255, 0.7);
    --text-primary: #212121;
    --text-secondary: #5f6368;
    --glass-border: rgba(0, 0, 0, 0.05);
    --glass-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --nav-bg: rgba(245, 245, 245, 0.8);
    --card-bg: rgba(255, 255, 255, 0.6);
    --card-hover: rgba(255, 255, 255, 0.9);
}

/* Warm Theme */
[data-theme="warm"] {
    --primary-color: #bf360c;
    --secondary-color: #ffccbc;
    --background-color: #faf3e0;
    --surface-color: rgba(255, 248, 225, 0.6);
    --text-primary: #3e2723;
    --text-secondary: #5d4037;
    --glass-border: rgba(62, 39, 35, 0.05);
    --glass-shadow: 0 4px 20px rgba(62, 39, 35, 0.1);
    --nav-bg: rgba(250, 243, 224, 0.8);
    --card-bg: rgba(255, 248, 225, 0.6);
    --card-hover: rgba(255, 248, 225, 0.9);
}

/* Neon Theme */
[data-theme="neon"] {
    --primary-color: #ff007f;
    --secondary-color: #00f0ff;
    --background-color: #050505;
    --surface-color: rgba(255, 0, 127, 0.05);
    --text-primary: #ffffff;
    --text-secondary: #00f0ff;
    --glass-border: rgba(0, 240, 255, 0.2);
    --glass-shadow: 0 4px 30px rgba(255, 0, 127, 0.3);
    --nav-bg: rgba(5, 5, 5, 0.85);
    --card-bg: rgba(15, 15, 15, 0.8);
    --card-hover: rgba(255, 0, 127, 0.1);
}

/* Cyberpunk Theme */
[data-theme="cyberpunk"] {
    --primary-color: #fcee0a;
    --secondary-color: #b026ff;
    --background-color: #0d0221;
    --surface-color: rgba(252, 238, 10, 0.05);
    --text-primary: #e0e0e0;
    --text-secondary: #fcee0a;
    --glass-border: rgba(176, 38, 255, 0.3);
    --glass-shadow: 0 4px 30px rgba(252, 238, 10, 0.15);
    --nav-bg: rgba(13, 2, 33, 0.9);
    --card-bg: rgba(26, 4, 66, 0.7);
    --card-hover: rgba(176, 38, 255, 0.15);
}

/* Blood Theme */
[data-theme="blood"] {
    --primary-color: #ff0000;
    --secondary-color: #8b0000;
    --background-color: #0a0000;
    --surface-color: rgba(255, 0, 0, 0.05);
    --text-primary: #ffe6e6;
    --text-secondary: #ff6666;
    --glass-border: rgba(255, 0, 0, 0.2);
    --glass-shadow: 0 4px 30px rgba(139, 0, 0, 0.4);
    --nav-bg: rgba(10, 0, 0, 0.9);
    --card-bg: rgba(20, 0, 0, 0.8);
    --card-hover: rgba(255, 0, 0, 0.1);
}

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

body {
    font-family: var(--font-body);
    background-color: var(--background-color);
    background-image:
        radial-gradient(circle at 10% 20%, var(--surface-color) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, var(--surface-color) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Glassmorphism Utilities */
.glass-nav {
    background: var(--nav-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: var(--glass-border);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: var(--glass-border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease, border-color 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px 0 rgba(0, 0, 0, 0.5);
    /* Keep shadow dark even in light mode for depth? Or use var? */
    border-color: var(--primary-color);
}

.glass-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--surface-color);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: var(--glass-border);
    border-radius: 50px;
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    cursor: pointer;

    /* Ensure clickability */
    position: relative;
    z-index: 2000;
}

.glass-btn:hover {
    background: var(--card-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Navbar */
.navbar-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.5rem;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: -0.5px;
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s ease;
}

.nav-toggle:hover {
    color: var(--primary-color);
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s ease;
    position: relative;
}

.nav-link:hover,
.nav-link.active {
    color: var(--primary-color);
}

.nav-link.active::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--primary-color);
    border-radius: 2px;
}

/* Layout */
.main-container {
    max-width: 1200px;
    margin: 2rem auto;
    padding: 0 2rem;
    padding-bottom: 4rem;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 1rem;
    margin-bottom: 2rem;
}

.hero h1 {
    font-family: var(--font-heading);
    font-size: 3.5rem;
    margin-bottom: 1rem;
    color: var(--text-primary);
    /* Removed fixed gradient text to support switching */
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-secondary);
    max-width: 700px;
    margin: 0 auto;
}

.hero-subtitle {
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.9rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: block;
}


/* Modules Grid */
.modules-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.module-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    display: inline-block;
}

.module-content ul {
    list-style: none;
}

.module-content li {
    margin-bottom: 0.5rem;
}

.module-content a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.module-content a:hover {
    color: var(--primary-color);
}

.module-content a::before {
    content: '→';
    color: var(--primary-color);
    opacity: 0;
    transform: translateX(-10px);
    transition: all 0.2s;
}

.module-content a:hover::before {
    opacity: 1;
    transform: translateX(0);
}

/* Footer */
footer {
    text-align: center;
    padding: 3rem 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
    border-top: var(--glass-border);
    margin-top: auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.5rem;
    }

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

    .nav-toggle {
        display: block;
    }

    .navbar-container {
        position: relative; /* Needed for absolute positioning of nav-links */
    }

    .nav-links {
        display: none; /* Hidden by default */
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--nav-bg);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: var(--glass-border);
        padding: 1rem 0;
        gap: 1.5rem;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    }

    .nav-links.show-menu {
        display: flex;
        animation: slideDown 0.3s ease-out forwards;
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Utility */
.text-teal {
    color: var(--primary-color);
}

.mt-4 {
    margin-top: 1rem;
}

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

/* Book Layout Styles */
.book-layout {
    max-width: 750px;
    /* Constrain width for optimal reading line length */
    margin: 3rem auto;
    font-family: 'Merriweather', 'Georgia', serif;
    /* Serif font for body text */
    font-size: 1.125rem;
    /* Slightly larger text */
    line-height: 1.8;
    /* Generous line height */
    color: var(--text-primary);
    text-align: left;
    padding: 2rem 3rem;
    /* Add padding to the "page" */

    /* Paper-like effect within the glassmorphism context */
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: var(--glass-border);
    border-radius: 8px;
    /* Slightly less rounded than cards */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.2);
}

.book-layout h1,
.book-layout h2,
.book-layout h3,
.book-layout h4 {
    font-family: var(--font-heading);
    /* Keep sans-serif for headings */
    color: var(--primary-color);
    margin-top: 2rem;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.book-layout h1 {
    font-size: 2.5rem;
    border-bottom: 2px solid var(--glass-border);
    padding-bottom: 1rem;
    margin-top: 0;
}

.book-layout h2 {
    font-size: 1.75rem;
}

.book-layout h3 {
    font-size: 1.4rem;
}

.book-layout p {
    margin-bottom: 1.5rem;
}

.book-layout ul,
.book-layout ol {
    margin-bottom: 1.5rem;
    padding-left: 1.5rem;
}

.book-layout li {
    margin-bottom: 0.5rem;
}

.book-layout img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 1.5rem auto;
    display: block;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.book-img-left {
    float: left;
    margin: 0.5rem 1.5rem 0.5rem 0 !important;
    max-width: 45% !important;
}

.book-img-right {
    float: right;
    margin: 0.5rem 0 0.5rem 1.5rem !important;
    max-width: 45% !important;
}

/* Clearfix for floated images */
.book-layout::after {
    content: "";
    display: table;
    clear: both;
}

/* Mobile cleanup for floats */
@media (max-width: 600px) {

    .book-img-left,
    .book-img-right {
        float: none;
        margin: 1rem auto !important;
        max-width: 100% !important;
        display: block;
    }
}

.book-layout blockquote {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
    margin-left: 0;
    margin-right: 0;
    font-style: italic;
    color: var(--text-secondary);
    background: rgba(var(--primary-color), 0.1);
    /* Subtle background if needed, currently CSS vars don't support rgba manipulation easily without calc, skipping bg for now */
}

/* Responsive Book Layout */
@media (max-width: 768px) {
    .book-layout {
        padding: 1.5rem;
        margin: 1rem auto;
        font-size: 1rem;
    }
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s ease-in forwards;
}

.slide-in {
    animation: slideIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}