/* ==========================================================================
   Lamma · Design Tokens
   الطبقة الأساسية: كل قيمة تصميمية في المشروع تبدأ من هنا.
   لا يُسمح بأي لون أو مقاس ثابت (hard-coded) خارج هذا الملف.

   هوية «لمّة»، أخضر وذهبي على عاجي:
     أخضر داكن عميق  #064E3B: العلامة والأزرار الأساسية
     أخضر غامق جداً  #0B302B: خلفيات الأقسام البارزة
     أخضر متوسط      #176B56: الأيقونات والعناصر التفاعلية
     ذهبي دافئ       #D5A85C: إبراز الكلمات المهمة والتفاصيل
     ذهبي فاتح       #E8C78F: أزرار الدعوة إلى الكفالة
     أبيض عاجي       #F8F5EF: الخلفية الأساسية
     بيج فاتح        #E9DFD0: الخلفيات الثانوية
     رمادي دافئ      #6B7280: النصوص الوصفية
     فحمي داكن       #202B29: النصوص الرئيسية

   القاعدة: المكونات تستعمل الأدوار الدلالية (--color-*) فقط، لا السلالم.
   هكذا يعمل الوضع الليلي بإعادة تعريف الأدوار وحدها، بلا لمس أي مكوّن.
   ========================================================================== */

