/* ==========================================================================
   المكوّنات — انضباط Genesis: مسطّح + حدّ 1px، والظل عند hover/focus فقط.
   ========================================================================== */

/* ---------- الشريط العلوي ---------- */
.nav {
  position: sticky;
  inset-block-start: 0;
  z-index: 60;
  height: 60px;
  background: color-mix(in srgb, var(--c-surface) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-block-end: 1px solid var(--c-border);
}
.nav__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--s-6);
}
.nav__brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  color: var(--c-text);
  font-weight: 700;
  font-size: var(--t-subhead);
  white-space: nowrap;
}
.nav__brand:hover { text-decoration: none; }
.nav__links {
  display: flex;
  align-items: center;
  gap: var(--s-1);
}
.nav__link {
  padding: var(--s-2) var(--s-3);
  border-radius: var(--r-control);
  font-size: var(--t-small);
  font-weight: 500;
  color: var(--c-text-2);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.nav__link:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
  text-decoration: none;
}
.nav__link[aria-current='page'] { color: var(--c-primary); font-weight: 600; }
/* تُثبَّت دائمًا عند حافة النهاية (اليسار في RTL)، بصرف النظر عن ظهور روابط سطح المكتب */
.nav__tools {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  margin-inline-start: auto;
}

@media (max-width: 860px) {
  .nav__links { display: none; }
}

/* شريط اسم المنصة الكامل — أخفت وأصغر من العلامة نفسها في الشريط، حتى
   لا ينافسها بصريًّا، ويسقط مع التمرير (غير مثبَّت) فلا يستهلك ارتفاعًا
   دائمًا في صفحات القراءة الطويلة. */
.tagline {
  background: var(--c-primary-soft);
  border-block-end: 1px solid var(--c-border);
}
.tagline .container {
  padding-block: var(--s-3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-3);
  color: var(--c-primary);
}
.tagline .container::before,
.tagline .container::after {
  content: '';
  flex: 1 1 56px;
  max-inline-size: 56px;
  block-size: 1px;
  background: currentColor;
  opacity: 0.35;
}
.tagline span {
  flex: none;
  font-size: var(--t-small);
  font-weight: 700;
  letter-spacing: 0.03em;
  white-space: nowrap;
}
@media (max-width: 480px) {
  .tagline .container::before, .tagline .container::after { flex-basis: 24px; }
  .tagline span { font-size: var(--t-caption); white-space: normal; text-align: center; }
}

/* الشعار: مربّع أزرق ثابت بداخله رمز نموّ (أعمدة متصاعدة وعلَم) */
.mark {
  inline-size: 32px;
  block-size: 32px;
  background: var(--c-brand);
  border-radius: var(--r-chip);
  display: grid;
  place-items: center;
  flex: none;
}
.mark svg { inline-size: 19px; block-size: 19px; }

