/* ==========================================================================
   أَعْيَادُ السَّيِّدَةِ الْعَذْرَاء — ورقة الأنماط الرئيسية
   تربية مسيحية · الصف الخامس · الدرس ١٥
   --------------------------------------------------------------------------
   الفهرس:
     1. المتغيّرات (Design tokens)
     2. إعادة الضبط والأساسيات
     3. الاتجاه العربي (RTL) والخطوط
     4. عناصر النموذج والأزرار وإمكانية الوصول
     5. نظام الأيقونات (SVG masks)
     6. الحركات (Animations)
     7. الوسائط والصور
     8. نظام الطباعة
   ========================================================================== */

/* ── 1. المتغيّرات ───────────────────────────────────────────────────────── */
:root {
  --navy: #16264a;
  --navy-soft: #23335e;
  --gold: #c9a227;
  --gold-light: #e8d59a;
  --cream: #faf5ea;
  --sand: #f3ead6;
  --line: #ddcba4;
  --ok: #3f7d55;
  --bad: #b3503f;

  --font-body: 'Baloo Bhaijaan 2', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Aref Ruqaa', 'Amiri', serif;
  --font-scripture: 'Amiri', 'Aref Ruqaa', serif;

  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 24px;
  --tap: 46px; /* أصغر مساحة لمس مقبولة */
}

/* ── 2. إعادة الضبط والأساسيات ──────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  /* يمنع تكبير الخط تلقائيًا عند تدوير الجهاز */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  background: var(--navy);
  font-family: var(--font-body);
  color: var(--cream);
  -webkit-tap-highlight-color: transparent;
  overflow-wrap: break-word;
}

/* ارتفاع الشاشة الحقيقي على الجوال (شريط المتصفح المتحرك) */
.app-shell {
  min-height: 100vh;
  min-height: 100svh;
  background: var(--navy);
}

.screen {
  min-height: 100vh;
  min-height: 100svh;
}

/* الشريط العلوي الثابت */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: rgba(22, 38, 74, 0.94);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(232, 213, 154, 0.22);
}

/* ── 3. الاتجاه العربي والخطوط ──────────────────────────────────────────── */
/* الاتجاه يُضبط على <html dir="rtl"> — هذه القواعد تعالج الحالات المختلطة */

/* أي رقم أو نص لاتيني داخل جملة عربية يبقى في مكانه الصحيح */
.ltr {
  direction: ltr;
  unicode-bidi: isolate;
}

/* عزل الأيقونات والرموز حتى لا تقلب ترتيب الكلمات حولها */
.bidi-isolate {
  unicode-bidi: isolate;
}

a {
  color: var(--gold);
  text-decoration: none;
}

a:hover {
  color: var(--gold-light);
}

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 700;
}

.scripture {
  font-family: var(--font-scripture);
}

/* ── 4. النماذج والأزرار وإمكانية الوصول ────────────────────────────────── */
button,
input,
textarea,
select {
  font-family: inherit;
  font-size: inherit;
}

button {
  /* الأزرار في النموذج تستخدم أنماطًا سطرية؛ هذه القواعد المشتركة فقط */
  appearance: none;
  -webkit-appearance: none;
}

textarea {
  resize: vertical;
}

/* حلقة تركيز واضحة لمستخدمي لوحة المفاتيح فقط — كانت مفقودة تمامًا */
:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
  border-radius: 6px;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--gold-light);
  outline-offset: 3px;
}

/* على الخلفية الفاتحة نحتاج تباينًا أعلى */
[data-paper] :focus-visible,
.panel :focus-visible {
  outline-color: var(--navy);
}

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

/* ── 5. نظام الأيقونات ──────────────────────────────────────────────────── */
/* أيقونات SVG أحادية اللون ترث لون النص المحيط بها.
   تحلّ محلّ الإيموجي الذي كان يختلف شكله من متصفّح لآخر
   ويقلب اتجاه النص العربي أحيانًا. */
.ico {
  display: inline-block;
  inline-size: 1.15em;
  block-size: 1.15em;
  flex: none;
  vertical-align: -0.2em;
  background-color: currentColor;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  unicode-bidi: isolate;
}

