/* --- RESET & VARIABLES --- */
:root {
    --primary: #047857; /* Emerald 700 */
    --primary-dark: #065f46;
    --primary-light: #d1fae5;
    --text-main: #0f172a; /* Slate 900 */
    --text-muted: #475569; /* Slate 600 */
    --text-light: #94a3b8;
    --bg-body: #ffffff;
    --bg-sidebar: #f8fafc; /* Slate 50 */
    --border: #e2e8f0; /* Slate 200 */

    --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-serif: Georgia, Cambria, "Times New Roman", Times, serif;
    --header-height: 64px;
    --sidebar-width: 320px;
}

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

body {
    font-family: var(--font-sans);
    color: var(--text-main);
    background: var(--bg-body);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    line-height: 1.5;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

button {
    border: none;
    background: none;
    cursor: pointer;
    font-family: inherit;
}

/* --- TYPOGRAPHY --- */
h1, h2, h3, h4, .font-serif {
    font-family: var(--font-serif);
}

.text-primary {
    color: var(--primary);
}

.text-muted {
    color: var(--text-muted);
}

.text-bold {
    font-weight: 700;
}

.text-center {
    text-align: center;
}

/* --- LAYOUT UTILITIES --- */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* --- HEADER --- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    background: white;
    border-bottom: 1px solid var(--border);
    z-index: 100;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: var(--font-serif);
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
}

    .logo svg {
        color: var(--primary);
        height: 24px;
        width: 24px;
    }

.nav-desktop {
    display: none;
    align-items: center;
    gap: 2rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
}

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

.menu-btn {
    color: var(--text-muted);
    padding: 0.5rem;
}

    .menu-btn svg {
        width: 24px;
        height: 24px;
    }

@media (min-width: 768px) {
    .nav-desktop {
        display: flex;
    }

    .menu-btn {
        display: none;
    }
}

/* --- SIDEBAR --- */
.sidebar {
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    z-index: 90;
    overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
}

    .sidebar.open {
        transform: translateX(0);
    }

/* On desktop, sidebar is always visible IF the body has the class 'has-sidebar' */
@media (min-width: 768px) {
    body.has-sidebar .sidebar {
        transform: translateX(0);
    }
}

.sidebar-content {
    padding: 1.5rem;
}

.sidebar-link {
    display: block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    color: var(--text-main);
    margin-bottom: 0.125rem;
}

    .sidebar-link:hover {
        background: white;
        color: #000000;
    }

    .sidebar-link.active {
        background: var(--primary-light);
        color: var(--primary-dark);
        font-weight: 700;
    }

/* --- MAIN CONTENT --- */
.main-content {
    margin-top: var(--header-height);
    flex-grow: 1;
    width: 100%;
}

