/* ──────────────────────────────────────────
   Guided Lesson — interactive engine styles
   ────────────────────────────────────────── */

body {
    background: radial-gradient(circle at top, #1e1b4b, var(--background));
    min-height: 100vh;
    min-height: 100dvh;
}

.hidden { display: none !important; }
.mt-4 { margin-top: 1rem; }

.lesson-container {
    max-width: 580px;
    margin: 0 auto;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
    gap: 1rem;
}

/* ── Header ── */
.lesson-header {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.7rem 1rem;
    border-radius: var(--radius-full);
}
.btn-back {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    transition: color 0.2s;
}
.btn-back:hover { color: var(--text); }

.progress-bar-container {
    flex: 1;
    height: 9px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: 0%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--primary), var(--accent));
    transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.progress-text {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    min-width: 34px;
    text-align: right;
}

/* ── Slide area ── */
.slide-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.slide-card {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25);
    padding: 1.6rem 1.4rem;
}

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

.slide-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}
.slide-sub {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 1.1rem;
    margin-top: -0.3rem;
}
.slide-body { color: #cbd5e1; line-height: 1.6; font-size: 1.02rem; }
.slide-body p { margin-bottom: 0.75rem; }
.slide-body strong { color: var(--text); }
.slide-body .formula {
    text-align: center;
    font-size: 1.15rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-md);
    padding: 0.85rem;
    margin: 0.4rem 0 0.2rem;
}
.slide-body .formula strong { color: #c4b5fd; }

/* ── Intro ── */
.slide-intro { text-align: center; }
.slide-intro .slide-body { text-align: left; }
.intro-emoji {
    font-size: 3.2rem;
    margin-bottom: 0.4rem;
    line-height: 1;
}

/* ── Callout ── */
.callout {
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.16), rgba(6, 182, 212, 0.1));
    border: 1px solid rgba(139, 92, 246, 0.35);
    border-radius: var(--radius-md);
    padding: 0.9rem 1rem;
    margin-top: 1.2rem;
    text-align: left;
    line-height: 1.5;
    font-size: 0.95rem;
    color: #e2e8f0;
}
.callout-icon { font-size: 1.2rem; flex-shrink: 0; }
.callout strong { color: #fff; }

/* ── Flip cards ── */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
    gap: 0.7rem;
    margin-top: 0.4rem;
}
.flip-card {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    aspect-ratio: 3 / 4;
    perspective: 800px;
    -webkit-tap-highlight-color: transparent;
}
.flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.4, 0.2, 0.2, 1);
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    border-radius: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 4px;
}
.flip-front {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--surface-border);
}
.flip-digit { font-size: 1.7rem; font-weight: 800; }
.flip-tap { font-size: 0.62rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.1em; }
.flip-back {
    background: linear-gradient(160deg, var(--primary), var(--primary-hover));
    transform: rotateY(180deg);
    color: #fff;
}
.flip-kr { font-family: var(--font-kr); font-size: 1.6rem; font-weight: 800; line-height: 1.1; }
.flip-pron { font-size: 0.78rem; opacity: 0.92; }
.flip-hint { font-size: 0.62rem; opacity: 0.8; text-align: center; line-height: 1.2; margin-top: 1px; }
.proceed-hint { text-align: center; color: var(--text-muted); font-size: 0.82rem; margin-top: 1rem; }

/* ── Build ── */
.build-target { text-align: center; margin-bottom: 1.1rem; }
.build-target-num {
    display: block;
    font-size: 3rem;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.05;
}
.build-prompt { color: var(--text-muted); font-size: 0.92rem; }

