/* ==========================================================================
   الأساسيات والطباعة العربية واتجاه RTL المنطقي
   ========================================================================== */

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

html {
  direction: rtl;
  font-size: 16px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  font-weight: 400;
  font-size: var(--text-base);
  line-height: 1.8;
  letter-spacing: 0;
  color: var(--text-primary);
  background-color: var(--bg-page);
  transition: var(--transition-theme);
  overflow-x: clip;
  text-align: start;
}

/* تأكد من استخدام خط Cairo في جميع العناصر التفاعلية */
button,
input,
select,
textarea,
optgroup {
  font-family: var(--font-sans);
  letter-spacing: 0;
}

/* العناوين والمستويات */
h1, h2, h3, h4, h5, h6 {
  margin-block: 0;
  font-family: var(--font-sans);
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--text-primary);
  font-weight: 700;
}

h1, .h1 { font-size: var(--text-5xl); font-weight: 800; }
h2, .h2 { font-size: var(--text-3xl); font-weight: 700; }
h3, .h3 { font-size: var(--text-2xl); font-weight: 700; }
h4, .h4 { font-size: var(--text-xl); font-weight: 600; }
h5, .h5 { font-size: var(--text-lg); font-weight: 600; }

p {
  margin-block: 0 1em;
  color: var(--text-secondary);
}

p:last-child {
  margin-block-end: 0;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-base);
}

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

img {
  height: auto;
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* حالات التركيز للوصول السهل (Accessibility) */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* شريط التمرير المخصص */
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
}
::-webkit-scrollbar-track {
  background: var(--bg-surface);
}
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent);
}

/* تخطي إلى المحتوى لقارئات الشاشة */
.skip-link {
  position: fixed;
  inset-block-start: -100px;
  inset-inline-start: var(--space-4);
  z-index: 9999;
  padding: var(--space-3) var(--space-5);
  background: var(--accent);
  color: var(--accent-contrast-text);
  font-weight: 700;
  border-radius: var(--radius-md);
  transition: inset-block-start 0.2s ease;
}
.skip-link:focus {
  inset-block-start: var(--space-4);
}

/* الحاوية الرئيسية */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-inline: auto;
  padding-inline: var(--space-5);
}

@media (min-width: 768px) {
  .container {
    padding-inline: var(--space-8);
  }
}

/* الأقسام */
.section {
  padding-block: var(--space-16);
  position: relative;
}

@media (min-width: 1024px) {
  .section {
    padding-block: var(--space-20);
  }
}

.section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  margin-block-end: var(--space-10);
}

.section-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--accent-text);
  margin-block-end: var(--space-2);
}

.section-eyebrow::before {
  content: '';
  display: inline-block;
  width: 24px;
  height: 2px;
  background: var(--accent-gradient);
  border-radius: var(--radius-full);
}

.section-subtitle {
  color: var(--text-secondary);
  font-size: var(--text-base);
  max-width: 620px;
  margin-block-start: var(--space-2);
}

/* عكس الأيقونات الاتجاهية في RTL */
.rtl-mirror {
  transform: scaleX(-1);
}

/* الأرقام الغربية المتناسقة */
.num {
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: embed;
  display: inline-block;
}

/* إخفاء بصري متاح لقارئات الشاشة */
.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;
}

/* حركات الظهور عند التمرير */
.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.65s cubic-bezier(0.22, 1, 0.36, 1), transform 0.65s cubic-bezier(0.22, 1, 0.36, 1);
}
.reveal.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* هياكل التحميل (Skeleton Loaders) */
.skeleton {
  position: relative;
  overflow: hidden;
  background-color: var(--bg-surface-2);
  border-radius: var(--radius-md);
}
.skeleton::after {
  content: '';
  position: absolute;
  inset: 0;
  transform: translateX(100%);
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.08), transparent);
  animation: skeleton-shimmer 1.5s infinite;
}
@keyframes skeleton-shimmer {
  100% {
    transform: translateX(-100%);
  }
}

/* احترام تفضيل تقليل الحركة */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .reveal {
    opacity: 1;
    transform: none;
  }
}
