/* Neural Networks Tutorial CSS */

/* Professional Color Palette */
:root {
    --alpine-oat: #F5EBDC;
    --dill-green: #5B7553;
    --aura-indigo: #4B3F72;
    --butter-yellow: #FFD95B;
    --dark-gray: #2E2E2E;
    --light-gray: #6B7280;
    --white: #FFFFFF;
}

/* Tutorial Header */
.tutorial-header {
    background: linear-gradient(135deg, var(--dill-green) 0%, var(--aura-indigo) 100%);
    color: var(--white);
    padding: 3rem 0;
    text-align: center;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
}

.chapter-title {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1;
}

.chapter-subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

/* CRITICAL: Chapter Progress Bar */
.chapter-progress {
    background: rgba(255, 255, 255, 0.2);
    height: 6px;
    border-radius: 3px;
    margin: 1rem auto;
    max-width: 600px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.chapter-progress-fill {
    background: linear-gradient(90deg, var(--butter-yellow), #F4C430);
    height: 100%;
    width: 0%; /* CRITICAL: Must start at 0, JavaScript sets width */
    border-radius: 3px;
    transition: width 0.5s ease;
    box-shadow: 0 0 10px rgba(255, 217, 91, 0.5);
}

/* CRITICAL: Section Progress Bar */
.section-progress {
    background: rgba(255, 255, 255, 0.1);
    height: 4px;
    border-radius: 2px;
    margin: 1.5rem auto 1rem auto; /* CRITICAL: Spacing from chapter-navigation */
    max-width: 400px;
    overflow: hidden;
    position: relative;
    z-index: 1;
}

.section-progress-fill {
    background: linear-gradient(90deg, var(--butter-yellow), #F4C430);
    height: 100%;
    width: 0%; /* CRITICAL: Must start at 0, JavaScript sets width */
    border-radius: 2px;
    transition: width 0.5s ease;
    box-shadow: 0 0 8px rgba(255, 217, 91, 0.5);
}

/* CRITICAL: Chapter Navigation */
.chapter-navigation {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 2rem 0; /* CRITICAL: Proper spacing */
    flex-wrap: wrap;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 1rem; /* CRITICAL: Internal padding */
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    position: relative;
    z-index: 1;
}

/* CRITICAL: Chapter Navigation Buttons */
.chapter-nav-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--dill-green);
    border-radius: 8px;
    padding: 0.75rem 1.25rem; /* CRITICAL: Proper padding */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--dark-gray);
    font-size: 0.9rem;
    white-space: nowrap;
    margin: 0.25rem; /* CRITICAL: Margin between buttons */
    text-decoration: none;
    min-width: 80px;
    text-align: center;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(91, 117, 83, 0.2);
}

.chapter-nav-btn:hover {
    background: var(--butter-yellow);
    border-color: var(--butter-yellow);
    color: var(--dark-gray);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 217, 91, 0.4);
}

.chapter-nav-btn.active {
    background: var(--butter-yellow);
    border-color: var(--butter-yellow);
    color: var(--dark-gray);
    box-shadow: 0 6px 20px rgba(255, 217, 91, 0.4);
    transform: translateY(-2px);
    font-weight: 700;
}

/* Section Navigation */
.section-nav {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin: 1rem 0; /* CRITICAL: Spacing from section-progress */
    position: relative;
    z-index: 1;
}

/* CRITICAL: Section Navigation Buttons */
.section-nav-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid var(--dill-green);
    border-radius: 8px;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--dark-gray);
    font-size: 0.9rem;
    white-space: nowrap;
    margin: 0.25rem;
    box-shadow: 0 2px 8px rgba(91, 117, 83, 0.2);
}

.section-nav-btn:hover {
    background: var(--butter-yellow);
    border-color: var(--butter-yellow);
    color: var(--dark-gray);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 217, 91, 0.4);
}

.section-nav-btn.active {
    background: var(--butter-yellow);
    border-color: var(--butter-yellow);
    color: var(--dark-gray);
    box-shadow: 0 6px 20px rgba(255, 217, 91, 0.4);
    transform: translateY(-2px);
    font-weight: 700;
}