.ico-book {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M3 4.5A1.5 1.5 0 0 1 4.5 3H9a3 3 0 0 1 3 3v13a2.5 2.5 0 0 0-2.5-2.5H3z'/><path d='M21 4.5A1.5 1.5 0 0 0 19.5 3H15a3 3 0 0 0-3 3v13a2.5 2.5 0 0 1 2.5-2.5H21z'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M3 4.5A1.5 1.5 0 0 1 4.5 3H9a3 3 0 0 1 3 3v13a2.5 2.5 0 0 0-2.5-2.5H3z'/><path d='M21 4.5A1.5 1.5 0 0 0 19.5 3H15a3 3 0 0 0-3 3v13a2.5 2.5 0 0 1 2.5-2.5H21z'/></svg>");
}

.ico-doc {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/><path d='M14 3v5h5'/><path d='M9 13h6M9 17h6'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M14 3H7a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V8z'/><path d='M14 3v5h5'/><path d='M9 13h6M9 17h6'/></svg>");
}

.ico-video {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='2.5' y='5' width='14' height='14' rx='2.5'/><path d='M16.5 10.5 21.5 7.5v9l-5-3z'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='2.5' y='5' width='14' height='14' rx='2.5'/><path d='M16.5 10.5 21.5 7.5v9l-5-3z'/></svg>");
}

.ico-mic {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='9' y='2.5' width='6' height='11' rx='3'/><path d='M5.5 11a6.5 6.5 0 0 0 13 0'/><path d='M12 17.5V21'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='9' y='2.5' width='6' height='11' rx='3'/><path d='M5.5 11a6.5 6.5 0 0 0 13 0'/><path d='M12 17.5V21'/></svg>");
}

.ico-image {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='16' rx='2.5'/><circle cx='8.5' cy='9.5' r='1.8'/><path d='m3.5 17 4.8-4.6a2 2 0 0 1 2.7-.05L20.5 20'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='4' width='18' height='16' rx='2.5'/><circle cx='8.5' cy='9.5' r='1.8'/><path d='m3.5 17 4.8-4.6a2 2 0 0 1 2.7-.05L20.5 20'/></svg>");
}

.ico-open {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M13 4h7v7'/><path d='M20 4 11 13'/><path d='M18 14v4.5a2 2 0 0 1-2 2H5.5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2H10'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M13 4h7v7'/><path d='M20 4 11 13'/><path d='M18 14v4.5a2 2 0 0 1-2 2H5.5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2H10'/></svg>");
}

.ico-print {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M7 9V3.5h10V9'/><rect x='3' y='9' width='18' height='8' rx='2'/><rect x='7' y='14' width='10' height='6.5' rx='1'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M7 9V3.5h10V9'/><rect x='3' y='9' width='18' height='8' rx='2'/><rect x='7' y='14' width='10' height='6.5' rx='1'/></svg>");
}

.ico-bulb {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M9 18h6'/><path d='M10 21.5h4'/><path d='M12 2.5a6 6 0 0 0-3.5 10.9V18h7v-4.6A6 6 0 0 0 12 2.5Z'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M9 18h6'/><path d='M10 21.5h4'/><path d='M12 2.5a6 6 0 0 0-3.5 10.9V18h7v-4.6A6 6 0 0 0 12 2.5Z'/></svg>");
}

.ico-headphones {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 15v-3a8 8 0 0 1 16 0v3'/><rect x='2.5' y='14' width='4.5' height='7' rx='2'/><rect x='17' y='14' width='4.5' height='7' rx='2'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 15v-3a8 8 0 0 1 16 0v3'/><rect x='2.5' y='14' width='4.5' height='7' rx='2'/><rect x='17' y='14' width='4.5' height='7' rx='2'/></svg>");
}

.ico-sound-on {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 9.5h3.5L12 5.5v13L7.5 14.5H4z'/><path d='M15.8 9a4 4 0 0 1 0 6'/><path d='M18.4 6.4a7.6 7.6 0 0 1 0 11.2'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 9.5h3.5L12 5.5v13L7.5 14.5H4z'/><path d='M15.8 9a4 4 0 0 1 0 6'/><path d='M18.4 6.4a7.6 7.6 0 0 1 0 11.2'/></svg>");
}

.ico-sound-off {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 9.5h3.5L12 5.5v13L7.5 14.5H4z'/><path d='m16 9.5 5 5M21 9.5l-5 5'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 9.5h3.5L12 5.5v13L7.5 14.5H4z'/><path d='m16 9.5 5 5M21 9.5l-5 5'/></svg>");
}

