/* ── Lesson page layout ──────────────────────────────────────── */

html {
    scroll-behavior: smooth;
}

.lesson-layout {
    display: flex;
    gap: 32px;
    align-items: flex-start;
    padding: 32px 0 80px;
}

/* ── Sidebar ─────────────────────────────────────────────────── */

.lesson-sidebar {
    width: 160px;
    flex-shrink: 0;
    position: sticky;
    top: 24px;
    padding-right: 16px;
    border-right: 1px solid var(--color-border);
}

.lesson-sidebar-title {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-text-muted);
    margin: 0 0 14px;
}

/* ── Progress bar steps ──────────────────────────────────────── */

.lesson-progress-bar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.lesson-step {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    padding: 2px 0;
    transition: color 0.15s;
    width: 100%;
}
.lesson-step:hover { text-decoration: none; }

.lesson-step-dot {
    width: 26px;
    height: 26px;
    flex-shrink: 0;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-border);
    background: var(--color-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--color-text-muted);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.lesson-step:hover .lesson-step-dot {
    border-color: var(--color-action);
    color: var(--color-action);
}

.lesson-step-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    min-width: 0;
    transition: color 0.15s;
}

.lesson-step:hover .lesson-step-label { color: var(--color-action); }

/* active step — set by JS via IntersectionObserver */
.lesson-step--active .lesson-step-dot {
    background: var(--color-action-gradient);
    border-color: transparent;
    color: #fff;
}
.lesson-step--active .lesson-step-label {
    color: var(--color-action);
    font-weight: 600;
}

/* completed step — set by JS */
.lesson-step--done .lesson-step-dot {
    background: var(--color-action);
    border-color: var(--color-action);
    color: #fff;
}
.lesson-step--done .lesson-step-label {
    color: var(--color-action);
}

.lesson-step-connector {
    position: relative;
    width: 2px;
    height: 18px;
    background: var(--color-border);
    margin-left: 12px; /* aligns with centre of the 26px dot */
    overflow: hidden;
}

/* animated fill travelling top → bottom */
.lesson-step-connector::after {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--color-action);
    transform: scaleY(0);
    transform-origin: top;
    transition: transform 0.35s ease;
}

.lesson-step-connector--done::after {
    transform: scaleY(1);
}

/* ── Main content column ─────────────────────────────────────── */

.lesson-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* ── Lesson header ───────────────────────────────────────────── */

.lesson-header {
    margin-bottom: 4px;
}

.lesson-header-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 10px;
}

.lesson-breadcrumb-link {
    display: inline-block;
    font-size: 0.83rem;
    color: var(--color-text-muted);
    text-decoration: none;
    transition: color 0.15s;
}
.lesson-breadcrumb-link:hover { color: var(--color-action); text-decoration: none; }

.lesson-btn-restart {
    font-size: 0.83rem;
    color: var(--color-text-muted);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: color 0.15s;
}
.lesson-btn-restart:hover { color: var(--color-action); }

.lesson-title {
    font-size: 1.9rem;
    font-weight: 800;
    color: var(--color-text-dark);
    margin: 0 0 6px;
    line-height: 1.2;
}

.lesson-subtitle {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    margin: 0;
}

/* locked step (not yet reached) */
.lesson-step--locked {
    pointer-events: none;
    opacity: 0.38;
}

/* ── Section reveal ──────────────────────────────────────────── */

.lesson-section--hidden {
    display: none;
}

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

.lesson-section--reveal {
    animation: sectionReveal 0.35s ease forwards;
}

/* ── Section cards ───────────────────────────────────────────── */

.lesson-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 32px 36px;
    box-shadow: var(--shadow-sm);
    scroll-margin-top: 80px;
}

.lesson-section-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 20px;
}

.lesson-section-number {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: var(--radius-full);
    background: var(--color-action-gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.30);
}

.lesson-section-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text-dark);
    margin: 0;
    line-height: 1.3;
}

.lesson-section-body {
    color: var(--color-text-dark);
    line-height: 1.75;
    margin-bottom: 28px;
}

