/* ============================================================
   مبادرة — Design Tokens v1.0
   الملف الأساسي — يُحمَّل قبل كل شيء
   لا hex مباشر في أي ملف آخر. كل قيمة مرجعها من هنا.
   ============================================================ */

:root {
  /* ========== الألوان الأساسية — Royal Purple (الهوية الرسمية) ========== */
  --indigo-50:  #F5F3FA;
  --indigo-100: #EEEDFE;
  --indigo-200: #DDD9F9;
  --indigo-300: #AFA9EC;
  --indigo-400: #9990E3;
  --indigo-500: #7F77DD;
  --indigo-600: #6862CE;
  --indigo-700: #534AB7;
  --indigo-800: #3C3489;   /* البنفسجي الملكي — الأساسي */
  --indigo-900: #26215C;

  /* ========== النيوترالات — Warm Stone ========== */
  --stone-0:   #FFFFFF;
  --stone-50:  #F5F3FA;    /* خلفية الصفحة */
  --stone-100: #EEEDFE;
  --stone-200: #E4E1F3;    /* حدود دقيقة */
  --stone-300: #C9C4E5;
  --stone-400: #AFA9EC;
  --stone-500: #7F77DD;    /* Muted text */
  --stone-600: #534AB7;
  --stone-700: #3C3489;    /* Body text */
  --stone-800: #2E276B;
  --stone-900: #26215C;    /* Ink — headings */

  /* ========== الألوان الوظيفية ========== */
  --success:      #1D9E75;
  --success-bg:   #E4F5EE;
  --warning:      #B0821B;
  --warning-bg:   #FBF5E4;
  --danger:       #E2556B;
  --danger-bg:    #FCEEF0;
  --premium:      #6B5410;
  --premium-bg:   #FDF7E7;

  /* ========== أدوار دلالية — استخدم هذه لا التي فوق ========== */
  --bg:              var(--stone-50);
  --surface:         var(--stone-0);
  --surface-raised:  var(--stone-0);
  --surface-sunk:    var(--stone-100);

  --ink:             var(--stone-900);
  --body:            var(--stone-700);
  --muted:           var(--stone-500);
  --faint:           var(--stone-400);

  --border:          var(--stone-200);
  --border-strong:   var(--stone-300);
  --border-inverse:  var(--indigo-800);

  --accent:          var(--indigo-800);
  --accent-hover:    var(--indigo-900);
  --accent-active:   var(--indigo-900);
  --accent-subtle:   var(--indigo-50);
  --accent-ring:     rgba(60, 52, 137, 0.20);

  --on-accent:       var(--stone-0);
  --on-surface:      var(--stone-900);

  /* ========== الطباعة ========== */
  --font-sans: 'IBM Plex Sans Arabic', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;

  /* Type Scale — Fluid — تتوسّع بلطف من الجوال إلى Desktop */
  --text-2xs:  clamp(0.6875rem, 0.65rem + 0.15vw, 0.75rem);   /* 11 → 12 */
  --text-xs:   clamp(0.75rem, 0.72rem + 0.15vw, 0.8125rem);   /* 12 → 13 */
  --text-sm:   clamp(0.8125rem, 0.78rem + 0.15vw, 0.875rem);  /* 13 → 14 */
  --text-base: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);  /* 14 → 15 */
  --text-md:   clamp(0.9375rem, 0.9rem + 0.2vw, 1.0625rem);   /* 15 → 17 */
  --text-lg:   clamp(1.0625rem, 1rem + 0.3vw, 1.25rem);       /* 17 → 20 */
  --text-xl:   clamp(1.25rem, 1.15rem + 0.5vw, 1.5rem);       /* 20 → 24 */
  --text-2xl:  clamp(1.5rem, 1.35rem + 0.7vw, 1.875rem);      /* 24 → 30 */
  --text-3xl:  clamp(1.875rem, 1.6rem + 1.2vw, 2.5rem);       /* 30 → 40 */

  /* أوزان الخط */
  --weight-regular:  400;
  --weight-medium:   500;
  --weight-semibold: 600;
  --weight-bold:     700;

  /* ارتفاعات السطور */
  --leading-tight:   1.25;
  --leading-snug:    1.4;
  --leading-normal:  1.6;
  --leading-relaxed: 1.75;
  --leading-loose:   1.9;

  /* Letter Spacing — للعربية والإنجليزية */
  --tracking-tight:   -0.02em;
  --tracking-normal:  0;
  --tracking-wide:    0.02em;

  /* ========== المسافات — Spacing Scale ========== */
  --space-1:  0.25rem;   /* 4px */
  --space-2:  0.5rem;    /* 8px */
  --space-3:  0.75rem;   /* 12px */
  --space-4:  1rem;      /* 16px */
  --space-5:  1.25rem;   /* 20px */
  --space-6:  1.5rem;    /* 24px */
  --space-7:  2rem;      /* 32px */
  --space-8:  2.5rem;    /* 40px */
  --space-9:  3rem;      /* 48px */
  --space-10: 4rem;      /* 64px */
  --space-11: 5rem;      /* 80px */

  /* ========== زوايا — Border Radius ========== */
  --radius-xs:   4px;
  --radius-sm:   6px;
  --radius-md:   8px;    /* افتراضي للأزرار والحقول */
  --radius-lg:   12px;   /* البطاقات */
  --radius-xl:   16px;   /* Modals */
  --radius-2xl:  20px;
  --radius-pill: 999px;
  --radius-full: 50%;

  /* ========== الظلال — Elevation ========== */
  --shadow-none: none;
  --shadow-xs:   0 1px 2px rgba(28, 26, 23, 0.04);
  --shadow-sm:   0 1px 3px rgba(28, 26, 23, 0.06), 0 1px 2px rgba(28, 26, 23, 0.04);
  --shadow-md:   0 4px 12px rgba(28, 26, 23, 0.08), 0 2px 4px rgba(28, 26, 23, 0.04);
  --shadow-lg:   0 8px 24px rgba(28, 26, 23, 0.10), 0 4px 8px rgba(28, 26, 23, 0.05);
  --shadow-xl:   0 20px 48px rgba(28, 26, 23, 0.15), 0 8px 16px rgba(28, 26, 23, 0.06);

  /* حلقة التركيز — accessibility critical */
  --focus-ring: 0 0 0 3px var(--accent-ring);

  /* ========== الحركة — Motion ========== */
  --duration-instant: 100ms;
  --duration-fast:    150ms;
  --duration-base:    200ms;
  --duration-slow:    300ms;
  --duration-slower:  500ms;

  --ease-linear:      linear;
  --ease-in:          cubic-bezier(0.4, 0, 1, 1);
  --ease-out:         cubic-bezier(0, 0, 0.2, 1);
  --ease-in-out:      cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);

  /* ========== Z-index ========== */
  --z-base:     0;
  --z-raised:   10;
  --z-sticky:   100;
  --z-overlay:  500;
  --z-modal:    1000;
  --z-popover:  1100;
  --z-tooltip:  1200;
  --z-toast:    1300;

  /* ========== أبعاد التخطيط ========== */
  --container-xs: 24rem;    /* 384px — تسجيل / دخول */
  --container-sm: 32rem;    /* 512px — نموذج بسيط */
  --container-md: 48rem;    /* 768px — محتوى قراءة */
  --container-lg: 64rem;    /* 1024px — البحث */
  --container-xl: 80rem;    /* 1280px — Landing */

  --header-height:  56px;
  --nav-mobile:     64px;

  /* ========== الأيقونات ========== */
  --icon-xs:  14px;
  --icon-sm:  16px;
  --icon-md:  20px;
  --icon-lg:  24px;
  --icon-xl:  32px;
  --icon-2xl: 40px;

  /* ========== حدود العناصر التفاعلية ========== */
  --touch-target: 44px;   /* WCAG 2.5.5 */
  --control-h-sm: 36px;
  --control-h-md: 42px;
  --control-h-lg: 48px;
}

/* ========== الوضع الداكن — جاهز لاحقاً ========== */
@media (prefers-color-scheme: dark) {
  /* :root { ... } سنبنيه في مرحلة لاحقة */
}

/* ========== احترام تفضيل تقليل الحركة ========== */
@media (prefers-reduced-motion: reduce) {
  :root {
    --duration-instant: 0.01ms;
    --duration-fast:    0.01ms;
    --duration-base:    0.01ms;
    --duration-slow:    0.01ms;
    --duration-slower:  0.01ms;
  }
}
