/* ===================================================================
   HEARTH LESSON PAGE — Book/Parchment Layout
   Open-book content area with left course navigation sidebar
   =================================================================== */

/* === Page Layout === */
.hearth-lesson-page {
    min-height: 100vh;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
}

/* === Breadcrumb Bar === */
.hearth-breadcrumb {
    background: var(--color-bg-dark);
    padding: 0.75rem 2rem;
    border-bottom: var(--border-ornate);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    min-height: 48px;
}

.hearth-breadcrumb a {
    color: var(--color-secondary-light);
    text-decoration: none;
    font-size: 0.85rem;
    font-family: var(--font-heading);
    transition: color var(--transition-smooth);
}

.hearth-breadcrumb a:hover {
    color: var(--color-secondary);
    text-decoration: underline;
}

.hearth-breadcrumb a:focus-visible {
    outline: 2px solid var(--color-focus);
    outline-offset: 2px;
    border-radius: 2px;
}

.hearth-breadcrumb-sep {
    color: var(--color-accent);
    font-size: 0.75rem;
}

.hearth-breadcrumb-current {
    color: var(--color-secondary);
    font-size: 0.85rem;
    font-family: var(--font-heading);
    font-weight: 700;
}


/* === Main Lesson Grid (Flex layout with sidebar + content) === */
.hearth-lesson-grid {
    display: flex;
    gap: 2rem;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* === Course Navigation Sidebar === */
.hearth-lesson-sidebar {
    width: 280px;
    flex-shrink: 0;
}

.lesson-nav-sidebar {
    background: var(--parchment-bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: var(--shadow-warm);
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
}

/* Scrollbar styling for sidebar */
.lesson-nav-sidebar::-webkit-scrollbar {
    width: 6px;
}
.lesson-nav-sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.lesson-nav-sidebar::-webkit-scrollbar-thumb {
    background: var(--color-accent-light);
    border-radius: 3px;
}
.lesson-nav-sidebar::-webkit-scrollbar-thumb:hover {
    background: var(--color-accent);
}

/* Nav Header — "Course Overview" back link */
.nav-header {
    padding-bottom: 0.75rem;
    border-bottom: 1px solid rgba(215, 168, 110, 0.3);
    margin-bottom: 0.75rem;
}

.nav-back-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-primary);
    text-decoration: none;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.85rem;
    transition: color var(--transition-smooth);
}

.nav-back-link:visited {
    color: var(--color-primary);
}

.nav-back-link:hover {
    color: var(--color-secondary-dark);
}

.nav-back-link svg {
    flex-shrink: 0;
}

/* Module Accordion */
.nav-module {
    margin-bottom: 0.5rem;
}

.nav-module-trigger {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    background: rgba(215, 168, 110, 0.08);
    border: 1px solid rgba(215, 168, 110, 0.2);
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-smooth);
    font-family: var(--font-heading);
}

.nav-module-trigger:hover {
    background: rgba(215, 168, 110, 0.15);
    border-color: rgba(215, 168, 110, 0.4);
}

.nav-module-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    background: var(--color-primary);
    color: var(--color-secondary-light);
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.nav-module-title {
    flex: 1;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-primary-dark);
    text-align: left;
}

.nav-expand-icon {
    flex-shrink: 0;
    transition: transform var(--transition-smooth);
    color: var(--color-accent);
}

.nav-module.active .nav-expand-icon {
    transform: rotate(180deg);
}

/* Lesson Links (collapsed by default) */
.nav-lessons {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    margin-top: 0;
}

.nav-module.active .nav-lessons {
    max-height: 500px;
    opacity: 1;
    margin-top: 0.5rem;
}

.nav-lesson-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.6rem;
    margin: 0.15rem 0;
    margin-left: 1.25rem;
    border-radius: 4px;
    text-decoration: none;
    color: var(--color-text-muted);
    font-size: 0.8rem;
    transition: all var(--transition-smooth);
    border-left: 3px solid transparent;
    line-height: 1.3;
}

