/* ==========================================================================
   الأساس — reset، RTL، تايبوغرافي
   قاعدة صارمة: خصائص منطقية حصرًا. لا left/right فيزيائية.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  background: var(--c-bg);
  color: var(--c-text);
  font-family: var(--f-ar);
  font-size: var(--t-body);
  line-height: var(--lh-body);
  font-weight: 400;
  /* العربية موصولة الحروف — التضييق يكسر الوصل. صفر أبدًا. */
  letter-spacing: 0;
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

h1, h2, h3, h4, h5, h6, p, figure, blockquote, dl, dd, ol, ul {
  margin: 0;
}
ol, ul { padding: 0; list-style: none; }

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: var(--lh-tight);
  letter-spacing: 0;
  text-wrap: balance;
}
h1 { font-size: var(--t-headline); }
h2 { font-size: var(--t-section); }
h3 { font-size: var(--t-subhead); }
h4 { font-size: var(--t-body); }

a {
  color: var(--c-primary);
  text-decoration: none;
  text-underline-offset: 4px;
}
a:hover { text-decoration: underline; }

img, svg { max-width: 100%; display: block; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
  letter-spacing: inherit;
}
button { cursor: pointer; background: none; border: none; padding: 0; }

/* حلقة تركيز واحدة، واضحة، على كل عنصر تفاعلي — في الوضعين */
:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: 2px;
  border-radius: var(--r-control);
}
:focus:not(:focus-visible) { outline: none; }

::selection {
  background: rgba(var(--c-primary-rgb), 0.22);
  color: var(--c-text);
}

/* ---- اللاتيني والأرقام داخل الجُمل العربية ----
   لا نترك المتصفح يختار الخط حسب المحارف — نُصرّح به. */
.en, .num, code, time, [lang='en'] {
  font-family: var(--f-en);
  font-feature-settings: 'tnum' 1;
  /* عزل ثنائي الاتجاه: يمنع المحرّك من إعادة ترتيب مثل «٠ / ٣٤» أو «٦٧٢–٧٢٣»
     حين تُحيط بالأرقام محارف محايدة داخل سياق RTL. */
  unicode-bidi: isolate;
}

/* بديل الـuppercase في العربية: وزن أثقل + تباعد موجب خفيف.
   الاسم `eyebrow` لا `overline` تفاديًا للتصادم مع أدوات الأطر. */
.eyebrow {
  font-size: var(--t-caption);
  font-weight: 700;
  letter-spacing: 0.06em;   /* موجب — لا سالب أبدًا على العربي */
  color: var(--c-text-2);
  display: block;
}

.muted { color: var(--c-text-2); }
.small { font-size: var(--t-small); }

/* ---- التخطيط ---- */
.container {
  max-width: var(--container);
  margin-inline: auto;
  padding-inline: var(--s-6);
}
@media (max-width: 640px) {
  .container { padding-inline: var(--s-4); }
}

.stack > * + * { margin-block-start: var(--s-4); }

.page {
  padding-block: var(--s-12) var(--s-24);
  animation: rise 320ms var(--ease) both;
}
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

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

.skip-link {
  position: absolute;
  inset-block-start: -100px;
  inset-inline-start: var(--s-4);
  z-index: 200;
  background: var(--c-primary);
  color: #fff;
  padding: var(--s-3) var(--s-5);
  border-radius: var(--r-control);
  font-weight: 600;
}
.skip-link:focus { inset-block-start: var(--s-4); }

/* ---- الفاصل الزخرفي: عنصر الزينة الوحيد، يُستعمل نادرًا ---- */
.ornament {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  color: var(--c-border-strong);
  margin-block: var(--s-10);
}
.ornament::before, .ornament::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--c-border);
}
.ornament span { font-size: 15px; line-height: 1; }

/* ---- الجداول: تنزلق داخل حاويتها، والصفحة لا تنزلق أفقيًّا أبدًا ---- */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--c-border);
  border-radius: var(--r-panel);
  background: var(--c-surface);
}
.scroll-x table {
  border-collapse: collapse;
  width: 100%;
  min-width: 460px;
  font-size: var(--t-small);
}
.scroll-x th, .scroll-x td {
  text-align: start;
  padding: var(--s-3) var(--s-4);
  border-block-end: 1px solid var(--c-border);
  line-height: 1.75;
  vertical-align: top;
}
.scroll-x th {
  background: var(--c-surface-2);
  font-weight: 600;
  font-size: var(--t-caption);
  color: var(--c-text-2);
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.scroll-x tbody tr:last-child td { border-block-end: none; }
.scroll-x td:first-child { font-weight: 600; }
