/* lesson.css */

:root {
    --lesson-bg: #ffffff;
    --lesson-text: #212529;
    --lesson-sidebar-bg: #f8f9fa;
    --lesson-accent-color: #3182ce; /* A nice blue */
    --lesson-border-color: #dee2e6;
    --lesson-button-bg: #3182ce;
    --lesson-button-hover-bg: #2b6cb0; /* Darker blue */
    --lesson-disabled-bg: #cccccc;
    --button-secondary-bg: #6c757d;
    --button-secondary-hover-bg: #5a6268;
}

body.dark-mode {
    --lesson-bg: #0d1117; /* GitHub dark background */
    --lesson-text: #c9d1d9; /* GitHub dark text */
    --lesson-sidebar-bg: #161b22; /* GitHub dark sidebar */
    --lesson-accent-color: #58a6ff; /* GitHub dark blue accent */
    --lesson-border-color: #30363d;
    --lesson-button-bg: #238636; /* GitHub dark green button */
    --lesson-button-hover-bg: #2ea043;
    --lesson-disabled-bg: #555555;
    --button-secondary-bg: #30363d;
    --button-secondary-hover-bg: #484f58;
}

.lesson-container {
    display: flex;
    height: 100vh;
    width: 100%;
    font-family: 'Noto Sans SC', sans-serif;
    background-color: var(--lesson-bg);
    color: var(--lesson-text);
}

.lesson-sidebar {
    width: 65px; /* Significantly reduced width */
    background-color: var(--lesson-sidebar-bg);
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    border-right: 1px solid var(--lesson-border-color);
    transition: width 0.3s ease;
}

.lesson-sidebar h3 {
    color: var(--lesson-accent-color);
    margin-top: 0;
    border-bottom: 2px solid var(--lesson-accent-color);
    padding-bottom: 0.5rem;
}

.progress-bar-container {
    width: 8px; /* Vertical bar width */
    height: 60vh; /* Vertical bar height */
    background-color: var(--lesson-border-color);
    border-radius: 4px;
    display: flex;
    flex-direction: column-reverse; /* Fills from bottom to top */
}

.progress-bar {
    width: 100%;
    height: 0%; /* Initially no progress */
    background-color: var(--lesson-accent-color);
    border-radius: 4px;
    transition: height 0.4s ease-in-out; /* Animate height */
}

.progress-text {
    font-size: 0.9rem;
    margin-top: 1rem;
    font-weight: 500;
}

.back-to-menu {
    color: var(--lesson-text);
    margin-bottom: 2rem;
}

.back-to-menu svg {
    transition: transform 0.3s;
}

.back-to-menu:hover svg{
    transform: scale(1.1);
}

.lesson-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    padding: 3rem 4rem;
    overflow: hidden; /* Keep for animation control */
    position: relative; /* Needed for positioning context */
}

.slide-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    line-height: 1.8;
    font-size: 1.2rem;
    width: 100%;
    overflow-y: auto; /* Allow content to scroll if it's too long */
    padding-right: 15px; /* Prevent scrollbar from overlapping content */
}

.slide-content h1,
.slide-content h2,
.slide-content h3,
.slide-content p,
.slide-content ul {
    width: 100%;
    max-width: 800px; /* Constrain content width for readability */
}

.slide-content h1 {
    font-size: 2.5rem;
    color: var(--lesson-accent-color);
}

.slide-content h3 {
    margin-top: 2rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--lesson-border-color);
}

.slide-content ul {
    padding-left: 20px;
    list-style-type: disc;
}

.slide-content li {
    margin-bottom: 0.8rem;
}

.slide-content p {
    max-width: 800px;
}

.slide-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin-top: 1rem;
    max-height: 70vh;
    object-fit: contain;
}

.lesson-navigation {
    display: flex;
    justify-content: flex-end;
    padding-top: 2rem;
    border-top: 1px solid var(--lesson-border-color);
}

.lesson-nav-btn {
    background-color: var(--lesson-button-bg);
    color: white;
    border: none;
    padding: 0.8rem 1.5rem;
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.3s;
    margin-left: 1rem;
}

