/* ─── Lesson Player — Duolingo-style step-by-step ─ */

/* ── Page lock when player is active ──────────────── */
body.lp-active {
    overflow: hidden;
    height: 100vh;
    height: 100dvh;
}

body.lp-active > main {
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* Hide footer in player mode */
body.lp-active > footer {
    display: none;
}

/* ── Player shell — fills remaining space via flex ── */
.lp-shell {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

@media (min-width: 1024px) {
    .lp-shell {
        flex-direction: row;
    }
}

/* ── Desktop sidebar ──────────────────────────────── */
.lp-sidebar {
    display: none;
}

@media (min-width: 1024px) {
    .lp-sidebar {
        display: flex;
        flex-direction: column;
        width: 280px;
        flex-shrink: 0;
        border-right: 1px solid #e5e7eb;
        overflow-y: auto;
        background: #fff;
    }
}

/* ── Main player area ─────────────────────────────── */
.lp-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

/* ── Top bar: back + title + progress ─────────────── */
.lp-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
    z-index: 10;
    min-height: 48px;
}

.lp-topbar__info {
    flex: 1;
    min-width: 0;
}

.lp-topbar__module {
    font-size: 10px;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.lp-topbar__title {
    font-size: 13px;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.lp-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.lp-progress__bar {
    width: 60px;
    height: 6px;
    background: #e5e7eb;
    border-radius: 3px;
    overflow: hidden;
}

.lp-progress__fill {
    height: 100%;
    background: #6366f1;
    border-radius: 3px;
    transition: width 0.5s ease;
    min-width: 0;
}

.lp-progress__fill--done {
    background: #22c55e;
}

.lp-progress__text {
    font-size: 11px;
    font-weight: 700;
    color: #6b7280;
    white-space: nowrap;
}

.lp-progress__xp {
    font-size: 11px;
    font-weight: 800;
    color: #6366f1;
    white-space: nowrap;
}

@media (min-width: 768px) {
    .lp-topbar { padding: 10px 16px; gap: 12px; }
    .lp-topbar__title { font-size: 15px; }
    .lp-topbar__module { font-size: 11px; }
    .lp-progress__bar { width: 100px; height: 7px; }
    .lp-progress__text { font-size: 12px; }
    .lp-progress__xp { font-size: 12px; }
}

@media (min-width: 1024px) {
    .lp-progress__bar { width: 140px; }
    .lp-topbar__title { font-size: 16px; }
}

/* Hide lesson header when player wraps the steps */
body.lp-active .lp-lesson-header {
    display: none;
}

/* Content containers fill height in player mode */
body.lp-active #lessonContent {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

body.lp-active #lessonBody {
    display: flex !important;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ── Step viewport — contains all slides ──────────── */
.lp-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f3f4f6;
    min-height: 0;
}

/* ── Individual step slide ────────────────────────── */
.lp-step {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, opacity;
}

.lp-step--active {
    transform: translateX(0);
    opacity: 1;
    z-index: 2;
}

.lp-step--left {
    transform: translateX(-100%);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}

.lp-step--right {
    transform: translateX(100%);
    opacity: 0;
    z-index: 1;
    pointer-events: none;
}

.lp-step--no-transition {
    transition: none !important;
}

@media (min-width: 768px) {
    .lp-step { padding: 20px; }
}

@media (min-width: 1024px) {
    .lp-step { padding: 24px 32px; }
}

/* ── Step card styling ────────────────────────────── */
.lp-step .step-block {
    max-width: 680px;
    margin: 0 auto;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    overflow: hidden;
}

/* Increase font size for readability */
.lp-step .step-body {
    font-size: 15px;
    line-height: 1.7;
    padding: 16px;
}

.lp-step .step-body .prose {
    font-size: inherit;
    line-height: inherit;
}

.lp-step .step-body .prose p {
    margin-bottom: 0.9em;
}

/* Bigger action buttons inside player */
.lp-step .step-complete-btn {
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    border-radius: 12px;
}

/* Quiz options bigger */
.lp-step .quiz-option {
    padding: 14px 16px;
    font-size: 15px;
    border-radius: 14px;
    border-width: 2px;
}

/* AI simulator inside player — stretch to fill */
.lp-step .ai-sim {
    max-height: none;
    border: none;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.lp-step .ai-sim__output {
    min-height: 120px;
    max-height: 260px;
}

.lp-step .ai-sim__textarea {
    font-size: 14px;
    padding: 12px 14px;
}

@media (min-width: 768px) {
    .lp-step .step-body { padding: 20px; font-size: 16px; }
    .lp-step .ai-sim__output { max-height: 340px; }
    .lp-step .quiz-option { padding: 16px 18px; }
}

/* ── Bottom navigation bar: [← Back] [dots] [Next →] ── */
.lp-navbar {
    display: flex;
    align-items: center;
    padding: 8px 8px;
    padding-bottom: max(8px, env(safe-area-inset-bottom, 8px));
    background: #fff;
    border-top: 1px solid #e5e7eb;
    flex-shrink: 0;
    gap: 4px;
}

.lp-navbar__btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 12px;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    background: transparent;
    color: #6b7280;
    transition: all 0.2s;
    flex-shrink: 0;
    font-family: inherit;
    white-space: nowrap;
}

.lp-navbar__btn:hover:not(:disabled) {
    background: #f3f4f6;
    color: #374151;
}

.lp-navbar__btn:disabled {
    opacity: 0.3;
    cursor: default;
}

.lp-navbar__btn--next {
    background: #4f46e5;
    color: #fff;
}

.lp-navbar__btn--next:hover:not(:disabled) {
    background: #4338ca;
    color: #fff;
}

.lp-navbar__btn--next:disabled {
    background: #e5e7eb;
    color: #9ca3af;
    opacity: 1;
}

/* Dots in center */
.lp-navbar__dots {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-width: 0;
    overflow: hidden;
    padding: 0 4px;
}

.lp-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5db;
    transition: all 0.3s ease;
    flex-shrink: 0;
    cursor: pointer;
    border: none;
    padding: 0;
}

.lp-dot:hover {
    background: #9ca3af;
}

.lp-dot--active {
    width: 20px;
    border-radius: 4px;
    background: #6366f1;
}

.lp-dot--active:hover {
    background: #6366f1;
}

.lp-dot--completed {
    background: #22c55e;
}

.lp-dot--completed:hover {
    background: #16a34a;
}

.lp-dot--locked {
    cursor: default;
    opacity: 0.5;
}

.lp-dot--locked:hover {
    background: #d1d5db;
}

/* Many dots: shrink */
.lp-navbar__dots--many .lp-dot {
    width: 6px;
    height: 6px;
}
.lp-navbar__dots--many .lp-dot--active {
    width: 14px;
}

/* ── Mobile bottom sheet ──────────────────────────── */

/* Lessons button — outlined style so it looks like a real button */
.lp-navbar__lessons {
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    color: #374151;
    padding: 6px 10px;
    font-size: 12px;
}

.lp-navbar__lessons:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
    color: #111827;
}

