/* ===================================================================
   library.css — المكتبة: الأقسام + ورقة الكتب + قارئ الـ PDF
=================================================================== */
.lib-wrap{ padding-top:10px; padding-bottom:60px; }
.lib-intro{ text-align:center; color:var(--text-dim); font-size:.88rem; margin:6px auto 22px; max-width:480px; line-height:1.8; }
.lib-sections{ display:flex; flex-direction:column; gap:14px; max-width:520px; margin:0 auto; }
.lib-section{
  display:flex; align-items:center; gap:14px; width:100%; text-align:start; cursor:pointer;
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:18px; box-shadow:var(--shadow); color:var(--text); font-family:inherit;
  transition:transform .25s ease, border-color .25s ease;
}
.lib-section:hover{ transform:translateY(-3px); border-color:var(--gold); }
.lib-section:active{ transform:scale(.98); }
.lib-section .ls-ico{ flex:0 0 auto; width:54px; height:54px; display:grid; place-items:center; font-size:1.7rem; border-radius:16px;
  background:linear-gradient(145deg,#33497a,#16264a); box-shadow:inset 0 0 0 1px rgba(255,255,255,.12); }
.lib-section .ls-txt{ flex:1 1 auto; min-width:0; }
.lib-section .ls-title{ font-weight:900; font-size:1.05rem; color:var(--gold-bright); }
.lib-section .ls-desc{ font-size:.78rem; color:var(--text-dim); margin-top:3px; line-height:1.6; }
.lib-section .ls-count{ flex:0 0 auto; font-size:.74rem; font-weight:700; padding:5px 10px; border-radius:20px; background:var(--surface-2); border:1px solid var(--border); color:var(--text); white-space:nowrap; }

/* ---------- الورقة المنزلقة ---------- */
.sheet-backdrop{ position:fixed; inset:0; background:rgba(0,0,0,.55); z-index:9600; opacity:0; transition:opacity .25s ease; }
.sheet-backdrop.show{ opacity:1; }
.sheet{
  position:fixed; left:0; right:0; bottom:0; z-index:9610; margin:0 auto; max-width:640px;
  height:min(92vh,92dvh); display:flex; flex-direction:column;
  background:var(--surface); color:var(--text); border-radius:28px 28px 0 0;
  box-shadow:0 -10px 40px rgba(0,0,0,.35); transform:translateY(100%); transition:transform .32s cubic-bezier(.2,.9,.3,1);
}
.sheet.show{ transform:translateY(0); }
.sheet[hidden], .sheet-backdrop[hidden], .rd[hidden]{ display:none !important; }
.sheet-grab{ width:44px; height:5px; border-radius:5px; background:var(--border); margin:10px auto 2px; flex:0 0 auto; }
.sheet-head{ display:flex; align-items:center; justify-content:space-between; flex-direction:row-reverse; padding:10px 18px 6px; flex:0 0 auto; }
.sheet-head h2{ margin:0; font-size:1.25rem; font-weight:900; }
.sheet-x{ width:40px; height:40px; border-radius:14px; border:1px solid var(--border); background:var(--surface-2); color:var(--text); font-size:1.1rem; cursor:pointer; }
.sheet-search{ display:flex; align-items:center; gap:10px; margin:6px 16px 10px; padding:0 14px; height:46px; border:1.5px solid var(--border); border-radius:16px; background:var(--surface-2); flex:0 0 auto; }
.sheet-search input{ flex:1; min-width:0; border:0; outline:0; background:transparent; color:var(--text); font-family:inherit; font-size:.95rem; height:100%; }
.book-list{ flex:1 1 auto; overflow-y:auto; padding:4px 16px 24px; display:flex; flex-direction:column; gap:12px; -webkit-overflow-scrolling:touch; }
.book-empty{ text-align:center; color:var(--text-dim); padding:40px 10px; font-size:.9rem; }

.book{
  display:flex; align-items:center; gap:14px; padding:12px 14px; border-radius:20px; cursor:pointer;
  background:var(--surface-2); border:1px solid var(--border);
}
.book:active{ transform:scale(.985); }
.book.off{ opacity:.55; }
.book-cover{
  position:relative; flex:0 0 auto; width:52px; height:70px; border-radius:6px 10px 10px 6px;
  background:linear-gradient(150deg,#5b6f9c 0%,#2a3f6e 55%,#1b2d57 100%);
  box-shadow:2px 4px 10px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.12);
}
.book-cover::before{ content:''; position:absolute; inset:0 6px 0 auto; width:3px; background:rgba(255,255,255,.28); border-radius:2px; }
.book-cover::after{ content:'❖'; position:absolute; left:0; right:0; top:50%; transform:translateY(-50%); text-align:center; font-size:.9rem; color:rgba(230,200,119,.85); }
.book-info{ flex:1 1 auto; min-width:0; }
.book-title{ font-weight:900; font-size:1.02rem; line-height:1.5; }
.book-author{ color:var(--text-dim); font-size:.84rem; margin-top:2px; }
.book-tag{ display:inline-block; margin-top:4px; font-size:.68rem; font-weight:700; padding:2px 8px; border-radius:10px; background:var(--surface); border:1px solid var(--border); color:var(--gold-bright); }
.book-dl{
  flex:0 0 auto; position:relative; width:46px; height:46px; border-radius:50%; border:0; cursor:pointer;
  background:#4a4a4a; color:var(--gold-bright); display:grid; place-items:center; font-family:inherit; font-size:.62rem; font-weight:900;
}
.book-dl svg{ width:22px; height:22px; fill:currentColor; }
.book-dl.done{ background:#2e7d5b; color:#fff; }
.book-dl.busy{ cursor:default; }
.book-dl .ring{ position:absolute; inset:0; border-radius:50%; background:conic-gradient(var(--gold-bright) calc(var(--p,0)*1%), transparent 0); -webkit-mask:radial-gradient(circle,transparent 17px,#000 18px); mask:radial-gradient(circle,transparent 17px,#000 18px); }
.book-dl[hidden]{ display:none; }

/* ---------- القارئ ---------- */
.rd{ position:fixed; inset:0; z-index:9800; display:flex; flex-direction:column; background:#3a3d44; color:#fff; direction:rtl; }
.rd-bar, .rd-foot{ flex:0 0 auto; display:flex; align-items:center; gap:8px; padding:8px 10px; background:#23262c; box-shadow:0 2px 12px rgba(0,0,0,.4); z-index:2; }
.rd-foot{ justify-content:center; padding-bottom:calc(8px + env(safe-area-inset-bottom,0px)); box-shadow:0 -2px 12px rgba(0,0,0,.4); flex-wrap:wrap; }
.rd-title{ flex:1; text-align:center; font-weight:800; font-size:.98rem; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.rd-btn{ min-width:42px; height:42px; padding:0 12px; border-radius:12px; border:1px solid rgba(255,255,255,.18); background:#31353d; color:#fff; font-size:1.05rem; cursor:pointer; font-family:inherit; }
.rd-btn:active{ background:#454b56; }
.rd-page{ display:flex; align-items:center; gap:6px; font-size:.9rem; direction:ltr; }
.rd-page input{ width:74px; height:42px; text-align:center; border-radius:12px; border:1px solid rgba(255,255,255,.25); background:#1b1d22; color:#fff; font-size:1rem; font-family:inherit; }
.rd-scroll{ flex:1 1 auto; overflow:auto; -webkit-overflow-scrolling:touch; position:relative; background:#3a3d44; }
.rd-pages{ display:flex; flex-direction:column; align-items:center; gap:10px; padding:10px 8px 40px; width:max-content; min-width:100%; box-sizing:border-box; }
.rd-pg{ position:relative; background:#fff; box-shadow:0 2px 10px rgba(0,0,0,.45); flex:0 0 auto; }
.rd-pg canvas{ display:block; width:100%; height:100%; }
.rd-pg .rd-num{ position:absolute; top:50%; left:0; right:0; text-align:center; color:#9aa; font-size:1.1rem; transform:translateY(-50%); pointer-events:none; }
.rd.night .rd-pg canvas{ filter:invert(1) hue-rotate(180deg); }
.rd.night .rd-pg{ background:#111; }
.rd-loading{ position:absolute; inset:0; display:flex; flex-direction:column; gap:14px; align-items:center; justify-content:center; background:rgba(20,22,26,.92); z-index:5; font-weight:700; text-align:center; padding:20px; }
.rd-loading.hide{ display:none; }
.rd-spin{ width:42px; height:42px; border-radius:50%; border:4px solid rgba(255,255,255,.2); border-top-color:var(--gold-bright,#e6c877); animation:rdspin 1s linear infinite; }
@keyframes rdspin{ to{ transform:rotate(360deg); } }

/* ---------- "المكتبة قريبًا" ---------- */
.lib-soon{
  max-width:520px; margin:6px auto 18px; padding:22px 18px 20px; text-align:center;
  border-radius:var(--radius); border:1.5px dashed color-mix(in srgb, var(--gold, #c9a24b) 70%, transparent);
  background: radial-gradient(120% 100% at 50% 0%, color-mix(in srgb, var(--gold, #c9a24b) 16%, transparent), transparent 75%), var(--surface);
}
.lib-soon-ico{ font-size:2.4rem; line-height:1; margin-bottom:6px; }
.lib-soon h2{ margin:0 0 6px; font-family:var(--font-display, 'Amiri', serif); font-size:1.6rem; color:var(--gold-bright, #e6c877); }
[data-theme="light"] .lib-soon h2{ color: color-mix(in srgb, var(--gold-bright, #fbbf24) 55%, #000); }
.lib-soon p{ margin:0; color:var(--text-dim); font-size:.88rem; line-height:1.8; }
.lib-section.soon{ opacity:.72; cursor:default; }
.lib-section.soon:hover{ transform:none; border-color:var(--border); }
.lib-section.soon:active{ transform:none; }
.lib-section.soon .ls-count{ color:var(--gold-bright, #e6c877); border-color:color-mix(in srgb, var(--gold, #c9a24b) 55%, var(--border)); }
[data-theme="light"] .lib-section.soon .ls-count{ color: color-mix(in srgb, var(--gold-bright, #fbbf24) 55%, #000); }

/* ---------- قسم مفتوح (open:true): متاح حتى والمكتبة "قريبًا" ---------- */
.lib-section.is-open{ border-color:color-mix(in srgb, var(--gold, #c9a24b) 65%, var(--border)); box-shadow:var(--shadow), 0 0 0 1px color-mix(in srgb, var(--gold, #c9a24b) 25%, transparent); }
.lib-section.is-open .ls-count{ background:var(--gold, #c9a24b); color:#171203; border-color:var(--gold, #c9a24b); }