/* ---------- ذيل الصفحة: صفّ واحد دائمًا — يمين / وسط / يسار ---------- */
.site-footer { border-block-start: 1px solid var(--c-border); margin-block-start: var(--s-12); }
.site-footer__inner {
  padding-block: var(--s-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
}
.site-footer__brand { font-size: var(--t-small); font-weight: 700; color: var(--c-text-2); flex: none; }
.site-footer__link { font-size: var(--t-small); color: var(--c-text-2); flex: none; }
.site-footer__link:hover { color: var(--c-primary); }
.site-footer__mail { display: inline-flex; align-items: center; gap: var(--s-2); }
@media (max-width: 340px) {
  .site-footer__brand { display: none; }
}

/* ---------- التنقّل السفلي للجوال ---------- */
.tabbar {
  display: none;
  position: fixed;
  inset-inline: 0;
  inset-block-end: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--c-surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-block-start: 1px solid var(--c-border);
  padding-block-end: env(safe-area-inset-bottom);
}
.tabbar__inner { display: flex; }
.tabbar a {
  flex: 1;
  padding-block: var(--s-2) var(--s-2);
  display: grid;
  justify-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: var(--c-text-2);
}
.tabbar a:hover { text-decoration: none; }
.tabbar a[aria-current='page'] { color: var(--c-primary); }
.tabbar svg { inline-size: 21px; block-size: 21px; }

@media (max-width: 860px) {
  .tabbar { display: block; }
  body { padding-block-end: 68px; }
}

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  block-size: 40px;
  padding-inline: var(--s-5);
  border-radius: var(--r-control);
  border: 1px solid transparent;
  font-size: var(--t-small);
  font-weight: 600;
  white-space: nowrap;
  transition: transform var(--dur) var(--ease), background var(--dur) var(--ease),
              box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease),
              color var(--dur) var(--ease);
}
.btn:hover { transform: translateY(-1px); text-decoration: none; }
.btn:active { transform: none; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

.btn--primary { background: var(--c-primary); color: var(--c-on-primary); }
.btn--primary:hover { background: var(--c-primary-hover); box-shadow: var(--e-primary); }

.btn--secondary {
  background: var(--c-surface);
  border-color: var(--c-border-strong);
  color: var(--c-text);
}
.btn--secondary:hover { border-color: var(--c-primary); color: var(--c-primary); }

.btn--ghost { color: var(--c-text-2); padding-inline: var(--s-3); }
.btn--ghost:hover { color: var(--c-text); background: var(--c-surface-2); }

.btn--sm { block-size: 32px; padding-inline: var(--s-3); font-size: var(--t-caption); }
.btn--lg { block-size: 46px; padding-inline: var(--s-6); font-size: var(--t-body); }
.btn--block { display: flex; inline-size: 100%; }

/* زر أيقونة مربّع */
.iconbtn {
  inline-size: 36px;
  block-size: 36px;
  border-radius: var(--r-control);
  display: grid;
  place-items: center;
  color: var(--c-text-2);
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
.iconbtn:hover { background: var(--c-surface-2); color: var(--c-text); }
.iconbtn svg { inline-size: 19px; block-size: 19px; }

/* زرّ حجم الخط — حرفان بدل أيقونة، مع شارة صغيرة تُظهر المستوى الحالي */
.iconbtn--text {
  font-family: var(--f-en);
  font-weight: 700;
  font-size: 14px;
  position: relative;
}
.iconbtn--text[data-level='1']::after {
  content: '';
  position: absolute;
  inset-inline-end: 4px;
  inset-block-start: 4px;
  inline-size: 5px;
  block-size: 5px;
  border-radius: var(--r-full);
  background: var(--c-primary);
}
.iconbtn--text[data-level='2']::after {
  content: '';
  position: absolute;
  inset-inline-end: 4px;
  inset-block-start: 4px;
  inline-size: 5px;
  block-size: 5px;
  border-radius: var(--r-full);
  background: var(--c-primary);
  box-shadow: -6px 0 0 var(--c-primary);
}
.iconbtn--text[data-level='3']::after {
  content: '';
  position: absolute;
  inset-inline-end: 4px;
  inset-block-start: 4px;
  inline-size: 5px;
  block-size: 5px;
  border-radius: var(--r-full);
  background: var(--c-primary);
  box-shadow: -6px 0 0 var(--c-primary), -12px 0 0 var(--c-primary);
}
.iconbtn--text.is-on { color: var(--c-primary); border-color: var(--c-border); background: var(--c-surface-2); }

/* ---------- البطاقات ---------- */
.card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-card);
  padding: var(--s-6);
  transition: transform var(--dur) var(--ease), box-shadow var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
a.card:hover, .card--link:hover {
  transform: translateY(-2px);
  box-shadow: var(--e-hover);
  border-color: var(--c-border-strong);
  text-decoration: none;
}

.panel {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-panel);
  padding: var(--s-5);
}

/* ---------- الشرائح ---------- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--s-1);
  padding: 3px var(--s-3);
  border-radius: var(--r-full);
  background: var(--c-surface-2);
  color: var(--c-text-2);
  font-size: var(--t-caption);
  font-weight: 600;
  white-space: nowrap;
}
.chip--primary { background: var(--c-primary-soft); color: var(--c-primary); }
.chip--success { background: var(--c-success-soft); color: var(--c-success); }

/* ---------- الحقول ---------- */
.field {
  inline-size: 100%;
  block-size: 46px;
  padding-inline: var(--s-4);
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-control);
  font-size: var(--t-body);
  transition: border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease);
}
.field::placeholder { color: var(--c-neutral); }
.field:focus {
  outline: none;
  border-color: var(--c-primary);
  box-shadow: var(--ring);
}

/* ---------- حلقة التقدّم ---------- */
.ring { position: relative; inline-size: 104px; block-size: 104px; flex: none; }
.ring svg { transform: rotate(-90deg) scaleX(-1); }  /* تبدأ من الأعلى وتدور مع اتجاه RTL */
.ring circle { fill: none; stroke-width: 6; }
.ring .ring__track { stroke: var(--c-border); }
.ring .ring__value {
  stroke: var(--c-primary);
  stroke-linecap: round;
  transition: stroke-dashoffset 700ms var(--ease);
}
.ring__label {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  gap: 0;
}
.ring__pct { font-family: var(--f-en); font-size: 25px; font-weight: 700; line-height: 1.1; }
.ring__cap { font-size: 11px; color: var(--c-text-2); font-weight: 600; }

/* ---------- شريط تقدّم خطّي ---------- */
.bar {
  block-size: 4px;
  border-radius: var(--r-full);
  background: var(--c-border);
  overflow: hidden;
}
.bar__fill {
  block-size: 100%;
  background: var(--c-primary);
  border-radius: var(--r-full);
  transition: inline-size 500ms var(--ease);
}

