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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  direction: rtl;
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--ink-900);
  min-height: 100vh;
  transition: background var(--dur-med) var(--ease-out), color var(--dur-med) var(--ease-out);
  overflow-x: hidden;
}

/* نسيج ورقي خفيف جدًا يعطي إحساس المخطوطة دون أن يزعج القراءة */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--grain-opacity);
  background-image: radial-gradient(circle at 1px 1px, currentColor 1px, transparent 0);
  background-size: 22px 22px;
  color: var(--ink-900);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* يُستخدم حصرًا للعناوين ذات الطابع الإسلامي/الهجري (اسم التطبيق، التاريخ
   الهجري، أسماء الأشهر الهجرية) — لا يُستخدم كخط عام للعناوين الأخرى */
.font-islamic { font-family: var(--font-islamic); }

p { margin: 0; }

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

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

a { color: inherit; text-decoration: none; }

::selection { background: var(--gold-300); color: var(--brand-900); }

/* شبكة أمان: أي أيقونة SVG مضمَّنة يجب ألا تتجاوز حجمها الطبيعي (1em) مهما
   كان السياق — هذا يمنع تضخّم الأيقونات في أماكن لا تُقيّد حجمها بصريًا */
svg { width: 1em; height: 1em; flex-shrink: 0; vertical-align: -0.125em; }

/* شريط تمرير مخصص */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  border: 2px solid transparent;
  background-clip: padding-box;
}

:focus-visible {
  outline: 2px solid var(--gold-500);
  outline-offset: 2px;
  border-radius: 4px;
}

.arabic-numerals { font-family: var(--font-data); font-variant-numeric: tabular-nums; }

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