/* ==========================================
   جوابي — ملف CSS موحد (كل شيء في مكان واحد)
   ========================================== */

/* === المتغيرات === */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --primary-dark: #1d4ed8;
  --secondary: #0ea5e9;
  --accent: #f59e0b;
  --accent-light: #fbbf24;
  --bg-dark: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --border: #334155;
  --shadow-lg: 0 10px 25px -3px rgba(0,0,0,0.3);
  --radius: 12px;

  /* === ألوان الصفحة الرئيسية (الأزرار والدروس) === */
  --level-bg: #334155;            /* بطاقات المستويات (غير نشطة) */
  --tab-active: #2563eb;          /* الزر النشط: المستويات والمواد */
  --feat-active: #2187e9;         /* الزر النشط: أنماط العرض */
  --box-bg: #2a3648;              /* خلفية الأزرار والدروس */
  --box-bg-hover: #38455a;
  --box-border: #3a4759;
  --box-text: #e6ecf5;            /* نص الدروس */
  --box-text-dim: #d3dbe6;        /* نص الأزرار غير النشطة */
  --badge-bg: #f5a623;            /* دائرة الرقم */
  --badge-text: #16213a;
  --title-gold: #f0b429;          /* عنوان الدورة */
}

body.geography-theme {
  --primary: #b45309;
  --primary-light: #d97706;
  --primary-dark: #92400e;
  --secondary: #65a30d;
  --accent: #fbbf24;
  --bg-dark: #1c1410;
  --bg-card: #2d1f16;
  --bg-card-hover: #3d2b1e;
  --border: #4a3222;

  /* === ألوان الصفحة الرئيسية في وضع الجغرافيا === */
  --level-bg: #4a3a2c;
  --tab-active: #b45309;
  --feat-active: #d97706;
  --box-bg: #3a2e23;
  --box-bg-hover: #4a3a2c;
  --box-border: #55452f;
  --box-text: #f3e9dd;
  --box-text-dim: #e0cfbb;
  --badge-bg: #f5a623;
  --badge-text: #2b1c0e;
  --title-gold: #f0b429;
}

/* === أساسيات === */
* { box-sizing: border-box; }

body {
  background: linear-gradient(135deg, var(--bg-dark) 0%, #1a2332 100%);
  margin: 0;
  padding: 0;
  direction: rtl;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text-primary);
  min-height: 100vh;
  transition: background 0.5s ease;
}

body.geography-theme {
  background: linear-gradient(135deg, var(--bg-dark) 0%, #2a1f15 100%);
}

a { color: var(--primary-light); text-decoration: none; }
a:hover { color: var(--accent-light); }

/* === الهيدر === */
.site-header {
  position: relative;
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--bg-card-hover) 100%);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  padding: 35px 20px 0;
  transition: border-color 0.5s ease, box-shadow 0.5s ease;
}

.site-header::before {
  content: '';
  position: absolute;
  top: -60%;
  right: -20%;
  width: 80%;
  height: 200%;
  background: radial-gradient(ellipse, rgba(37,99,235,0.12) 0%, transparent 70%);
  pointer-events: none;
  transition: background 0.5s ease;
}

body.geography-theme .site-header::before {
  background: radial-gradient(ellipse, rgba(180,83,9,0.18) 0%, transparent 70%);
}

.header-container {
  max-width: 1100px;
  margin: 0 auto;
  text-align: center;
  position: relative;
  z-index: 1;
  padding-bottom: 20px;
}

.brand-sub {
  position: relative;
  display: inline-block;
  color: var(--accent-light);
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0;
  margin-bottom: 8px;
  padding: 0 0 7px;
  text-shadow: 0 0 22px rgba(245,158,11,0.3);
}

.brand-sub::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
}

body.geography-theme .brand-sub {
  color: #fbbf24;
  text-shadow: 0 0 22px rgba(251,191,36,0.35);
}