/* CRITICAL: Content Sections - Hidden by Default */
.content-section {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

/* CRITICAL: Only Active Section is Visible */
.content-section.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Learning Objectives Box */
.learning-objectives-box {
    background: var(--alpine-oat);
    border: 2px solid var(--dill-green);
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
}

.learning-objectives-box h2 {
    color: var(--dill-green);
    margin-bottom: 1rem;
}

.learning-objectives-box ul {
    list-style: none;
    padding-left: 0;
}

.learning-objectives-box li {
    padding: 0.5rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.learning-objectives-box li::before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--dill-green);
    font-weight: bold;
}

/* Explanation Box */
.explanation-box {
    background: var(--alpine-oat);
    border: 2px solid var(--dill-green);
    border-radius: 12px;
    padding: 2rem;
    margin: 1.5rem 0;
    line-height: 1.7;
}

.explanation-box h3 {
    margin-top: 0;
    margin-bottom: 1.25rem;
    color: var(--dill-green);
    font-size: 1.5rem;
}

.explanation-box h4 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--dill-green);
    font-size: 1.25rem;
}

.explanation-box h5 {
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--dill-green);
    font-size: 1.1rem;
}

.explanation-box p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.explanation-box ul,
.explanation-box ol {
    margin: 1rem 0;
    padding-left: 2rem;
    line-height: 1.8;
}

.explanation-box li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.explanation-box > *:first-child {
    margin-top: 0;
}

.explanation-box > *:last-child {
    margin-bottom: 0;
}

/* Formula Box */
.formula-box {
    background: var(--alpine-oat);
    border: 2px solid var(--aura-indigo);
    border-radius: 12px;
    padding: 2rem;
    margin: 1.5rem 0;
    line-height: 1.7;
}

.formula-box h4 {
    margin-top: 0;
    margin-bottom: 1.25rem;
    color: var(--aura-indigo);
    font-size: 1.5rem;
}

.formula-box h5 {
    margin-top: 1.25rem;
    margin-bottom: 0.75rem;
    color: var(--aura-indigo);
    font-size: 1.1rem;
}

.formula-box ul {
    margin: 1rem 0;
    padding-left: 2rem;
    line-height: 1.8;
}

.formula-box li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.formula-display {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin: 1rem 0;
    text-align: center;
    overflow-x: auto;
}

/* KaTeX styling */
.formula-display .katex {
    font-size: 1.2rem;
}

.formula-display .katex-display {
    margin: 0.5em 0;
}

.formula-explanation {
    margin-top: 1rem;
}

/* Code Box */
.code-box {
    background: var(--dark-gray);
    border: 2px solid var(--aura-indigo);
    border-radius: 12px;
    padding: 2rem;
    margin: 1.5rem 0;
}

.code-box h4 {
    margin-top: 0;
    margin-bottom: 1.25rem;
    color: #f8f8f2;
    font-size: 1.5rem;
}

.code-box pre {
    background: #1a1a1a;
    color: #f8f8f2;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
}

.code-box code {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
}

.code-explanation {
    background: rgba(255, 255, 255, 0.1);
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1rem;
    color: #e0e0e0;
}

/* Example Box */
.example-box {
    background: var(--alpine-oat);
    border: 2px solid var(--butter-yellow);
    border-radius: 12px;
    padding: 2rem;
    margin: 1.5rem 0;
    line-height: 1.7;
}

.example-box h4 {
    margin-top: 0;
    margin-bottom: 1.25rem;
    color: var(--dill-green);
    font-size: 1.5rem;
}

.example-box h5 {
    margin-top: 1.5rem;
    margin-bottom: 1rem;
    color: var(--dill-green);
    font-size: 1.25rem;
}

.example-box p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.example-box p:first-of-type {
    margin-top: 0;
}

.example-box ul,
.example-box ol {
    margin: 1rem 0;
    padding-left: 2rem;
    line-height: 1.8;
}

.example-box li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

.example-box > *:first-child {
    margin-top: 0;
}

/* Chapter Main Content */
.chapter-main-content {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    margin: 2rem 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    line-height: 1.7;
}

.chapter-main-content h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--dill-green);
    font-size: 2rem;
}

.chapter-main-content > .content-section > h2 {
    margin-top: 0;
    margin-bottom: 1.5rem;
}

.chapter-main-content > .content-section {
    line-height: 1.7;
}

.chapter-main-content p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

.chapter-main-content ul,
.chapter-main-content ol {
    margin: 1rem 0;
    padding-left: 2rem;
    line-height: 1.8;
}

.chapter-main-content li {
    margin-bottom: 0.75rem;
    line-height: 1.8;
}