:root {
  color-scheme: light;

  /* ------------------------------------------------------------------
     1. السلالم الخام
     ------------------------------------------------------------------ */

  /* الأخضر (الاسم القديم teal باقٍ لأن المكوّنات كلها تستعمله): ٧٠٠ #064E3B الأساسي، ٦٠٠ #176B56 للأيقونات والتفاعل، ٩٠٠ #0B302B للأقسام البارزة */
  --teal-50:  #edf6f2;
  --teal-100: #d2e9df;
  --teal-200: #a7d3c1;
  --teal-300: #74b89f;
  --teal-400: #3f9a7d;
  --teal-500: #1f8165;
  --teal-600: #176b56;
  --teal-700: #064e3b;
  --teal-800: #053f30;
  --teal-900: #0b302b;
  --teal-950: #061e1a;

  /* الذهبي: ٥٠٠ #D5A85C للإبراز، و٣٠٠ #E8C78F لأزرار الدعوة إلى الكفالة */
  --gold-50:  #fbf6ec;
  --gold-100: #f6ebd5;
  --gold-200: #f0ddb6;
  --gold-300: #e8c78f;
  --gold-400: #dfb877;
  --gold-500: #d5a85c;
  --gold-600: #b98a3e;
  --gold-700: #91692c;
  --gold-800: #6c4e22;

  /* الطين — للصحة في المخططات وبرامج الكفالة فقط */
  --clay-500: #c9694b;
  --clay-600: #b5543a;
  --clay-300: #e08a6c;

  /* النمو والنجاح */
  --leaf-50:  #effbf3;
  --leaf-300: #7fd6a0;
  --leaf-400: #4cc47c;
  --leaf-600: #1f8048;
  --leaf-700: #186638;

  /* المعلومات */
  --sky-100: #e0f2fe;
  --sky-300: #7dd3fc;
  --sky-700: #0369a1;

  /* العاجل */
  --rose-100: #ffe4e6;
  --rose-400: #fb7185;
  --rose-700: #be123c;

  /* سلسلة للمخططات وبرنامج التعليم */
  --indigo-300: #9ea2f0;
  --indigo-500: #6366d9;

  /* المحايد: أرضية دافئة ونصوص رمادية مزرقّة */
  --sand-0:   #ffffff;
  --sand-25:  #fcfaf6;
  --sand-50:  #f8f5ef;
  --sand-100: #f1eae0;
  --sand-200: #e9dfd0;
  --sand-300: #d9ccb8;
  --sand-400: #a39a8c;
  --sand-500: #857c6f;   /* 3.5 على الأبيض: أدنى ما يُرى به حدّ حقل */
  --ink-500:  #6b7280;   /* 4.7 على السطح البديل */
  --ink-600:  #5a625f;
  --ink-700:  #3a4441;
  --ink-900:  #202b29;

  /* ------------------------------------------------------------------
     2. الأدوار الدلالية — استخدم هذه في المكونات، لا السلالم أعلاه
     ------------------------------------------------------------------ */

  /* العلامة: #064E3B يعطي 9.4 للنص الأبيض فوقه */
  --color-brand:            var(--teal-700);
  /* الشعار: ورقتان بلون العلامة وورقةٌ ذهبية (partials/logo-mark) */
  --logo-leaf:              #064e3b;
  --logo-gold:              #d5a85c;
  --font-logo:              'Tajawal', var(--font-display);
  --color-brand-hover:      var(--teal-800);
  --color-brand-strong:     var(--teal-800);   /* نص فوق السطح الناعم */
  --color-brand-soft:       var(--teal-50);
  --color-brand-border:     var(--teal-200);
  --color-brand-contrast:   var(--sand-0);
  --color-brand-2:          var(--teal-600);   /* الثانوي: أيقونات ومؤشرات */

  /* «اكفل»: الذهبي الفاتح لا يحمل نصاً أبيض، فنصّه الحبر الفحمي بتباين 10 */
  --color-cta:              var(--gold-300);
  --color-cta-hover:        var(--gold-400);
  --color-cta-contrast:     var(--ink-900);
  --color-cta-soft:         var(--gold-50);
  --color-cta-strong:       var(--gold-800);   /* نص فوق السطح الذهبي الناعم */
  --color-cta-display:      var(--gold-700);   /* نص عرض كبير فقط: 4.2 ≥ 3 */
  --color-highlight:        rgb(213 168 92 / 0.28);

  --color-accent:           var(--gold-500);
  --color-accent-soft:      var(--gold-50);
  --color-accent-strong:    var(--gold-800);

  --color-growth:           var(--teal-600);
  --color-growth-soft:      var(--teal-50);
  --color-growth-strong:    var(--teal-700);

  --color-canvas:           var(--sand-50);
  --color-surface:          var(--sand-0);
  --color-surface-alt:      var(--sand-200);
  --color-surface-raised:   var(--sand-0);

  --color-text:             var(--ink-900);
  --color-text-muted:       var(--ink-500);
  --color-text-subtle:      var(--ink-500);

  --color-border:           var(--sand-200);
  --color-border-strong:    var(--sand-300);
  /* حدّ الحقول وخانات الاختيار: مكوّن تفاعلي يلزمه 3:1 (WCAG 1.4.11)،
     والحدّ الزخرفي أعلاه 1.3:1 فيضيع الحقل على الأرضية */
  --color-border-field:     var(--sand-500);

  --color-success:          var(--leaf-600);
  --color-success-soft:     var(--leaf-50);
  --color-info:             var(--sky-700);
  --color-info-soft:        var(--sky-100);
  --color-urgent:           var(--rose-700);
  --color-urgent-soft:      var(--rose-100);
  --color-urgent-contrast:  var(--sand-0);

  /* الأقسام الداكنة — تركوازي عميق في الوضعين، فهي توقيع الهوية */
  --color-ink:              var(--teal-900);
  --color-on-ink:           #f4f7f5;
  --color-on-ink-muted:     rgb(244 247 245 / 0.76);
  --color-on-ink-accent:    var(--gold-300);
  --color-on-ink-cta:       var(--gold-300);
  --color-on-ink-brand:     var(--teal-300);
  --color-ink-line:         rgb(255 255 255 / 0.12);
  --color-ink-glass:        rgb(255 255 255 / 0.08);
  --color-ink-line-strong:  rgb(255 255 255 / 0.24);

  /* الأفاتار الحرفي — كلها تحمل نصاً أبيض بتباين ≥ 4.6 */
  --avatar-1: var(--teal-700);
  --avatar-2: var(--indigo-500);
  --avatar-3: var(--gold-700);
  --avatar-4: var(--leaf-700);

  /* نص فوق الصور الفوتوغرافية — أبيض دائماً لأن الصورة لا تتبع السمة */
  --color-on-photo:         #ffffff;
  --color-on-photo-muted:   rgb(255 255 255 / 0.84);
  --color-photo-glass:      rgb(255 255 255 / 0.14);
  --color-photo-line:       rgb(255 255 255 / 0.30);

  --color-scrim:            rgb(11 48 43 / 0.55);
  --color-selection:        var(--teal-100);
  --color-selection-text:   var(--teal-900);
  --color-scrollbar:        var(--sand-300);

  --color-focus:            var(--teal-600);
  --color-focus-halo:       var(--sand-25);

  /* ------------------------------------------------------------------
     3. ألوان البيانات — المخططات وشرائح الإنفاق وبرامج الكفالة
     قاعدة البيانات تخزّن أسماء هذه المتغيرات (لا قيماً)، فتتبع السمة.
     مُتحقَّق منها آلياً: أسوأ زوج ΔE 14.7 لعمى الأخضر، و20.1 لعمى الأحمر.
     ------------------------------------------------------------------ */
  --chart-1: var(--teal-700);
  --chart-2: var(--clay-500);
  --chart-3: var(--gold-300);
  --chart-4: var(--gold-500);
  --chart-5: var(--indigo-500);
  --chart-muted: var(--sand-400);

  --program-full: linear-gradient(var(--teal-700), var(--teal-700));
  --program-education: linear-gradient(var(--indigo-500), var(--indigo-500));
  --program-health: linear-gradient(var(--clay-600), var(--clay-600));
  --program-family: linear-gradient(var(--teal-500), var(--teal-500));

  /* ------------------------------------------------------------------
     4. الخلفيات — مسطّحة عمداً: الهوية بلا تدرجات لونية.
        تبقى بصيغة linear-gradient(لون، اللون نفسه) لأنها تُستعمل طبقات
        صورة (background-image، border-box)، واللون المجرد لا يصلح هناك.
        الاستثناء الوحيد fade-b: تعتيم أسود شفاف فوق الصور لقراءة النص.
     ------------------------------------------------------------------ */
  --gradient-brand: linear-gradient(var(--color-brand), var(--color-brand));
  --gradient-cta: linear-gradient(var(--color-cta), var(--color-cta));
  --gradient-shine: linear-gradient(var(--color-brand), var(--color-brand));
  --gradient-warm: linear-gradient(var(--color-surface), var(--color-surface));
  --gradient-night: linear-gradient(var(--color-ink), var(--color-ink));
  --gradient-gold: linear-gradient(var(--gold-300), var(--gold-300));
  --gradient-glow: linear-gradient(transparent, transparent);
  --gradient-fade-b: linear-gradient(to top, rgb(9 31 31 / 0.82), rgb(9 31 31 / 0.1) 55%, transparent);
  --gradient-mesh: linear-gradient(transparent, transparent);

  /* ------------------------------------------------------------------
     5. الطباعة — Readex Pro للعناوين، IBM Plex Sans Arabic للمتن،
        Aref Ruqaa للنصوص الروحية (الآيات والاقتباسات)
     ------------------------------------------------------------------ */
  --font-display: "Readex Pro", "Segoe UI", system-ui, sans-serif;
  --font-body:    "IBM Plex Sans Arabic", "Segoe UI", system-ui, sans-serif;
  --font-quote:   "Aref Ruqaa", "Readex Pro", serif;
  --font-num:     "IBM Plex Sans Arabic", ui-monospace, monospace;

  /* مقياس طباعي سلس (fluid) — يتمدد مع عرض الشاشة بلا قفزات */
  --text-2xs: clamp(0.75rem, 0.73rem + 0.10vw, 0.8125rem);   /* ١٢px حدٌّ أدنى للقراءة، والعربية أحوج */
  --text-xs:  clamp(0.78rem, 0.75rem + 0.14vw, 0.86rem);
  --text-sm:  clamp(0.88rem, 0.85rem + 0.16vw, 0.97rem);
  --text-md:  clamp(1.00rem, 0.96rem + 0.20vw, 1.10rem);
  --text-lg:  clamp(1.13rem, 1.07rem + 0.28vw, 1.28rem);
  --text-xl:  clamp(1.30rem, 1.20rem + 0.45vw, 1.55rem);
  --text-2xl: clamp(1.55rem, 1.38rem + 0.80vw, 2.05rem);
  --text-3xl: clamp(1.95rem, 1.60rem + 1.60vw, 3.05rem);
  --text-4xl: clamp(2.35rem, 1.80rem + 2.50vw, 4.10rem);
  --text-5xl: clamp(2.70rem, 1.90rem + 3.60vw, 5.40rem);

  --leading-tight:   1.15;
  --leading-snug:    1.35;
  --leading-normal:  1.65;
  --leading-relaxed: 1.85;

  --tracking-tight: -0.025em;
  --tracking-wide:  0.04em;

  /* ------------------------------------------------------------------
     6. المسافات — مقياس 4px متسق
     ------------------------------------------------------------------ */
  --space-1:  0.25rem;
  --space-2:  0.5rem;
  --space-3:  0.75rem;
  --space-4:  1rem;
  --space-5:  1.25rem;
  --space-6:  1.5rem;
  --space-8:  2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;
  --space-20: 5rem;
  --space-24: 6rem;

  /* حشوة الأقسام — تتنفس مع الشاشة */
  --section-gap: clamp(4rem, 2rem + 7.5vw, 8rem);
  --gutter:      clamp(1rem, 0.5rem + 2.2vw, 2.5rem);
  --container:   80rem;
  --container-narrow: 46rem;

  /* ------------------------------------------------------------------
     7. الأشكال — زوايا سخيّة بأسلوب Bento، وأزرار حبّية
     ------------------------------------------------------------------ */
  --radius-xs:   0.375rem;
  --radius-sm:   0.625rem;
  --radius-md:   0.875rem;
  --radius-lg:   1.25rem;
  --radius-xl:   1.75rem;
  --radius-2xl:  2.25rem;
  --radius-3xl:  3rem;
  --radius-pill: 999px;

  /* ------------------------------------------------------------------
     8. الظلال — مبنية على الفيروزي الداكن لا الأسود، فتبدو طبيعية
     ------------------------------------------------------------------ */
  --shadow-xs: 0 1px 2px rgb(9 31 31 / 0.05);
  --shadow-sm: 0 1px 3px rgb(9 31 31 / 0.06), 0 1px 2px rgb(9 31 31 / 0.04);
  --shadow-md: 0 8px 22px -6px rgb(9 31 31 / 0.10), 0 2px 6px -2px rgb(9 31 31 / 0.06);
  --shadow-lg: 0 20px 44px -12px rgb(9 31 31 / 0.16), 0 6px 14px -8px rgb(9 31 31 / 0.08);
  --shadow-xl: 0 36px 72px -20px rgb(9 31 31 / 0.26), 0 12px 26px -12px rgb(9 31 31 / 0.12);
  --shadow-brand: 0 12px 28px -10px rgb(15 92 92 / 0.45);
  --shadow-cta:   0 14px 30px -10px rgb(224 166 59 / 0.55);

  /* زجاج */
  --glass-bg:     rgb(255 255 255 / 0.72);
  --glass-strong: rgb(255 255 255 / 0.90);
  --glass-border: rgb(255 255 255 / 0.65);
  --glass-blur:   saturate(1.6) blur(18px);

  /* ------------------------------------------------------------------
     9. الحركة
     ------------------------------------------------------------------ */
  --ease-out:  cubic-bezier(0.16, 1, 0.3, 1);
  --ease-soft: cubic-bezier(0.33, 1, 0.68, 1);
  --ease-back: cubic-bezier(0.34, 1.4, 0.64, 1);

  --dur-fast:   180ms;
  --dur-normal: 320ms;
  --dur-slow:   620ms;
  --dur-scene:  900ms;

  /* ------------------------------------------------------------------
     10. الطبقات (z-index) — مركزية حتى لا تتضارب
     ------------------------------------------------------------------ */
  --z-base:    1;
  --z-raised:  10;
  --z-sticky:  100;
  --z-header:  200;
  --z-drawer:  300;
  --z-overlay: 400;
  --z-modal:   500;
  --z-toast:   600;
}