@media (min-width: 768px) {
    body.has-sidebar .main-content {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* --- HOME HERO & FEATURES --- */
.hero {
    text-align: center;
    padding: 5rem 1.5rem;
    max-width: 48rem;
    margin: 0 auto;
}

.hero-icon {
    background: var(--primary-light);
    color: var(--primary-dark);
    width: 4rem;
    height: 4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem auto;
}

.hero h1 {
    font-size: 2.5rem;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    color: var(--text-main);
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-muted);
    font-family: var(--font-serif);
    line-height: 1.6;
    margin-bottom: 2.5rem;
}

.hero-btn {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 1rem 2rem;
    border-radius: 0.5rem;
    font-weight: 700;
    font-size: 1.125rem;
}


    .features {
        max-width: 64rem;
        margin: 0 auto;
        padding: 0 1.5rem 5rem 1.5rem;
        display: grid;
        gap: 2rem;
        grid-template-columns: 1fr;
    }

@media (min-width: 768px) {
    .features {
        grid-template-columns: repeat(3, 1fr);
    }
}

.feature-card {
    padding: 1.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    transition: box-shadow 0.2s;
}

    .feature-card:hover {
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    }

.feature-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

    .feature-title svg {
        width: 18px;
        height: 18px;
        color: var(--primary);
    }

.feature-text {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* --- LESSON/ARTICLE VIEW --- */
.lesson-container {
    max-width: 48rem;
    margin: 0 auto;
    padding: 3rem 1.5rem;
}

.breadcrumbs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 2rem;
}

    .breadcrumbs a {
        color: var(--text-muted);
        text-decoration: underline;
        text-underline-offset: 4px;
        text-decoration-color: var(--border);
    }

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

    .breadcrumbs svg {
        width: 14px;
        height: 14px;
    }

.prose {
    color: #334155;
    max-width: 100%;
}

    .prose h1 {
        font-size: 2.5rem;
        margin-bottom: 1.5rem;
        color: var(--text-main);
        line-height: 1.2;
    }

    .prose p {
        margin-bottom: 1.5em;
        line-height: 1.8;
        font-size: 1.05rem;
        font-size: 1.25rem;
        color: var(--text-muted);
        font-family: var(--font-serif);
        margin-bottom: 2em;
    }

    .prose h3 {
        font-family: var(--font-serif);
        font-weight: 700;
        margin-top: 2.5em;
        margin-bottom: 0.75em;
        font-size: 1.5rem;
        color: #1e293b;
    }

    .prose ul {
        list-style-type: disc;
        padding-left: 1.5em;
        margin-bottom: 1.5em;
    }

    .prose li {
        margin-bottom: 0.5em;
        padding-left: 0.5em;
    }

    .prose strong {
        color: #0f172a;
        font-weight: 700;
    }

    /* --- IMAGE RESPONSIVENESS --- */
    .prose img {
        max-width: 100%;
        height: auto;
        display: block;
        margin: 2rem auto;
        border-radius: 0.5rem;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    }

    /* Links inside the main article text */
    .prose a {
        color: #e67e57; /* Your orange-ish brand color */
        font-weight: 600;
    }

        .prose a:hover {
            color: #d96d45; /* Darker orange on hover */
        }

    /* --- FIGURES & CAPTIONS --- */
    .prose figure {
        display: block;
        margin: 2rem auto; /* Matches your previous inline style */
        text-align: center;
        max-width: 100%;
    }

        /* Ensure images inside figures don't add extra unnecessary margins 
   since the figure wrapper handles the outer spacing now */
        .prose figure img {
            margin: 0 auto;
        }

    .prose figcaption {
        font-size: 0.75rem;
        color: var(--text-muted);
        font-family: var(--font-sans);
        margin-top: 0.75rem;
        line-height: 1.5;
    }

        /* Specific styling for links inside captions to keep them subtle */
        .prose figcaption a {
            color: var(--text-muted);
            text-decoration: underline;
            font-weight: 400; /* Overrides the heavy bolding of standard prose links */
            transition: color 0.2s ease;
        }

            .prose figcaption a:hover {
                color: var(--primary);
            }

/* --- BOXES & CALLOUTS --- */

/* 1. Quick Facts / Diagram Box 
   (Replaces previous dashed-border style) */
.diagram-box {
    background-color: #f9f9f9;
    border-left: 5px solid #2c3e50; /* Dark Slate */
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 0 4px 4px 0;
    color: #334155;
    text-align: left;
    font-style: normal;
}

    .diagram-box .box-title {
        margin-bottom: 0.75rem;
        font-weight: 700;
        font-size: 1.1rem;
        color: #2c3e50;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    .diagram-box ul {
        margin: 0;
        padding-left: 1.5rem;
        list-style-type: disc;
    }

    .diagram-box li {
        margin-bottom: 0.5rem;
    }

        .diagram-box li:last-child {
            margin-bottom: 0;
        }

/* 2. Alert / Important Box */
.alert-box {
    background-color: #eef6fc; /* Light Blue BG */
    border: 1px solid #b8daff; /* Blue Border */
    border-left: 5px solid #004085; /* Darker Blue Accent */
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 4px;
    color: #004085;
}

    .alert-box .alert-title {
        margin-bottom: 0.75rem;
        font-weight: 700;
        font-size: 1.1rem;
        color: #004085;
    }

    .alert-box p {
        margin-bottom: 0; /* Overrides default prose margin */
        color: #004085;
        line-height: 1.6;
    }

.pro-tip {
    background-color: var(--primary-light); /* Uses your light green variable */
    border-left: 5px solid var(--primary); /* Uses your main darker green */
    padding: 1.5rem;
    margin: 2rem 0;
    border-radius: 4px;
    color: var(--primary-dark); /* Dark green text for readability */
}

    /* Optional: Make the "Beginner Tip:" bold text pop more */
    .pro-tip strong {
        color: var(--primary);
        font-weight: 800;
    }

/* Lesson Nav */
.lesson-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.nav-block {
    display: flex;
    flex-direction: column;
}

    .nav-block.right {
        align-items: flex-end;
        text-align: right;
    }

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 0.25rem;
}

.nav-title {
    font-family: var(--font-serif);
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text-main);
}

.nav-block:hover .nav-title {
    text-decoration: underline;
}

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

/* --- FOOTER --- */
.footer {
    background-color: var(--text-main); /* Slate 900 */
    color: #f1f5f9; /* Slate 100 */
    padding: 4rem 0 2rem;
    margin-top: auto; /* Pushes footer to bottom if content is short */
    width: 100%;
}

.footer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    margin-bottom: 3rem;
}

@media (min-width: 768px) {
    .footer-grid {
        grid-template-columns: 2fr 1fr 1fr;
    }
}

.footer-brand h3 {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    margin-bottom: 1rem;
    color: white;
}

.footer-brand p {
    color: #94a3b8; /* Slate 400 */
    font-size: 0.875rem;
    line-height: 1.6;
    max-width: 300px;
}

