@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;700&family=Merriweather:ital,wght@0,400;0,700;1,400&display=swap');

:root {
    --primary-color: #2E7D32;
    /* Mate Green */
    --accent-color: #C5A059;
    /* Mate Gold/Straw */
    --bg-color: #FDFCFB;
    /* Warm bone white */
    --text-color: #2C3E50;
    --heading-color: #1A252F;
    --sidebar-bg: rgba(255, 255, 255, 0.9);
    --sidebar-width: 300px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #121212;
        --text-color: #E0E0E0;
        --heading-color: #FFFFFF;
        --sidebar-bg: rgba(30, 30, 30, 0.95);
        --shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    background-color: var(--bg-color);
}

body {
    font-family: 'Merriweather', serif;
    line-height: 1.8;
    color: var(--text-color);
}

/* --- SIDEBAR (Fixed) --- */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    border-right: 1px solid rgba(0, 0, 0, 0.05);
    position: fixed;
    overflow-y: auto;
    padding: 2rem;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

@media (prefers-color-scheme: dark) {
    #sidebar {
        border-right: 1px solid rgba(255, 255, 255, 0.05);
    }
}

#sidebar h2 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 2rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

#sidebar ul {
    list-style: none;
    padding: 0;
}

#sidebar ul li {
    margin-bottom: 0.8rem;
}

#sidebar ul li a {
    text-decoration: none;
    color: var(--text-color);
    font-family: 'Montserrat', sans-serif;
    font-size: 0.9rem;
    font-weight: 400;
    display: block;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    transition: var(--transition);
}

#sidebar ul li a:hover {
    background: rgba(46, 125, 50, 0.1);
    color: var(--primary-color);
}

/* --- MAIN LAYOUT --- */
#content {
    margin-left: var(--sidebar-width);
    padding: 4rem 2rem;
    min-height: 100vh;
}

.chapter-web {
    max-width: 800px;
    margin: 0 auto 4rem auto;
    background: white;
    padding: 3rem;
    border-radius: 24px;
    box-shadow: var(--shadow);
    overflow-wrap: break-word;
}

@media (prefers-color-scheme: dark) {
    .chapter-web {
        background: #1E1E1E;
    }
}

/* Typography & Images */
h1,
h2,
h3,
h4 {
    font-family: 'Montserrat', sans-serif;
    color: var(--heading-color);
    font-weight: 700;
}

h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-top: 0;
}

h2 {
    font-size: 1.8rem;
    border-left: 5px solid var(--accent-color);
    padding-left: 15px;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 2rem auto;
    border-radius: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

blockquote {
    border-left: 4px solid var(--accent-color);
    background: rgba(197, 160, 89, 0.05);
    padding: 1.5rem 2rem;
    margin: 2rem 0;
    font-style: italic;
    border-radius: 0 12px 12px 0;
}

pre,
code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

pre {
    padding: 1.5rem;
    overflow-x: auto;
    border-radius: 12px;
}

/* --- MOBILE RESPONSIVE (Breakpoint 1024px) --- */
#menu-toggle {
    display: none;
    position: fixed;
    top: 15px;
    right: 15px;
    /* Moved to right for better thumb access */
    z-index: 2000;
    background: var(--primary-color);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

@media (max-width: 1024px) {
    #sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    #sidebar.active {
        transform: translateX(0);
    }

    #content {
        margin-left: 0;
        padding: 5rem 1rem 2rem 1rem;
    }

    .chapter-web {
        padding: 2rem 1.5rem;
        border-radius: 16px;
    }

    #menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        backdrop-filter: blur(2px);
    }

    #sidebar.active+.sidebar-overlay {
        display: block;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
    }

    .chapter-web {
        padding: 1.5rem 1rem;
    }
}