.ico-guide {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 5.5A2.5 2.5 0 0 1 6.5 3H19v15H6.5A2.5 2.5 0 0 0 4 20.5z'/><path d='M4 20.5A2.5 2.5 0 0 1 6.5 18H19v3H6.5'/><path d='M8.5 7.5h7M8.5 11h5'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'><path d='M4 5.5A2.5 2.5 0 0 1 6.5 3H19v15H6.5A2.5 2.5 0 0 0 4 20.5z'/><path d='M4 20.5A2.5 2.5 0 0 1 6.5 18H19v3H6.5'/><path d='M8.5 7.5h7M8.5 11h5'/></svg>");
}

/* أيقونات شريط التنقّل — الأسهم معكوسة لتناسب الاتجاه من اليمين إلى اليسار */
.ico-back {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 12h16'/><path d='m14 6 6 6-6 6'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M4 12h16'/><path d='m14 6 6 6-6 6'/></svg>");
}

.ico-map {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M9 4 3 6.5v13L9 17l6 2.5 6-2.5v-13L15 7z'/><path d='M9 4v13M15 7v12.5'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round' stroke-linejoin='round'><path d='M9 4 3 6.5v13L9 17l6 2.5 6-2.5v-13L15 7z'/><path d='M9 4v13M15 7v12.5'/></svg>");
}

/* «السابقة» في RTL تشير إلى اليمين */
.ico-prev {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m9 5 7 7-7 7'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m9 5 7 7-7 7'/></svg>");
}

/* «التالية» في RTL تشير إلى اليسار */
.ico-next {
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m15 5-7 7 7 7'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'><path d='m15 5-7 7 7 7'/></svg>");
}

/* في المتصفحات القديمة التي لا تدعم mask نُخفي الأيقونة بدل إظهار مربّع أسود */
@supports not ((-webkit-mask-image: none) or (mask-image: none)) {
  .ico {
    display: none;
  }
}

/* ── 5ب. شريط التنقّل — قطعةٌ عائمةٌ موحَّدةٌ على كلِّ الأجهزة ────────────
   قطعةٌ صغيرةٌ عائمةٌ في وسطِ الأسفل بحوافٍّ دائريّةٍ وزجاجٍ ضبابيّ.
   مرفوعةٌ عن حافّةِ الشَّاشةِ فيسهُلُ الوصولُ إليها بالإبهام، وتتخطّى
   شريطَ الهومِ في الآيفون تلقائيًّا، والمحتوى يمرُّ تحتَها فتبدو الشَّاشةُ أخفّ.
   العرضُ يتبعُ المحتوى: يتَّسِعُ ويضيقُ حسبَ عددِ الأزرارِ الظّاهرة.        */
.bottom-nav {
  position: fixed;
  inset-inline: 0;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  z-index: 40;

  width: max-content;
  max-width: calc(100% - 20px);
  margin-inline: auto;

  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 5px;
  padding: 8px;

  border-radius: 999px;
  background: rgba(19, 32, 63, 0.74);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  backdrop-filter: blur(20px) saturate(180%);
  border: 1px solid rgba(232, 213, 154, 0.22);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.44), 0 2px 8px rgba(0, 0, 0, 0.26),
    inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

/* المتصفّحاتُ التي لا تدعمُ الزُّجاجَ الضَّبابيّ تحصلُ على خلفيّةٍ معتمة */
@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
  .bottom-nav {
    background: rgba(19, 32, 63, 0.97);
  }
}

/* الأزرار أفقيّةٌ افتراضيًّا على كلِّ الأجهزة: الأيقونةُ والكلمةُ جنبَ بعضِهما،
   وهو أوضحُ وأوسعُ من وضعِ الكلمةِ تحتَ الأيقونة */
.nav-btn {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 48px;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 17px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: rgba(250, 245, 234, 0.75);
  font-weight: 700;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.11);
  color: var(--cream);
}

.nav-btn:active {
  transform: scale(0.94);
}

.nav-btn .ico {
  inline-size: 20px;
  block-size: 20px;
  vertical-align: 0;
}

.nav-txt {
  font-size: 13.5px;
  line-height: 1.2;
  white-space: nowrap;
}

.nav-pos {
  align-self: center;
  flex: none;
  padding: 0 9px;
  font-size: 13px;
  font-weight: 800;
  color: var(--gold);
  direction: ltr;
  unicode-bidi: isolate;
  white-space: nowrap;
}

