/* ══════════════════════════════════════════════════════════════
   صفحة القراءة — إطار فخم يستضيف كتاب الـ248 صفحة
   ══════════════════════════════════════════════════════════════ */











@media (max-width:820px){}

:root{
  color-scheme:dark;
  --bg-0:#170309;--bg-1:#22060d;
  --cover:#41161e;
  --burg-deep:#3d0d19;--burg:#511322;--burg-soft:#6b2434;
  --gold:#C9A961;--gold-deep:#b8944d;--gold-soft:#e6d4a3;--gold-bright:#ffe89e;--gold-white:#fff5d9;
  --ink:#fdfbf7;--body:rgba(253,251,247,.80);--muted:rgba(253,251,247,.56);--faint:rgba(253,251,247,.32);
  --line:rgba(201,169,97,.20);--line-hi:rgba(201,169,97,.48);
  --serif:"Playfair Display",Georgia,serif;
  --sans:"Cairo",system-ui,-apple-system,sans-serif;
  --mono:"JetBrains Mono",ui-monospace,monospace;
  --ease-expo:cubic-bezier(.16,1,.3,1);
  --ease-out:cubic-bezier(.22,1,.36,1);
  --ease-pop:cubic-bezier(.34,1.56,.64,1);
  --sh-1:0 2px 8px rgba(0,0,0,.34);
  --sh-2:0 14px 40px rgba(0,0,0,.46);
  --sh-3:0 32px 90px rgba(0,0,0,.60);
}