/* Quiz Container */
.quiz-container {
    margin: 2rem 0;
}

.quiz-question {
    background: var(--alpine-oat);
    border: 2px solid var(--dill-green);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 1.5rem 0;
}

.quiz-option {
    background: white;
    border: 2px solid var(--dill-green);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin: 0.5rem 0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.quiz-option:hover {
    background: var(--butter-yellow);
    border-color: var(--butter-yellow);
    transform: translateX(5px);
}

.quiz-option.correct {
    background: #d4edda !important;
    border-color: #28a745 !important;
    color: #155724 !important;
    font-weight: 600;
    box-shadow: 0 0 20px rgba(40, 167, 69, 0.8), 0 0 40px rgba(40, 167, 69, 0.5), 0 0 60px rgba(40, 167, 69, 0.3) !important;
    animation: glowGreen 0.8s ease-in-out;
    transform: scale(1.02);
}

.quiz-option.incorrect {
    background: #f8d7da !important;
    border-color: #dc3545 !important;
    color: #721c24 !important;
    font-weight: 600;
    box-shadow: 0 0 15px rgba(220, 53, 69, 0.6), 0 0 30px rgba(220, 53, 69, 0.4) !important;
    animation: shake 0.6s ease-in-out;
}

@keyframes glowGreen {
    0% {
        box-shadow: 0 0 5px rgba(40, 167, 69, 0.3);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 30px rgba(40, 167, 69, 1), 0 0 50px rgba(40, 167, 69, 0.7), 0 0 70px rgba(40, 167, 69, 0.5);
        transform: scale(1.05);
    }
    100% {
        box-shadow: 0 0 20px rgba(40, 167, 69, 0.8), 0 0 40px rgba(40, 167, 69, 0.5), 0 0 60px rgba(40, 167, 69, 0.3);
        transform: scale(1.02);
    }
}

@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-5px);
    }
    75% {
        transform: translateX(5px);
    }
}

/* RAG Flow Diagram */
.rag-flow-diagram {
    position: relative;
    margin: 2rem 0;
    padding: 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    border: 2px solid var(--dill-green);
    display: flex;
    flex-direction: column;
    gap: 3rem;
}

.flow-phase {
    position: relative;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.7);
    border-radius: 10px;
    border: 1px solid rgba(91, 117, 83, 0.3);
}

.phase-title {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--dill-green);
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 0.75rem;
    border-bottom: 2px solid var(--dill-green);
}

.flow-step {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.flow-box {
    background: white;
    border: 2px solid var(--dill-green);
    border-radius: 10px;
    padding: 1.5rem;
    min-width: 280px;
    max-width: 320px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.flow-box:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.flow-icon {
    font-size: 2.5rem;
    text-align: center;
    margin-bottom: 0.5rem;
}

.flow-title {
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--dill-green);
    text-align: center;
    margin-bottom: 0.75rem;
}

.flow-library {
    background: var(--butter-yellow);
    color: var(--dark-gray);
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 0.75rem;
    display: inline-block;
    width: 100%;
}

.flow-content {
    font-size: 0.9rem;
    color: var(--dark-gray);
    text-align: center;
    line-height: 1.5;
}

.flow-arrow {
    text-align: center;
    font-size: 2rem;
    color: var(--dill-green);
    font-weight: bold;
    margin: 0.5rem 0;
}

.flow-box.storage {
    border-color: var(--aura-indigo);
}

.flow-box.storage .flow-title {
    color: var(--aura-indigo);
}

.flow-box.similarity {
    border-color: #9c27b0;
}

.flow-box.similarity .flow-title {
    color: #9c27b0;
}

.flow-box.similarity .flow-library {
    background: #e1bee7;
    color: #4a148c;
}

.flow-legend {
    margin-top: 2rem;
    padding: 1.5rem;
    background: white;
    border-radius: 8px;
    border: 1px solid var(--dill-green);
}

.flow-legend h5 {
    color: var(--dill-green);
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.flow-legend ul {
    margin: 0;
    padding-left: 1.5rem;
}

.flow-legend li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

/* Responsive design for flow diagram */
@media (max-width: 768px) {
    .rag-flow-diagram {
        padding: 1rem;
        gap: 2rem;
    }
    
    .flow-phase {
        padding: 1rem;
    }
    
    .flow-box {
        min-width: 100%;
        max-width: 100%;
    }
    
    .phase-title {
        font-size: 1rem;
    }
}

