/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg: #faf9f6;
    --surface: #ffffff;
    --text: #1a1a2e;
    --text-muted: #6b7280;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --accent: #f59e0b;
    --success: #10b981;
    --error: #ef4444;
    --border: #e5e7eb;
    --hebrew-size: 2rem;
    --sidebar-width: 280px;
    --radius: 12px;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    display: flex;
    min-height: 100vh;
    line-height: 1.6;
}

/* === Hebrew text === */
.heb {
    font-family: 'Frank Ruhl Libre', 'Noto Sans Hebrew', serif;
    direction: rtl;
    unicode-bidi: bidi-override;
    font-size: var(--hebrew-size);
    line-height: 1.8;
}

.heb-inline {
    font-family: 'Frank Ruhl Libre', serif;
    direction: rtl;
    unicode-bidi: bidi-override;
    font-size: 1.3em;
}

.heb-big {
    font-family: 'Frank Ruhl Libre', serif;
    direction: rtl;
    unicode-bidi: bidi-override;
    font-size: 4rem;
    font-weight: 700;
    line-height: 1.4;
}

/* === Sidebar === */
#sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 16px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 10;
}

.sidebar-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.sidebar-header .subtitle {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 2px;
}

.progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    margin: 16px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

#lessonNav {
    list-style: none;
}

#lessonNav li {
    margin: 2px 0;
}

#lessonNav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    transition: background 0.2s;
    cursor: pointer;
}

#lessonNav a:hover {
    background: #f3f4f6;
}

#lessonNav a.active {
    background: #eff6ff;
    color: var(--primary);
    font-weight: 600;
}

#lessonNav a .nav-status {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    flex-shrink: 0;
}

#lessonNav a .nav-status.completed {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

#lessonNav .nav-section {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 16px 12px 6px;
}

/* === Main content === */
main {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: 32px 48px;
    max-width: 840px;
}

.screen { display: none; }
.screen.active { display: block; }

/* === Hero === */
.hero {
    text-align: center;
    padding: 60px 0 40px;
}

.hero-hebrew {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 5rem;
    font-weight: 700;
    direction: rtl;
    color: var(--primary);
    margin-bottom: 16px;
}

.hero h2 {
    font-size: 2rem;
    margin-bottom: 12px;
}

.hero p {
    color: var(--text-muted);
    font-size: 1.1rem;
    margin-bottom: 32px;
}

/* === Features grid === */
.features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.feature {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    text-align: center;
}

.feature-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
    font-family: 'Frank Ruhl Libre', serif;
}

.feature h3 {
    font-size: 1rem;
    margin-bottom: 6px;
}