/* الشاشات تترك مساحةً أسفلها حتى لا يغطّي الشريطُ آخرَ المحتوى */
.app-shell:has(.bottom-nav) .screen {
  padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)) !important;
}

/* بديل للمتصفّحات التي لا تدعم :has */
@supports not selector(:has(*)) {
  .screen {
    padding-bottom: calc(104px + env(safe-area-inset-bottom, 0px)) !important;
  }
}

/* ── 5ج. الحاسوب واللابتوب: القطعةُ أبعدُ عن الحافّةِ وأوسعُ قليلًا ───────── */
@media (min-width: 901px) {
  .bottom-nav {
    bottom: 24px;
    max-width: min(760px, calc(100% - 48px));
  }

  .nav-btn {
    padding: 0 19px;
    min-height: 46px;
  }

  .nav-txt {
    font-size: 14px;
  }

  /* حركةٌ لطيفةٌ شبيهةٌ بارتفاعِ أيقوناتِ الـDock */
  .nav-btn:hover {
    transform: translateY(-2px);
  }

  .app-shell:has(.bottom-nav) .screen {
    padding-bottom: 110px !important;
  }
}

/* ── 5د. عارض الصفحات (بديل PDF) ────────────────────────────────────────
   صفحاتُ الكتابِ وشرائحُ المُلخَّصِ مُصيَّرةٌ مسبقًا كصورٍ webp، لأنَّ عرضَ
   ملفِّ PDF داخلَ <iframe> لا يعملُ على iOS ولا على معظمِ أجهزةِ أندرويد
   (يفرضُ تنزيلَ الملفِّ بدل عرضِه).                                       */
.page-viewer {
  border-radius: 16px;
  overflow: hidden;
  border: 2px solid #e0d0aa;
  background: #fff;
  /* بلا تمريرٍ داخليّ: الصُّورةُ تأخذُ عرضَ الحاويةِ وتنمو الحاويةُ بارتفاعِها،
     فتُمرَّرُ الصَّفحةُ طبيعيًّا بالإصبعِ ويبقى التَّكبيرُ بإصبعَينِ متاحًا */
}

.page-viewer > img {
  display: block;
  width: 100%;
  height: auto;
  background: #fff;
}

/* زرٌّ كبسوليٌّ بسيط (السابقة/التالية في عارضِ الكتاب) */
.pill-btn {
  font-family: inherit;
  transition: transform 0.15s ease, filter 0.15s ease;
}

.pill-btn:hover {
  filter: brightness(1.15);
}

.pill-btn:active {
  transform: scale(0.96);
}