.nav-lesson-link:visited {
    color: var(--color-text-muted);
}

.nav-lesson-link.current:visited {
    color: var(--color-primary-dark);
}

.nav-lesson-link:hover {
    background: rgba(215, 168, 110, 0.1);
    color: var(--color-text);
    border-left-color: rgba(215, 168, 110, 0.4);
}

.nav-lesson-link.current {
    background: rgba(215, 168, 110, 0.15);
    color: var(--color-primary-dark);
    font-weight: 600;
    border-left-color: var(--color-secondary);
}

.nav-lesson-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: rgba(93, 64, 55, 0.15);
    color: var(--color-primary);
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
    flex-shrink: 0;
}

.nav-lesson-link.current .nav-lesson-number {
    background: var(--color-primary);
    color: var(--color-secondary-light);
}

.nav-lesson-title {
    flex: 1;
    line-height: 1.3;
}

/* Main content area fills remaining space */
.hearth-lesson-main {
    flex: 1;
    min-width: 0;
}

/* Mobile hamburger toggle (hidden on desktop) */
.hearth-mobile-menu-toggle {
    display: none;
    position: fixed;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 1001;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    background: #5D4037;
    border: 1.5px solid rgba(212, 168, 83, 0.5);
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
    color: #FFFFFF;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.hearth-mobile-menu-toggle:hover,
.hearth-mobile-menu-toggle:active {
    background: var(--color-primary);
}

/* Hamburger SVG icon — override base.css height:auto that collapses the SVG */
.hearth-mobile-menu-toggle .hamburger-icon {
    display: block;
    width: 22px;
    height: 16px;
    max-width: none;
    flex-shrink: 0;
    transition: transform 0.3s ease;
}

.hearth-mobile-menu-toggle .hamburger-icon rect {
    fill: #FFFFFF;
    transition: all 0.3s ease;
}

/* Mobile nav overlay */
.hearth-nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(62, 39, 35, 0.5);
    z-index: 998;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.hearth-nav-overlay.active {
    opacity: 1;
    pointer-events: auto;
}


/* === Book / Parchment Content Area === */
.book-spread {
    background: var(--parchment-bg);
    border: var(--leather-border);
    border-radius: var(--leather-border-radius);
    box-shadow: var(--shadow-warm-lg), var(--shadow-warm-inset);
    padding: 2.5rem 3rem;
    position: relative;
    min-height: 600px;
}

/* Book spine effect (visible at large screens) */
@media (min-width: 1300px) {
    .book-spread::after {
        content: '';
        position: absolute;
        left: 50%;
        top: 2.5rem;
        bottom: 2.5rem;
        width: 1px;
        background: linear-gradient(to bottom, transparent, rgba(215, 168, 110, 0.4), transparent);
        pointer-events: none;
    }
}

/* Parchment texture overlay */
.book-spread::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--warm-vignette);
    pointer-events: none;
    border-radius: var(--leather-border-radius);
}

/* === Book Content === */
.book-content {
    position: relative;
    z-index: 1;
}

