/* AI Learning Platform — bright modern theme. RTL Hebrew. */

:root {
    --bg: #fafbfc;
    --bg-elevated: #ffffff;
    --bg-subtle: #f4f5f7;
    --bg-tinted: #f8f5ff;
    --border: #e8eaed;
    --border-strong: #d0d5dc;
    --text: #1a1d29;
    --text-dim: #5b6478;
    --text-faint: #8b94a7;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-soft: #eef2ff;
    --accent: #10b981;
    --accent-soft: #d1fae5;
    --warning: #f59e0b;
    --warning-soft: #fef3c7;
    --error: #ef4444;
    --error-soft: #fee2e2;
    --info: #3b82f6;
    --info-soft: #dbeafe;
    --pink: #ec4899;
    --pink-soft: #fce7f3;
    --orange: #fb923c;

    --gradient-1: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-2: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-3: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    --gradient-hero: linear-gradient(135deg, #6366f1 0%, #ec4899 50%, #f59e0b 100%);

    --radius-sm: 8px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 3px rgba(15,23,42,0.06), 0 1px 2px rgba(15,23,42,0.04);
    --shadow: 0 4px 6px rgba(15,23,42,0.07), 0 2px 4px rgba(15,23,42,0.06);
    --shadow-lg: 0 12px 24px rgba(15,23,42,0.08), 0 4px 8px rgba(15,23,42,0.04);
    --shadow-xl: 0 24px 48px rgba(15,23,42,0.12);

    --font-body: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    direction: rtl;
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    min-height: 100vh;
    font-feature-settings: "kern", "liga";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--primary); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--primary-hover); }

/* ─── Auth (login) page ──────────────────────────────────────── */
.auth-page {
    background:
        radial-gradient(circle at 20% 20%, rgba(99,102,241,0.08) 0%, transparent 40%),
        radial-gradient(circle at 80% 80%, rgba(236,72,153,0.08) 0%, transparent 40%),
        var(--bg);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-container { width: 100%; max-width: 460px; }

.auth-card {
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    padding: 48px 40px;
    box-shadow: var(--shadow-xl);
    border: 1px solid var(--border);
}

.auth-brand { text-align: center; margin-bottom: 36px; }
.auth-logo {
    width: 72px; height: 72px;
    border-radius: 20px;
    background: var(--gradient-hero);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 38px;
    margin-bottom: 16px;
    box-shadow: 0 8px 24px rgba(99,102,241,0.3);
}
.auth-brand h1 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
    color: var(--text);
    letter-spacing: -0.02em;
}
.auth-subtitle { color: var(--text-dim); font-size: 15px; }

.auth-form { display: flex; flex-direction: column; gap: 18px; }
.auth-form label {
    display: flex; flex-direction: column; gap: 8px;
    font-size: 13px; color: var(--text-dim); font-weight: 500;
}
.auth-form input {
    background: var(--bg-elevated);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 13px 16px;
    color: var(--text);
    font-size: 15px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}

.btn-primary, .btn-secondary {
    border: none;
    border-radius: var(--radius-sm);
    padding: 13px 24px;
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.15s;
}
.btn-primary {
    background: var(--gradient-hero);
    color: white;
    margin-top: 12px;
    box-shadow: 0 4px 14px rgba(99,102,241,0.35);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(99,102,241,0.45); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
    background: var(--bg-subtle);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-elevated); border-color: var(--primary); }

.auth-footer {
    text-align: center;
    margin-top: 28px;
    color: var(--text-faint);
    font-size: 13px;
}