.lesson-section-body p { margin-bottom: 12px; }
.lesson-section-body p:last-child { margin-bottom: 0; }

.lesson-section-footer {
    display: flex;
    justify-content: center;
    padding-top: 18px;
    border-top: 1px solid var(--color-border);
}

/* ── Conditional next button ─────────────────────────────────── */

.lesson-btn-next--locked,
.lesson-btn-finish--locked {
    display: none !important;
}

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

.lesson-btn-next--unlocked,
.lesson-btn-finish--unlocked {
    display: inline-block;
    animation: lessonBtnReveal 0.35s ease both;
}

/* ── Navigation buttons ──────────────────────────────────────── */

.lesson-btn-next,
.lesson-btn-finish {
    display: inline-block;
    padding: 10px 28px;
    border-radius: var(--radius);
    background: var(--color-action-gradient);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
    text-decoration: none;
    letter-spacing: 0.02em;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.30);
    transition: box-shadow 0.15s, transform 0.1s;
}

.lesson-btn-next:hover,
.lesson-btn-finish:hover {
    color: #fff;
    text-decoration: none;
    box-shadow: 0 6px 18px rgba(16, 185, 129, 0.42);
    transform: translateY(-1px);
}

.lesson-btn-next:active,
.lesson-btn-finish:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.30);
}

/* ── Mobile ──────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .lesson-layout {
        flex-direction: column;
        gap: 0;
        padding-top: 20px;
    }

    .lesson-sidebar {
        width: 100%;
        position: static;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
        padding: 0 0 16px;
        margin-bottom: 24px;
    }

    .lesson-progress-bar {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;
    }

    .lesson-step-connector {
        width: 14px;
        height: 2px;
        margin-left: 0;
    }

    .lesson-step-connector::after {
        transform: scaleX(0);
        transform-origin: left;
    }

    .lesson-step-connector--done::after {
        transform: scaleX(1);
    }

    .lesson-step-label { display: none; }

    .lesson-step-dot {
        width: 24px;
        height: 24px;
        font-size: 0.62rem;
    }

    .lesson-section {
        padding: 22px 20px;
    }
}

/* ── Completion modal ─────────────────────────────────────────── */

.lc-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}

.lc-overlay[hidden] { display: none; }

.lc-modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg, 16px);
    padding: 36px 32px;
    max-width: 420px;
    width: 100%;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0,0,0,0.25);
    animation: lcModalIn 0.3s ease both;
}

@keyframes lcModalIn {
    from { opacity: 0; transform: translateY(20px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.lc-confetti {
    font-size: 2.8rem;
    margin-bottom: 10px;
}

.lc-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-text-dark);
    margin: 0 0 8px;
}

.lc-score {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-action);
    margin-bottom: 24px;
    min-height: 1.4em;
}

.lc-rate-label {
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.lc-stars {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-bottom: 24px;
}

.lc-star {
    background: none;
    border: none;
    font-size: 2.2rem;
    color: var(--color-border);
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.1s, transform 0.1s;
}

.lc-star--hover,
.lc-star--active {
    color: #f59e0b;
}

.lc-star:hover { transform: scale(1.15); }

.lc-confirm-btn {
    display: inline-block;
    padding: 11px 36px;
    border-radius: var(--radius);
    background: var(--color-action-gradient);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(16,185,129,0.30);
    transition: opacity 0.15s, box-shadow 0.15s, transform 0.1s;
}

.lc-confirm-btn:disabled {
    opacity: 0.4;
    cursor: default;
    box-shadow: none;
}

.lc-confirm-btn:not(:disabled):hover {
    box-shadow: 0 6px 18px rgba(16,185,129,0.42);
    transform: translateY(-1px);
}

/* ── Rating badge on course cards ─────────────────────────────── */

.subject-card-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}

.subject-rating {
    font-size: 0.8rem;
    font-weight: 700;
    color: #f59e0b;
    white-space: nowrap;
}
