:root {
    --primary: #2563eb;
    /* Brighter Blue */
    --primary-dark: #1e40af;
    --secondary: #f59e0b;
    /* Warmer Orange/Amber */
    --accent: #3b82f6;
    /* Vivid Blue */
    --bg-color: #f1f5f9;
    /* Light Grey/Blue Tint */
    --card-bg: #ffffff;
    --text-color: #334155;
    /* Slate 700 */
    --text-light: #64748b;
    /* Slate 500 */
    --sidebar-width: 280px;
    --sidebar-bg: #ffffff;
    /* White Sidebar */
    --sidebar-text: #334155;
    /* Dark Text */
    --font-heading: 'Georgia', 'Times New Roman', serif;
    --font-body: 'Segoe UI', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

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

html,
body {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.7;
}

a {
    text-decoration: none;
    color: inherit;
    transition: all 0.3s;
}

/* Layout */
.layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Styling */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 2rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    left: 0;
    top: 0;
    z-index: 100;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.05);
    transition: transform 0.3s ease;
    border-right: 1px solid #e2e8f0;
}

.brand {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.brand h3 a {
    color: var(--primary);
    font-size: 1.5rem;
    font-family: var(--font-heading);
    letter-spacing: 1px;
    font-weight: bold;
}

.nav-list {
    list-style: none;
}

.nav-item {
    margin-bottom: 0.5rem;
}

.nav-link {
    display: block;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    color: var(--text-light);
    font-size: 0.95rem;
    font-weight: 500;
}

.nav-link:hover {
    background: #f1f5f9;
    color: var(--primary);
    transform: translateX(5px);
}

.nav-link.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 700;
    border-left: 4px solid var(--primary);
    box-shadow: none;
}

footer a.active {
    color: var(--primary);
    text-decoration: none;
}

/* Main Content Area */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 3rem;
    background-color: var(--bg-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Center Content & Allow Full Width */
.main-content>* {
    width: 100%;
    /* max-width removed to allow full width usage */
    margin-left: auto;
    margin-right: auto;
}

/* Hero Section */
.hero {
    background: linear-gradient(120deg, var(--primary), var(--accent));
    color: white;
    padding: 5rem 3rem;
    border-radius: 20px;
    margin-bottom: 4rem;
    text-align: center;
    box-shadow: 0 20px 40px rgba(37, 99, 235, 0.2);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at top right, rgba(255, 255, 255, 0.2), transparent 40%);
}

.hero h1 {
    color: white;
    font-size: 3.5rem;
    margin-bottom: 1.5rem;
    text-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-weight: 800;
}

.hero p {
    font-size: 1.4rem;
    opacity: 0.95;
    max-width: 800px;
    margin: 0 auto;
    font-weight: 500;
    color: #eff6ff;
    /* Very light blue for better contrast against blue bg */
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-family: var(--font-heading);
    color: var(--primary-dark);
    line-height: 1.3;
}

h2 {
    font-size: 2.2rem;
    margin-top: 3rem;
    margin-bottom: 2rem;
    position: relative;
    display: inline-block;
}

h2::after {
    content: '';
    display: block;
    width: 60%;
    height: 5px;
    background: var(--secondary);
    margin-top: 0.8rem;
    border-radius: 10px;
}

p {
    margin-bottom: 1.5rem;
    font-size: 1.15rem;
    color: #475569;
}

ul,
ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
}

li {
    margin-bottom: 0.8rem;
    color: #475569;
}

/* Cards & Grid */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 2rem;
    width: 100%;
}

.card {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
    border: 1px solid #f1f5f9;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card h3 {
    margin-top: 0.5rem;
    color: var(--primary);
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.card p {
    color: var(--text-light);
    font-size: 1rem;
    flex-grow: 1;
}

/* Homepage Card Specifics */
.grid .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    border-color: var(--accent);
}

.grid .card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(to right, var(--primary), var(--accent));
}

.grid .card::after {
    content: 'Start Lesson →';
    display: inline-block;
    margin-top: 1.5rem;
    color: var(--accent);
    font-weight: bold;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Lesson Content Card Specifics (Article) */
.lesson-content .card {
    margin-bottom: 3rem;
    /* Increase spacing between sections */
    padding: 3rem;
    /* More internal breathing room */
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    /* Softer shadow */
}

.lesson-content .card:hover {
    transform: none;
    /* No movement while reading */
}

/* Ensure text wrapping */
h1,
h2,
h3,
h4,
p,
li,
span {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}


/* Buttons */
.btn {
    display: inline-block;
    padding: 1rem 2.5rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    border-radius: 50px;
    font-weight: bold;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 0.9rem;
}

.btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px rgba(37, 99, 235, 0.4);
    color: #fff;
}