/* Hidden on desktop — sidebar is visible there */
@media (min-width: 1024px) {
    .lp-navbar__lessons { display: none !important; }
}

/* Legacy floating trigger — no longer used but kept for safety */
.lp-sheet-trigger {
    display: none !important;
}

/* Backdrop */
.lp-sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: rgba(0, 0, 0, 0);
    pointer-events: none;
    transition: background 0.3s ease;
}

.lp-sheet-backdrop--visible {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
}

/* Sheet panel */
.lp-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 51;
    background: #fff;
    border-radius: 20px 20px 0 0;
    max-height: 75vh;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.12);
}

.lp-sheet--open {
    transform: translateY(0);
}

.lp-sheet__handle {
    width: 36px;
    height: 4px;
    border-radius: 2px;
    background: #d1d5db;
    margin: 10px auto 0;
    flex-shrink: 0;
}

.lp-sheet__header {
    padding: 12px 20px 10px;
    border-bottom: 1px solid #f3f4f6;
    flex-shrink: 0;
}

.lp-sheet__body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0;
    padding-bottom: env(safe-area-inset-bottom, 16px);
}

/* Lesson items inside sheet */
.lp-sheet__body .module-group {
    padding: 0 12px;
}

.lp-sheet__body .lesson-btn {
    padding: 10px 14px;
    font-size: 14px;
}

@media (min-width: 1024px) {
    .lp-sheet-backdrop,
    .lp-sheet { display: none !important; }
}

/* ── Completion screen ────────────────────────────── */
.lp-complete {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    min-height: 100%;
    position: relative;
}

.lp-complete__icon {
    font-size: 56px;
    margin-bottom: 12px;
    animation: lp-celebrate 0.6s ease-out;
}

@keyframes lp-celebrate {
    0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(5deg); }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.lp-complete__title {
    font-size: 22px;
    font-weight: 800;
    color: #111827;
    margin-bottom: 6px;
}

.lp-complete__subtitle {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 20px;
}

.lp-complete__stats {
    display: flex;
    gap: 16px;
    margin: 0 0 24px;
    padding: 16px 24px;
    background: #f9fafb;
    border-radius: 16px;
    border: 1px solid #e5e7eb;
}

.lp-complete__stat {
    text-align: center;
    min-width: 60px;
}

.lp-complete__stat-value {
    font-size: 22px;
    font-weight: 800;
    color: #6366f1;
    line-height: 1.2;
}

.lp-complete__stat-value--green {
    color: #22c55e;
}

.lp-complete__stat-label {
    font-size: 11px;
    color: #6b7280;
    margin-top: 2px;
    font-weight: 500;
}

.lp-complete__actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    max-width: 280px;
}

.lp-complete__btn-primary {
    padding: 14px 24px;
    background: #4f46e5;
    color: #fff;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.lp-complete__btn-primary:hover {
    background: #4338ca;
}

.lp-complete__btn-secondary {
    padding: 12px 24px;
    background: transparent;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

.lp-complete__btn-secondary:hover {
    background: #f9fafb;
}

/* Confetti */
.lp-confetti {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}

.lp-confetti__piece {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 2px;
    top: -12px;
    animation: lp-confetti-fall 2.8s ease-in forwards;
}

@keyframes lp-confetti-fall {
    0%   { transform: translateY(0) rotate(0deg) scale(1); opacity: 1; }
    80%  { opacity: 1; }
    100% { transform: translateY(calc(100vh)) rotate(720deg) scale(0.5); opacity: 0; }
}

/* ── Empty state in player mode ───────────────────── */
.lp-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px 20px;
    height: 100%;
    color: #6b7280;
}

.lp-empty__icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.lp-empty__text {
    font-size: 15px;
    font-weight: 500;
}