/* ==========================================================================
   الوضع الليلي
   يُعرَّف مرتين بالقيم نفسها: مرة لتفضيل الجهاز (ما لم يختر الزائر الفاتح
   صراحةً)، ومرة للاختيار اليدوي. لا يُعاد تعريف إلا الأدوار الدلالية.
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --logo-leaf: #3f9a7d;
    --logo-gold: #e8c78f;
    color-scheme: dark;

    --color-brand:          var(--teal-300);
    --color-brand-hover:    var(--teal-200);
    --color-brand-strong:   var(--teal-200);
    --color-brand-soft:     rgb(116 187 178 / 0.12);
    --color-brand-border:   rgb(116 187 178 / 0.32);
    --color-brand-contrast: var(--teal-950);
    --color-brand-2:        var(--teal-400);

    --color-cta:            var(--gold-400);
    --color-cta-hover:      var(--gold-300);
    --color-cta-soft:       rgb(224 166 59 / 0.14);
    --color-cta-strong:     var(--gold-300);
    --color-cta-display:    var(--gold-300);
    --color-highlight:      rgb(224 166 59 / 0.16);

    --color-accent:         var(--gold-300);
    --color-accent-soft:    rgb(224 166 59 / 0.12);
    --color-accent-strong:  var(--gold-200);

    --color-growth:         var(--teal-300);
    --color-growth-soft:    rgb(116 187 178 / 0.12);
    --color-growth-strong:  var(--teal-200);

    --color-canvas:         #0a1614;
    --color-surface:        #10201d;
    --color-surface-alt:    #152a26;
    --color-surface-raised: #1a322d;

    --color-text:           #ecefea;
    --color-text-muted:     #aab5b3;
    --color-text-subtle:    #909d9c;

    --color-border:         #263a3c;
    --color-border-strong:  #34494b;
    --color-border-field:   #667b7d;   /* 3.7 على السطح */

    --color-success:        var(--leaf-400);
    --color-success-soft:   rgb(76 196 124 / 0.14);
    --color-info:           var(--sky-300);
    --color-info-soft:      rgb(125 211 252 / 0.12);
    --color-urgent:         var(--rose-400);
    --color-urgent-soft:    rgb(251 113 133 / 0.14);
    --color-urgent-contrast: var(--teal-950);   /* الأبيض على الوردي الفاتح 2.8 */

    --color-ink:            #0b302b;
    --color-scrim:          rgb(0 0 0 / 0.62);
    --color-selection:      var(--teal-800);
    --color-selection-text: var(--teal-50);
    --color-scrollbar:      #34494b;

    --color-focus:          var(--teal-300);
    --color-focus-halo:     #0a1614;

    --chart-1: var(--teal-300);
    --chart-2: var(--clay-300);
    --chart-3: var(--gold-300);
    --chart-4: var(--gold-300);
    --chart-5: var(--indigo-300);
    --chart-muted: #6b7375;

    --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.30);
    --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.35);
    --shadow-md: 0 8px 22px -6px rgb(0 0 0 / 0.45);
    --shadow-lg: 0 20px 44px -12px rgb(0 0 0 / 0.55);
    --shadow-xl: 0 36px 72px -20px rgb(0 0 0 / 0.65);
    --shadow-brand: 0 12px 28px -10px rgb(116 187 178 / 0.30);
    --shadow-cta:   0 14px 30px -10px rgb(224 166 59 / 0.35);

    --glass-bg:     rgb(20 32 34 / 0.72);
    --glass-strong: rgb(20 32 34 / 0.92);
    --glass-border: rgb(255 255 255 / 0.08);
  }
}

