/* ============================================================================
   الأساس: تصفير · طباعة · اتجاه · أدوات
   ============================================================================ */

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

* { margin: 0; padding: 0; }

html {
  -webkit-text-size-adjust: 100%;
  font-size: 16px;
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t), color var(--t);
}

/* الأرقام لاتينية دائمًا: الأرقام الهندية تربك قراءة المعرّفات والمؤقتات */
body, input, select, textarea, table {
  font-variant-numeric: lining-nums tabular-nums;
}

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

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button { background: none; border: none; cursor: pointer; }

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.3; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }

code, kbd, .mono { font-family: var(--mono); font-size: .92em; }

hr { border: none; border-top: 1px solid var(--border); }

/* ─── إتاحة ─────────────────────────────────────────────────────────────── */

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.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;
}

/* من يطلب تقليل الحركة يحصل عليه — لا استثناءات */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ─── شريط التمرير ─────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-str);
  border-radius: var(--r-full);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── منطق الاتجاه ─────────────────────────────────────────────────────── */
/* الخصائص المنطقية (inline-start/end) تتبع الاتجاه تلقائيًا فلا نكتب
   قواعد [dir] مكررة. تُستخدم في كل الملفات بدل left/right. */

.flip-rtl { transform: scaleX(1); }
[dir="rtl"] .flip-rtl { transform: scaleX(-1); }

/* ─── أدوات ────────────────────────────────────────────────────────────── */

.row     { display: flex; align-items: center; gap: var(--sp-3); }
.row-end { display: flex; align-items: center; gap: var(--sp-3); justify-content: flex-end; }
.col     { display: flex; flex-direction: column; gap: var(--sp-3); }
.spread  { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.wrap    { flex-wrap: wrap; }
.grow    { flex: 1 1 auto; min-width: 0; }

.hidden  { display: none !important; }
.muted   { color: var(--text-2); }
.dim     { color: var(--text-3); }
.tiny    { font-size: var(--fs-xs); }
.small   { font-size: var(--fs-sm); }
.bold    { font-weight: 700; }
.center  { text-align: center; }
.nowrap  { white-space: nowrap; }

.truncate {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.mt-2 { margin-top: var(--sp-2); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-4 { margin-bottom: var(--sp-4); }

.stack > * + * { margin-top: var(--sp-4); }
