/*
 * Interactive Tutors Math Lessons Styles
 * Version: 4.1.0
 * 
 * TABLE OF CONTENTS:
 * 1. Archive & Filters
 * 2. Lesson Cards
 * 3. Single Lesson Header
 * 4. Shortcuts & Navigation
 * 5. Content Boxes (Examples, Takeaways, Key Formulas, Practice)
 * 6. Collapsible Sections (Practice/Quiz)
 * 7. Quiz Styles
 * 8. Code & Math Typography
 * 9. MathJax Overrides
 * 10. Sidebar Styles
 * 11. Scroll & Smooth Behavior
 * 12. MathJax Inline Fix
 */

/* =================================================================== */
/* 1. ARCHIVE & FILTERS */
/* =================================================================== */

.lesson-filters {
    background: white;
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-label {
    font-size: 1rem;
    font-weight: 600;
    color: #374151;
}

.filter-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 50px;
    background-color: #fff;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
}

.filter-btn:hover {
    background-color: #f3f4f6;
    border-color: #9ca3af;
}

.filter-btn.active {
    color: white;
}

.filter-btn[data-filter="math_grade"].active {
    background-color: #2E8B57;
    border-color: #2E8B57;
}

.filter-btn[data-filter="math_topic"].active {
    background-color: #4A90E2;
    border-color: #4A90E2;
}

.filter-btn[data-filter="math_difficulty"].active {
    background-color: #F5A623;
    border-color: #F5A623;
}

/* =================================================================== */
/* 2. LESSON CARDS */
/* =================================================================== */

.lesson-card {
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
}

.lesson-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
    border-color: #2E8B57;
}

.lesson-card__image-link {
    display: block;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.lesson-card__image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.taxonomy-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    margin: 0.25rem;
    color: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: all 0.2s ease-in-out;
}

.taxonomy-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.25);
}

.taxonomy-badge.topic {
    background-color: #4A90E2;
}

.taxonomy-badge.difficulty {
    background-color: #F5A623;
}

/* =================================================================== */
/* 3. SINGLE LESSON HEADER */
/* =================================================================== */

.math-lesson-header {
    background-color: #2e8775;
    color: white;
    padding: 2.5rem 1.5rem;
    border-radius: 20px;
    margin-bottom: 1.5rem;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.math-lesson-header h1,
.math-lesson-header p {
    text-shadow: 1px 1px 3px rgba(0,0,0,0.2);
}

/* =================================================================== */
/* 4. SHORTCUTS & NAVIGATION */
/* =================================================================== */

.lesson-shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 2.5rem;
}

.shortcut-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    color: white;
    border: 1px solid transparent;
    transition: all 0.2s ease-in-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.shortcut-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    filter: brightness(1.1);
}