/* Images */
.img-fluid {
    max-width: 100%;
    height: auto;
    border-radius: 16px;
    margin: 3rem auto;
    display: block;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    background: #fff;
    padding: 2rem;
    border: 1px solid #f1f5f9;
}

/* Lesson Meta */
.lesson-meta {
    background: #fff;
    padding: 1rem 2rem;
    border-radius: 50px;
    display: inline-block;
    margin-bottom: 2rem;
    font-size: 0.95rem;
    color: var(--text-light);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    border: 1px solid #e2e8f0;
    font-weight: 500;
}

/* Footer */
.site-footer {
    margin-top: 6rem;
    padding-top: 4rem;
    border-top: 1px solid #cbd5e1;
    text-align: center;
    color: #64748b;
    width: 100%;
    padding-bottom: 2rem;
}

.legal-links {
    margin-bottom: 2rem;
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.legal-links a {
    color: #64748b;
    font-size: 0.95rem;
    font-weight: 500;
}

.legal-links a:hover {
    color: var(--primary);
    text-decoration: none;
}

/* Mobile Toggle */
.menu-toggle {
    display: none;
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 1001;
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-weight: bold;
    transition: transform 0.2s;
}

.menu-toggle:hover {
    transform: scale(1.05);
    background: var(--primary-dark);
}

/* Mobile Toggle & Header */
.mobile-header {
    display: none;
}

.no-scroll {
    overflow: hidden;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

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

.animate-fade-in {
    animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Responsive */
@media (max-width: 992px) {
    .main-content {
        padding: 3rem 1.5rem;
        /* Reduce side padding on tablets */
    }

    .hero h1 {
        font-size: 2.8rem;
    }
}

@media (max-width: 768px) {

    .brand {
        margin-bottom: 0;
        padding-bottom: 0;
    }

    /* STRICT OVERFLOW CONTROL */
    html,
    body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
        position: relative;
    }

    .main-content {
        padding: 1rem !important;
        /* Force small padding */
        padding-top: 80px !important;
        /* Space for header */
        margin: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    .lesson-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .lesson-content .card {
        padding: 1.25rem !important;
        /* Force small card padding */
        margin-bottom: 2rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 12px !important;
    }

    /* Mobile Header Visible */
    .mobile-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 60px;
        /* Slightly shorter */
        background: #fff;
        padding: 0 1rem;
        z-index: 9999;
        /* Highest Z-index */
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
        border-bottom: 1px solid #f1f5f9;
    }

    .mobile-header .brand h3 a {
        font-size: 1.3rem;
        color: var(--primary);
        text-decoration: none;
    }

    .menu-toggle {
        display: block;
        background: var(--primary);
        color: white;
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 8px;
        /* Square-ish button */
        font-weight: 600;
        font-size: 0.85rem;
        cursor: pointer;
        position: static;
        top: auto;
        right: auto;
        box-shadow: none;
    }

    /* Sidebar Mobile Full Screen */
    .sidebar {
        transform: translateX(-100%);
        box-shadow: none;
        width: 100% !important;
        height: calc(100vh - 60px) !important;
        top: 60px !important;
        z-index: 9998;
        transition: transform 0.3s ease-in-out;
        padding-bottom: 100px;
        /* Space for scrolling */
    }

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

    /* Hide duplicate logo inside sidebar */
    .sidebar .brand {
        display: none;
    }

    /* Typography Adjustments */
    h1 {
        font-size: 1.8rem !important;
    }

    h2 {
        font-size: 1.5rem !important;
    }

    .hero {
        padding: 2rem 1rem !important;
        border-radius: 0 !important;
        /* Full width look */
        margin: -1rem -1rem 2rem -1rem !important;
        /* Pull to edges */
        width: calc(100% + 2rem) !important;
    }

    .hero h1 {
        font-size: 1.8rem !important;
    }

    .lesson-meta {
        padding: 0.5rem;
        width: 100%;
        border-radius: 8px;
        text-align: center;
        display: block;
        font-size: 0.85rem;
    }

    /* Adjust Lesson Header */
    .lesson-header h1 {
        font-size: 1.6rem !important;
        word-break: break-word;
        line-height: 1.3;
    }
}