*,*::before,*::after{box-sizing:border-box}
html{scroll-behavior:smooth;-webkit-text-size-adjust:100%}body,button,input,select,textarea,h1,h2,h3,h4,p,a,span,b,i,em,strong,small,label,li{
  font-family:var(--sans);
}
body{
  margin:0;direction:rtl;background:var(--bg-0);color:var(--body);
  font-size:15px;line-height:1.7;-webkit-font-smoothing:antialiased;
  display:flex;flex-direction:column;height:100vh;overflow:hidden;
}
img{max-width:100%;display:block}
a{color:inherit;text-decoration:none}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer}
::selection{background:rgba(201,169,97,.34);color:#fff}
:focus-visible{outline:2px solid var(--gold);outline-offset:3px;border-radius:8px}

/* خلفيّة الصفحة */
.bg{position:fixed;inset:0;z-index:0;pointer-events:none;background:
  radial-gradient(900px 620px at 78% -8%,rgba(201,169,97,.14),transparent 62%),
  radial-gradient(760px 520px at 8% 12%,rgba(122,45,63,.30),transparent 60%),
  radial-gradient(1200px 900px at 50% 118%,rgba(81,19,34,.55),transparent 70%)}
.grain{position:fixed;inset:0;z-index:9;pointer-events:none;opacity:.32;
  mix-blend-mode:soft-light;background-size:220px 220px;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.42'/%3E%3C/svg%3E")}
body>*:not(.bg):not(.grain){position:relative;z-index:2}

/* ═══════ الشريط العلويّ ═══════ */
.top{
  height:66px;flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;
  gap:14px;padding:0 clamp(14px,3vw,28px);
  background:linear-gradient(180deg,rgba(23,3,9,.94),rgba(23,3,9,.78));
  -webkit-backdrop-filter:blur(20px) saturate(160%);backdrop-filter:blur(20px) saturate(160%);
  border-bottom:1px solid var(--line);box-shadow:0 6px 28px rgba(0,0,0,.44);
  z-index:40;
}
.t-brand{display:flex;align-items:center;gap:11px;min-width:0}
.t-mark{width:36px;height:36px;flex:0 0 auto;border-radius:10px;display:grid;place-items:center;
  background:linear-gradient(145deg,var(--burg-soft),var(--bg-0));
  border:1px solid var(--line-hi);font-family:var(--serif);font-weight:900;font-size:16px;
  color:var(--gold);box-shadow:var(--sh-1),inset 0 1px 0 rgba(255,255,255,.14)}
.t-txt{display:flex;flex-direction:column;line-height:1.25;min-width:0}
.t-txt b{font-size:13.2px;font-weight:800;color:var(--ink);white-space:nowrap}
.t-txt span{font-size:9.6px;font-weight:700;color:var(--gold-deep);white-space:nowrap}

/* شريط التقدّم */
.t-prog{flex:1;max-width:420px;display:flex;align-items:center;gap:11px;min-width:0}
.t-bar{flex:1;height:5px;border-radius:99px;background:rgba(255,255,255,.09);
  overflow:hidden;position:relative;box-shadow:inset 0 1px 2px rgba(0,0,0,.5)}
.t-bar i{display:block;height:100%;width:0;border-radius:99px;
  background:linear-gradient(90deg,var(--gold-deep),var(--gold-bright));
  box-shadow:0 0 12px rgba(201,169,97,.8);transition:width .35s var(--ease-out)}
.t-pct{font-family:var(--mono);font-size:10.6px;font-weight:700;color:var(--gold-soft);
  min-width:38px;text-align:center}

/* أزرار */
.t-actions{display:flex;align-items:center;gap:9px}
.tb{
  display:inline-flex;align-items:center;gap:8px;padding:10px 17px;border-radius:11px;
  font-size:13.2px;font-weight:700;white-space:nowrap;
  transition:transform .38s var(--ease-pop),box-shadow .38s,background .34s,border-color .34s}
.tb svg{width:16px;height:16px;flex:0 0 auto}
.tb-gold{color:#2a0810;
  background:linear-gradient(135deg,var(--gold-white),var(--gold) 52%,var(--gold-deep));
  box-shadow:0 8px 24px rgba(201,169,97,.26),inset 0 1px 0 rgba(255,255,255,.45)}
.tb-gold:hover{transform:translateY(-2px);box-shadow:0 14px 34px rgba(201,169,97,.4)}
.tb-glass{color:var(--ink);border:1px solid rgba(255,255,255,.15);background:rgba(255,255,255,.055);
  -webkit-backdrop-filter:blur(14px);backdrop-filter:blur(14px)}
.tb-glass:hover{transform:translateY(-2px);border-color:var(--gold);color:var(--gold-bright);background:rgba(201,169,97,.13)}
.tb-icon{width:42px;height:42px;padding:0;justify-content:center;border-radius:11px}
.tb-icon svg{width:18px;height:18px}

/* ═══════ الساحة ═══════ */
.stage{
  flex:1;min-height:0;display:grid;
  grid-template-columns:290px 1fr;
  transition:grid-template-columns .45s var(--ease-expo);
}
.stage.closed{grid-template-columns:0 1fr}

/* اللوحة الجانبيّة (الفهرس) */
.side{
  overflow:hidden auto;border-left:1px solid var(--line);
  background:linear-gradient(180deg,rgba(34,6,13,.70),rgba(23,3,9,.55));
  -webkit-backdrop-filter:blur(18px);backdrop-filter:blur(18px);
  padding:20px 0 40px;
}
.side::-webkit-scrollbar{width:7px}
.side::-webkit-scrollbar-thumb{background:rgba(201,169,97,.34);border-radius:7px}
.side-in{width:290px}
.sd-head{padding:0 20px 16px;border-bottom:1px solid var(--line);margin-bottom:12px}
.sd-head h3{font-size:15px;font-weight:800;color:var(--ink);margin:0 0 4px}
.sd-head p{font-size:11.4px;color:var(--muted);margin:0}
.sd-group{margin-bottom:6px}
.sd-part{
  display:flex;align-items:center;gap:10px;padding:12px 20px 8px;cursor:pointer;
  font-size:12.6px;font-weight:800;color:var(--gold);user-select:none}
.sd-part:hover{color:var(--gold-bright)}
.sd-roman{font-family:var(--sans);font-weight:900;font-size:15px;min-width:16px}
.sd-list{overflow:hidden;transition:max-height .45s var(--ease-expo);max-height:3000px}
.sd-group.collapsed .sd-list{max-height:0}
.sd-item{
  display:flex;align-items:baseline;gap:9px;padding:8px 20px 8px 26px;
  font-size:12.8px;color:var(--body);cursor:pointer;position:relative;
  border-right:2px solid transparent;transition:all .3s var(--ease-out)}
.sd-item:hover{background:rgba(201,169,97,.08);color:var(--gold-soft)}
.sd-item.on{background:rgba(201,169,97,.13);color:var(--gold-bright);border-right-color:var(--gold)}
.sd-item .n{font-family:var(--mono);font-size:9.6px;font-weight:700;color:var(--gold-deep);min-width:20px}
.sd-item .pg{margin-right:auto;font-family:var(--mono);font-size:9.6px;color:var(--muted)}

/* منطقة الكتاب */
.reader{
  overflow:auto;padding:clamp(14px,2.4vw,30px);
  display:flex;flex-direction:column;align-items:center;gap:0;
  scroll-behavior:smooth;
}
.reader::-webkit-scrollbar{width:10px}
.reader::-webkit-scrollbar-thumb{background:linear-gradient(180deg,var(--gold-deep),var(--gold));
  border-radius:10px}
.reader::-webkit-scrollbar-track{background:rgba(0,0,0,.3)}

/* ── الإطار الفخم ── */
.frame{
  position:relative;width:100%;max-width:900px;margin:0 auto;
  border-radius:18px;overflow:hidden;
  background:#fff;
  border:1px solid var(--line-hi);
  box-shadow:var(--sh-3),0 0 60px rgba(201,169,97,.10),inset 0 1px 0 rgba(255,255,255,.4)}
.frame::before{content:"";position:absolute;inset:0;border-radius:inherit;padding:1.6px;pointer-events:none;z-index:5;
  background:linear-gradient(180deg,rgba(255,232,158,.85),rgba(201,169,97,.25) 20%,
    rgba(201,169,97,0) 45%,rgba(201,169,97,0) 55%,rgba(201,169,97,.25) 80%,rgba(255,232,158,.7));
  -webkit-mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);
  -webkit-mask-composite:xor;
          mask:linear-gradient(#000 0 0) content-box,linear-gradient(#000 0 0);
          mask-composite:exclude}
/* شريط النافذة الفخم */
.f-bar{
  display:flex;align-items:center;gap:12px;padding:11px 16px;
  background:linear-gradient(180deg,#2a0810,#1c050b);
  border-bottom:1px solid rgba(201,169,97,.28)}
.f-dots{display:flex;gap:6px;flex:0 0 auto}
.f-dots span{width:10px;height:10px;border-radius:50%}
.f-dots span:nth-child(1){background:#e35d51}
.f-dots span:nth-child(2){background:#e6c04a}
.f-dots span:nth-child(3){background:#65c563}
.f-name{
  flex:1;text-align:center;font-family:var(--mono);font-size:9.6px;font-weight:700;
  letter-spacing:1.4px;color:var(--gold);text-transform:uppercase;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.f-page{
  font-family:var(--mono);font-size:10px;font-weight:800;color:#2a0810;
  background:linear-gradient(135deg,var(--gold-white),var(--gold));
  padding:4px 10px;border-radius:7px;flex:0 0 auto;min-width:58px;text-align:center}
.f-body{position:relative;background:#FBF8F2}
.f-body iframe{display:block;width:100%;border:0;height:calc(100vh - 66px - 52px - 60px)}

/* شريط الأدوات السفليّ */
.f-ctrl{
  display:flex;align-items:center;justify-content:center;gap:10px;
  padding:14px;background:linear-gradient(180deg,rgba(28,5,11,.9),rgba(23,3,9,.96));
  border-top:1px solid rgba(201,169,97,.24)}
.cbtn{
  display:inline-flex;align-items:center;gap:8px;padding:11px 20px;border-radius:12px;
  font-size:13.2px;font-weight:700;color:var(--ink);
  border:1px solid var(--line);background:rgba(255,255,255,.05);
  -webkit-backdrop-filter:blur(12px);backdrop-filter:blur(12px);
  transition:transform .38s var(--ease-pop),background .34s,border-color .34s,color .34s}
.cbtn:hover:not(:disabled){transform:translateY(-2px);border-color:var(--gold);
  background:rgba(201,169,97,.14);color:var(--gold-bright)}
.cbtn:disabled{opacity:.32;cursor:not-allowed}
.cbtn svg{width:16px;height:16px}
.cnum{font-family:var(--mono);font-size:12.4px;font-weight:800;color:var(--gold-soft);
  padding:0 12px;min-width:104px;text-align:center}
.cnum b{color:var(--gold-bright);font-size:14px}

/* المؤشّر العائم */
.cur{display:none}
html.has-cur{cursor:none}
html.has-cur .cur{display:block;position:fixed;top:0;left:0;width:26px;height:26px;
  pointer-events:none;z-index:9999;
  transform:translate(var(--cx,-120px),var(--cy,-120px)) translate(-50%,-50%)}
html.has-cur .cur::after{content:"";position:absolute;inset:0;border-radius:50%;
  border:1.5px solid rgba(201,169,97,.9);mix-blend-mode:exclusion;
  transition:transform .22s var(--ease-pop)}
html.has-cur .cur.on::after{transform:scale(1.85)}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{animation-duration:.01ms !important;transition-duration:.01ms !important}
  .cur{display:none !important}html.has-cur{cursor:auto}}

/* الاستجابة */
@media (max-width:1000px){
  .stage{grid-template-columns:1fr}
  .side{position:fixed;top:66px;bottom:0;right:0;width:290px;z-index:35;
    transform:translateX(100%);transition:transform .45s var(--ease-expo);
    box-shadow:-20px 0 50px rgba(0,0,0,.6)}
  .stage.open .side{transform:translateX(0)}
  .stage.closed .side{transform:translateX(100%)}}
@media (max-width:640px){
  .prop{display:none}
  .t-prog{display:none}
  .f-body iframe{height:calc(100vh - 66px - 52px - 58px)}
  .cbtn span{display:none}
  .cbtn{padding:11px 15px}}

/* ═══════════════════════════════════════════════════════════════
   ⚠️ إصلاح الإطار الفارغ — ١٩ أكتوبر ٢٠٢٦
   العطل الحقيقيّ: `.stage` شبكة grid، و`.frame` و`.f-body` بلا ارتفاع
   صريح ⇒ الصفّ ياخد ارتفاع **المحتوى** (٠) — والإطار `height:calc(100vh…)`
   بس أبوه مالو ارتفاع، فينكمش لصفر ⇒ **مستطيل أبيض فاضي**.
   الحلّ: نُعطي السلسلة كلّها ارتفاعًا صريحًا (min-height:0 على كل أب)،
   ونستعمل flex column للـreader حتى يقدر الإطار ياخد المساحة الباقية.
   ═══════════════════════════════════════════════════════════════ */

/* ١) الأب الأكبر: ارتفاع ثابت بلا تمرير */
.stage{ height:calc(100vh - 66px); min-height:0; overflow:hidden }

/* ٢) عمود القارئ: flex عموديّ + min-height:0 (الأهمّ — بدونه ما ينكمش) */
.reader{ display:flex; flex-direction:column; min-height:0; height:100%; overflow:hidden }

/* ٣) الإطار: ياخد المساحة الباقية */
.frame{ display:flex; flex-direction:column; min-height:0; height:100%; overflow:hidden }

/* ٤) جسم الكتاب: flex:1 + min-height:0 ⇒ إطار الكتاب ياخد الباقي */
.f-body{ flex:1; min-height:0; overflow:hidden; display:flex; flex-direction:column }

/* ٥) الإطار نفسه: يملأ أباه تمامًا (بدل calc هشّ) */
.f-body iframe,
#bookFrame{
  display:block;
  width:100%;
  flex:1;
  min-height:0;
  height:auto;          /* نتجاوز calc(100vh…) القديم */
  border:0;
  background:#fff;
}

/* ٦) على الجوال: نفس المنطق، وارتفاع أدقّ */
@media (max-width:900px){
  .stage{ height:calc(100vh - 58px) }
  .f-body iframe,#bookFrame{ height:auto }
}

/* ⚠️ احتياط — ١٩ أكتوبر ٢٠٢٦
   Book Navigator داخل Book.html كان position:fixed;inset:0;z-index:99999
   فيغطّي الصفحات ⇒ منطقة فاضية. هذا التعطيل يشمل أيّ إطار. */
iframe .bnv-root, iframe .bnv-backdrop, iframe .bnv-panel,
.bnv-root, .bnv-backdrop, .bnv-panel{
  display:none !important;visibility:hidden !important;pointer-events:none !important}

/* ══════════════════════════════════════════════════════════════
   تجربة القراءة على الموبايل — ١٩ أكتوبر ٢٠٢٦
   الأغلبية تفتح من الجوال ⇒ نُخفي الفهرس الجانبيّ تلقائيًّا،
   ونُعطي الإطار كامل العرض، ونُصغّر هوامش الأدوات.
   ══════════════════════════════════════════════════════════════ */
@media screen and (max-width:900px){
  /* الإطار يملأ الشاشة بلا هوامش */
  .frame{ max-width:100% !important; border-radius:0 !important; border-left:0 !important; border-right:0 !important }

  /* ارتفاع أدقّ: يخصم الشريط العلويّ وشريط الأدوات */
  .stage{ height:calc(100dvh - 58px) !important }
  .f-body iframe,#bookFrame{ height:auto !important }

  /* شريط الأدوات السفليّ أصغر */
  .f-ctrl{ padding:9px 8px !important; gap:7px !important }
  .cbtn{ padding:9px 13px !important; font-size:12.4px !important }

  /* شريط عنوان الكتاب أصغر */
  .f-bar{ padding:9px 13px !important }
  .f-page{ font-size:9.6px !important }
}
@media screen and (max-width:420px){
  .cbtn{ padding:9px 10px !important; font-size:11.8px !important }
  .f-name{ font-size:10.2px !important }
}
/* ضمان: لا تمرير أفقيّ في أيّ حال */
html,body{ max-width:100%; overflow-x:hidden }

/* ══════════════════════════════════════════════════════════════
   أزرار التحكّم بحجم القراءة — ١٩ أكتوبر ٢٠٢٦
   ══════════════════════════════════════════════════════════════ */
.zoombox{
  display:inline-flex; align-items:center; gap:2px;
  padding:3px 4px; border-radius:11px;
  background:rgba(255,255,255,.05);
  border:1px solid var(--line);
}
.zbtn{
  width:30px;height:30px;flex:0 0 auto;
  display:grid;place-items:center;cursor:pointer;
  border-radius:8px;border:0;background:transparent;
  color:var(--gold-soft);
  transition:background .25s, color .25s, transform .25s;
}
.zbtn:hover:not(:disabled){ background:rgba(201,169,97,.18); color:var(--gold-bright); transform:translateY(-1px) }
.zbtn:active:not(:disabled){ transform:scale(.92) }
.zbtn:disabled{ opacity:.28; cursor:not-allowed }
.zval{
  min-width:44px; text-align:center;
  font-family:var(--mono); font-size:10.8px; font-weight:800;
  color:var(--gold); letter-spacing:.3px;
  user-select:none;
}
@media (max-width:520px){
  .zbtn{ width:27px;height:27px }
  .zval{ min-width:38px;font-size:10px }
  .zoombox{ padding:2px 3px; gap:0 }
}

/* ══════════════════════════════════════════════════════════════════
   🔒 إصلاحات درج الفهرس على الجوال — ٢٢ أكتوبر ٢٠٢٦
   ══════════════════════════════════════════════════════════════════ */

/* زرّ إغلاق واضح داخل الدرج (يُضاف من JS) */
.sd-close{
  position:absolute; top:14px; left:14px; z-index:5;
  width:40px; height:40px; border-radius:50%;
  display:grid; place-items:center; cursor:pointer;
  font-size:16px; font-family:var(--sans); color:var(--ink);
  background:rgba(201,169,97,.14); border:1px solid var(--line-hi);
  transition:background .3s var(--ease-out), transform .3s var(--ease-pop);
}
.sd-close:hover{ background:rgba(201,169,97,.26); transform:scale(1.06) }
.sd-close:active{ transform:scale(.94) }
@media (min-width:1001px){ .sd-close{ display:none } }

@media (max-width:1000px){
  /* ⚠️ العرض الثابت 290px على شاشة 360 ⇒ 70px مهدورة.
     نجعلها مرنة: ٨٦٪ من العرض بحدّ أقصى 320px. */
  .side{
    width:min(86vw, 320px) !important;
    top:60px !important;
    padding-top:64px !important;   /* مساحة لزرّ ✕ */
  }
  .side-in{ width:100% !important; }
  .sd-head{ padding-left:62px; }   /* لا يتقاطع مع زرّ ✕ */
}

/* حماية من أيّ محتوى يخرج أفقياً */
@media screen and (max-width:1000px){
  html, body{ overflow-x:hidden !important; max-width:100% !important }
  .reader, .frame, .f-body, .f-ctrl{ max-width:100% !important }
  .f-name{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap }
}

/* ═══ طبقة تعتيم خلف درج الفهرس ═══
   الضغط عليها يغلق الدرج — أوضح من «الضغط خارجاً» على شاشة صغيرة. */
/* ⚠️ تعارض حقيقيّ: القاعدة العامّة
     body>*:not(.bg):not(.grain){position:relative;z-index:2}
   تخصيصها (٠,٢,٠) — أعلى من `.sd-scrim` (٠,١,٠) ⇒ كانت تلغي
   `position:fixed` و`z-index:34` فيظهر الشريط كعنصر عاديّ لا يغطّي شيئًا.
   ✅ الحلّ: !important + تخصيص أعلى. */
body > .sd-scrim{
  position:fixed !important;
  inset:60px 0 0 0 !important;
  z-index:34 !important;
  background:rgba(10,2,5,.62);
  -webkit-backdrop-filter:blur(3px); backdrop-filter:blur(3px);
  opacity:0; pointer-events:none;
  transition:opacity .35s var(--ease-out);
}
body.sd-open > .sd-scrim{ opacity:1 !important; pointer-events:auto !important }
/* نظهرها فقط على الجوال/التابلت */
@media (min-width:1001px){ .sd-scrim{ display:none !important } }


/* ══════════════════════════════════════════════════════════════════
   🔒 إصلاح ترتيب الطبقات (z-index) — ٢٤ أكتوبر ٢٠٢٦
   ──────────────────────────────────────────────────────────────────
   🐞 العطل: الفهرس كان يظهر **معتمًا ومشوّشًا** عند فتحه على الجوال.
   🔬 السبب: القاعدة العامّة `body>*:not(.bg):not(.grain)` تُعطي
      `.stage` قيمة `z-index:2`. وطبقة التعتيم `.sd-scrim` عند ٣٤
      ⇒ فكانت **فوق الفهرس** وتُعتّمه.
   ✅ الحلّ: `.stage` يحصل على z-index أعلى من الـscrim، ليظهر
      الدرج واضحًا فوق التعتيم (وهذا هو السلوك المطلوب في أيّ drawer).
   ══════════════════════════════════════════════════════════════════ */
@media (max-width:1000px){
  .stage{
    position:relative !important;
    z-index:40 !important;      /* أعلى من .sd-scrim (34) */
  }
  body > .sd-scrim{ z-index:34 !important }
}
