/* الأساس: إعادة الضبط، الخطوط، العناصر العامة */

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

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

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.75;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color .35s var(--ease), color .35s var(--ease);
}

/* حبيبات الورق: ضجيج خفيف جداً يُعطي ملمس المخطوط */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--paper-grain);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .3 0 0 0 0 .22 0 0 0 0 .12 0 0 0 .9 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

h1, h2, h3, h4, p { margin: 0; }
h1, h2, h3, h4 { font-weight: 700; line-height: 1.35; }

a { color: inherit; }
img, svg { display: block; }

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; opacity: .5; }

:focus-visible { outline: 2.5px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

[hidden] { display: none !important; }

/* أيقونات الـ sprite */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg:has(> use) {
  width: 18px; height: 18px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round;
}
.brand-mark, svg.brand-mark { stroke: none; }

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

.skip-link {
  position: fixed; top: -60px; inset-inline-start: 16px; z-index: 100;
  background: var(--neutral); color: var(--on-neutral);
  padding: 10px 16px; border-radius: var(--radius-s); text-decoration: none;
  transition: top .2s var(--ease);
}
.skip-link:focus { top: 12px; }

kbd {
  font-family: var(--font); font-size: 11px; line-height: 1;
  padding: 4px 6px; border-radius: 5px;
  background: var(--surface-alt); color: var(--muted);
  border: 1px solid var(--border); border-bottom-width: 2px;
  direction: ltr; display: inline-block;
}

code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .86em; direction: ltr; unicode-bidi: isolate; }

mark {
  background: var(--highlight-bg); color: var(--highlight-fg);
  border-radius: 3px; padding: 0 2px; box-decoration-break: clone; -webkit-box-decoration-break: clone;
}

::selection { background: var(--accent-soft); color: var(--text); }
[data-theme="dark"] ::selection { background: #5a4722; color: #fff4dc; }

/* شريط التمرير رفيع ودافئ كما في البرنامج */
* { scrollbar-width: thin; scrollbar-color: var(--scrollbar) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 9px; border: 2px solid transparent; background-clip: padding-box; }

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