/*
==============================================
--- Single Lesson Page Styles ---
==============================================
*/

/* --- Main Layout Grid --- */
.m-lesson-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 2rem;
}

/* --- Main Content Container --- */
.m-lesson-container {
    /* max-width: 800px; */
    /* background-color: var(--card-background); */
    /* padding: 2.5rem; */
    /* border-radius: var(--border-radius); */
    /* border: 1px solid var(--border-color); */
    grid-column: 1 / -1; 
}

.m-lesson-breadcrumb {
    margin-bottom: 1.5rem;
}

.m-lesson-breadcrumb a {
    text-decoration: none;
    color: var(--primary-purple);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.m-lesson-breadcrumb a:hover {
    text-decoration: underline;
}

.m-lesson-container h1 {
    margin-bottom: 1.5rem;
    font-size: clamp(1.8rem, 5vw, 2.25rem); /* Responsive font size */
}

/*
==============================================
--- Mobile Nav & Sidebars ---
==============================================
*/

/* The container for the 'Menu' and 'On this page' buttons */
.mobile-nav-bar {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
}

.mobile-nav-toggle {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.2s ease;
}

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

.mobile-nav-toggle i {
    transition: transform 0.3s ease;
}

.mobile-sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 150;
}

.mobile-sidebar-backdrop.is-active {
    display: block;
}

body.sidebar-open {
    overflow: hidden;
}

/* --- Mobile TOC Dropdown --- */
.mobile-toc-container {
    /* Hidden by default */
    max-height: 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
    margin-bottom: 1.5rem;
}

.mobile-toc-container.is-open {
    max-height: 500px; /* Or a sufficiently large value */
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mobile-toc-container .m-lesson-toc {
    background-color: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}


/*
==============================================
--- Responsive Layouts & Sidebars ---
==============================================
*/

/* --- Default Mobile Layout --- */
.m-lesson-sidebar-desktop {
    display: none;
}

.course-lesson-sidebar {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 300px;
    background-color: var(--card-background);
    z-index: 200;
    transition: transform 0.3s ease-in-out;
    padding: 2rem;
    overflow-y: auto;
    transform: translateX(-100%); /* Start off-screen */
}

.course-lesson-sidebar.is-open {
    transform: translateX(0); /* Slide in */
}


/* --- Tablet and Medium Screens (TOC appears) --- */
@media (min-width: 992px) {
    .mobile-nav-bar, .mobile-toc-container {
        display: none; /* Hide all mobile nav elements */
    }

    .m-lesson-grid {
        grid-template-columns: 1fr 250px; 
    }
    .m-lesson-container {
        grid-column: 1 / 2;
    }
    
    .course-lesson-sidebar {
        /* Reset sidebar for desktop view */
        display: none; /* Still hidden until large screens */
        position: static;
        transform: none;
        /* padding: 0; */
        padding-top: 0;
        background-color: transparent;
        border: none;
        height: auto;
        overflow-y: visible;
    }

    .m-lesson-sidebar-desktop {
        display: block;
        position: sticky;
        top: 100px;
        align-self: start;
        grid-column: 2 / 3;
    }
    .m-lesson-sidebar-desktop .m-lesson-toc {
        max-height: none;
        background-color: transparent;
        border: none;
        padding: 0;
        padding-left: 1.5rem;
        border-left: 2px solid var(--border-color);
    }
}

/* --- Large Desktop Screens (Lesson Sidebar appears) --- */
@media (min-width: 1200px) {
    .m-lesson-grid {
        grid-template-columns: 250px 1fr 250px;
        gap: 2.5rem;
    }
    .m-lesson-container {
        grid-column: 2 / 3;
    }
    .course-lesson-sidebar {
        display: block;
        position: sticky;
        top: 100px;
        align-self: start;
        grid-column: 1 / 2;
    }
    .m-lesson-sidebar-desktop {
        grid-column: 3 / 4;
    }
}

/* --- Small Screen Adjustments --- */
@media (max-width: 576px) {
    .m-lesson-container {
        padding: 1.5rem;
    }
}