.alert {
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    margin-bottom: 18px;
    font-size: 14px;
    font-weight: 500;
}
.alert-error { background: var(--error-soft); border: 1px solid #fecaca; color: #b91c1c; }
.alert-info { background: var(--info-soft); border: 1px solid #bfdbfe; color: #1e40af; }
.alert-success { background: var(--accent-soft); border: 1px solid #a7f3d0; color: #047857; }

/* ─── Dashboard / chapter list ─────────────────────────────── */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 16px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(12px);
    background: rgba(255,255,255,0.85);
}
.app-header h1 {
    font-size: 19px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}
.app-header h1 a { color: inherit; }
.app-header nav { display: flex; gap: 20px; align-items: center; }
.app-header nav a { color: var(--text-dim); font-size: 14px; font-weight: 500; }
.app-header nav a:hover { color: var(--primary); text-decoration: none; }
.user-name {
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    padding: 6px 14px;
    background: var(--primary-soft);
    border-radius: 999px;
}

.app-main {
    flex: 1;
    max-width: 1180px;
    margin: 0 auto;
    padding: 40px 28px;
    width: 100%;
}

.welcome-block {
    margin-bottom: 36px;
    padding: 36px 40px;
    background: linear-gradient(135deg, var(--primary-soft) 0%, var(--pink-soft) 100%);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}
.welcome-block::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -20%;
    width: 60%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.5) 0%, transparent 70%);
    pointer-events: none;
}
.welcome-block h2 {
    font-size: 28px;
    margin-bottom: 10px;
    color: var(--text);
    font-weight: 800;
    letter-spacing: -0.02em;
    position: relative;
}
.welcome-block p { color: var(--text-dim); font-size: 16px; position: relative; }

.progress-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}
.stat-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card .stat-value {
    font-size: 36px;
    font-weight: 800;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.03em;
}
.stat-card .stat-label {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 6px;
    font-weight: 500;
}

.chapters-list { display: flex; flex-direction: column; gap: 12px; }

.app-main h2 {
    font-size: 22px;
    margin-bottom: 18px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.01em;
}

.chapter-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 22px 26px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
    box-shadow: var(--shadow-sm);
}
.chapter-card:hover {
    border-color: var(--primary);
    transform: translateX(-4px);
    box-shadow: var(--shadow);
}
.chapter-info { flex: 1; }
.chapter-number {
    font-family: var(--font-mono);
    color: var(--text-faint);
    font-size: 11px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}
.chapter-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
    color: var(--text);
}
.chapter-summary { color: var(--text-dim); font-size: 14px; line-height: 1.5; }
.chapter-meta {
    display: flex;
    gap: 18px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-faint);
}
.chapter-status {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    margin-right: 18px;
}
.status-icon {
    width: 38px; height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 17px;
    font-weight: 700;
    transition: transform 0.15s;
}
.status-icon.completed { background: var(--accent); color: white; box-shadow: 0 2px 8px rgba(16,185,129,0.3); }
.status-icon.in_progress { background: var(--warning); color: white; box-shadow: 0 2px 8px rgba(245,158,11,0.3); }
.status-icon.not_started { background: var(--bg-subtle); color: var(--text-faint); border: 1.5px dashed var(--border-strong); }

/* ─── Chapter view ─────────────────────────────────────────── */
.chapter-view {
    max-width: 820px;
    margin: 0 auto;
    padding: 48px 32px 100px;
}
.chapter-view > .chapter-number { font-size: 12px; margin-bottom: 12px; }

.hero-illustration {
    position: relative;
    width: 100%;
    height: 220px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 12px 32px rgba(15,23,42,0.12);
}
.hero-illustration svg.hero-pattern {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0.6;
}
.hero-emoji {
    position: relative;
    font-size: 96px;
    z-index: 2;
    filter: drop-shadow(0 6px 20px rgba(0,0,0,0.18));
    animation: heroFloat 5s ease-in-out infinite;
}
@keyframes heroFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    50% { transform: translateY(-10px) rotate(2deg); }
}

.chapter-view h1 {
    font-size: 38px;
    margin-bottom: 12px;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.2;
}
.chapter-view h2 {
    font-size: 24px;
    margin: 40px 0 14px;
    color: var(--text);
    font-weight: 700;
    letter-spacing: -0.01em;
}
.chapter-view h3 {
    font-size: 19px;
    margin: 28px 0 10px;
    color: var(--text);
    font-weight: 600;
}
.chapter-view p { margin-bottom: 18px; color: var(--text); font-size: 16px; line-height: 1.75; }
.chapter-view ul, .chapter-view ol { margin-bottom: 18px; padding-right: 28px; }
.chapter-view li { margin-bottom: 8px; color: var(--text); }

.chapter-view .lead {
    font-size: 18px;
    color: var(--text-dim);
    margin-bottom: 28px;
    padding: 18px 22px;
    background: var(--bg-tinted);
    border-right: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    line-height: 1.65;
}

.chapter-view img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 20px 0;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.chapter-view video {
    width: 100%;
    max-width: 100%;
    border-radius: var(--radius);
    margin: 20px 0;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    background: var(--bg-subtle);
}

.chapter-view figure {
    margin: 28px 0;
    text-align: center;
}
.chapter-view figcaption {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 10px;
    font-style: italic;
}

