/* المكتبة الإلكترونية — بنفس هوية منظومة الجمعية: الأزرق الملكي والكحلي واللمسة الذهبية،
   بطاقات بزوايا 12px، وأزرار كرستالية، وخلفية فاتحة مائلة إلى الزرقة. */
/* الألوان الثلاثة تُضبط من إعدادات الإضافة (تُكتب بعد هذا الملف فتغلبه) */
:root { --wl-brand: #2253a2; --wl-navy: #173f80; --wl-gold: #a87b1f; }
.wics-lib {
  --wl-brand-2: color-mix(in srgb, var(--wl-brand) 82%, #fff);
  --wl-brand-soft: color-mix(in srgb, var(--wl-brand) 11%, #fff);
  --wl-gold-soft: #f8efd8;
  --wl-bg: #f2f5fb; --wl-surface: #fff; --wl-surface-2: #f7f9fd; --wl-line: #e0e7f2; --wl-line-strong: #c6d2e4;
  --wl-ink: #15233b; --wl-ink-2: #4f5f79; --wl-ink-3: #73829b;
  --wl-shadow: 0 1px 2px rgba(23, 50, 96, .06), 0 6px 18px rgba(23, 50, 96, .06);
  --wl-shadow-up: 0 10px 26px rgba(23, 50, 96, .16);
  font-family: var(--wl-font, "Segoe UI", "Noto Naskh Arabic", "Noto Sans Arabic", Tahoma, "Geeza Pro", Arial, sans-serif);
  color: var(--wl-ink); font-size: 15px; line-height: 1.6; direction: rtl; text-align: right;
  max-width: 1280px; margin-inline: auto;
}
.wics-lib *, .wics-lib *::before, .wics-lib *::after { box-sizing: border-box; }
.wics-lib [hidden] { display: none !important; }
.wics-lib a { text-decoration: none; }
.wics-lib h2, .wics-lib h3 { font-family: inherit; margin: 0; line-height: 1.35; font-weight: 700; letter-spacing: 0; }
.wics-lib .wl-ic { flex: none; vertical-align: middle; }
.wics-lib .screen-reader-text { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(1px, 1px, 1px, 1px); white-space: nowrap; }

/* ===== الأزرار الكرستالية (منقولة من المنظومة) ===== */
.wics-lib .wl-btn {
  position: relative; isolation: isolate; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 6px 16px; border-radius: 9px; border: 1px solid var(--wl-line-strong);
  background: linear-gradient(180deg, #fff 0%, #fff 46%, color-mix(in srgb, #fff 88%, var(--wl-brand)) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), inset 0 -1px 0 rgba(21, 35, 59, .07), 0 1px 2px rgba(21, 35, 59, .1);
  color: var(--wl-ink); font: inherit; font-weight: 600; font-size: 14px; line-height: 1.2; cursor: pointer; white-space: nowrap;
  transition: box-shadow .16s, transform .1s, border-color .16s, filter .16s;
}
.wics-lib .wl-btn::before { content: ""; position: absolute; z-index: -1; inset: 1px 1px 50% 1px; border-radius: 8px 8px 60% 60% / 8px 8px 9px 9px; background: linear-gradient(180deg, rgba(255, 255, 255, .7), transparent); pointer-events: none; }
.wics-lib .wl-btn:hover { border-color: var(--wl-brand-2); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .9), 0 3px 10px color-mix(in srgb, var(--wl-brand) 22%, transparent); color: var(--wl-ink); }
.wics-lib .wl-btn:active { transform: translateY(1px) scale(.99); box-shadow: inset 0 2px 5px rgba(21, 35, 59, .22); }
.wics-lib .wl-btn.wl-primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--wl-brand) 84%, #fff) 0%, var(--wl-brand) 42%, color-mix(in srgb, var(--wl-brand) 92%, #000) 100%);
  border-color: color-mix(in srgb, var(--wl-brand) 82%, #000); color: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .38), inset 0 -1px 0 rgba(0, 0, 0, .16), 0 2px 8px color-mix(in srgb, var(--wl-brand) 35%, transparent);
}
.wics-lib .wl-btn.wl-primary::before { background: linear-gradient(180deg, rgba(255, 255, 255, .3), rgba(255, 255, 255, 0)); }
.wics-lib .wl-btn.wl-primary:hover { color: #fff; filter: brightness(1.06) saturate(1.05); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), 0 5px 16px color-mix(in srgb, var(--wl-brand) 45%, transparent); }
.wics-lib .wl-btn.wl-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--wl-ink-2); }
.wics-lib .wl-btn.wl-ghost::before { opacity: 0; }
.wics-lib .wl-btn.wl-ghost:hover { background: #e9eef7; }
.wics-lib .wl-btn.wl-sm { min-height: 32px; padding: 3px 11px; font-size: 13px; border-radius: 8px; }
.wics-lib .wl-btn.wl-lg { min-height: 46px; padding: 8px 22px; font-size: 15.5px; border-radius: 10px; }
.wics-lib .wl-btn small { font-weight: 500; opacity: .75; }
.wics-lib .wl-btn:disabled { opacity: .55; cursor: default; }

/* ===== رأس المكتبة ===== */
.wics-lib .wl-hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 30px 30px 24px; margin-bottom: 18px; color: #fff;
  background: linear-gradient(135deg, var(--wl-navy), var(--wl-brand) 55%, var(--wl-brand-2));
  box-shadow: 0 18px 50px rgba(5, 20, 50, .22);
}
/* الدوائر الخفيفة نفسها التي في شاشة دخول المنظومة */
.wics-lib .wl-hero::before, .wics-lib .wl-hero::after { content: ""; position: absolute; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .13); pointer-events: none; }
.wics-lib .wl-hero::before { width: 520px; height: 520px; top: -260px; left: -160px; box-shadow: 0 0 0 60px rgba(255, 255, 255, .03), 0 0 0 130px rgba(255, 255, 255, .02); }
.wics-lib .wl-hero::after { width: 340px; height: 340px; bottom: -200px; right: -90px; box-shadow: 0 0 0 50px rgba(255, 255, 255, .03); }
.wics-lib .wl-hero > * { position: relative; z-index: 1; }
.wics-lib .wl-hero-text { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.wics-lib .wl-hero-logo { width: 76px; height: auto; flex: none; background: #fff; border-radius: 14px; padding: 6px; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
.wics-lib .wl-hero h2 { color: #fff; font-size: 28px; }
.wics-lib .wl-hero p { margin: 4px 0 0; color: #dbe6f8; font-size: 15px; }

.wics-lib .wl-search { display: flex; flex-wrap: wrap; gap: 8px; padding: 8px; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22); border-radius: 14px; backdrop-filter: blur(6px); }
.wics-lib .wl-search-box { flex: 1 1 320px; position: relative; display: flex; align-items: center; margin: 0; }
.wics-lib .wl-search-box .wl-ic { position: absolute; right: 14px; color: var(--wl-ink-3); pointer-events: none; }
.wics-lib .wl-search input[type=search], .wics-lib .wl-search select {
  width: 100%; min-height: 48px; margin: 0; border: 1px solid transparent; border-radius: 10px; background: #fff; color: var(--wl-ink);
  font: inherit; font-size: 16px; box-shadow: none;
}
.wics-lib .wl-search input[type=search] { padding: 8px 44px 8px 14px; }
.wics-lib .wl-search select { flex: 0 1 190px; width: auto; padding: 6px 12px; font-size: 14.5px; }
.wics-lib .wl-search input:focus, .wics-lib .wl-search select:focus { outline: 3px solid color-mix(in srgb, var(--wl-gold) 70%, #fff); outline-offset: 0; }
.wics-lib .wl-search .wl-btn.wl-primary { min-height: 48px; padding-inline: 26px; font-size: 15.5px; background: linear-gradient(180deg, color-mix(in srgb, var(--wl-gold) 80%, #fff), var(--wl-gold) 45%, color-mix(in srgb, var(--wl-gold) 88%, #000)); border-color: color-mix(in srgb, var(--wl-gold) 80%, #000); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), 0 2px 8px rgba(0, 0, 0, .2); }
.wics-lib .wl-stats { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; font-size: 13.5px; color: #dbe6f8; }
.wics-lib .wl-stats span { display: inline-flex; align-items: center; gap: 6px; }

/* ===== التصنيفات ===== */
.wics-lib .wl-chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 6px; scrollbar-width: thin; }
.wics-lib .wl-chip { flex: none; padding: 6px 15px; border-radius: 20px; background: #fff; border: 1px solid var(--wl-line); color: var(--wl-ink-2); font-size: 14px; font-weight: 600; transition: background .16s, color .16s, border-color .16s; }
.wics-lib .wl-chip:hover { border-color: var(--wl-brand-2); color: var(--wl-brand); }
.wics-lib .wl-chip.is-active { background: var(--wl-brand); border-color: var(--wl-brand); color: #fff; }

/* ===== النتائج ===== */
.wics-lib .wl-results { transition: opacity .18s; }
.wics-lib .wl-results.is-loading { opacity: .45; pointer-events: none; }
.wics-lib .wl-result-head { display: flex; justify-content: space-between; align-items: center; margin: 4px 2px 12px; color: var(--wl-ink-2); font-size: 14px; font-weight: 600; }
.wics-lib .wl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 18px; }
.wics-lib .wl-card {
  display: flex; flex-direction: column; background: var(--wl-surface); border: 1px solid var(--wl-line); border-radius: 12px; overflow: hidden;
  box-shadow: var(--wl-shadow); transition: transform .18s, box-shadow .18s, border-color .18s; animation: wl-rise .36s cubic-bezier(.2, .8, .25, 1) both;
}
.wics-lib .wl-card:hover { transform: translateY(-3px); box-shadow: var(--wl-shadow-up); border-color: var(--wl-brand-2); }
.wics-lib .wl-card-cover { display: block; aspect-ratio: 3 / 4; background: var(--wl-surface-2); overflow: hidden; }
.wics-lib .wl-card-cover img, .wics-lib .wl-cover-img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s; }
.wics-lib .wl-card:hover .wl-card-cover img { transform: scale(1.04); }
.wics-lib .wl-card-body { display: flex; flex-direction: column; gap: 5px; padding: 12px 13px 13px; flex: 1; }
.wics-lib .wl-card-title { font-size: 15.5px; }
.wics-lib .wl-card-title a { color: var(--wl-ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.wics-lib .wl-card-title a:hover { color: var(--wl-brand); }
.wics-lib .wl-card-author { display: flex; align-items: center; gap: 5px; margin: 0; color: var(--wl-ink-2); font-size: 13px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.wics-lib .wl-card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: auto; padding-top: 8px; }
.wics-lib .wl-views { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 4px; color: var(--wl-ink-3); font-size: 12.5px; }

.wics-lib .wl-badge { align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; padding: 1px 10px; border-radius: 20px; background: var(--wl-brand-soft); color: var(--wl-brand); font-size: 12.5px; font-weight: 600; }
.wics-lib .wl-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.wics-lib a.wl-badge:hover { background: var(--wl-brand); color: #fff; }

/* الغلاف التلقائي: أزرق وكحلي بإطار ذهبي */
.wics-lib .wl-cover-auto {
  position: relative; width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 26px 18px; text-align: center; color: #fff; background: linear-gradient(160deg, var(--wl-brand), var(--wl-navy));
}
.wics-lib .wl-cover-frame { position: absolute; inset: 10px; border: 1.5px solid color-mix(in srgb, var(--wl-gold) 80%, #fff); border-radius: 6px; opacity: .85; }
.wics-lib .wl-cover-frame::after { content: ""; position: absolute; inset: 4px; border: 1px solid color-mix(in srgb, var(--wl-gold) 55%, transparent); border-radius: 4px; }
.wics-lib .wl-cover-auto .wl-ic { color: color-mix(in srgb, var(--wl-gold) 70%, #fff); }
.wics-lib .wl-cover-auto b { font-size: 17px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.wics-lib .wl-cover-auto small { font-size: 12.5px; color: #dbe6f8; }

.wics-lib .wl-empty { display: grid; justify-items: center; gap: 6px; padding: 48px 16px; text-align: center; color: var(--wl-ink-2); background: #fff; border: 1px dashed var(--wl-line-strong); border-radius: 12px; }
.wics-lib .wl-empty .wl-ic { color: var(--wl-ink-3); }
.wics-lib .wl-empty b { color: var(--wl-ink); font-size: 17px; }

.wics-lib .wl-pager { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 26px 0 6px; }
.wics-lib .wl-page, .wics-lib .wl-dots { min-width: 40px; height: 40px; display: inline-grid; place-items: center; padding: 0 10px; border-radius: 9px; font-weight: 600; }
.wics-lib .wl-page { background: #fff; border: 1px solid var(--wl-line-strong); color: var(--wl-ink); }
.wics-lib .wl-page:hover { border-color: var(--wl-brand-2); color: var(--wl-brand); }
.wics-lib .wl-page.is-current { background: var(--wl-brand); border-color: var(--wl-brand); color: #fff; }
.wics-lib .wl-dots { color: var(--wl-ink-3); }

/* أحدث الكتب */
.wics-lib.wl-latest { margin-block: 24px; }
.wics-lib .wl-latest-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; padding-bottom: 10px; border-bottom: 2px solid var(--wl-line); position: relative; }
.wics-lib .wl-latest-head::after { content: ""; position: absolute; bottom: -2px; right: 0; width: 90px; height: 2px; background: var(--wl-gold); }
.wics-lib .wl-latest-head h2 { font-size: 22px; color: var(--wl-ink); }

/* ===== صفحة الكتاب ===== */
.wics-lib.wl-book { display: grid; gap: 20px; }
.wics-lib .wl-back { display: inline-flex; align-items: center; gap: 4px; color: var(--wl-brand); font-weight: 600; font-size: 14px; justify-self: start; }
.wics-lib .wl-back:hover { text-decoration: underline; }
.wics-lib .wl-book-head { display: grid; grid-template-columns: minmax(180px, 260px) 1fr; gap: 26px; align-items: start; padding: 22px; background: #fff; border: 1px solid var(--wl-line); border-radius: 14px; box-shadow: var(--wl-shadow); border-top: 4px solid var(--wl-brand); }
.wics-lib .wl-book-cover { aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; box-shadow: 0 12px 30px rgba(23, 50, 96, .25); background: var(--wl-surface-2); }
.wics-lib .wl-book-info { display: grid; gap: 12px; align-content: start; min-width: 0; }
.wics-lib .wl-badges { display: flex; flex-wrap: wrap; gap: 6px; }
.wics-lib .wl-book-author { display: flex; align-items: center; gap: 6px; margin: 0; font-size: 17px; font-weight: 600; color: var(--wl-ink-2); }
.wics-lib .wl-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0; margin: 0; border: 1px solid var(--wl-line); border-radius: 10px; overflow: hidden; }
.wics-lib .wl-dl div { padding: 9px 12px; border-bottom: 1px solid var(--wl-line); border-inline-start: 1px solid var(--wl-line); margin-inline-start: -1px; margin-bottom: -1px; background: var(--wl-surface-2); }
.wics-lib .wl-dl dt { color: var(--wl-ink-3); font-size: 12.5px; font-weight: 600; margin: 0; }
.wics-lib .wl-dl dd { margin: 1px 0 0; font-weight: 600; overflow-wrap: anywhere; }
.wics-lib .wl-actions { display: flex; flex-wrap: wrap; gap: 10px; padding-top: 4px; }
.wics-lib .wl-note { margin: 0; background: var(--wl-gold-soft); border: 1px solid color-mix(in srgb, var(--wl-gold) 35%, transparent); border-radius: 8px; padding: 10px 14px; font-size: 14px; }

.wics-lib .wl-card-box { background: #fff; border: 1px solid var(--wl-line); border-radius: 12px; box-shadow: var(--wl-shadow); padding: 18px 22px; }
.wics-lib .wl-card-box > h3 { font-size: 18px; margin-bottom: 10px; padding-inline-start: 12px; border-inline-start: 3px solid var(--wl-gold); }
.wics-lib .wl-about-body > :first-child { margin-top: 0; }
.wics-lib .wl-about-body > :last-child { margin-bottom: 0; }

/* ===== القارئ ===== */
.wics-lib .wl-reader { scroll-margin-top: 80px; background: #fff; border: 1px solid var(--wl-line); border-radius: 14px; box-shadow: var(--wl-shadow); overflow: hidden; display: flex; flex-direction: column; }
.wics-lib .wl-reader-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; padding: 8px 12px; background: linear-gradient(175deg, var(--wl-navy), color-mix(in srgb, var(--wl-navy) 78%, #000)); color: #dbe6f8; }
.wics-lib .wl-group { display: flex; align-items: center; gap: 4px; }
.wics-lib .wl-tool { width: 38px; height: 38px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 9px; background: transparent; color: #fff; cursor: pointer; transition: background .16s; }
.wics-lib .wl-tool:hover { background: rgba(255, 255, 255, .14); color: #fff; }
.wics-lib .wl-tool:focus-visible { outline: 2px solid #9cc2ff; }
.wics-lib .wl-pageno { display: inline-flex; align-items: center; gap: 6px; margin: 0 4px; font-size: 14px; color: #dbe6f8; }
.wics-lib .wl-pageno input { width: 64px; min-height: 34px; margin: 0; padding: 2px 6px; text-align: center; border-radius: 8px; border: 1px solid rgba(255, 255, 255, .25); background: rgba(255, 255, 255, .12); color: #fff; font: inherit; font-weight: 600; }
.wics-lib .wl-pageno b { color: #fff; }
.wics-lib .wl-zoom { min-width: 52px; text-align: center; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.wics-lib .wl-progress { height: 3px; background: transparent; }
.wics-lib .wl-progress i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--wl-brand-2), #8fb8ff); transition: width .2s, opacity .4s; }
.wics-lib .wl-reader:not(.is-loading) .wl-progress i { opacity: 0; }
.wics-lib .wl-stage { position: relative; height: min(82vh, 1100px); overflow: auto; background: #e9eef7; display: flex; justify-content: center; align-items: flex-start; padding: 12px; outline: none; }
.wics-lib .wl-canvas { display: block; margin: 0 auto; background: #fff; box-shadow: 0 4px 18px rgba(23, 50, 96, .22); border-radius: 2px; }
.wics-lib .wl-start { align-self: center; display: grid; justify-items: center; gap: 10px; text-align: center; padding: 30px 16px; color: var(--wl-ink-2); }
.wics-lib .wl-start .wl-ic { color: var(--wl-brand); }
.wics-lib .wl-start b { font-size: 18px; color: var(--wl-ink); }
.wics-lib .wl-resume { font-size: 14px; }
.wics-lib .wl-hint { margin: 0; padding: 8px 14px; font-size: 12.5px; color: var(--wl-ink-3); background: var(--wl-surface-2); border-top: 1px solid var(--wl-line); }
.wics-lib .wl-reader:not(.is-open) .wl-reader-bar .wl-tool, .wics-lib .wl-reader:not(.is-open) .wl-pageno, .wics-lib .wl-reader:not(.is-open) .wl-zoom { opacity: .5; }
/* ملء الشاشة */
.wics-lib .wl-reader:fullscreen { border-radius: 0; border: 0; }
.wics-lib .wl-reader:fullscreen .wl-stage, .wics-lib .wl-reader.is-full .wl-stage { height: auto; flex: 1; }
.wics-lib .wl-reader.is-full { position: fixed; inset: 0; z-index: 99999; border-radius: 0; }
.wics-lib .wl-reader:fullscreen .wl-hint, .wics-lib .wl-reader.is-full .wl-hint { display: none; }

@keyframes wl-rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.wics-lib .wl-grid .wl-card:nth-child(2) { animation-delay: .03s; }
.wics-lib .wl-grid .wl-card:nth-child(3) { animation-delay: .06s; }
.wics-lib .wl-grid .wl-card:nth-child(4) { animation-delay: .09s; }
.wics-lib .wl-grid .wl-card:nth-child(n+5) { animation-delay: .12s; }
@media (prefers-reduced-motion: reduce) { .wics-lib *, .wics-lib *::before, .wics-lib *::after { animation: none !important; transition: none !important; } }

/* ===== الهاتف ===== */
@media (max-width: 760px) {
  .wics-lib .wl-hero { padding: 22px 16px 18px; border-radius: 14px; }
  .wics-lib .wl-hero h2 { font-size: 22px; }
  .wics-lib .wl-hero-logo { width: 58px; }
  .wics-lib .wl-search select { flex: 1 1 40%; }
  .wics-lib .wl-search .wl-btn.wl-primary { flex: 1 1 100%; }
  .wics-lib .wl-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .wics-lib .wl-card-body { padding: 10px; }
  .wics-lib .wl-card-title { font-size: 14.5px; }
  .wics-lib .wl-card-actions .wl-btn { flex: 1; }
  .wics-lib .wl-views { display: none; }
  .wics-lib .wl-book-head { grid-template-columns: 1fr; padding: 16px; }
  .wics-lib .wl-book-cover { width: min(220px, 70%); justify-self: center; }
  .wics-lib .wl-actions .wl-btn { flex: 1 1 100%; }
  .wics-lib .wl-stage { height: 75vh; padding: 6px; }
  .wics-lib .wl-reader-bar { justify-content: center; }
  .wics-lib .wl-card-box { padding: 16px; }
}