body.geography-theme .brand-sub::after {
  background: linear-gradient(90deg, transparent, #fbbf24, transparent);
}

.brand-title {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.5;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--accent-light) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

body.geography-theme .brand-title {
  background: linear-gradient(135deg, var(--text-primary) 0%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-divider {
  width: 60%;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  margin: 20px auto 0;
  border-radius: 3px;
  box-shadow: 0 0 15px rgba(245,158,11,0.2);
}

body.geography-theme .header-divider {
  background: linear-gradient(90deg, transparent, #fbbf24, transparent);
  box-shadow: 0 0 15px rgba(251,191,36,0.3);
}

/* === المحتوى الرئيسي === */
.page-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 25px 20px;
}

/* === الفوتر === */
.site-footer {
  position: relative;
  background: linear-gradient(180deg, var(--bg-card) 0%, var(--bg-dark) 100%);
  color: var(--text-secondary);
  padding: 40px 20px 25px;
  margin-top: 50px;
  border-top: 1px solid var(--border);
  text-align: center;
  overflow: hidden;
}

.footer-glow {
  position: absolute;
  top: -60px;
  left: 50%;
  transform: translateX(-50%);
  width: 400px;
  height: 120px;
  background: radial-gradient(ellipse, rgba(37,99,235,0.12) 0%, transparent 70%);
  pointer-events: none;
}

body.geography-theme .footer-glow {
  background: radial-gradient(ellipse, rgba(180,83,9,0.18) 0%, transparent 70%);
}

.footer-container {
  max-width: 800px;
  margin: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  position: relative;
  z-index: 1;
}

.footer-logo {
  font-size: 26px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.footer-tagline {
  font-size: 13px;
  color: var(--text-secondary);
}

.footer-text {
  margin: 0;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.8;
}

.footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.footer-links a {
  color: var(--accent);
  font-size: 14px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.3s ease;
}

.footer-links a:hover {
  color: var(--text-primary);
  background: rgba(255,255,255,0.05);
}

.footer-bottom-bar {
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent 0%, var(--primary) 50%, transparent 100%);
  border-radius: 2px;
  margin-top: 10px;
}

body.geography-theme .footer-bottom-bar {
  background: linear-gradient(90deg, transparent 0%, #d97706 50%, transparent 100%);
}

/* ==========================================
   الصفحة الرئيسية: أزرار المواد والأنماط + قائمة الدروس
   ========================================== */

/* === الخط الفاصل الذهبي (مطابق لخط الهيدر) === */
.gold-divider {
  width: 60%;
  height: 4px;
  border-radius: 3px;
  margin: 20px auto 16px;
  background: linear-gradient(90deg, transparent 0%, var(--title-gold) 50%, transparent 100%);
  box-shadow: 0 0 15px rgba(240, 180, 41, 0.28);
}

/* === أزرار المواد (التاريخ / الجغرافيا) === */
.subject-tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 12px;
}

.subject-btn {
  flex: 1;
  background: var(--box-bg);
  color: var(--box-text-dim);
  border: 1px solid var(--box-border);
  border-radius: 6px;
  padding: 10px 0;
  text-align: center;
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 0.2s ease, color 0.2s ease;
}

.subject-btn:hover {
  background: var(--box-bg-hover);
  color: #fff;
}

.subject-btn.active {
  background: var(--tab-active);
  border-color: var(--tab-active);
  color: #fff;
}

/* === عنوان الدورة === */
.semester-title {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--title-gold);
  font-size: 14px;
  font-weight: 700;
  margin: 16px 0 9px;
}

.semester-title::before {
  content: '';
  width: 3px;
  height: 16px;
  border-radius: 2px;
  background: var(--title-gold);
  flex-shrink: 0;
}

/* === قائمة الدروس === */
.lessons-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 22px;
}

.lesson-item {
  display: block;
}

.lesson-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  background: var(--box-bg);
  border: 1px solid var(--box-border);
  border-radius: 6px;
  padding: 9px 12px;
  color: var(--box-text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 700;
  text-align: right;
  text-decoration: none;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.lesson-btn:hover {
  background: var(--box-bg-hover);
  color: #fff;
  transform: translateX(-3px);
}

.lesson-item.open .lesson-toggle {
  background: var(--box-bg-hover);
  border-color: var(--feat-active);
}

.lesson-btn:focus-visible,
.lesson-action:focus-visible {
  outline: 2px solid var(--title-gold);
  outline-offset: 2px;
}

.lesson-number {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--badge-bg);
  color: var(--badge-text);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11.5px;
  font-weight: 800;
  flex-shrink: 0;
}

.lesson-name {
  flex: 1;
  text-align: right;
}

.lesson-chevron {
  width: 7px;
  height: 7px;
  border: solid currentColor;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.lesson-item.open .lesson-chevron {
  transform: rotate(225deg);
}

.lesson-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
  padding: 0 32px 2px 0;
}

.lesson-actions[hidden] {
  display: none;
}

.lesson-actions:not([hidden]) {
  animation: lessonActionsIn 0.18s ease both;
}

@keyframes lessonActionsIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.lesson-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 44px;
  padding: 7px 6px;
  background: var(--box-bg);
  border: 1px solid var(--box-border);
  border-radius: 6px;
  color: var(--box-text);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.lesson-action:hover {
  background: var(--feat-active);
  border-color: var(--feat-active);
  color: #fff;
}

.lesson-action.is-soon {
  border-style: dashed;
  color: var(--box-text-dim);
}

.lesson-action.is-soon:hover {
  background: var(--box-bg-hover);
  border-color: var(--box-border);
  color: var(--box-text);
}

.lesson-action-badge {
  color: var(--title-gold);
  font-size: 9.5px;
  font-weight: 600;
  line-height: 1;
}

@media (prefers-reduced-motion: reduce) {
  .lesson-btn,
  .lesson-chevron,
  .lesson-action {
    transition: none;
  }

  .lesson-actions:not([hidden]) {
    animation: none;
  }
}

/* === التجاوب === */
@media (max-width: 900px) {
  .lesson-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 600px) {
  .site-header { padding: 25px 15px 0; }
  .brand-sub { font-size: 20px; letter-spacing: 0; padding: 0 0 7px; }
  .brand-title { font-size: 24px; }
  .header-divider { width: 80%; height: 3px; }
  .site-footer { padding: 30px 15px 20px; }
  .footer-logo { font-size: 22px; }

  .page-content { padding: 18px 12px; }
  .subject-btn { font-size: 15px; padding: 11px 0; }
  .lesson-btn { font-size: 13px; padding: 10px; gap: 8px; }
  .lesson-number { width: 22px; height: 22px; font-size: 11px; }
  .lesson-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-right: 30px; }
  .lesson-action { flex-direction: column; gap: 2px; min-height: 42px; padding: 8px 4px; font-size: 12px; line-height: 1.3; }
  .semester-title { font-size: 14px; }
}