/* ── 6. الحركات ─────────────────────────────────────────────────────────── */
@keyframes popIn {
  from {
    opacity: 0;
    transform: scale(0.94) translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes riseUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes shakeX {
  10%,
  90% {
    transform: translateX(-2px);
  }
  30%,
  70% {
    transform: translateX(4px);
  }
  50% {
    transform: translateX(-6px);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.25;
  }
  50% {
    opacity: 0.9;
  }
}

/* ── 7. الوسائط والصور ──────────────────────────────────────────────────── */
img,
video,
canvas,
iframe {
  max-width: 100%;
}

img {
  /* يمنع القفزات أثناء التحميل */
  background-color: rgba(243, 234, 214, 0.4);
}

video,
audio {
  outline: none;
}

audio {
  width: 100%;
}

/* ── 7ب. الاستجابة للشاشات (Responsive) ─────────────────────────────────
   الموقع مبنيّ أصلًا على clamp() وحدود مرنة؛ هذه القواعد تعالج ما تبقّى
   من مشكلاتٍ على الشاشاتِ الصَّغيرةِ وأجهزةِ الجَيْب.                     */

/* منع أيّ تمريرٍ أفقيّ مهما طال نصٌّ أو اتّسع عنصر */
html,
body {
  max-width: 100%;
  overflow-x: hidden;
}

/* احترام حوافّ الشاشات ذات الحزّة (iPhone) في الوضع الأفقيّ */
.screen,
.app-bar > div {
  padding-inline: max(0px, env(safe-area-inset-right)) max(0px, env(safe-area-inset-left));
}

/* الجداول المرنة والشبكات لا تفيض عن أعمدتها */
[style*="grid-template-columns"] > * {
  min-width: 0;
}

/* ═══ شاشات ≤ 900px: أجهزة لوحيّة وهواتف ═══ */
@media (max-width: 900px) {
  /* شريط تبويبات مكتبة الوسائط يصير قابلًا للتمرير أفقيًّا
     بدل أن يلتفّ على أربعة أسطر ويأكل نصف الشاشة */
  .media-tabs {
    display: flex;
    flex-wrap: nowrap !important;
    justify-content: flex-start !important;
    overflow-x: auto;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
  }

  .media-tabs::-webkit-scrollbar {
    display: none;
  }

  .media-tabs > button {
    flex: 0 0 auto;
    scroll-snap-align: start;
    white-space: nowrap;
  }
}

/* ═══ شاشات ≤ 560px: الهواتف ═══ */
@media (max-width: 560px) {
  /* لعبتا التوصيل: عمودان ضيّقان جدًّا على الهاتف — نجعلهما عمودًا واحدًا
     مع فاصلٍ واضحٍ بين «الصِّفة» و«ما يدلّ عليها» */
  .match-grid {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }

  .match-grid > div {
    gap: 8px !important;
  }

  /* الزَّخارف ذات التَّباعد الكبير تفيض على الشاشات الضيّقة */
  [style*="letter-spacing:10px"],
  [style*="letter-spacing:12px"] {
    letter-spacing: 5px !important;
  }

  /* عارض الصفحات على الهاتف: حوافٌّ أصغرُ وعرضٌ كامل */
  .page-viewer {
    border-radius: 12px;
    border-width: 1px;
  }

  /* صناديق إحصاءات الشهادة تملأ العرض */
  .cert-stats > div {
    flex: 1 1 100px;
    min-width: 0 !important;
  }

  /* القطعةُ العائمةُ على الهاتف: تبقى أزرارُها أفقيّةً وواسعة،
     ونكتفي بتقليصٍ طفيفٍ في الحشوِ لتتّسِعَ داخلَ عرضِ الشَّاشة */
  .bottom-nav {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    gap: 4px;
    padding: 7px;
    max-width: calc(100% - 16px);
  }

  .nav-btn {
    padding: 0 14px;
    min-height: 48px;
  }

  .nav-txt {
    font-size: 13px;
  }

  .nav-pos {
    padding: 0 7px;
    font-size: 12.5px;
  }
}

/* ═══ إخفاء كلماتِ الشَّريطِ حسبَ عددِ أزرارِه لا حسبَ عرضِ الشَّاشةِ وحدَه ═══
   داخلَ المحطّاتِ يحتوي الشَّريطُ خمسةَ أزرارٍ وعدّادًا (يوجدُ .nav-pos)،
   فلا تتّسِعُ كلماتُها إلّا على الشَّاشاتِ العريضة. أمّا الخريطةُ والمكتبةُ
   والشَّهادةُ فثلاثةُ أزرارٍ فقط، وتبقى كلماتُها ظاهرةً حتّى على الهاتف.
   وعندَ إخفاءِ الكلماتِ نُكبِّرُ الأيقوناتِ حتّى لا يبدوَ الشَّريطُ مضغوطًا.  */
@media (max-width: 760px) {
  .bottom-nav:has(.nav-pos) .nav-txt {
    display: none;
  }

  .bottom-nav:has(.nav-pos) .nav-btn {
    padding: 0 15px;
    min-height: 50px;
  }

  .bottom-nav:has(.nav-pos) .nav-btn .ico {
    inline-size: 24px;
    block-size: 24px;
  }
}

/* ═══ شاشات ≤ 360px: الهواتف الصغيرة جدًّا ═══ */
@media (max-width: 360px) {
  /* المحطّات: نُضيِّقُ الحشوَ قليلًا لتتّسِعَ الأزرارُ الستّة */
  .bottom-nav:has(.nav-pos) .nav-btn {
    padding: 0 11px;
  }

  .bottom-nav:has(.nav-pos) .nav-btn .ico {
    inline-size: 23px;
    block-size: 23px;
  }

  /* باقي الشَّاشات: ثلاثةُ أزرارٍ — تبقى الكلماتُ لكن بحشوٍ أقلّ */
  .nav-btn {
    padding: 0 12px;
  }

  .nav-txt {
    font-size: 12.5px;
  }
}

/* ═══ شاشات ≤ 340px: أضيقُ الهواتف (iPhone SE الأوّل) ═══
   هامشُ أمانٍ إضافيٌّ حتّى لو خرجَ عرضُ الخطِّ عن التَّقدير */
@media (max-width: 340px) {
  .bottom-nav {
    gap: 3px;
    padding: 6px;
    max-width: calc(100% - 12px);
  }

  .nav-btn,
  .bottom-nav:has(.nav-pos) .nav-btn {
    padding: 0 9px;
  }

  .nav-txt {
    font-size: 12px;
  }

  .nav-pos {
    padding: 0 5px;
    font-size: 12px;
  }
}

/* بديلٌ للمتصفّحاتِ التي لا تدعم :has — نُخفي الكلماتِ في كلِّ الشَّاشاتِ
   الضيّقةِ لأنّنا لا نستطيعُ معرفةَ عددِ الأزرارِ من غيرِها */
@supports not selector(:has(*)) {
  @media (max-width: 420px) {
    .nav-txt {
      display: none;
    }

    .nav-btn {
      padding: 0 15px;
      min-height: 50px;
    }

    .nav-btn .ico {
      inline-size: 24px;
      block-size: 24px;
    }
  }
}

/* ═══ الوضع الأفقيّ القصير: لا نُثبّت الشريط حتى لا يبتلع الشاشة ═══ */
@media (max-height: 430px) and (orientation: landscape) {
  .bottom-nav {
    position: static;
    margin: 18px auto;
    bottom: auto;
  }

  .app-shell:has(.bottom-nav) .screen {
    padding-bottom: 16px !important;
  }
}

/* ═══ أجهزة اللمس: تكبير مساحات اللمس ═══ */
@media (hover: none) and (pointer: coarse) {
  button,
  a[href],
  select {
    min-height: var(--tap);
  }
}

/* ── 8. نظام الطباعة ────────────────────────────────────────────────────── */
.print-only {
  display: none;
}

@page {
  size: A4 portrait;
  margin: 12mm;
}

@media print {
  /* أ. طباعة الألوان كما هي على الشاشة */
  *,
  *::before,
  *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    box-shadow: none !important;
    text-shadow: none !important;
    animation: none !important;
    transition: none !important;
  }

  /* ب. تحييد خلفية الموقع الكحليّة — كانت تُطبع صفحةً كاملةً سوداء */
  html,
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .app-shell,
  .screen {
    background: #fff !important;
    min-height: 0 !important;
    padding: 0 !important;
  }

  /* ج. إخفاء كل عناصر التحكّم والتنقّل */
  .app-bar,
  .no-print,
  .screen-only,
  nav,
  [data-noprint],
  button,
  input,
  select,
  .ico {
    display: none !important;
  }

  /* د. إظهار البدائل المخصّصة للطباعة */
  .print-only {
    display: block !important;
  }

  /* هـ. الورقة المطبوعة */
  [data-paper] {
    width: auto !important;
    max-width: none !important;
    margin: 0 auto !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }

  [data-paper] + [data-paper] {
    margin-top: 10mm !important;
    break-before: page;
    page-break-before: always;
  }

  /* و. مناطق النصّ الحرّة تُستبدل بنسخة نصيّة كاملة (.print-only)
        لأنّ <textarea> يقتطع ما لا يظهر داخل مربّعه عند الطباعة */
  textarea {
    display: none !important;
  }

  .print-text {
    display: block !important;
    white-space: pre-wrap;
    font-family: var(--font-scripture);
    font-size: 17px;
    line-height: 2.3;
    min-height: 60mm;
    border-bottom: 1px dashed #ccc;
  }

  /* ز. الروابط: لا نطبع عناوين URL الطويلة داخل نصّ عربيّ */
  a {
    color: inherit !important;
    text-decoration: none !important;
  }

  /* ح. العناوين */
  h1,
  h2,
  h3 {
    color: var(--navy) !important;
    break-after: avoid;
    page-break-after: avoid;
  }

  p,
  li {
    orphans: 3;
    widows: 3;
  }

  /* ط. لا نطبع الوسائط الثقيلة */
  video,
  iframe,
  canvas.no-print {
    display: none !important;
  }

  /* ي. تذييل الطباعة */
  .print-footer {
    display: block !important;
    margin-top: 8mm;
    padding-top: 4mm;
    border-top: 1px solid var(--line);
    font-size: 11px;
    color: #555 !important;
    text-align: center;
  }
}