.lesson-nav-btn:hover {
    background-color: var(--lesson-button-hover-bg);
}

.lesson-nav-btn:disabled {
    background-color: var(--lesson-disabled-bg);
    cursor: not-allowed;
}

/* Modal styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--lesson-bg);
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    color: var(--lesson-text);
}

.modal-buttons {
    margin-top: 1.5rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.modal-buttons button {
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

#jump-yes {
    background-color: var(--lesson-button-bg);
    color: white;
}
#jump-yes:hover {
    background-color: var(--lesson-button-hover-bg);
}
#jump-no {
    background-color: var(--button-secondary-bg);
    color: white;
}
#jump-no:hover {
    background-color: var(--button-secondary-hover-bg);
}

/* Responsive */
@media (max-width: 768px) {
    .lesson-container {
        flex-direction: column;
        height: auto;
    }
    .lesson-sidebar {
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--lesson-border-color);
        flex-direction: row;
        align-items: center;
        padding: 0.5rem 1rem;
        justify-content: space-between;
    }
    .lesson-sidebar h3 {
        display: none;
    }
    .progress-bar-container {
        width: 60vw; /* Horizontal bar on mobile */
        height: 8px; /* Horizontal bar height */
        flex-direction: row; /* Fill from left to right */
    }
    .back-to-menu {
        margin-bottom: 0;
        margin-right: 1rem;
    }
    .progress-text {
        margin-top: 0;
    }
    .lesson-main {
        padding: 1.5rem;
    }
    .slide-content {
        font-size: 1rem;
    }
    .slide-content h1 {
        font-size: 1.8rem;
    }
}

@keyframes slide-in-up {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes slide-out-up {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(-30px);
        opacity: 0;
    }
}

.slide-in {
    animation: slide-in-up 0.5s forwards ease-out;
}

.slide-out {
    animation: slide-out-up 0.5s forwards ease-out;
}

/* Quiz Styles */
.quiz-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.quiz-question {
    font-size: 1.5rem;
    margin-bottom: 2rem;
    font-weight: 500;
}

.quiz-question code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
    background-color: rgba(var(--lesson-accent-color-rgb), 0.1);
    padding: 0.2rem 0.5rem;
    border-radius: 6px;
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    width: 100%;
    max-width: 600px;
    margin-bottom: 2rem;
}

.quiz-option-btn {
    background-color: var(--lesson-sidebar-bg);
    border: 2px solid var(--lesson-border-color);
    border-radius: 8px;
    padding: 1.2rem;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    color: var(--lesson-text);
}

.quiz-option-btn:not(:disabled):hover {
    transform: translateY(-3px);
    border-color: var(--lesson-accent-color);
}

.quiz-option-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}

.quiz-explanation {
    background-color: var(--lesson-sidebar-bg);
    border-left: 4px solid var(--lesson-accent-color);
    padding: 1rem 1.5rem;
    width: 100%;
    max-width: 800px;
    display: none; /* Initially hidden */
}

.quiz-explanation.visible {
    display: block;
    animation: slide-in-up 0.4s ease-out;
}

/* Animations for quiz answers */
@keyframes shake-horizontal {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes celebrate {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.quiz-option-btn.correct {
    background-color: #28a745; /* Green */
    color: white;
    border-color: #28a745;
    animation: celebrate 0.6s ease;
}

.quiz-option-btn.incorrect {
    background-color: #dc3545; /* Red */
    color: white;
    border-color: #dc3545;
    animation: shake-horizontal 0.5s ease-in-out;
}

/* Custom Confetti Animation */
#confetti-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    z-index: 100;
}

#confetti-container i {
    position: absolute;
    display: block;
    width: 8px;
    height: 16px;
    background: #f00; /* Will be overridden by JS */
    opacity: 0;
    animation: fall 3s linear infinite;
}

@keyframes fall {
    0% {
        transform: translateY(-100px) rotateZ(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotateZ(720deg);
        opacity: 0;
    }
}