.callout {
    padding: 18px 22px;
    border-radius: var(--radius);
    margin: 24px 0;
    border-right: 4px solid;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-sm);
}
.callout-tip { background: var(--accent-soft); border-color: var(--accent); }
.callout-warn { background: var(--warning-soft); border-color: var(--warning); }
.callout-info { background: var(--info-soft); border-color: var(--info); }
.callout-analogy { background: var(--pink-soft); border-color: var(--pink); }
.callout-title { font-weight: 700; margin-bottom: 8px; font-size: 15px; }
.callout p { margin-bottom: 0; }

.chapter-view code {
    font-family: var(--font-mono);
    background: var(--bg-subtle);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.88em;
    direction: ltr;
    display: inline-block;
    color: var(--primary-hover);
    border: 1px solid var(--border);
}
.chapter-view pre {
    background: #1e293b;
    border-radius: var(--radius);
    padding: 20px 24px;
    overflow-x: auto;
    direction: ltr;
    text-align: left;
    margin: 20px 0;
    box-shadow: var(--shadow);
}
.chapter-view pre code {
    background: none;
    padding: 0;
    font-size: 13.5px;
    line-height: 1.6;
    color: #e2e8f0;
    border: none;
}

.chapter-view table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}
.chapter-view table th, .chapter-view table td {
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    text-align: right;
}
.chapter-view table th {
    background: var(--bg-subtle);
    font-weight: 700;
    color: var(--text);
}
.chapter-view table tr:last-child td { border-bottom: none; }
.chapter-view table tr:hover { background: var(--bg-subtle); }

/* ─── Quiz ─────────────────────────────────────────────────── */
.quiz-section {
    margin-top: 56px;
    padding: 32px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.quiz-section h2 { margin-top: 0; }
.quiz-question {
    margin-bottom: 24px;
    padding: 22px;
    background: var(--bg-subtle);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.quiz-question .q-text {
    font-weight: 600; margin-bottom: 14px;
    font-size: 16px;
    color: var(--text);
}
.quiz-options { display: flex; flex-direction: column; gap: 10px; }
.quiz-option {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    align-items: flex-start;
}
.quiz-option:hover { border-color: var(--primary); background: var(--primary-soft); }
.quiz-option input[type="radio"] {
    margin-top: 4px;
    accent-color: var(--primary);
    width: 18px; height: 18px;
}
.quiz-option.correct { background: var(--accent-soft); border-color: var(--accent); }
.quiz-option.wrong { background: var(--error-soft); border-color: var(--error); }

.quiz-feedback {
    margin-top: 16px;
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
}
.quiz-feedback.correct { background: var(--accent-soft); border: 1px solid var(--accent); color: #047857; }
.quiz-feedback.wrong { background: var(--error-soft); border: 1px solid var(--error); color: #b91c1c; }

.quiz-results {
    text-align: center;
    padding: 40px;
    background: linear-gradient(135deg, var(--primary-soft) 0%, var(--pink-soft) 100%);
    border-radius: var(--radius-lg);
    margin-top: 32px;
    border: 1px solid var(--border);
}
.quiz-results .score-big {
    font-size: 64px;
    font-weight: 900;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.04em;
    line-height: 1;
}
.quiz-results .score-label { color: var(--text-dim); margin-top: 12px; font-size: 16px; font-weight: 500; }

.chapter-nav {
    display: flex;
    justify-content: space-between;
    margin-top: 56px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}
.chapter-nav a {
    padding: 14px 22px;
    background: var(--bg-elevated);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-weight: 500;
    transition: all 0.15s;
    box-shadow: var(--shadow-sm);
}
.chapter-nav a:hover {
    border-color: var(--primary);
    color: var(--primary);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* ─── Mobile ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    .app-header { padding: 14px 18px; flex-wrap: wrap; gap: 10px; }
    .app-main, .chapter-view { padding: 24px 18px 80px; }
    .chapter-view h1 { font-size: 28px; }
    .chapter-card { flex-direction: column-reverse; align-items: stretch; gap: 14px; }
    .chapter-status { flex-direction: row; justify-content: flex-start; }
    .auth-card { padding: 32px 24px; }
    .welcome-block { padding: 28px 24px; }
    .welcome-block h2 { font-size: 22px; }
    .quiz-section { padding: 22px; }
}
