/*
 * طبقة خط ثمانية — نبراس
 * خط فقط: لا ألوان، لا تخطيط، لا مقاسات مكوّنات. كل القواعد داخل @media screen
 * فتختفي كليًا عند الطباعة. مستندات الطباعة وقوالب A4 وورقة التقارير مستثناة
 * حتى على الشاشة لأن تصدير PDF يلتقط أنماط الشاشة نفسها.
 *
 * الملفات الرسمية من حزمة ترخيص عائلة ثمانية:
 * - Thmanyah Sans لنصوص الواجهة، مع خاصية "swsh" (المدّات المرسلة في نهايات
 *   الكلمات — بصمة ثمانية البصرية) مفعّلة في كل النصوص.
 * - Thmanyah Serif Display للعناوين الكبيرة مع "dlig" إضافةً للمدّات.
 */

@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Light.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 300;
}

@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Regular.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 400;
}

@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Medium.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 500;
}

@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Bold.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 700;
}

@font-face {
  font-family: "Thmanyah Sans";
  src: url("fonts/thmanyahsans-Black.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 900;
}

@font-face {
  font-family: "Thmanyah Serif Display";
  src: url("fonts/thmanyahserifdisplay-Medium.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 500;
}

@font-face {
  font-family: "Thmanyah Serif Display";
  src: url("fonts/thmanyahserifdisplay-Bold.woff2") format("woff2");
  font-display: swap;
  font-style: normal;
  font-weight: 700;
}

@media screen {
  :root {
    --thm-font: "Thmanyah Sans", "Cairo", "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
    --thm-font-display: "Thmanyah Serif Display", "Thmanyah Sans", "Cairo", "Tajawal", "Segoe UI", Tahoma, Arial, sans-serif;
    --thm-feat-text: "swsh" 1, "kern" 1, "liga" 1;
    --thm-feat-display: "swsh" 1, "dlig" 1, "kern" 1, "liga" 1;
  }

  body {
    font-family: var(--thm-font);
    font-feature-settings: var(--thm-feat-text);
    font-kerning: normal;
    text-rendering: optimizeLegibility;
  }

  /*
   * فرض ثمانية على كل عناصر الشاشة، حتى القواعد القديمة التي تطلب Cairo أو
   * Amiri أو Tajawal أو Courier مباشرة. جذور المستندات القابلة للطباعة
   * وكل أبنائها خارج هذا الفرض كي يبقى تصدير A4/PDF مطابقًا تمامًا.
   */
  body :where(*:not(:where(
    .a4,
    .a4 *,
    .gp-card,
    .gp-card *,
    .print-pack,
    .print-pack *,
    .stage .sheet,
    .stage .sheet *,
    .sheet.export,
    .sheet.export *
  ))) {
    font-family: var(--thm-font) !important;
    font-feature-settings: var(--thm-feat-text);
    font-kerning: normal;
  }

  body :where(*:not(:where(
    .a4,
    .a4 *,
    .gp-card,
    .gp-card *,
    .print-pack,
    .print-pack *,
    .stage .sheet,
    .stage .sheet *,
    .sheet.export,
    .sheet.export *
  )))::before,
  body :where(*:not(:where(
    .a4,
    .a4 *,
    .gp-card,
    .gp-card *,
    .print-pack,
    .print-pack *,
    .stage .sheet,
    .stage .sheet *,
    .sheet.export,
    .sheet.export *
  )))::after {
    font-family: inherit !important;
    font-feature-settings: inherit;
  }

  body :where(input, textarea):not(:where(
    .a4 *,
    .gp-card *,
    .print-pack *,
    .stage .sheet *,
    .sheet.export *
  ))::placeholder,
  body :where(input[type="file"]):not(:where(
    .a4 *,
    .gp-card *,
    .print-pack *,
    .stage .sheet *,
    .sheet.export *
  ))::file-selector-button {
    font-family: var(--thm-font) !important;
    font-feature-settings: var(--thm-feat-text);
  }

  /*
   * العناوين الكبيرة بعائلة Thmanyah Serif Display بأسلوب عناوين ثمانية،
   * مع إلغاء أي تقارب أحرف سالب لأنه يضر بجمال التشكيل العربي.
   */
  body :where(h1, h2, h3, [role="heading"]):not(:where(
    .a4 *,
    .gp-card *,
    .print-pack *,
    .stage .sheet *,
    .sheet.export *
  )) {
    font-family: var(--thm-font-display) !important;
    font-feature-settings: var(--thm-feat-display);
    font-kerning: normal;
    letter-spacing: 0 !important;
  }

  body :where(h4, h5, h6, legend):not(:where(
    .a4 *,
    .gp-card *,
    .print-pack *,
    .stage .sheet *,
    .sheet.export *
  )) {
    font-feature-settings: var(--thm-feat-display);
  }

  /*
   * جذور المستندات القابلة للطباعة تستعيد خط ما قبل الطبقة بقاعدة عديمة
   * التخصيص، فلا تتفوق على أي محدد مباشر من ملفات الطباعة، وتمنع في الوقت
   * نفسه وراثة خط الشاشة الجديد من body.
   */
  :where(body) :where(.a4, .gp-card, .print-pack, .stage .sheet, .sheet.export) {
    font-family: "Tajawal", "Cairo", sans-serif;
    font-feature-settings: normal;
    font-kerning: auto;
    font-synthesis: weight style small-caps;
    text-rendering: auto;
  }
}