.footer-col h4 {
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #94a3b8;
    margin-bottom: 1.25rem;
    font-weight: 700;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

    .footer-links a {
        color: #cbd5e1; /* Slate 300 */
        font-size: 0.95rem;
        transition: color 0.2s;
    }

        .footer-links a:hover {
            color: var(--primary-light);
            text-decoration: underline;
        }

.footer-bottom {
    border-top: 1px solid #334155; /* Slate 700 */
    padding-top: 2rem;
    text-align: center;
    color: #64748b; /* Slate 500 */
    font-size: 0.875rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
}

@media (min-width: 768px) {
    .footer-bottom {
        flex-direction: row;
        justify-content: space-between;
    }
}

/* --- SIDEBAR LAYOUT FIX FOR FOOTER --- */
@media (min-width: 768px) {
    body.has-sidebar .main-content,
    body.has-sidebar .footer {
        margin-left: var(--sidebar-width);
        width: calc(100% - var(--sidebar-width));
    }
}

/* --- IMAGE WRAPPER & HOVER EFFECT --- */
.zoomable-wrapper {
    position: relative;
    display: inline-block; /* Wraps tightly around image */
    margin: 2rem auto;
    border-radius: 0.5rem;
    overflow: hidden; /* Keeps overlay inside rounded corners */
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    cursor: pointer;
}

    .zoomable-wrapper img {
        display: block;
        max-width: 100%;
        height: auto;
        transition: transform 0.3s ease;
    }

/* The Dark Overlay */
.zoomable-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6); /* Dark see-through background */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.3s ease;
    z-index: 10;
}

/* Text & Icon inside Overlay */
.overlay-content {
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    transform: translateY(10px); /* Slide up effect */
    transition: transform 0.3s ease;
}

.overlay-icon {
    display: block;
    margin: 0 auto 0.5rem auto;
    width: 32px;
    height: 32px;
}

/* Hover States */
.zoomable-wrapper:hover .zoomable-overlay {
    opacity: 1;
}

.zoomable-wrapper:hover .overlay-content {
    transform: translateY(0);
}

.zoomable-wrapper:hover img {
    transform: scale(1.03); /* Slight zoom on the image itself */
}


/* --- MODAL & ORANGE PILL BUTTONS --- */
.modal {
    display: none !important; /* Hidden by default */
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.95);
    padding: 20px;
}

    .modal[style*="display: block"] {
        display: flex !important;
    }

.modal-content {
    margin: 0;
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 140px);
    border-radius: 4px;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    object-fit: contain;
}

/* Close "X" */
.close-modal {
    position: absolute;
    top: 20px;
    right: 40px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2010;
}

/* Button Container */
.modal-toolbar {
    position: static;
    transform: none;
    display: flex;
    gap: 1.5rem;
    z-index: 2010;
    margin-bottom: 20px; /* Pushes the image down */
}

.modal-btn {
    background-color: #e67e57;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 2rem;
    border-radius: 999px;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(230, 126, 87, 0.4);
    transition: all 0.2s ease;
}

    .modal-btn:hover {
        background-color: #d96d45;
        transform: translateY(-2px);
        box-shadow: 0 6px 15px rgba(230, 126, 87, 0.5);
        color: white;
    }

    .modal-btn svg {
        width: 20px;
        height: 20px;
    }

/* --- ACCORDION SIDEBAR STYLES --- */
.nav-group {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid transparent;
}

.nav-group-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.5rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 800;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    text-align: left;
    transition: color 0.2s ease;
}

    .nav-group-trigger:hover {
        color: var(--text-main);
    }

/* The Chevron Icon Animation */
.chevron {
    width: 16px;
    height: 16px;
    color: #64748b;
    transition: transform 0.3s ease;
}

.nav-group.open .chevron {
    transform: rotate(180deg);
}

/* The container for the links (Hidden by default) */
.nav-group-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.3s ease-out;
}

/* The inner wrapper is needed for the grid animation trick */
.nav-link-wrapper {
    overflow: hidden;
}

/* State: OPEN */
.nav-group.open .nav-group-content {
    grid-template-rows: 1fr;
}

.nav-link-wrapper .sidebar-link {
    padding-left: 1rem;
    border-left: 2px solid transparent;
    border-radius: 0 4px 4px 0;
}

    .nav-link-wrapper .sidebar-link.active {
        border-left-color: var(--primary);
        background: var(--primary-light);
    }

/* RESET IMAGE STYLES WHEN INSIDE THE WRAPPER */
.zoomable-wrapper img {
    margin: 0; /* Removes the gap inside the wrapper */
    box-shadow: none; /* Removes the double shadow */
    border-radius: 0; /* Let the wrapper handle the rounded corners */
    display: block; /* Ensures no bottom-gap from inline layout */
}

/* Fix for Hero Button inside Prose text */
.prose a.hero-btn {
    color: white;
    text-decoration: none;
}

    /* Ensure it stays white on hover */
    .prose a.hero-btn:hover {
        color: white;
    }