.shortcut-btn.hcf { background-color: #2E8B57; }
.shortcut-btn.lcm { background-color: #4A90E2; }
.shortcut-btn.calc { background-color: #F5A623; }
.shortcut-btn.quiz { background-color: #8e44ad; }
.shortcut-btn.practice { background-color: #16a085; }

.nav-link-btn {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    text-align: center;
    font-weight: 500;
    color: white;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}

.nav-link-btn:hover {
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.nav-link-btn--all { background-color: #6c757d; }
.nav-link-btn--all:hover { background-color: #5a6268; }
.nav-link-btn--topic { background-color: #2E8B57; }
.nav-link-btn--topic:hover { background-color: #247653; }
.nav-link-btn--grade { background-color: #4A90E2; }
.nav-link-btn--grade:hover { background-color: #3b7dd8; }

/* =================================================================== */
/* 5. CONTENT BOXES (Examples, Takeaways, Key Formulas, Practice) */
/* =================================================================== */

.example-box,
.takeaways,
.key-formula,
.prose .practice-section {
    background-color: rgba(55, 65, 81, 0.1);
    border-left: 5px solid;
    padding: 1.5rem;
    margin: 2em 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.example-box h3, .example-box h4,
.takeaways h3, .takeaways h4,
.key-formula h3, .key-formula h4,
.prose .practice-section h3,
.prose .practice-section h4 {
    margin-top: 0 !important;
    font-size: 1.25rem;
    display: flex;
    align-items: center;
}

.example-box h3::before, .example-box h4::before,
.takeaways h3::before, .takeaways h4::before,
.key-formula h3::before, .key-formula h4::before,
.prose .practice-section h3::before,
.prose .practice-section h4::before {
    font-family: "Font Awesome 5 Free";
    font-weight: 900;
    margin-right: 0.75rem;
    font-size: 1.1rem;
}

.example-box {
    border-color: #2E8B57;
    background-color: rgba(46, 139, 87, 0.05);
}

.example-box h3, .example-box h4 { color: #2E8B57; }
.example-box h3::before, .example-box h4::before { content: '\f044'; }

.takeaways {
    border-color: #4A90E2;
    background-color: rgba(74, 144, 226, 0.05);
}

.takeaways h3, .takeaways h4 { color: #4A90E2; }
.takeaways h3::before, .takeaways h4::before { content: '\f0eb'; }

.key-formula {
    border-color: #8e44ad;
    background-color: rgba(142, 68, 173, 0.05);
}

.key-formula h3, .key-formula h4 { color: #8e44ad; }
.key-formula h3::before, .key-formula h4::before { content: '\f084'; }

.prose .practice-section {
    border-color: #F5A623;
    background-color: rgba(245, 166, 35, 0.05);
}

.prose .practice-section h3,
.prose .practice-section h4 { color: #D08C1D; }

.prose .practice-section h3::before,
.prose .practice-section h4::before { content: '\f303'; }

/* Common content styles */
.example-box ul, .takeaways ul, .key-formula ul,
.prose .practice-section ul, .prose ul {
    list-style-type: disc;
    margin: 1.25em 0;
    padding-left: 1.5em;
}

.example-box li, .takeaways li, .key-formula li,
.prose .practice-section li, .prose li {
    margin: 0.5em 0;
}

.prose ol {
    list-style-type: decimal;
    margin: 1.25em 0;
    padding-left: 1.5em;
}

/* =================================================================== */
/* 6. COLLAPSIBLE SECTIONS (Practice & Quiz) */
/* =================================================================== */

.collapsible-section {
    border-radius: 1.1rem;
    margin-top: 2.5rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    background: #ffffff;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
    overflow: hidden;
}

.collapsible-section details {
    border-radius: inherit;
    background: transparent;
}

.collapsible-section > details > summary {
    list-style: none;
    cursor: pointer;
    padding: 1.35rem 1.75rem;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    transition: background-color 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
    position: relative;
    font-weight: 700;
    font-size: 1.25rem;
    border: none;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: inherit;
    background: #ffffff;
}

.collapsible-section > details > summary::-webkit-details-marker {
    display: none;
}

.collapsible-section > details > summary h3 {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    color: inherit;
}

.collapsible-section > details > summary h3 i {
    font-size: 1.1em;
}

.collapsible-section > details > .content-wrapper {
    padding: 1.75rem 1.85rem;
    background: transparent;
}

/* Practice Section */
.collapsible-section.practice-section {
    border-color: #fde68a;
    background: #fdfaf3;
    box-shadow: 0 18px 36px rgba(249, 180, 36, 0.18);
}

.collapsible-section.practice-section > details > summary {
    background: linear-gradient(90deg, rgba(254, 243, 199, 0.9), rgba(255, 255, 255, 0.95));
    color: #b45309;
    border-left: 6px solid #f59e0b;
    box-shadow: inset 0 -1px 0 rgba(180, 83, 9, 0.15);
}

.collapsible-section.practice-section > details[open] > summary {
    background: linear-gradient(90deg, rgba(254, 243, 199, 1), #ffffff);
    box-shadow: inset 0 -2px 0 rgba(180, 83, 9, 0.18);
}

/* Quiz Section */
.collapsible-section.quiz-section-container {
    border-color: #bfdbfe;
    background: #f7faff;
    box-shadow: 0 20px 44px rgba(37, 99, 235, 0.15);
}

.collapsible-section.quiz-section-container > details > summary {
    background: linear-gradient(90deg, rgba(191, 219, 254, 0.85), rgba(255, 255, 255, 0.95));
    color: #1d4ed8;
    border-left: 6px solid #2563eb;
    box-shadow: inset 0 -1px 0 rgba(37, 99, 235, 0.18);
}

.collapsible-section.quiz-section-container > details[open] > summary {
    background: linear-gradient(90deg, rgba(191, 219, 254, 1), #ffffff);
    box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.2);
}

/* Practice Section content */
.practice-section .content-wrapper {
    background: transparent;
}

.practice-problem {
    padding: 1.2rem 0;
    border-bottom: 1px solid rgba(180, 83, 9, 0.12);
}

.practice-problem:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.practice-problem h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    margin: 0 0 0.85rem;
}

.answer-accordion summary {
    font-weight: 600;
    color: #2563eb;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    list-style: none;
    transition: color 0.2s ease;
}

.answer-accordion summary:hover {
    color: #1d4ed8;
}

.answer-accordion summary::marker {
    display: none;
}

.answer-accordion summary::before {
    content: '\25B6';
    font-size: 0.8rem;
    display: inline-block;
    transform-origin: center;
    transition: transform 0.2s ease;
    color: currentColor;
    line-height: 1;
}

.answer-accordion[open] summary::before {
    transform: rotate(90deg);
}

.answer-accordion .answer-content {
    margin-top: 0.85rem;
    padding: 1.05rem 1.2rem;
    border-radius: 0.85rem;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #1f2937;
}

/* =================================================================== */
/* 7. QUIZ STYLES */
/* =================================================================== */

.quiz-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 0.5rem 0 0;
}

.quiz-question {
    padding-bottom: 1.5rem;
    border-bottom: 1px solid rgba(29, 78, 216, 0.12);
}

.quiz-question:last-of-type {
    border-bottom: none;
    padding-bottom: 0;
}

.quiz-question h4 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 0.95rem;
}

.quiz-options {
    display: grid;
    gap: 0.9rem;
}

.quiz-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.95rem 1.2rem;
    border: 1px solid #dbeafe;
    border-radius: 0.9rem;
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.quiz-option:hover {
    border-color: #2563eb;
    box-shadow: 0 8px 18px rgba(37, 99, 235, 0.16);
}

.quiz-option .radio-btn {
    width: 1.1rem;
    height: 1.1rem;
    border-radius: 999px;
    border: 2px solid #bfdbfe;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.quiz-option.is-selected,
.quiz-option.selected {
    border-color: #2563eb;
    background: #eff6ff;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.2);
}

.quiz-option.is-selected .radio-btn,
.quiz-option.selected .radio-btn {
    border-color: #2563eb;
    background: #2563eb;
    box-shadow: inset 0 0 0 2px #ffffff;
}

.quiz-option .option-text {
    font-size: 1rem;
    line-height: 1.5;
    color: #1f2937;
}

/* Feedback states */
.quiz-option.correct {
    background-color: rgba(46, 139, 87, 0.1) !important;
    border-color: #2E8B57 !important;
    font-weight: 600;
}

.quiz-option.correct .radio-btn {
    border-color: #2E8B57;
    background: #2E8B57;
    box-shadow: inset 0 0 0 2px #ffffff;
}

.quiz-option.incorrect {
    background-color: rgba(217, 83, 79, 0.1) !important;
    border-color: #d9534f !important;
    font-weight: 600;
}

.quiz-option.incorrect .radio-btn {
    border-color: #d9534f;
    background: #d9534f;
    box-shadow: inset 0 0 0 2px #ffffff;
}

.submit-quiz-btn,
.redo-quiz-btn {
    display: inline-block;
    background-color: #2563eb;
    color: #fff;
    border: none;
    padding: 0.95rem 2rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 999px;
    cursor: pointer;
    margin-top: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.25);
}

.submit-quiz-btn:hover,
.redo-quiz-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px rgba(29, 78, 216, 0.28);
}

.submit-quiz-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.redo-quiz-btn {
    background-color: #2E8B57;
}

#quiz-results {
    margin-top: 1.1rem;
    font-weight: 600;
    font-size: 1.05rem;
    color: #0f172a;
}

.quiz-score {
    padding: 1.5rem;
    border-radius: 0.9rem;
    text-align: center;
    border: 2px solid transparent;
}

.quiz-score h3 {
    margin: 0 0 1rem;
    font-size: 1.5rem;
}

.quiz-score.pass {
    background-color: rgba(46, 139, 87, 0.1);
    border-color: #2E8B57;
    color: #1a5c37;
}

.quiz-score.fail {
    background-color: rgba(217, 83, 79, 0.1);
    border-color: #d9534f;
    color: #a94442;
}

.score-text {
    font-size: 1.125rem;
    margin-bottom: 0.5rem;
}

.message-text {
    font-size: 1rem;
    margin-bottom: 1rem;
}

/* =================================================================== */
/* 8. CODE & MATH TYPOGRAPHY */
/* =================================================================== */

code {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, monospace;
    font-size: 1em !important;
    font-weight: 500;
    background-color: rgba(55, 65, 81, 0.1);
    color: #374151;
    padding: 0.25em 0.5em;
    border-radius: 4px;
    border: 1px solid rgba(55, 65, 81, 0.2);
}

/* =================================================================== */
/* 9. MATHJAX OVERRIDES */
/* =================================================================== */

.MathJax,
.MathJax_Display,
.MathJax_SVG,
.MathJax_SVG_Display,
mjx-container,
mjx-container svg,
mjx-container[jax="CHTML"][display="false"],
mjx-container[jax="CHTML"][display="true"] {
    background: transparent !important;
    background-color: transparent !important;
}

code .MathJax,
code .MathJax_Display,
code .MathJax_SVG,
code:has(.MathJax),
code:has(.MathJax_Display),
code:has(.MathJax_SVG) {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
}

.MathJax { font-size: 1.1em !important; }
.MathJax_Display { margin: 1em 0 !important; }

/* =================================================================== */
/* 10. SIDEBAR STYLES */
/* =================================================================== */

#section-1, #section-2, #section-3, 
#quiz-section, #practice-section,
#calculator-section {
    scroll-margin-top: 120px;
}

html { scroll-behavior: smooth; }

/* =================================================================== */
/* 11. RESPONSIVE TWEAKS */
/* =================================================================== */

@media (max-width: 640px) {
    .collapsible-section > details > summary {
        padding: 1.15rem 1.25rem;
        font-size: 1.15rem;
    }

    .collapsible-section > details > .content-wrapper {
        padding: 1.35rem 1.25rem 1.5rem;
    }

    .practice-problem {
        padding: 1rem 0;
    }

    .quiz-option {
        padding: 0.85rem 1rem;
    }

    .submit-quiz-btn,
    .redo-quiz-btn {
        width: 100%;
        justify-content: center;
    }
}

/* =================================================================== */
/* 12. MATHJAX INLINE FIX */
/* =================================================================== */

mjx-container[display="false"] {
    display: inline !important;
    margin: 0 2px !important;
}

mjx-container[display="true"] {
    display: block !important;
    margin: 1em 0 !important;
}

.practice-problem mjx-container,
.quiz-option mjx-container,
.answer-content mjx-container {
    vertical-align: baseline;
}