/* ===========================================================================
   Base — إعادة ضبط + الطباعة العربية + RTL
   =========================================================================== */

/* الخط محفوظ محلياً: لا اعتماد على Google Fonts وقت التشغيل */
@font-face {
  font-family: 'Tajawal';
  src: url('../fonts/tajawal-regular.woff2') format('woff2');
  font-weight: 400; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Tajawal';
  src: url('../fonts/tajawal-medium.woff2') format('woff2');
  font-weight: 500; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Tajawal';
  src: url('../fonts/tajawal-bold.woff2') format('woff2');
  font-weight: 700; font-display: swap; font-style: normal;
}
@font-face {
  font-family: 'Tajawal';
  src: url('../fonts/tajawal-extrabold.woff2') format('woff2');
  font-weight: 800; font-display: swap; font-style: normal;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* يمنع اختفاء المحتوى خلف الهيدر الثابت عند القفز لمرساة */
  scroll-padding-top: calc(var(--header-h) + var(--sp-4));
}

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--fs-base);
  line-height: var(--lh-base);
  color: var(--text);
  background: var(--surface);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* الحارس ضد التمرير الأفقي — أُثبت بالاختبار على 320px */
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0 0 var(--sp-3);
  font-family: var(--font-head);
  font-weight: var(--fw-bold);
  line-height: var(--lh-tight);
  color: var(--c-ink-900);
  /* يمنع كسر الكلمات العربية بشكل قبيح على الشاشات الضيقة */
  overflow-wrap: break-word;
}

h1 { font-size: var(--fs-2xl); font-weight: var(--fw-black); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

@media (min-width: 768px) {
  h1 { font-size: var(--fs-3xl); }
  h2 { font-size: var(--fs-2xl); }
}

p { margin: 0 0 var(--sp-4); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--c-brand-600);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--dur-fast) var(--ease);
}
a:hover { color: var(--c-brand-700); }

img, video, svg, picture { max-width: 100%; height: auto; display: block; }

ul, ol { padding-inline-start: 1.4em; margin: 0 0 var(--sp-4); }
li { margin-bottom: var(--sp-2); }

hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-8) 0; }

/* --- تركيز واضح لمستخدمي لوحة المفاتيح ---------------------------------- */
:focus-visible {
  outline: 3px solid var(--c-brand-500);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
:focus:not(:focus-visible) { outline: none; }

/* --- أدوات مساعدة -------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--sp-4);
}
@media (min-width: 768px) { .container { padding-inline: var(--sp-8); } }

.container-narrow { max-width: var(--container-narrow); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* رابط "تخطَّ إلى المحتوى" — أول عنصر يصله مستخدم لوحة المفاتيح */
.skip-link {
  position: absolute; inset-inline-start: var(--sp-4); top: -100px;
  z-index: var(--z-toast);
  background: var(--c-brand-600); color: var(--text-inverse);
  padding: var(--sp-3) var(--sp-5); border-radius: var(--r-md);
  font-weight: var(--fw-bold); text-decoration: none;
  transition: top var(--dur-base) var(--ease);
}
.skip-link:focus { top: var(--sp-4); color: var(--text-inverse); }

.icon {
  width: 1.25em; height: 1.25em;
  fill: none; stroke: currentColor;
  stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round;
  flex-shrink: 0; vertical-align: -0.22em;
}
.icon-lg { width: 1.75em; height: 1.75em; }

/* في RTL تُعكس الأيقونات الاتجاهية فقط (أسهم)، لا كلها */
[dir="rtl"] .icon-flip { transform: scaleX(-1); }

.stack > * + * { margin-top: var(--sp-4); }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.eyebrow {
  display: inline-block;
  font-size: var(--fs-sm);
  font-weight: var(--fw-bold);
  color: var(--c-brand-600);
  letter-spacing: 0.02em;
  margin-bottom: var(--sp-2);
}