/* Two-column book text flow (breakpoint accounts for 280px sidebar) */
@media (min-width: 1300px) {
    .book-text-flow {
        columns: 2;
        column-gap: 3.5rem;
        column-rule: 1px solid rgba(215, 168, 110, 0.2);
        position: relative;
    }

    /* Reading direction hint */
    .book-text-flow::before {
        content: '\25BC  Read left column first, then continue right  \25BC';
        column-span: all;
        display: block;
        text-align: center;
        font-family: var(--font-heading);
        font-size: 0.7rem;
        font-style: italic;
        letter-spacing: 0.05em;
        color: var(--color-accent-light);
        padding: 0.25rem 0 0.75rem;
        margin-bottom: 0.5rem;
        border-bottom: 1px solid rgba(215, 168, 110, 0.15);
    }

    .book-text-flow .hearth-callout {
        break-inside: avoid;
    }

    .book-text-flow .reflection-box,
    .book-text-flow .knowledge-check,
    .book-text-flow .branching-scenario-activity,
    .book-text-flow .quiz-container,
    .book-text-flow .quiz-wrapper,
    .book-text-flow .drag-drop-activity,
    .book-text-flow .video-section,
    .book-text-flow .podcast-section,
    .book-text-flow .spectrum-container,
    .book-text-flow .click-reveal-container,
    .book-text-flow .accordion-container,
    .book-text-flow .drag-drop-container,
    .book-text-flow .hearth-exercise,
    .book-text-flow .hearth-reflection,
    .book-text-flow .hearth-key-takeaway {
        break-inside: avoid;
        column-span: all;
    }
}


/* === Lesson Title === */
.book-title {
    font-family: var(--font-heading);
    font-size: clamp(1.5rem, 3vw, 2rem);
    font-weight: 900;
    color: var(--color-primary-dark);
    margin: 0 0 0.5rem;
    line-height: 1.2;
}

.book-module-label {
    font-family: var(--font-heading);
    font-size: 0.85rem;
    color: var(--color-accent-dark, #6D4C41);
    font-style: italic;
    margin: 0 0 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(215, 168, 110, 0.3);
}

/* === Content Sections === */
.book-section {
    margin-bottom: 2rem;
}

.book-section h2 {
    font-size: clamp(1.2rem, 2.5vw, 1.5rem);
    color: var(--color-primary-dark);
    margin: 0 0 0.75rem;
    padding-top: 0.5rem;
}

.book-section h3 {
    font-size: clamp(1rem, 2vw, 1.2rem);
    color: var(--color-primary);
    margin: 0 0 0.5rem;
}

.book-section p {
    margin: 0 0 1rem;
    line-height: 1.8;
}

.book-section ul, .book-section ol {
    margin: 0 0 1rem;
    padding-left: 1.5rem;
}

.book-section li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.book-section strong {
    color: var(--color-primary-dark);
}

/* === Callout Boxes === */
.hearth-callout {
    background: rgba(215, 168, 110, 0.12);
    border-left: 4px solid var(--color-secondary);
    border-radius: 0 8px 8px 0;
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
}

.hearth-callout-title {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin: 0 0 0.5rem;
}

.hearth-callout p {
    margin: 0;
    line-height: 1.6;
}

.hearth-callout--insight { border-left-color: var(--color-secondary); }
.hearth-callout--important { border-left-color: var(--color-warning); }
.hearth-callout--definition { border-left-color: var(--color-accent); }

/* === Key Takeaway Box === */
.hearth-key-takeaway {
    background: linear-gradient(135deg, rgba(215, 168, 110, 0.15), rgba(232, 201, 160, 0.1));
    border: 2px solid var(--color-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin: 2rem 0;
    position: relative;
}

.hearth-key-takeaway::before {
    content: 'Key Flame';
    position: absolute;
    top: -0.75rem;
    left: 1.5rem;
    background: var(--parchment-bg);
    padding: 0 0.5rem;
    font-family: var(--font-heading);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-secondary-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* === Reflection Prompt === */
.hearth-reflection {
    background: var(--parchment-bg-subtle);
    border: 2px solid var(--color-secondary);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
}

.hearth-reflection h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    color: var(--color-primary-dark);
    margin: 0 0 0.75rem;
}

.hearth-reflection-prompt {
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text-secondary);
    margin: 0 0 1rem;
}

.hearth-reflection textarea {
    width: 100%;
    min-height: 120px;
    padding: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.7);
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-text);
    resize: vertical;
    transition: border-color var(--transition-smooth);
}

.hearth-reflection textarea:focus {
    outline: none;
    border-color: var(--color-secondary);
    box-shadow: 0 0 0 3px rgba(215, 168, 110, 0.25);
}