/* ---------- الفهرس بنقاط الوصل — يُحاكي فهرس الكتاب المطبوع ---------- */
.toc { border-block-start: 1px solid var(--c-border); }
.toc__row {
  display: flex;
  align-items: baseline;
  gap: var(--s-3);
  padding-block: var(--s-3);
  border-block-end: 1px solid var(--c-border);
  color: var(--c-text);
  transition: background var(--dur) var(--ease);
  padding-inline: var(--s-3);
  margin-inline: calc(var(--s-3) * -1);
  border-radius: var(--r-chip);
}
.toc__row:hover { background: var(--c-surface-2); text-decoration: none; }
.toc__num {
  font-family: var(--f-en);
  font-size: var(--t-caption);
  font-weight: 700;
  color: var(--c-primary);
  min-inline-size: 26px;
  flex: none;
}
/* يتقلّص العنوان عند الضيق، وتبتلع نقاطُ الوصل ما تبقّى من فراغ — فلا ينزلق الصفّ أبدًا */
.toc__title { font-weight: 500; flex: 0 1 auto; min-inline-size: 0; }
.toc__dots {
  flex: 1 1 var(--s-3);
  min-inline-size: var(--s-3);
  border-block-end: 1.5px dotted var(--c-border-strong);
  transform: translateY(-5px);
}
.toc__meta {
  flex: none;
  font-size: var(--t-caption);
  color: var(--c-text-2);
  font-family: var(--f-en);
  font-weight: 600;
}
.toc__row.is-done .toc__title { color: var(--c-text-2); }
.toc__row.is-done .toc__num::after { content: ' ✓'; color: var(--c-success); }

@media (max-width: 520px) {
  .toc__row { padding-inline: var(--s-2); margin-inline: calc(var(--s-2) * -1); gap: var(--s-2); }
}

/* ---------- الشبكات ---------- */
.grid { display: grid; gap: var(--s-5); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--tiles { grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: var(--s-4); }

/* ---------- رابط الرجوع أعلى الصفحات الفرعية ---------- */
.backlink {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  color: var(--c-text-2);
  font-size: var(--t-small);
  font-weight: 600;
  margin-block-end: var(--s-6);
  transition: color var(--dur) var(--ease);
}
.backlink svg { flex: none; }
.backlink:hover { color: var(--c-primary); text-decoration: none; }

/* ---------- بطاقة درسٍ مصغَّرة (أيقونة) — تُستعمل في صفحة الوحدة ---------- */
.lesson-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-3);
  padding: var(--s-5) var(--s-3);
}
.lesson-tile__no {
  inline-size: 48px;
  block-size: 48px;
  border: 1px solid var(--c-primary);
  border-radius: var(--r-panel);
  display: grid;
  place-items: center;
  color: var(--c-primary);
  font-weight: 700;
  font-size: var(--t-subhead);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lesson-tile.is-done .lesson-tile__no {
  background: var(--c-primary);
  color: var(--c-on-primary);
}
.lesson-tile__title { font-weight: 600; font-size: var(--t-small); line-height: 1.6; }
.lesson-tile__meta { font-size: var(--t-caption); color: var(--c-text-2); }

/* ---------- الطبقة العائمة (شيت التثبيت) ---------- */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
  display: grid;
  place-items: end center;
  animation: fade 200ms var(--ease) both;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  inline-size: min(520px, 100%);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-start-start-radius: 16px;
  border-start-end-radius: 16px;
  box-shadow: var(--e-float);
  padding: var(--s-6) var(--s-6) calc(var(--s-6) + env(safe-area-inset-bottom));
  animation: slide-up 280ms var(--ease) both;
  max-block-size: 88vh;
  overflow-y: auto;
}
@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to   { transform: none; opacity: 1; }
}
@media (min-width: 640px) {
  .sheet-backdrop { place-items: center; }
  .sheet { border-radius: 16px; }
}
.sheet__grip {
  inline-size: 38px;
  block-size: 4px;
  border-radius: var(--r-full);
  background: var(--c-border-strong);
  margin: 0 auto var(--s-5);
}
.sheet__steps { counter-reset: step; margin-block: var(--s-5); }
.sheet__steps li {
  counter-increment: step;
  display: flex;
  gap: var(--s-4);
  align-items: flex-start;
  padding-block: var(--s-3);
  border-block-end: 1px solid var(--c-border);
  font-size: var(--t-small);
  line-height: 1.8;
}
.sheet__steps li:last-child { border-block-end: none; }
.sheet__steps li::before {
  content: counter(step);
  font-family: var(--f-en);
  font-weight: 700;
  font-size: var(--t-caption);
  inline-size: 26px;
  block-size: 26px;
  flex: none;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--r-chip);
  display: grid;
  place-items: center;
  color: var(--c-primary);
}

/* ---------- شريط إشعار خفيف ---------- */
.toast {
  position: fixed;
  inset-block-end: calc(var(--s-6) + env(safe-area-inset-bottom));
  inset-inline: var(--s-4);
  margin-inline: auto;
  inline-size: fit-content;
  max-inline-size: calc(100% - var(--s-8));
  z-index: 120;
  background: var(--c-text);
  color: var(--c-bg);
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-full);
  font-size: var(--t-small);
  font-weight: 600;
  box-shadow: var(--e-float);
  animation: slide-up 240ms var(--ease) both;
}
@media (max-width: 860px) {
  .toast { inset-block-end: calc(76px + env(safe-area-inset-bottom)); }
}

/* ---------- حالة فارغة ---------- */
.empty {
  text-align: center;
  padding: var(--s-16) var(--s-6);
  color: var(--c-text-2);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--r-card);
}
