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

   الاتجاه يُضبط على <html dir> من جافاسكربت. كل التباعد يستخدم
   الخصائص المنطقية (inline-start/end) فينقلب تلقائيًا مع اللغة
   بلا أي CSS مكرّر للاتجاهين.
   ============================================================ */

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

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

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

h1, h2, h3, h4 { margin: 0; font-weight: 650; line-height: 1.3; letter-spacing: -.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
p { margin: 0; }

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

/* النصوص البرمجية تبقى LTR دائمًا مهما كانت لغة الواجهة. */
code, pre, .mono {
  font-family: var(--font-mono);
  direction: ltr;
  text-align: left;
  unicode-bidi: embed;
  font-size: .93em;
}

pre {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  overflow-x: auto;
  font-size: var(--fs-sm);
  line-height: 1.7;
  white-space: pre;
}

::selection { background: var(--accent); color: var(--on-accent); }

/* شريط تمرير رفيع يتبع المظهر. */
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--r-full); }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* حلقة تركيز واضحة لمستخدمي لوحة المفاتيح فقط. */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
:focus:not(:focus-visible) { outline: none; }

/* ---------- أدوات ---------- */
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grow { flex: 1; }

.row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.row.tight { gap: var(--sp-1); }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: var(--sp-2); }

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

.grid { display: grid; gap: var(--sp-4); }
.grid.c2 { grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); }
.grid.c4 { grid-template-columns: repeat(auto-fit, minmax(172px, 1fr)); }

/* ---------- حركات مشتركة ---------- */
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { 100% { transform: translateX(100%); } }

.animate-in { animation: fade-up var(--t-slow) both; }

/* بديل السمة style= المضمّنة — تمنعها سياسة CSP. */
.noscript { padding: 40px; text-align: center; }