.build-tray {
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    flex-wrap: wrap;
    border: 2px dashed var(--surface-border);
    border-radius: var(--radius-md);
    padding: 0.7rem;
    transition: border-color 0.25s, background 0.25s;
}
.build-tray.done { border-style: solid; border-color: var(--success); background: rgba(16, 185, 129, 0.08); }
.tray-placeholder { color: var(--text-muted); font-size: 0.85rem; }
.tray-chip {
    font-family: var(--font-kr);
    font-size: 1.5rem;
    font-weight: 800;
    padding: 0.2rem 0.7rem;
    border-radius: 10px;
    background: rgba(139, 92, 246, 0.25);
    border: 1px solid rgba(139, 92, 246, 0.5);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes popIn { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.piece-row {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.6rem;
    margin-top: 1.1rem;
}
.piece {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 78px;
    padding: 0.7rem 0.9rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.piece:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--primary); }
.piece-kr { font-family: var(--font-kr); font-size: 1.5rem; font-weight: 800; }
.piece-sub { font-size: 0.72rem; color: var(--text-muted); }
.piece.used { opacity: 0.35; cursor: default; }
.piece.shake { animation: shake 0.35s ease; }
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* ── Feedback line (build + quiz) ── */
.feedback {
    margin-top: 1.1rem;
    background: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.4);
    border-radius: var(--radius-md);
    padding: 0.8rem 1rem;
    color: #d1fae5;
    line-height: 1.5;
    font-size: 0.95rem;
    animation: slideIn 0.3s ease;
}
.feedback .tick, .recap-check { color: var(--success); font-weight: 800; }
.feedback strong { color: #fff; font-family: var(--font-kr); }

/* ── Match ── */
.match-wrap { display: flex; gap: 1rem; margin-top: 0.5rem; }
.match-col { flex: 1; display: flex; flex-direction: column; gap: 0.6rem; }
.match-item {
    padding: 0.85rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 1.25rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.match-item.kr { font-family: var(--font-kr); }
.match-item:hover:not(.matched) { border-color: var(--primary); }
.match-item.selected { border-color: var(--accent); background: rgba(6, 182, 212, 0.18); transform: scale(1.03); }
.match-item.matched {
    border-color: var(--success);
    background: rgba(16, 185, 129, 0.18);
    color: #6ee7b7;
    cursor: default;
}
.match-item.flash { animation: shake 0.35s ease; border-color: var(--error); }

/* ── Quiz ── */
.quiz-q { text-align: center; font-size: 1.35rem; }
.quiz-options { display: flex; flex-direction: column; gap: 0.7rem; margin-top: 0.4rem; }
.quiz-option {
    padding: 1rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--surface-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-family: var(--font-kr);
    font-size: 1.45rem;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s, border-color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.quiz-option:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--primary); }
.quiz-option.correct { border-color: var(--success); background: rgba(16, 185, 129, 0.22); color: #6ee7b7; }
.quiz-option.wrong { border-color: var(--error); background: rgba(239, 68, 68, 0.18); opacity: 0.85; animation: shake 0.35s ease; }
.quiz-option:disabled { cursor: default; }

/* ── Recap ── */
.slide-recap { text-align: center; }
.recap-check {
    width: 54px; height: 54px;
    margin: 0 auto 0.6rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.8rem; font-weight: 800;
    border-radius: 50%;
    background: rgba(16, 185, 129, 0.18);
    border: 2px solid var(--success);
    color: var(--success);
}
.recap-table {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.5rem;
    margin: 1rem 0;
}
.recap-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--surface-border);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.4rem;
}
.recap-digit { font-weight: 800; color: var(--accent); min-width: 2.4em; text-align: right; }
.recap-kr { font-family: var(--font-kr); font-weight: 700; font-size: 1.1rem; }
.recap-pron { color: var(--text-muted); font-size: 0.78rem; }
.slide-recap .callout { text-align: left; }

/* ── Footer button ── */
.lesson-footer { padding: 0.75rem; border-radius: var(--radius-lg); }
.lesson-btn {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-ui);
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    background: rgba(255, 255, 255, 0.08);
    cursor: not-allowed;
    transition: background 0.2s, transform 0.15s, box-shadow 0.2s;
}
.lesson-btn.ready {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
}
.lesson-btn.ready:hover { transform: translateY(-2px); }
.lesson-btn.ready:active { transform: translateY(0); }
.lesson-btn:disabled { opacity: 0.55; }

/* ── Completion ── */
.completion-screen {
    text-align: center;
    padding: 2.5rem 1.5rem;
    border-radius: var(--radius-lg);
    animation: slideIn 0.4s ease;
}
.completion-icon { font-size: 4.5rem; margin-bottom: 0.5rem; }
.completion-screen h2 { font-size: 1.7rem; margin-bottom: 0.4rem; }
.completion-screen p { color: var(--text-muted); margin-bottom: 0.5rem; }

@media (max-width: 420px) {
    .slide-card { padding: 1.3rem 1.1rem; }
    .slide-title { font-size: 1.3rem; }
    .quiz-option { font-size: 1.3rem; }
    .card-grid { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); }
}
