/* Ketab Shafagh v1.1.0 — isolated front-end stylesheet */
.ffb-widget, .ffb-widget * { box-sizing: border-box; }
.ffb-widget { --ffb-ink:#e8effa; --ffb-accent:#4dc9bd; --ffb-dark:#142138; --ffb-glow:#233952; position:relative; width:100%; max-width:1180px; margin:28px auto; padding:18px 18px 10px; border-radius:17px; background:linear-gradient(145deg,#182c45 0%,#0d1626 100%); box-shadow:0 22px 68px rgba(13,28,49,.20); color:var(--ffb-ink); font-family:Tahoma,"Vazirmatn",Arial,sans-serif; direction:rtl; isolation:isolate; }
.ffb-widget button { font-family:inherit; }
.ffb-topline { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px; padding:0 6px 12px; }
.ffb-book-title { font-size:17px; font-weight:700; line-height:1.7; color:#f6f9ff; overflow-wrap:anywhere; }
.ffb-mode-hint { color:#9bafc6; font-size:11px; white-space:nowrap; }
.ffb-viewport { position:relative; display:block; width:100%; min-height:210px; padding:17px 49px 20px; border-radius:12px; background:radial-gradient(ellipse at 50% 30%,#354764 0%,#17283e 52%,#0b1526 100%); overflow:auto; overscroll-behavior:contain; touch-action:pan-y; outline-offset:3px; }
.ffb-viewport:focus-visible { outline:2px solid var(--ffb-accent); }
.ffb-scene { --ffb-zoom:1; position:relative; width:100%; max-width:none; margin:0 auto; aspect-ratio:var(--ffb-aspect, 1.46); perspective:2100px; transform-style:preserve-3d; }
.ffb-book { width:100%; height:100%; position:relative; transform-style:preserve-3d; filter:drop-shadow(0 13px 13px rgba(0,0,0,.36)); }
.ffb-book::before { content:""; display:block; position:absolute; inset:0; border-radius:4px; background:#e0dcd1; transform:translate(0,6px); box-shadow:0 5px #b6b3ab,0 9px #e5e3db,0 11px #777b7a; }
.ffb-static { position:absolute; inset:0; display:flex; direction:ltr; }
.ffb-page { position:relative; flex:1 1 50%; width:50%; min-width:0; height:100%; overflow:hidden; background:#fcfaf5; border:1px solid #d4d0c7; color:#283041; }
.ffb-page--left { flex:0 0 var(--ffb-left-width, 50%); width:var(--ffb-left-width, 50%); border-radius:5px 0 0 5px; box-shadow:inset -18px 0 25px -25px #111; }
.ffb-page--right { flex:0 0 var(--ffb-right-width, 50%); width:var(--ffb-right-width, 50%); border-radius:0 5px 5px 0; box-shadow:inset 18px 0 25px -25px #111; }
.ffb-page--empty { background:linear-gradient(160deg,#eeece6,#e3dfd5); }
.ffb-page img { width:100%!important; height:100%!important; max-width:none!important; max-height:none!important; display:block; object-fit:contain; background:#fff; border:0; border-radius:0; user-select:none; -webkit-user-drag:none; pointer-events:none; }
.ffb-page-number { position:absolute; bottom:7px; left:10px; font-family:Tahoma,sans-serif; direction:ltr; font-size:10px; color:#667085; opacity:.62; background:#fff9; border-radius:3px; padding:0 3px; pointer-events:none; }
.ffb-spine { display:block; position:absolute; z-index:2; top:0; bottom:0; left:calc(var(--ffb-left-width, 50%) - 3px); width:6px; pointer-events:none; background:linear-gradient(to right,rgba(0,0,0,.24),rgba(255,255,255,.29),rgba(0,0,0,.23)); box-shadow:0 0 15px rgba(0,0,0,.12); }
.ffb-overlay { position:absolute; inset:0; pointer-events:none; transform-style:preserve-3d; z-index:5; }
.ffb-leaf { position:absolute; top:0; width:50%; height:100%; transform-style:preserve-3d; will-change:transform; }
.ffb-leaf[data-side="left"] { width:var(--ffb-left-width, 50%); left:0; transform-origin:right center; }
.ffb-leaf[data-side="right"] { width:var(--ffb-right-width, 50%); right:0; transform-origin:left center; }
.ffb-leaf[data-direction="y"] { transition:transform 940ms cubic-bezier(.34,.03,.16,1); }
.ffb-leaf-face { position:absolute; inset:0; backface-visibility:hidden; -webkit-backface-visibility:hidden; transform-style:preserve-3d; overflow:hidden; background:#fff; }
.ffb-leaf-face .ffb-page { width:100%; height:100%; }
.ffb-leaf-front { transform:rotateY(0deg) translateZ(.3px); }
.ffb-leaf-back { transform:rotateY(180deg) translateZ(.3px); }
.ffb-leaf-front::after, .ffb-leaf-back::after { content:""; position:absolute; inset:0; pointer-events:none; background:linear-gradient(to right,rgba(10,19,30,.22),transparent 32%,transparent 68%,rgba(10,19,30,.17)); opacity:.6; }
.ffb-leaf-front::before { content:""; position:absolute; inset:0; z-index:2; pointer-events:none; background:linear-gradient(100deg,transparent 45%,rgba(0,0,0,.1) 85%,rgba(255,255,255,.07)); }
.ffb-toolbar { display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:8px 16px; padding:13px 2px 3px; }
.ffb-toolgroup { display:flex; flex-wrap:wrap; align-items:center; justify-content:center; gap:5px; }
.ffb-widget .ffb-toolbar button { appearance:none; display:inline-flex; justify-content:center; align-items:center; background:#273c55; border:1px solid #405673; border-radius:9px; color:#eaf3ff; width:37px; height:36px; padding:0; cursor:pointer; font:700 21px/1 Tahoma,Arial,sans-serif; transition:background .16s, border-color .16s,transform .16s; }
.ffb-widget .ffb-toolbar button:hover:not(:disabled) { background:#375473; border-color:#67c9c0; transform:translateY(-1px); }
.ffb-widget .ffb-toolbar button:focus-visible { outline:2px solid var(--ffb-accent); outline-offset:2px; }
.ffb-widget .ffb-toolbar button:disabled { cursor:not-allowed; opacity:.34; }
.ffb-widget .ffb-toolbar button[aria-pressed="true"] { background:#136f6c; border-color:#62d4c7; }
.ffb-counter, .ffb-zoom-level { font-size:12px; min-width:67px; text-align:center; color:#e5eefc; font-weight:bold; direction:ltr; white-space:nowrap; font-variant-numeric:tabular-nums; }
.ffb-zoom-level { min-width:48px; }
.ffb-message { height:auto; min-height:21px; margin:0; padding:3px 4px 0; color:#8bd9d3; text-align:center; font-size:12px; }
.ffb-loader { display:none; position:absolute; z-index:15; top:50%; left:50%; transform:translate(-50%,-50%); background:rgba(9,19,34,.9); color:#fff; padding:12px 19px; border:1px solid #738ea2; border-radius:9px; font-size:13px; text-align:center; pointer-events:none; }
.ffb-widget.ffb-loading .ffb-loader { display:block; }
.ffb-widget.ffb-loading .ffb-viewport { cursor:progress; }
.ffb-widget[data-layout="vertical"] .ffb-scene { aspect-ratio:var(--ffb-aspect, .73); }
.ffb-widget[data-layout="vertical"] .ffb-static { display:block; }
.ffb-widget[data-layout="vertical"] .ffb-viewport { touch-action:pan-x; }
.ffb-widget[data-layout="vertical"] .ffb-page { flex:none; width:100%; height:100%; border-radius:6px; box-shadow:inset 0 -14px 24px -22px #111; }
.ffb-widget[data-layout="vertical"] .ffb-spine { display:none; }
.ffb-widget[data-layout="vertical"] .ffb-leaf { width:100%; left:0; right:0; }
.ffb-widget[data-layout="vertical"] .ffb-leaf[data-side="bottom"] { transform-origin:center top; }
.ffb-widget[data-layout="vertical"] .ffb-leaf[data-side="top"] { transform-origin:center bottom; }
.ffb-widget[data-layout="vertical"] .ffb-leaf[data-direction="x"] { transition:transform 850ms cubic-bezier(.36,.04,.18,1); }
.ffb-widget[data-layout="vertical"] .ffb-leaf-front { transform:rotateX(0deg) translateZ(.3px); }
.ffb-widget[data-layout="vertical"] .ffb-leaf-back { transform:rotateX(180deg) translateZ(.3px); }
.ffb-widget[data-layout="vertical"] .ffb-leaf-front::after,.ffb-widget[data-layout="vertical"] .ffb-leaf-back::after { background:linear-gradient(to bottom,rgba(5,12,27,.16),transparent 25%,transparent 68%,rgba(5,12,27,.28)); }

/* دکمه‌های ورق‌زدن داخل قاب؛ دسکتاپ: راست و چپ، موبایل: بالا و پایین */
.ffb-widget .ffb-nav { appearance:none; position:absolute; z-index:10; top:50%; transform:translateY(-50%); width:37px; height:52px; border:1px solid #607691; border-radius:11px; background:rgba(15,34,55,.88); color:#efffff; display:flex; align-items:center; justify-content:center; cursor:pointer; padding:0; font:700 31px/1 Tahoma,Arial,sans-serif; box-shadow:0 4px 14px rgba(0,0,0,.18); }
.ffb-widget .ffb-nav:hover:not(:disabled) { background:#126d7b; border-color:#87e5dc; }
.ffb-widget .ffb-nav:focus-visible { outline:2px solid var(--ffb-accent); outline-offset:2px; }
.ffb-widget .ffb-nav:disabled { opacity:.23; cursor:not-allowed; }
.ffb-widget .ffb-nav-prev { right:7px; }
.ffb-widget .ffb-nav-next { left:7px; }
.ffb-widget .ffb-nav-mobile { display:none; }
.ffb-widget[data-layout="vertical"] .ffb-nav { top:auto; bottom:auto; left:50%; right:auto; transform:translateX(-50%); width:67px; height:34px; font-size:22px; }
.ffb-widget[data-layout="vertical"] .ffb-nav-prev { top:6px; }
.ffb-widget[data-layout="vertical"] .ffb-nav-next { bottom:6px; }
.ffb-widget[data-layout="vertical"] .ffb-nav-mobile { display:block; }
.ffb-widget[data-layout="vertical"] .ffb-nav-desktop { display:none; }
.ffb-widget[data-layout="vertical"] .ffb-viewport { padding:48px 10px 49px; }
.ffb-widget .ffb-toolbar button[data-action="mute"] { font-size:19px; }

.ffb-widget:fullscreen { max-width:none; width:100vw; height:100vh; border-radius:0; margin:0; display:flex; flex-direction:column; justify-content:center; }
.ffb-widget:fullscreen .ffb-viewport { min-height:0; flex:1 1 auto; }
.ffb-widget:fullscreen .ffb-scene { max-height:none; }
.ffb-widget.ffb-error-state .ffb-message { color:#ffbba5; }
.ffb-public-wrap { max-width:1580px; margin:0 auto; padding:32px 15px 70px; }
.ffb-public-heading { direction:rtl; text-align:right; margin:0 0 12px; font:700 25px/1.7 Tahoma,sans-serif; }
.ffb-error { direction:rtl; text-align:center; padding:20px; }
@media (max-width:700px) {
  .ffb-widget { padding:12px 9px 8px; border-radius:12px; margin:15px auto; }
  .ffb-book-title { font-size:14px; }
  .ffb-topline { padding-bottom:6px; }
  .ffb-mode-hint { font-size:10px; }
  .ffb-viewport { padding:48px 10px 49px; }
  .ffb-toolbar { justify-content:center; gap:8px; }
  .ffb-widget .ffb-toolbar button { width:33px; height:33px; font-size:18px; }
  .ffb-counter { min-width:62px; }
  .ffb-public-wrap { padding:16px 7px 35px; }
  .ffb-public-heading { font-size:20px; }
}
@media (prefers-reduced-motion:reduce) {
  .ffb-leaf { transition-duration:120ms!important; }
  .ffb-widget .ffb-toolbar button { transition:none; }
}

/* Shafagh v1.2: responsive, two-page stacked mobile book and optional chrome. */
.ffb-widget{max-width:1480px;margin:16px auto;padding:14px 13px 10px}
.ffb-widget .ffb-viewport{padding:13px 46px 18px}
.ffb-widget .ffb-toolbar{justify-content:center;gap:8px 20px;padding-top:14px}
.ffb-widget.ffb-style--minimal{background:transparent!important;box-shadow:none!important;border:0;border-radius:0;padding:0!important;color:#233047}
.ffb-widget.ffb-style--minimal .ffb-viewport{background:transparent!important;border-radius:0}
.ffb-widget.ffb-style--minimal .ffb-topline{padding:3px 0 10px}
.ffb-widget.ffb-style--minimal .ffb-book-title{color:inherit}
.ffb-widget.ffb-style--minimal .ffb-mode-hint{color:#536881}
.ffb-widget.ffb-style--minimal .ffb-toolbar button{background:#e8eef6;border-color:#c7d2e2;color:#162941}
.ffb-widget.ffb-style--minimal .ffb-toolbar button[aria-pressed="true"]{background:#b8e4df;border-color:#5ab5a9}
.ffb-widget.ffb-style--minimal .ffb-counter,.ffb-widget.ffb-style--minimal .ffb-zoom-level{color:#233047}
.ffb-widget.ffb-style--minimal .ffb-message{color:#176867}
.ffb-widget[data-layout="vertical"] .ffb-static{display:flex;flex-direction:column;direction:ltr}
.ffb-widget[data-layout="vertical"] .ffb-page--top{flex:0 0 var(--ffb-top-height,50%);height:var(--ffb-top-height,50%);width:100%;border-radius:5px 5px 0 0;box-shadow:inset 0 -15px 25px -20px #101827}
.ffb-widget[data-layout="vertical"] .ffb-page--bottom{flex:0 0 var(--ffb-bottom-height,50%);height:var(--ffb-bottom-height,50%);width:100%;border-radius:0 0 5px 5px;box-shadow:inset 0 15px 25px -20px #101827}
.ffb-widget[data-layout="vertical"] .ffb-spine{display:block;left:0;right:0;top:calc(var(--ffb-top-height,50%) - 4px);bottom:auto;width:100%;height:8px;background:linear-gradient(to bottom,rgba(18,26,36,.48),rgba(245,248,251,.38) 44%,rgba(9,20,33,.42));box-shadow:0 0 15px rgba(0,0,0,.22)}
.ffb-widget[data-layout="vertical"] .ffb-leaf[data-side="bottom"]{top:var(--ffb-top-height,50%);height:var(--ffb-bottom-height,50%);transform-origin:center top}
.ffb-widget[data-layout="vertical"] .ffb-leaf[data-side="top"]{top:0;height:var(--ffb-top-height,50%);transform-origin:center bottom}
.ffb-widget[data-layout="vertical"] .ffb-leaf-face .ffb-page{width:100%;height:100%}
.ffb-widget[data-layout="vertical"] .ffb-leaf-front::after,.ffb-widget[data-layout="vertical"] .ffb-leaf-back::after{background:linear-gradient(to bottom,rgba(2,12,27,.24),transparent 35%,transparent 70%,rgba(2,12,27,.31))}
.ffb-widget[data-layout="vertical"] .ffb-book{filter:drop-shadow(0 9px 9px rgba(0,0,0,.32))}
@media(max-width:700px){
  .ffb-widget{width:100%;max-width:100%;padding:9px 5px 8px;margin:8px auto;border-radius:10px}
  .ffb-widget .ffb-viewport,.ffb-widget[data-layout="vertical"] .ffb-viewport{padding:45px 3px 43px;border-radius:9px;overflow:auto}
  .ffb-widget .ffb-scene{width:100%;}
  .ffb-widget .ffb-toolbar{gap:8px 6px;justify-content:center;padding:10px 0 2px}
  .ffb-widget .ffb-toolgroup{gap:3px;flex-wrap:nowrap}
  .ffb-widget .ffb-toolbar button{width:31px;height:32px;border-radius:7px;font-size:16px}
  .ffb-widget .ffb-counter{min-width:55px;font-size:11px}
  .ffb-widget .ffb-zoom-level{min-width:41px;font-size:10px}
  .ffb-widget .ffb-nav{width:65px;height:32px}
  .ffb-widget.ffb-style--minimal .ffb-viewport{padding-left:3px;padding-right:3px}
  .ffb-public-wrap{padding:12px 3px 28px}
}
@media(max-width:360px){
  .ffb-widget .ffb-toolbar button{width:27px;height:29px;font-size:15px}
  .ffb-widget .ffb-counter{min-width:47px}
  .ffb-widget .ffb-toolgroup{gap:2px}
}
/* Cover gallery */
.ffb-catalog-gallery{box-sizing:border-box;width:100%;margin:18px auto;direction:rtl;font-family:Tahoma,Arial,sans-serif}
.ffb-catalog-gallery *{box-sizing:border-box}
.ffb-gallery-grid{display:grid;grid-template-columns:repeat(var(--ffb-gallery-columns,3),minmax(0,1fr));gap:22px}
.ffb-gallery-card{display:flex;flex-direction:column;min-width:0;padding:10px;text-decoration:none!important;border:1px solid #dce3ed;border-radius:13px;background:#fff;color:#1b2b42!important;box-shadow:0 6px 21px rgba(18,35,60,.06);transition:transform .2s,box-shadow .2s}
.ffb-gallery-card:hover{transform:translateY(-3px);box-shadow:0 12px 30px rgba(18,35,60,.14)}
.ffb-gallery-cover{aspect-ratio:4 / 3;overflow:hidden;display:flex;align-items:center;justify-content:center;background:#eff3f8;border-radius:9px}
.ffb-gallery-cover img{display:block;width:100%!important;height:100%!important;object-fit:contain;max-width:none!important}
.ffb-gallery-card h3{font:700 15px/1.85 Tahoma,Arial,sans-serif!important;margin:10px 2px 6px!important;color:#172a43!important}
.ffb-gallery-open{margin:auto 2px 3px;color:#047d88;font-size:12px;font-weight:bold}
.ffb-gallery-placeholder{height:100%;display:flex;gap:8px;flex-direction:column;align-items:center;justify-content:center;color:#546982;font-size:13px}
.ffb-gallery-placeholder span:first-child{font-size:45px;color:#90a9c2}
.ffb-gallery-pagination{display:flex;flex-wrap:wrap;justify-content:center;align-items:center;gap:9px;margin:26px auto}
.ffb-gallery-pagination .page-numbers{border:1px solid #cbd7e1;border-radius:8px;padding:7px 13px;text-decoration:none;background:#fff;color:#193d59}
.ffb-gallery-pagination .page-numbers.current{background:#17334f;color:#fff}
.ffb-gallery-empty{text-align:center;padding:25px;color:#5a687a}
@media(max-width:700px){.ffb-gallery-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:10px}.ffb-gallery-card{padding:6px}.ffb-gallery-card h3{font-size:12px!important}}
@media(max-width:380px){.ffb-gallery-grid{grid-template-columns:1fr}}