/* ==========================================
   زر صوت التقييم (عائم أسفل يسار الشاشة)
   ========================================== */
.sound-toggle {
  position: fixed;
  left: 14px;
  bottom: 14px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 1px solid var(--box-border);
  border-radius: 50%;
  background: var(--box-bg);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  z-index: 60;
  opacity: 0.92;
  transition: transform 0.15s ease, opacity 0.15s ease, color 0.15s ease;
}

.sound-toggle:hover { transform: scale(1.07); opacity: 1; }
.sound-toggle:active { transform: scale(0.96); }

.sound-toggle .sound-slash { display: none; }

.sound-toggle.muted { color: var(--text-secondary); }
.sound-toggle.muted .sound-waves { display: none; }
.sound-toggle.muted .sound-slash { display: block; }

@media (max-width: 600px) {
  .sound-toggle { width: 36px; height: 36px; left: 10px; bottom: 10px; }
}

/* ===== سجل أفضل نتيجة (بطاقات صفحة اختيار المستوى + بطاقة النتيجة) ===== */
.quiz-level-best {
  margin-top: 6px;
  padding: 3px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  color: #22c55e;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.quiz-level-best.empty {
  color: var(--text-secondary);
  background: transparent;
  border-color: var(--box-border);
  font-weight: 500;
}

.quiz-level-best.low {
  color: var(--text-secondary);
  background: transparent;
  border-color: var(--box-border);
}

.quiz-best {
  margin: 10px 0 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--title-gold);
}

.quiz-best.record { color: #22c55e; }