.hearth-reflection-saved {
    font-size: 0.8rem;
    color: var(--color-success);
    margin-top: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.hearth-reflection-saved.visible {
    opacity: 1;
}

/* === Video Section within Book === */
.book-content .video-section {
    margin: 1.5rem 0 2rem;
    border-radius: 8px;
    overflow: hidden;
}

/* === Lesson Navigation (Prev/Next) === */
.hearth-lesson-nav {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(215, 168, 110, 0.3);
}

.hearth-lesson-nav a {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-primary);
    color: var(--color-secondary-light);
    text-decoration: none;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    font-weight: 700;
    border-radius: 8px;
    transition: all var(--transition-smooth);
    min-height: 48px;
}

.hearth-lesson-nav a:hover {
    background: var(--color-primary-dark);
    color: var(--color-secondary);
    transform: translateX(2px);
}

.hearth-lesson-nav a:focus-visible {
    outline: 3px solid var(--color-focus);
    outline-offset: 2px;
}

.hearth-lesson-nav .prev-lesson:hover {
    transform: translateX(-2px);
}

/* === Desktop Sidebar Toggle Support === */
body.sidebar-hidden .hearth-lesson-sidebar {
    display: none;
}

body.sidebar-hidden .hearth-lesson-grid {
    max-width: 1100px;
}

/* === Responsive: Tablet === */
@media (max-width: 1023px) {
    .hearth-lesson-grid {
        padding: 1.5rem;
    }

    /* Sidebar becomes fixed slide-in on tablet */
    .hearth-mobile-menu-toggle {
        display: flex;
    }

    .hearth-lesson-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        max-width: 85vw;
        background: var(--color-bg);
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        overflow-y: auto;
        box-shadow: 4px 0 20px rgba(62, 39, 35, 0.3);
        padding: 1rem;
    }

    .hearth-lesson-sidebar.active {
        transform: translateX(0);
    }

    .hearth-nav-overlay {
        display: block;
    }

    .lesson-nav-sidebar {
        position: static;
        max-height: none;
        box-shadow: none;
        border: none;
    }

    .book-spread {
        padding: 2rem;
    }

    .book-spread::after {
        display: none;
    }

    .hearth-breadcrumb {
        padding-left: 3rem;
    }
}

/* === Responsive: Mobile === */
@media (max-width: 767px) {
    .hearth-lesson-grid {
        padding: 0.75rem;
        gap: 1rem;
    }

    .book-spread {
        padding: 1.25rem;
        border-width: 3px;
        border-radius: 2px;
    }

    .hearth-lesson-nav {
        flex-direction: column;
    }

    .hearth-lesson-nav a {
        justify-content: center;
    }

    /* Compact breadcrumb on mobile — single line, truncated */
    .hearth-breadcrumb {
        padding: 0.35rem 0.5rem 0.35rem 3.25rem;
        font-size: 0.65rem;
        min-height: 28px;
        gap: 0.15rem;
        flex-wrap: nowrap;
        overflow: hidden;
    }

    .hearth-breadcrumb a,
    .hearth-breadcrumb-current {
        font-size: 0.65rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .hearth-breadcrumb-current {
        flex: 0 1 auto;
        min-width: 0;
    }

    .hearth-breadcrumb-sep {
        flex-shrink: 0;
    }

    /* Hide the home link and its separator on mobile */
    .hearth-breadcrumb > a:first-child,
    .hearth-breadcrumb > .hearth-breadcrumb-sep:first-of-type {
        display: none;
    }
}

/* === Print Styles === */
@media print {
    .hearth-lesson-sidebar,
    .hearth-breadcrumb,
    .hearth-lesson-nav,
    .hearth-mobile-menu-toggle,
    .hearth-nav-overlay {
        display: none;
    }

    .book-spread {
        border: 1px solid #ccc;
        box-shadow: none;
        padding: 1rem;
    }
}
