/* Scoped to a tools-page prototype; does not affect visitors. */
.ahqaf-flip-admin-wrap{max-width:1500px}.ahqaf-flip-prototype{border:1px solid #d7dee5;background:#f4f7fb;border-radius:14px;padding:12px;margin-top:16px;position:relative;color:#1d3652}
.afp-toolbar{display:flex;align-items:center;justify-content:center;flex-wrap:wrap;gap:10px;padding:8px 4px}.afp-toolbar input{width:68px!important;text-align:center}.afp-message{text-align:center;margin:8px;color:#536478}
.afp-viewport{width:100%;max-height:min(77vh,850px);overflow:auto;background:#d8e0e6;border-radius:10px;padding:16px;box-sizing:border-box;scrollbar-gutter:stable}
.afp-spread{display:flex;flex-direction:row;align-items:flex-start;justify-content:center;gap:6px;width:100%;min-width:0;transform:none;perspective:1800px}
.afp-sheet{position:relative;flex:0 0 calc(50% - 3px);min-width:0;max-width:610px;aspect-ratio:0.707;box-shadow:0 5px 16px #27374a30;background:#fff;overflow:hidden;transform-style:preserve-3d}
.afp-sheet canvas{display:block;width:100%;height:100%;object-fit:contain;background:#fff}
.afp-sheet .afp-number{position:absolute;bottom:3px;left:7px;background:#fff9;padding:1px 7px;border-radius:5px;font-size:12px}
.afp-prototype-turning .afp-right{animation:afpFlipRight .38s ease-in-out}
.afp-prototype-back .afp-left{animation:afpFlipLeft .38s ease-in-out}
@keyframes afpFlipRight{0%{transform:rotateY(0)}50%{transform:rotateY(-55deg);filter:brightness(.76)}100%{transform:rotateY(0)}}
@keyframes afpFlipLeft{0%{transform:rotateY(0)}50%{transform:rotateY(55deg);filter:brightness(.76)}100%{transform:rotateY(0)}}
.afp-viewport.afp-zoomed .afp-spread{width:var(--afp-spread-width,120%);justify-content:flex-start}
.afp-viewport.afp-zoomed .afp-sheet{flex-basis:calc(50% - 3px);max-width:none}
.afp-viewport.afp-zoomed{cursor:grab}.afp-viewport.afp-zoomed:active{cursor:grabbing}
.ahqaf-flip-prototype.afp-expanded{position:fixed!important;z-index:100000;inset:0;border-radius:0;margin:0;padding:12px;background:#eef3f8;display:flex;flex-direction:column}
.ahqaf-flip-prototype.afp-expanded .afp-viewport{flex:1;max-height:none;min-height:0}
.ahqaf-flip-prototype.afp-expanded .afp-close{display:inline-block!important}
body.afp-modal-open{overflow:hidden}
@media(max-width:700px){.afp-sheet{flex-basis:100%;max-width:100%}.afp-left{display:none}.afp-viewport.afp-zoomed .afp-sheet{flex-basis:100%}.afp-viewport.afp-zoomed .afp-spread{width:var(--afp-spread-width,120%)}}
@media(prefers-reduced-motion:reduce){.afp-prototype-turning .afp-right,.afp-prototype-back .afp-left{animation:none}}

/* Version 0.3: physically adjacent facing pages, right-to-left order. */
.ahqaf-flip-prototype .afp-viewport{max-height:min(85vh,900px);overflow:auto;padding:12px;background:#303b45}
.ahqaf-flip-prototype .afp-spread{direction:rtl;display:flex;flex-direction:row;align-items:stretch;justify-content:center;gap:0;width:min(100%,1040px);max-width:100%;margin:0 auto;min-width:0}
.ahqaf-flip-prototype .afp-sheet{flex:0 0 50%;width:50%;max-width:none;min-width:0;aspect-ratio:0.707;box-shadow:0 3px 8px #0003;overflow:hidden;border:1px solid #d9d8d2;box-sizing:border-box}
.ahqaf-flip-prototype .afp-right{order:0;border-radius:0 4px 4px 0}
.ahqaf-flip-prototype .afp-left{order:1;border-radius:4px 0 0 4px}
.ahqaf-flip-prototype .afp-sheet canvas{width:100%;height:100%;object-fit:contain;display:block}
.ahqaf-flip-prototype .afp-blank{background:#f6f3e9}
.ahqaf-flip-prototype .afp-blank canvas{visibility:hidden}
.ahqaf-flip-prototype .afp-prototype-changing .afp-sheet{opacity:.72}
.ahqaf-flip-prototype .afp-viewport.afp-zoomed .afp-spread{width:var(--afp-spread-width,125%);max-width:none;margin:0;justify-content:flex-start}
.ahqaf-flip-prototype .afp-viewport:not(.afp-zoomed) .afp-left,.ahqaf-flip-prototype .afp-viewport:not(.afp-zoomed) .afp-right{cursor:pointer}
@media(max-width:700px){.ahqaf-flip-prototype .afp-spread{width:min(100%,530px)}.ahqaf-flip-prototype .afp-sheet{flex-basis:100%;width:100%}.ahqaf-flip-prototype .afp-left{display:none}.ahqaf-flip-prototype .afp-viewport.afp-zoomed .afp-spread{width:var(--afp-spread-width,125%)}}

/* 0.4: live pointer-driven 3D paper curl. Stage dimensions and the proven Arabic canvas renderer are unchanged. */
.ahqaf-flip-prototype .afp-viewport{position:relative;isolation:isolate}
.ahqaf-flip-prototype .afp-spread{position:relative;perspective:1600px;overflow:visible}
.ahqaf-flip-prototype .afp-fold{
  position:absolute;top:0;width:50%;height:100%;z-index:25;display:none;
  transform-style:preserve-3d;pointer-events:none;will-change:transform;
}
.ahqaf-flip-prototype .afp-fold-next{right:0;transform-origin:left center}
.ahqaf-flip-prototype .afp-fold-prev{left:0;transform-origin:right center}
.ahqaf-flip-prototype .afp-fold-front,.ahqaf-flip-prototype .afp-fold-back{
  position:absolute;inset:0;backface-visibility:hidden;overflow:hidden;background:#fff;
  box-shadow:0 5px 22px rgba(0,0,0,.2);
}
.ahqaf-flip-prototype .afp-fold-front canvas{width:100%;height:100%;display:block}
.ahqaf-flip-prototype .afp-fold-back{
  transform:rotateY(180deg);background:linear-gradient(90deg,#f0ede5,#fff 55%,#f1eee8);
  box-shadow:inset 0 0 26px rgba(25,30,30,.14);
}
.ahqaf-flip-prototype .afp-fold-front::after{
  content:'';position:absolute;inset:0;pointer-events:none;
  background:linear-gradient(90deg,rgba(0,0,0,.20),transparent 32%,rgba(0,0,0,.12));
  opacity:var(--curl-opacity,.12);
}
.ahqaf-flip-prototype .afp-corner{
  position:sticky;bottom:15px;z-index:30;width:44px;height:44px;border-radius:50%;
  border:1px solid #a3b4c1;background:#fff;color:#173652;
  font-size:26px;line-height:1;cursor:grab;touch-action:none;
  box-shadow:0 2px 10px #0003;user-select:none;
}
.ahqaf-flip-prototype .afp-corner-next{float:right;margin-right:4px}
.ahqaf-flip-prototype .afp-corner-prev{float:left;margin-left:4px}
.ahqaf-flip-prototype .afp-corner:active{cursor:grabbing}
.ahqaf-flip-prototype .afp-corner:disabled{opacity:.3;cursor:not-allowed}
@media(max-width:700px){.ahqaf-flip-prototype .afp-fold{width:100%}.ahqaf-flip-prototype .afp-fold-next{right:0}.ahqaf-flip-prototype .afp-corner-prev{left:6px}}
@media(prefers-reduced-motion:reduce){.ahqaf-flip-prototype .afp-fold{will-change:auto}}

/* 0.5: clear page-corner affordance and readable single-page zoom. */
.ahqaf-flip-prototype.afp-single-zoom .afp-spread{width:var(--afp-spread-width,125%)!important;max-width:none!important;margin:0!important;justify-content:flex-start!important}
.ahqaf-flip-prototype.afp-single-zoom .afp-right{flex:0 0 100%;width:100%;max-width:none;aspect-ratio:.707}
.ahqaf-flip-prototype.afp-single-zoom .afp-left{display:none!important}
.ahqaf-flip-prototype.afp-single-zoom .afp-viewport{overflow:auto;cursor:auto}
.ahqaf-flip-prototype .afp-sheet>.afp-corner{
 position:absolute!important;bottom:0!important;z-index:40;float:none!important;margin:0!important;
 width:70px!important;height:74px!important;border:0!important;border-radius:0!important;
 background:transparent!important;box-shadow:none!important;color:transparent!important;font-size:0!important;
 cursor:grab!important;opacity:1!important;display:block!important;
}
.ahqaf-flip-prototype .afp-right>.afp-corner-next{right:0;left:auto}
.ahqaf-flip-prototype .afp-left>.afp-corner-prev{left:0;right:auto}
.ahqaf-flip-prototype .afp-sheet>.afp-corner::before{
 content:'';position:absolute;bottom:0;width:0;height:0;display:block;
 transition:width .16s ease,height .16s ease,filter .16s ease;
 filter:drop-shadow(0 0 0 transparent);pointer-events:none;
}
.ahqaf-flip-prototype .afp-right>.afp-corner-next::before{right:0;border-style:solid;border-width:0 0 0 0;border-color:transparent transparent #dfd9c8 transparent}
.ahqaf-flip-prototype .afp-left>.afp-corner-prev::before{left:0;border-style:solid;border-color:transparent transparent #dfd9c8 transparent}
.ahqaf-flip-prototype .afp-sheet>.afp-corner:not(:disabled):hover::before,
.ahqaf-flip-prototype .afp-sheet>.afp-corner:not(:disabled):focus-visible::before{
 width:0;height:0;border-bottom:54px solid #e9e3d7;filter:drop-shadow(0 -3px 4px #0005);
}
.ahqaf-flip-prototype .afp-right>.afp-corner-next:not(:disabled):hover::before,
.ahqaf-flip-prototype .afp-right>.afp-corner-next:not(:disabled):focus-visible::before{border-left:54px solid transparent}
.ahqaf-flip-prototype .afp-left>.afp-corner-prev:not(:disabled):hover::before,
.ahqaf-flip-prototype .afp-left>.afp-corner-prev:not(:disabled):focus-visible::before{border-right:54px solid transparent}
.ahqaf-flip-prototype .afp-sheet>.afp-corner:disabled{pointer-events:none!important;opacity:0!important}
.ahqaf-flip-prototype.afp-single-zoom .afp-sheet>.afp-corner{display:none!important}

/* 0.6: discoverable page-edge curl, with larger and accessible hit targets. */
.ahqaf-flip-prototype .afp-sheet>.afp-corner{
  width:clamp(76px,18%,118px)!important;
  height:clamp(100px,27%,184px)!important;
  background:transparent!important;
  cursor:grab!important;
}
.ahqaf-flip-prototype .afp-sheet>.afp-corner:focus-visible{outline:3px solid #1e68c9!important;outline-offset:-4px}
.ahqaf-flip-prototype .afp-sheet>.afp-corner:not(:disabled):hover::before,
.ahqaf-flip-prototype .afp-sheet>.afp-corner:not(:disabled):focus-visible::before{border-bottom-width:65px!important}
.ahqaf-flip-prototype .afp-right>.afp-corner-next:not(:disabled):hover::before,
.ahqaf-flip-prototype .afp-right>.afp-corner-next:not(:disabled):focus-visible::before{border-left-width:65px!important}
.ahqaf-flip-prototype .afp-left>.afp-corner-prev:not(:disabled):hover::before,
.ahqaf-flip-prototype .afp-left>.afp-corner-prev:not(:disabled):focus-visible::before{border-right-width:65px!important}
.ahqaf-flip-prototype .afp-sheet>.afp-corner:active{cursor:grabbing!important}
@media(prefers-reduced-motion:reduce){.ahqaf-flip-prototype .afp-fold{transition:none!important}}

/* 0.7: fixed reading window, zoom never expands the reader itself. */
.ahqaf-flip-prototype .afp-viewport{height:min(72vh,740px)!important;max-height:none!important;overflow:auto!important;overscroll-behavior:contain;scrollbar-gutter:stable both-edges}
.ahqaf-flip-prototype.afp-expanded .afp-viewport{height:auto!important;min-height:0!important;max-height:none!important;flex:1 1 auto}
.ahqaf-flip-prototype.afp-single-zoom .afp-spread{width:var(--afp-spread-width,125%)!important;max-width:none!important;min-width:0!important;margin:0!important;justify-content:flex-start!important}
.ahqaf-flip-prototype.afp-single-zoom .afp-sheet{flex:0 0 100%!important;max-width:none!important}
/* Wide page-edge zones: next on outer right edge, previous on outer left edge. */
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet>.afp-corner{
  top:12%!important;bottom:auto!important;height:76%!important;width:clamp(46px,15%,94px)!important;
  touch-action:none!important;cursor:grab!important;z-index:55!important;
}
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-right>.afp-corner-next{right:0!important;left:auto!important}
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-left>.afp-corner-prev{left:0!important;right:auto!important}
.ahqaf-flip-prototype .afp-sheet>.afp-corner::before{bottom:0!important}
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet>.afp-corner:not(:disabled):hover{background:linear-gradient(to right,transparent,rgba(220,205,169,.12))!important}
@media(max-width:700px){.ahqaf-flip-prototype .afp-viewport{height:min(68vh,600px)!important}}

/* 0.8: reset overlapping legacy zoom rules. 100% shows a two-page spread;
   >100% shows exactly one enlarged page inside the fixed viewport. */
.ahqaf-flip-prototype .afp-viewport{height:min(75vh,780px)!important;overflow:auto!important;scrollbar-gutter:auto!important;}
.ahqaf-flip-prototype.afp-single-zoom .afp-spread,
.ahqaf-flip-prototype.afp-single-zoom .afp-viewport.afp-zoomed .afp-spread{
  width:var(--afp-single-width,800px)!important;
  min-width:var(--afp-single-width,800px)!important;
  max-width:none!important;
  margin:0!important;
  gap:0!important;
  display:flex!important;
  justify-content:flex-start!important;
}
.ahqaf-flip-prototype.afp-single-zoom .afp-right{
  display:block!important;width:100%!important;flex:0 0 100%!important;
  max-width:none!important;aspect-ratio:.707!important;
}
.ahqaf-flip-prototype.afp-single-zoom .afp-left{display:none!important;}
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-spread{
  width:min(100%,1040px)!important;max-width:100%!important;
  min-width:0!important;margin:0 auto!important;
}
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet{
  flex:0 0 50%!important;width:50%!important;max-width:50%!important;
}
/* Visible affordance from both page edges, not tiny invisible targets. */
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet>.afp-corner{
  position:absolute!important;top:7%!important;bottom:7%!important;
  width:clamp(55px,21%,130px)!important;height:auto!important;
  opacity:1!important;cursor:grab!important;border:0!important;
  background:transparent!important;color:transparent!important;
}
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet>.afp-corner:not(:disabled):hover,
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet>.afp-corner:not(:disabled):focus-visible{
  background:linear-gradient(90deg,rgba(210,194,158,.24),rgba(245,237,217,.02))!important;
}
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet>.afp-corner:not(:disabled)::after{
  content:'اسحب أو انقر للتقليب';position:absolute;bottom:8px;right:3px;left:3px;
  font-size:11px;line-height:1.4;color:#1b3b4a;text-align:center;
  background:rgba(255,255,255,.90);padding:4px 2px;border-radius:6px;
  opacity:0;transition:opacity .14s ease;pointer-events:none;
}
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet>.afp-corner:not(:disabled):hover::after,
.ahqaf-flip-prototype:not(.afp-single-zoom) .afp-sheet>.afp-corner:not(:disabled):focus-visible::after{opacity:1;}
.ahqaf-flip-prototype.afp-single-zoom .afp-sheet>.afp-corner{display:none!important;}

/* Public single-book mode: keep the open book and its navigation only. */
.ahqaf-public-book{max-width:1240px;margin:12px auto 30px;padding:10px;box-sizing:border-box;font-family:inherit}
.ahqaf-public-book .afp-toolbar button{padding:8px 12px;background:#fff;color:#163f50;border:1px solid #9fb0bd;border-radius:7px;font:inherit;cursor:pointer}
.ahqaf-public-book .afp-toolbar button:hover{background:#eaf4f7}
.ahqaf-public-book .afp-toolbar button:disabled{opacity:.45;cursor:default}
.ahqaf-public-book .afp-toolbar .afp-next{background:#186b57;color:#fff;border-color:#186b57}
.ahqaf-public-book .afp-toolbar input{font:inherit;border:1px solid #b7c4d0;border-radius:5px;padding:6px}
.ahqaf-public-book .afp-viewport{min-height:380px}
@media(max-width:700px){.ahqaf-public-book .afp-toolbar{gap:6px}.ahqaf-public-book .afp-toolbar button{padding:7px 9px}}


/* 0.9.1: responsive book fit and fullscreen portal. Override older prototype rules. */
.ahqaf-public-book.afp-expanded{
  position:fixed!important;inset:0!important;z-index:2147483000!important;
  width:100vw!important;max-width:none!important;height:100vh!important;height:100dvh!important;
  margin:0!important;padding:10px!important;border:0!important;box-sizing:border-box!important;
  display:flex!important;flex-direction:column!important;background:#edf3f6!important;
  transform:none!important;overflow:hidden!important;
}
body.afp-modal-open{overflow:hidden!important}
.ahqaf-public-book.afp-expanded .afp-toolbar{flex:0 0 auto;gap:8px}
.ahqaf-public-book.afp-expanded .afp-message{flex:0 0 auto;margin:2px 0 6px;font-size:13px}
.ahqaf-public-book.afp-expanded .afp-viewport{
  display:block!important;flex:1 1 auto!important;width:100%!important;
  min-height:0!important;height:auto!important;max-height:none!important;
  overflow:auto!important;
}
.ahqaf-public-book .afp-viewport{height:min(82vh,930px)!important;overflow:auto!important}
.ahqaf-public-book:not(.afp-single-zoom) .afp-spread,
.ahqaf-public-book:not(.afp-single-zoom) .afp-viewport .afp-spread{
  width:var(--afp-fit-spread-width,100%)!important;min-width:0!important;
  max-width:100%!important;margin:0 auto!important;justify-content:center!important;
}
.ahqaf-public-book.afp-single-zoom .afp-spread,
.ahqaf-public-book.afp-single-zoom .afp-viewport .afp-spread{
  width:var(--afp-single-width,700px)!important;
  min-width:var(--afp-single-width,700px)!important;max-width:none!important;
  margin:0 auto!important;display:flex!important;
}
.ahqaf-public-book.afp-single-zoom .afp-sheet.afp-right{
  flex:0 0 100%!important;width:100%!important;max-width:none!important;
}
.ahqaf-public-book .afp-sheet canvas{object-fit:fill!important}
.ahqaf-public-book.afp-single-zoom .afp-viewport{overflow:auto!important}
.ahqaf-public-book .afp-single-toggle{font-weight:600!important}
@media(max-width:700px){
 .ahqaf-public-book.afp-expanded{padding:5px!important}
 .ahqaf-public-book.afp-expanded .afp-toolbar{max-height:120px;overflow:auto}
}
