/* AlNashra flipbook viewer — theme */
:root{
  --navy:#2c398b;
  --navy-d:#212c6e;
  --green:#8fb071;
  --sky:#618ed1;
  --ink:#1d2340;
  --muted:#6b7090;
  --paper:#ffffff;
  --bg1:#e9ecf3;
  --bg2:#cfd5e4;
  --bar-h:52px;
  --top-h:52px;
  --font:"Noto Kufi Arabic", "Segoe UI", Tahoma, Arial, sans-serif;
}
*{box-sizing:border-box}
html,body{margin:0;height:100%;overflow:hidden;background:var(--bg1)}
body{
  font-family:var(--font);color:var(--ink);
  background:radial-gradient(ellipse at 50% 40%, #f6f7fb 0%, var(--bg1) 45%, var(--bg2) 100%);
  -webkit-tap-highlight-color:transparent;
}
button{font-family:inherit}
[hidden]{display:none!important}
svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
svg .fill{fill:currentColor;stroke:none}

/* ---------- loader ---------- */
#loader{position:fixed;inset:0;z-index:100;display:grid;place-items:center;background:var(--navy);color:#fff;transition:opacity .5s}
#loader.done{opacity:0;pointer-events:none}
.loader-box{text-align:center}
.loader-mark{font-size:44px;font-weight:700;letter-spacing:1px;margin-bottom:18px}
.loader-text{margin-top:14px;font-size:14px;opacity:.85}
.spinner{width:38px;height:38px;margin:auto;border-radius:50%;border:3px solid rgba(255,255,255,.25);border-top-color:var(--green);animation:spin .9s linear infinite}
@keyframes spin{to{transform:rotate(360deg)}}

/* ---------- top bar ---------- */
.topbar{
  position:fixed;top:0;inset-inline:0;height:var(--top-h);z-index:20;
  display:flex;align-items:center;justify-content:space-between;gap:12px;
  padding:0 16px;background:var(--navy);color:#fff;
  box-shadow:0 2px 10px rgba(20,28,80,.25);
  border-bottom:3px solid var(--green);
}
.brand{display:flex;align-items:center;gap:12px;min-width:0;white-space:nowrap}
.brand-mark{font-size:22px;font-weight:700}
.brand-sep{width:1px;height:22px;background:rgba(255,255,255,.35)}
.brand-issue{font-size:14px;opacity:.95;overflow:hidden;text-overflow:ellipsis}
.brand-issue small{opacity:.7;font-size:12px}
.search{display:flex;align-items:center;background:rgba(255,255,255,.14);border-radius:8px;padding-inline-start:10px;height:34px;transition:background .2s}
.search:focus-within{background:#fff}
.search input{border:0;background:transparent;color:#fff;font:inherit;font-size:13px;width:210px;outline:none}
.search:focus-within input{color:var(--ink)}
.search input::placeholder{color:rgba(255,255,255,.75)}
.search:focus-within input::placeholder{color:#999}
.search:focus-within .icon-btn{color:var(--navy)}
.search .icon-btn{height:34px;width:36px}

/* ---------- stage & book ---------- */
#stage{position:fixed;top:var(--top-h);bottom:var(--bar-h);inset-inline:0;overflow:hidden}
#bookWrap{position:absolute;left:50%;top:50%;transform:translate(-50%,-50%);transition:transform .45s ease}
#book{margin:0 auto}
.stf__wrapper{height:100%}
.stf__parent{filter:drop-shadow(0 10px 22px rgba(20,28,80,.28))}
.page{background:var(--paper);overflow:hidden}
.page .pg{position:absolute;inset:0;width:100%;height:100%;object-fit:fill;user-select:none;-webkit-user-drag:none;pointer-events:none;opacity:0;transition:opacity .25s}
.page .pg.ok{opacity:1}
.page .pg-wait{position:absolute;inset:0;display:grid;place-items:center;background:#f3f4f8}
.page .pg-wait::after{content:"";width:26px;height:26px;border-radius:50%;border:3px solid #d8dbe8;border-top-color:var(--navy);animation:spin .9s linear infinite}
.page.loaded .pg-wait{display:none}
.page.blank .pg-wait{display:none}
/* inner gutter shading for a printed feel */
.page::after{content:"";position:absolute;top:0;bottom:0;width:11%;pointer-events:none;z-index:2}
.page.side-left::after{right:0;background:linear-gradient(to left,rgba(0,0,0,.26) 0%,rgba(0,0,0,.10) 18%,rgba(0,0,0,.03) 55%,rgba(0,0,0,0) 100%)}
.page.side-right::after{left:0;background:linear-gradient(to right,rgba(0,0,0,.22) 0%,rgba(0,0,0,.08) 18%,rgba(0,0,0,.02) 55%,rgba(0,0,0,0) 100%)}
/* outer-edge light falloff, like paper curving away */
.page.side-left::before,.page.side-right::before{content:"";position:absolute;top:0;bottom:0;width:3%;pointer-events:none;z-index:2}
.page.side-left::before{left:0;background:linear-gradient(to right,rgba(0,0,0,.06),rgba(0,0,0,0))}
.page.side-right::before{right:0;background:linear-gradient(to left,rgba(0,0,0,.06),rgba(0,0,0,0))}
.page.cover::before{display:none}
/* stacked page edges */
.edge{position:absolute;top:3px;bottom:3px;pointer-events:none;z-index:-1;
  background:repeating-linear-gradient(to right,#fdfdfd 0 1px,#c9ccd6 1px 2px);
  box-shadow:0 6px 14px rgba(20,28,80,.22)}
.edge-r{border-radius:0 3px 3px 0}
.edge-l{border-radius:3px 0 0 3px}
#bookWrap.open-book::after{content:"";position:absolute;left:50%;top:0;bottom:0;width:2px;margin-left:-1px;pointer-events:none;
  background:linear-gradient(to bottom,rgba(0,0,0,.18),rgba(0,0,0,.28) 50%,rgba(0,0,0,.18));z-index:5}
body.flipping #bookWrap.open-book::after{opacity:0}
.page.cover::after{display:none}

/* clickable TOC hotspots */
.hot{position:absolute;display:block;border-radius:3px;z-index:3;cursor:pointer;transition:background .15s, box-shadow .15s}
.hot:hover,.hot:focus-visible{background:rgba(97,142,209,.16);box-shadow:inset 0 0 0 1.5px rgba(44,57,139,.55);outline:none}
.hot.h:hover{background:rgba(143,176,113,.25)}
.hot-hint .hot{animation:hint 1.6s ease 2}
@keyframes hint{0%,100%{background:transparent}50%{background:rgba(97,142,209,.18)}}

.side-nav{
  position:absolute;top:50%;transform:translateY(-50%);z-index:5;
  width:46px;height:86px;border:0;border-radius:10px;cursor:pointer;
  background:rgba(255,255,255,.55);color:var(--navy);backdrop-filter:blur(4px);
  display:grid;place-items:center;transition:background .2s,opacity .2s;
}
.side-nav:hover{background:#fff}
.side-nav svg{width:28px;height:28px;stroke-width:2}
.side-next{left:12px}
.side-prev{right:12px}
.side-nav:disabled{opacity:0;pointer-events:none}

/* ---------- bottom toolbar ---------- */
.toolbar{
  position:fixed;bottom:0;inset-inline:0;height:var(--bar-h);z-index:20;
  display:flex;align-items:center;justify-content:space-between;padding:0 10px;
  background:var(--navy);color:#fff;box-shadow:0 -2px 10px rgba(20,28,80,.2);
  padding-bottom:env(safe-area-inset-bottom);
}
.tb-group{display:flex;align-items:center;gap:2px;flex:1}
.tb-nav{justify-content:center;flex:0 0 auto}
.tb-end{justify-content:flex-end}
.icon-btn{
  display:inline-grid;place-items:center;width:40px;height:40px;border:0;border-radius:8px;
  background:transparent;color:inherit;cursor:pointer;text-decoration:none;transition:background .15s,color .15s
}
.icon-btn:hover{background:rgba(255,255,255,.14)}
.icon-btn.active{background:var(--green);color:#fff}
.icon-btn:disabled{opacity:.35;cursor:default;background:transparent}
.icon-btn.dark{color:var(--ink)}
.icon-btn.dark:hover{background:#eef0f6}
.page-box{display:flex;align-items:center;gap:6px;margin:0 6px;background:#fff;color:var(--ink);border-radius:7px;height:32px;padding:0 8px;font-size:13px;direction:ltr}
.page-box input{width:76px;border:0;outline:none;text-align:center;font:inherit;font-weight:600;color:var(--navy);background:transparent}
.page-box span{color:var(--muted);white-space:nowrap}

/* ---------- drawers (TOC, search) ---------- */
.drawer{
  position:fixed;top:calc(var(--top-h) + 10px);bottom:calc(var(--bar-h) + 10px);right:10px;z-index:30;
  width:min(400px, calc(100vw - 20px));display:flex;flex-direction:column;
  background:rgba(255,255,255,.97);border-radius:12px;box-shadow:0 12px 40px rgba(20,28,80,.3);
  animation:slideIn .25s ease;
}
@keyframes slideIn{from{transform:translateX(30px);opacity:0}}
.drawer-head{display:flex;align-items:center;justify-content:space-between;padding:12px 16px;border-bottom:1px solid #e6e8f0}
.drawer-head strong{color:var(--navy);font-size:16px}
.muted{color:var(--muted);font-size:12px}
.drawer-body{overflow-y:auto;padding:8px 8px 16px;overscroll-behavior:contain}
.toc-sec{margin:6px 0 2px}
.toc-sec > button{
  width:100%;display:flex;align-items:center;gap:10px;text-align:start;border:0;cursor:pointer;
  background:var(--navy);color:#fff;border-radius:8px;padding:9px 12px;font:inherit
}
.toc-sec > button:hover{background:var(--navy-d)}
.toc-sec.single > button{background:#eef0f7;color:var(--navy)}
.toc-sec.single > button:hover{background:#e2e6f3}
.toc-sec .t{flex:1;min-width:0}
.toc-sec .ar{display:block;font-weight:700;font-size:14px;line-height:1.5}
.toc-sec .tr{display:block;font-size:11.5px;opacity:.8;direction:ltr;text-align:right;line-height:1.5}
.toc-sec .pn{font-size:12px;font-weight:700;min-width:30px;text-align:center;background:rgba(255,255,255,.18);border-radius:6px;padding:2px 4px}
.toc-sec.single .pn{background:#fff}
.toc-sec .chev{transition:transform .2s;width:16px;height:16px;flex:0 0 auto}
.toc-sec.open .chev{transform:rotate(180deg)}
.toc-items{display:none;padding:4px 4px 6px}
.toc-sec.open .toc-items{display:block}
.toc-item{
  display:flex;gap:10px;align-items:flex-start;width:100%;text-align:start;border:0;background:transparent;
  padding:9px 8px;border-radius:8px;cursor:pointer;font:inherit;color:inherit;border-bottom:1px solid #f0f1f6
}
.toc-item:hover{background:#f1f4fb}
.toc-item.current{background:#eaf2e3;box-shadow:inset -3px 0 0 var(--green)}
.toc-item .t{flex:1;min-width:0}
.toc-item .ar{display:block;font-size:13.5px;font-weight:600;color:var(--navy);line-height:1.6}
.toc-item .au{display:block;font-size:12px;color:#4a5280;line-height:1.5}
.toc-item .tr{display:block;font-size:11.5px;color:var(--muted);direction:ltr;text-align:right;line-height:1.5;margin-top:2px}
.toc-item .pn{font-size:12px;font-weight:700;color:var(--green);min-width:30px;text-align:center;padding-top:2px}

/* search results */
.sr{display:flex;gap:12px;align-items:center;width:100%;border:0;background:transparent;text-align:start;padding:8px;border-radius:8px;cursor:pointer;font:inherit;color:inherit;border-bottom:1px solid #f0f1f6}
.sr:hover{background:#f1f4fb}
.sr img{width:52px;height:74px;object-fit:cover;border-radius:3px;box-shadow:0 1px 4px rgba(0,0,0,.2);flex:0 0 auto;background:#eee}
.sr b{color:var(--navy);display:block;font-size:14px}
.sr span{font-size:12px;color:var(--muted)}
.sr-empty{padding:24px 12px;text-align:center;color:var(--muted);font-size:13px;line-height:1.8}
.sr-note{margin:8px 6px 0;font-size:11px;color:var(--muted);line-height:1.7}

/* ---------- thumbnails sheet ---------- */
.sheet{position:fixed;bottom:var(--bar-h);inset-inline:0;z-index:25;background:rgba(29,35,64,.94);color:#fff;padding:8px 12px 12px;animation:up .25s ease}
@keyframes up{from{transform:translateY(20px);opacity:0}}
.sheet-head{display:flex;align-items:center;justify-content:space-between;font-size:14px;padding:0 4px 6px}
.thumbs{display:flex;gap:14px;overflow-x:auto;padding:4px 4px 8px;scroll-behavior:smooth;overscroll-behavior:contain}
.thumbs::-webkit-scrollbar{height:8px}.thumbs::-webkit-scrollbar-thumb{background:rgba(255,255,255,.3);border-radius:4px}
.th{flex:0 0 auto;border:0;background:transparent;cursor:pointer;padding:4px;border-radius:6px;color:#cfd3ea;font:inherit;font-size:11px}
.th:hover{background:rgba(255,255,255,.1)}
.th.current{background:var(--green);color:#fff}
.th .imgs{display:flex;direction:rtl;height:120px;box-shadow:0 2px 8px rgba(0,0,0,.4)}
.th img{height:120px;width:84px;object-fit:cover;background:#fff;display:block}
.th .lbl{display:block;text-align:center;margin-top:4px;direction:ltr}

/* ---------- share popover ---------- */
.popover{position:fixed;bottom:calc(var(--bar-h) + 10px);left:10px;z-index:30;background:#fff;border-radius:12px;padding:14px;box-shadow:0 12px 40px rgba(20,28,80,.3);width:300px;animation:up .2s ease}
.share-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:8px}
.share-grid a,.share-grid button{display:flex;flex-direction:column;align-items:center;gap:4px;font-size:11.5px;color:var(--ink);text-decoration:none;padding:8px 4px;border-radius:8px;border:0;background:transparent;cursor:pointer;font-family:inherit}
.share-grid a:hover,.share-grid button:hover{background:#f1f4fb}
.share-grid i{width:38px;height:38px;border-radius:50%;display:grid;place-items:center;color:#fff;font-style:normal;font-weight:700;font-size:15px;font-family:Arial,sans-serif}
.share-grid svg{width:18px;height:18px}
.share-link{display:flex;gap:6px;margin-top:10px}
.share-link input{flex:1;min-width:0;border:1px solid #dde0ea;border-radius:7px;padding:6px 8px;font-size:12px;color:var(--muted)}
.share-link button{border:0;background:var(--navy);color:#fff;border-radius:7px;padding:0 14px;cursor:pointer;font-family:inherit}

/* ---------- zoom ---------- */
#zoomLayer{position:fixed;inset:0;z-index:50;background:#161b36;display:flex;flex-direction:column}
.zoom-bar{display:flex;align-items:center;justify-content:center;gap:6px;height:52px;color:#fff;background:var(--navy);flex:0 0 auto;font-size:13px}
.zoom-bar #zLevel{min-width:52px;text-align:center;direction:ltr}
.zoom-bar #zPages{min-width:70px;text-align:center;direction:ltr}
.zoom-sep{width:1px;height:24px;background:rgba(255,255,255,.25);margin:0 6px}
.zoom-scroll{flex:1;overflow:auto;cursor:grab;overscroll-behavior:contain;touch-action:pan-x pan-y}
.zoom-scroll.drag{cursor:grabbing}
.zoom-canvas{display:flex;direction:rtl;margin:20px auto;width:max-content;box-shadow:0 10px 40px rgba(0,0,0,.5)}
.zoom-canvas img{display:block;background:#fff;user-select:none;-webkit-user-drag:none}

/* ---------- toast & noscript ---------- */
.toast{position:fixed;bottom:calc(var(--bar-h) + 18px);left:50%;transform:translateX(-50%);z-index:60;background:var(--ink);color:#fff;padding:8px 16px;border-radius:8px;font-size:13px}
.noscript{position:fixed;inset:0;z-index:200;background:#fff;padding:40px;text-align:center}

/* ---------- small screens ---------- */
@media (max-width:760px){
  :root{--top-h:46px;--bar-h:50px}
  .brand-issue small,.brand-sep{display:none}
  .brand-mark{font-size:19px}
  .brand-issue{font-size:12px}
  .search input{width:110px}
  .search:focus-within input{width:150px}
  .side-nav{width:34px;height:64px;background:rgba(255,255,255,.4)}
  .side-next{left:4px}.side-prev{right:4px}
  .tb-group{gap:0}
  .icon-btn{width:36px;height:38px}
  #btnFirst,#btnLast{display:none}
  .page-box input{width:58px}
  .popover{left:8px;right:8px;width:auto}
  .th .imgs,.th img{height:96px}.th img{width:67px}
}
@media (max-width:420px){
  .brand-issue{display:none}
}
.portrait .page::after,.portrait .page::before{display:none}
.toc-sec .pn:empty{visibility:hidden}