:root[data-theme="dark"] {
  --logo-leaf: #3f9a7d;
  --logo-gold: #e8c78f;
  color-scheme: dark;

  --color-brand:          var(--teal-300);
  --color-brand-hover:    var(--teal-200);
  --color-brand-strong:   var(--teal-200);
  --color-brand-soft:     rgb(116 187 178 / 0.12);
  --color-brand-border:   rgb(116 187 178 / 0.32);
  --color-brand-contrast: var(--teal-950);
  --color-brand-2:        var(--teal-400);

  --color-cta:            var(--gold-400);
  --color-cta-hover:      var(--gold-300);
  --color-cta-soft:       rgb(224 166 59 / 0.14);
  --color-cta-strong:     var(--gold-300);
  --color-cta-display:    var(--gold-300);
  --color-highlight:      rgb(224 166 59 / 0.16);

  --color-accent:         var(--gold-300);
  --color-accent-soft:    rgb(224 166 59 / 0.12);
  --color-accent-strong:  var(--gold-200);

  --color-growth:         var(--teal-300);
  --color-growth-soft:    rgb(116 187 178 / 0.12);
  --color-growth-strong:  var(--teal-200);

  --color-canvas:         #0a1614;
  --color-surface:        #10201d;
  --color-surface-alt:    #152a26;
  --color-surface-raised: #1a322d;

  --color-text:           #ecefea;
  --color-text-muted:     #aab5b3;
  --color-text-subtle:    #909d9c;

  --color-border:         #263a3c;
  --color-border-strong:  #34494b;
  --color-border-field:   #667b7d;   /* 3.7 على السطح */

  --color-success:        var(--leaf-400);
  --color-success-soft:   rgb(76 196 124 / 0.14);
  --color-info:           var(--sky-300);
  --color-info-soft:      rgb(125 211 252 / 0.12);
  --color-urgent:         var(--rose-400);
  --color-urgent-soft:    rgb(251 113 133 / 0.14);
  --color-urgent-contrast: var(--teal-950);   /* الأبيض على الوردي الفاتح 2.8 */

  --color-ink:            #0b302b;
  --color-scrim:          rgb(0 0 0 / 0.62);
  --color-selection:      var(--teal-800);
  --color-selection-text: var(--teal-50);
  --color-scrollbar:      #34494b;

  --color-focus:          var(--teal-300);
  --color-focus-halo:     #0a1614;

  --chart-1: var(--teal-300);
  --chart-2: var(--clay-300);
  --chart-3: var(--gold-300);
  --chart-4: var(--gold-300);
  --chart-5: var(--indigo-300);
  --chart-muted: #6b7375;

  --shadow-xs: 0 1px 2px rgb(0 0 0 / 0.30);
  --shadow-sm: 0 1px 3px rgb(0 0 0 / 0.35);
  --shadow-md: 0 8px 22px -6px rgb(0 0 0 / 0.45);
  --shadow-lg: 0 20px 44px -12px rgb(0 0 0 / 0.55);
  --shadow-xl: 0 36px 72px -20px rgb(0 0 0 / 0.65);
  --shadow-brand: 0 12px 28px -10px rgb(116 187 178 / 0.30);
  --shadow-cta:   0 14px 30px -10px rgb(224 166 59 / 0.35);

  --glass-bg:     rgb(20 32 34 / 0.72);
  --glass-strong: rgb(20 32 34 / 0.92);
  --glass-border: rgb(255 255 255 / 0.08);
}

/* --------------------------------------------------------------------
   التتبّع والعربية
   الحروف العربية متصلة، وأي تباعدٍ بينها (موجباً أو سالباً) يقطع وصلها
   أو يُركِب بعضها على بعض. فالتتبّع صفرٌ للنص العربي، ويعود لما يُكتب
   بلغة لاتينية داخله (`lang="en"`)، والأرقام لها قيمها الخاصة في مواضعها.
   -------------------------------------------------------------------- */
:lang(ar) {
  --tracking-tight: 0;
  --tracking-wide:  0;
}

:lang(en) {
  --tracking-tight: -0.025em;
  --tracking-wide:  0.04em;
}