.feature p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* === Buttons === */
.btn {
    padding: 10px 24px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover { background: #f3f4f6; }

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-success {
    background: var(--success);
    color: white;
    border-color: var(--success);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.85rem;
}

/* === Lesson content === */
.lesson-container {
    max-width: 680px;
}

.lesson-container h2 {
    font-size: 1.75rem;
    margin-bottom: 8px;
}

.lesson-container h3 {
    font-size: 1.25rem;
    margin: 32px 0 12px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.lesson-container h3:first-of-type {
    border-top: none;
}

.lesson-container p {
    margin-bottom: 12px;
}

.lesson-goals {
    background: #eff6ff;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 16px 0 24px;
}

.lesson-goals h4 {
    color: var(--primary);
    margin-bottom: 8px;
}

.lesson-goals ul {
    margin-left: 20px;
    color: #1e40af;
}

/* Letter card */
.letter-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin: 16px 0;
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.letter-card .letter-display {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
    min-width: 80px;
    text-align: center;
    direction: rtl;
}

.letter-card .letter-info h4 {
    font-size: 1.1rem;
    margin-bottom: 4px;
}

.letter-card .letter-info .sound {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    padding: 2px 10px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.letter-card .letter-info .examples {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.letter-card .letter-info .examples .heb-inline {
    color: var(--text);
}

/* Word table */
.word-table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

.word-table th {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 2px solid var(--border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.word-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
}

.word-table .col-heb {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 1.5rem;
    direction: rtl;
    text-align: right;
}

.word-table tr:hover {
    background: #f9fafb;
}

/* Dialogue */
.dialogue {
    background: #f0fdf4;
    border-radius: var(--radius);
    padding: 20px;
    margin: 16px 0;
}

.dialogue-line {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    align-items: baseline;
}

.dialogue-line:last-child { margin-bottom: 0; }

.dialogue-speaker {
    font-weight: 600;
    color: var(--success);
    min-width: 24px;
}

.dialogue-hebrew {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 1.3rem;
    direction: rtl;
}

.dialogue-trans {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Cultural note */
.culture-note {
    background: #fef3c7;
    border-radius: var(--radius);
    padding: 16px 20px;
    margin: 20px 0;
    border-left: 4px solid var(--accent);
}

.culture-note h4 {
    color: #92400e;
    margin-bottom: 6px;
}

/* Lesson bottom nav */
.lesson-nav-bottom {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

/* === Exercises === */
.exercise-container {
    max-width: 680px;
}

.exercise-container h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.exercise-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}

.exercise-block h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
}

.exercise-item {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.exercise-item:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.exercise-question {
    margin-bottom: 10px;
    font-weight: 500;
}

.exercise-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.exercise-option {
    padding: 8px 18px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.exercise-option:hover {
    border-color: var(--primary);
    background: #eff6ff;
}

.exercise-option.correct {
    border-color: var(--success);
    background: #f0fdf4;
    color: #065f46;
}

.exercise-option.wrong {
    border-color: var(--error);
    background: #fef2f2;
    color: #991b1b;
}

.exercise-option.disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* Matching exercise */
.matching-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.match-item {
    padding: 12px 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.match-item:hover { border-color: var(--primary); }
.match-item.selected { border-color: var(--primary); background: #eff6ff; }
.match-item.matched { border-color: var(--success); background: #f0fdf4; pointer-events: none; }
.match-item.wrong-match { border-color: var(--error); background: #fef2f2; }

.match-item .heb-inline {
    font-size: 1.5em;
}

/* Fill in */
.fill-input {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    width: 200px;
    font-family: 'Frank Ruhl Libre', serif;
    direction: rtl;
    transition: border-color 0.2s;
}

.fill-input:focus {
    outline: none;
    border-color: var(--primary);
}

.fill-input.correct { border-color: var(--success); background: #f0fdf4; }
.fill-input.wrong { border-color: var(--error); background: #fef2f2; }

.exercise-feedback {
    margin-top: 8px;
    font-size: 0.9rem;
    font-weight: 500;
}

.exercise-feedback.correct { color: var(--success); }
.exercise-feedback.wrong { color: var(--error); }

.exercise-score {
    background: #eff6ff;
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    margin-top: 20px;
}

.exercise-score .score-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
}

/* === Quiz === */
.quiz-container {
    max-width: 680px;
}

.quiz-container h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.quiz-progress {
    display: flex;
    gap: 4px;
    margin: 16px 0 24px;
}

.quiz-dot {
    width: 32px;
    height: 6px;
    border-radius: 3px;
    background: var(--border);
    transition: background 0.3s;
}

.quiz-dot.current { background: var(--primary); }
.quiz-dot.correct { background: var(--success); }
.quiz-dot.wrong { background: var(--error); }

.quiz-question-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    text-align: center;
}

.quiz-prompt {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.quiz-hebrew {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 3.5rem;
    font-weight: 700;
    direction: rtl;
    margin-bottom: 24px;
    color: var(--text);
}

.quiz-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    max-width: 400px;
    margin: 0 auto;
}

.quiz-option {
    padding: 14px;
    border: 2px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.2s;
}

.quiz-option:hover { border-color: var(--primary); transform: translateY(-1px); }
.quiz-option.correct { border-color: var(--success); background: #f0fdf4; }
.quiz-option.wrong { border-color: var(--error); background: #fef2f2; }
.quiz-option.disabled { pointer-events: none; }

.quiz-result {
    text-align: center;
    padding: 40px;
}

.quiz-result .score-big {
    font-size: 4rem;
    font-weight: 700;
    color: var(--primary);
}

.quiz-result .score-label {
    color: var(--text-muted);
    margin-bottom: 24px;
}

/* === Flashcards === */
.flashcards-container {
    max-width: 680px;
}

.flashcards-container h2 {
    font-size: 1.5rem;
    margin-bottom: 20px;
}

.flashcard-counter {
    text-align: center;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.flashcard {
    perspective: 1000px;
    width: 100%;
    max-width: 420px;
    height: 280px;
    margin: 0 auto 24px;
    cursor: pointer;
}

.flashcard-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
    transform: rotateY(180deg);
}

.flashcard-front, .flashcard-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.flashcard-back {
    transform: rotateY(180deg);
    background: #eff6ff;
}

.flashcard-front .card-hebrew {
    font-family: 'Frank Ruhl Libre', serif;
    font-size: 4rem;
    font-weight: 700;
    direction: rtl;
    color: var(--primary);
}

.flashcard-front .card-hint {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 12px;
}

.flashcard-back .card-translit {
    font-size: 1.3rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.flashcard-back .card-meaning {
    font-size: 1.5rem;
    font-weight: 600;
}

.flashcard-controls {
    display: flex;
    justify-content: center;
    gap: 12px;
}

/* === Responsive === */
@media (max-width: 768px) {
    #sidebar {
        position: fixed;
        transform: translateX(-100%);
        transition: transform 0.3s;
        z-index: 100;
    }

    #sidebar.open { transform: translateX(0); }

    main {
        margin-left: 0;
        padding: 20px;
    }

    .hero-hebrew { font-size: 3.5rem; }
    .letter-card { flex-direction: column; }
    .quiz-options { grid-template-columns: 1fr; }
}
