/* Araby Flipbook viewer
   One deliberate look (lapis ground, gold line, turquoise accent) so it sits well on any site theme. */
.afb {
  --afb-bg: #0f2433;
  --afb-bg-2: #0a1a26;
  --afb-line: rgba(200, 161, 75, 0.28);
  --afb-gold: #c8a14b;
  --afb-gold-hi: #e4c77f;
  --afb-turq: #3aa6a0;
  --afb-ink: #f3ead6;
  --afb-muted: rgba(243, 234, 214, 0.68);
  --afb-paper: #fbf7ee;
  --afb-height: min(82vh, 820px);
  --afb-radius: 8px;
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  background: var(--afb-bg);
  color: var(--afb-ink);
  border-radius: var(--afb-radius);
  overflow: hidden;
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
  color-scheme: dark;
  outline: none;
  isolation: isolate;
}
.afb *, .afb *::before, .afb *::after { box-sizing: border-box; }
.afb:focus-visible { box-shadow: inset 0 0 0 2px var(--afb-gold); }

.afb-stage {
  position: relative;
  height: var(--afb-height);
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background:
    radial-gradient(ellipse 70% 65% at 50% 50%, rgba(15, 36, 51, 0.35), rgba(10, 26, 38, 0.92) 78%),
    var(--afb-pattern, none) center / 112px 112px repeat,
    var(--afb-bg);
  touch-action: pan-y;
}
.afb-shift {
  transition: transform 0.75s cubic-bezier(0.3, 0.7, 0.2, 1);
  will-change: transform;
}
.afb-mount { position: relative; filter: drop-shadow(0 22px 28px rgba(0, 0, 0, 0.5)); }
.afb-book { min-width: 0 !important; min-height: 0 !important; }

.afb-page {
  background: var(--afb-paper);
  overflow: hidden;
  container-type: inline-size;
  -webkit-user-select: none;
  user-select: none;
}
.afb-page.afb-blank { background: var(--afb-paper); }
.afb-pdf img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s;
}
.afb-pdf.afb-ready img { opacity: 1; }
.afb-ph {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 9cqw;
  color: rgba(15, 36, 51, 0.25);
  background: linear-gradient(110deg, #f4efe3 30%, #fbf8f0 50%, #f4efe3 70%) 0 0 / 300% 100%;
  animation: afb-shimmer 1.6s linear infinite;
}
.afb-pdf.afb-ready .afb-ph { display: none; }
@keyframes afb-shimmer { to { background-position: -150% 0; } }

/* spine shading on the inner edge of each page */
.afb-gutter { position: absolute; top: 0; bottom: 0; width: 9%; pointer-events: none; z-index: 2; }
.afb-on-left .afb-gutter { right: 0; background: linear-gradient(to left, rgba(40, 25, 5, 0.22), rgba(40, 25, 5, 0.05) 45%, transparent); }
.afb-on-right .afb-gutter { left: 0; background: linear-gradient(to right, rgba(40, 25, 5, 0.22), rgba(40, 25, 5, 0.05) 45%, transparent); }
.afb-portrait .afb-gutter { display: none; }

/* arrows */
.afb-nav {
  position: absolute;
  top: 50%;
  z-index: 5;
  width: 44px;
  height: 72px;
  margin-top: -36px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--afb-line);
  border-radius: 999px;
  background: rgba(10, 26, 38, 0.7);
  color: var(--afb-gold-hi);
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s, transform 0.2s;
}
.afb-nav-l { left: 14px; }
.afb-nav-r { right: 14px; }
.afb-nav:hover:not(:disabled) { background: rgba(200, 161, 75, 0.18); }
.afb-nav:disabled { opacity: 0.25; cursor: default; }
.afb-nav svg, .afb-ico svg, .afb-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.afb-portrait .afb-nav { width: 36px; height: 56px; margin-top: -28px; background: rgba(10, 26, 38, 0.55); }
.afb-portrait .afb-nav-l { left: 4px; }
.afb-portrait .afb-nav-r { right: 4px; }

/* toolbar */
.afb-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 8px 14px;
  background: var(--afb-bg-2);
  border-top: 1px solid var(--afb-line);
}
.afb-group { display: flex; align-items: center; gap: 6px; min-width: 0; }
.afb-mid { flex: 1 1 auto; justify-content: center; }
.afb-end { justify-content: flex-end; }
.afb-dir {
  display: inline-flex;
  padding: 3px;
  border: 1px solid var(--afb-line);
  border-radius: 999px;
}
.afb-dir button {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 12px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--afb-muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.afb-dir button b { font-weight: 600; letter-spacing: 0.06em; font-size: 12px; }
.afb-dir button span { font-size: 12px; opacity: 0.85; }
.afb-dir button[aria-pressed="true"] { background: var(--afb-gold); color: #1b1408; }
.afb-dir button:not([aria-pressed="true"]):hover { color: var(--afb-ink); }
.afb-count {
  min-width: 9ch;
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: var(--afb-ink);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.afb-ico, .afb-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  min-width: 34px;
  padding: 0 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--afb-gold-hi);
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
}
.afb-btn { border-color: var(--afb-line); padding: 0 12px; color: var(--afb-ink); }
.afb-ico:hover:not(:disabled), .afb-btn:hover { background: rgba(200, 161, 75, 0.14); }
.afb-ico:disabled { opacity: 0.3; cursor: default; }
.afb-btn input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.afb-btn:focus-within, .afb button:focus-visible, .afb a:focus-visible { outline: 2px solid var(--afb-gold-hi); outline-offset: 2px; }

/* loading */
.afb-status {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(10, 26, 38, 0.72);
  text-align: center;
  padding: 16px;
}
.afb-status[hidden] { display: none; }
.afb-msg { margin: 0; color: var(--afb-ink); font-size: 15px; }
.afb-prog { width: min(260px, 70%); height: 3px; background: var(--afb-line); border-radius: 3px; overflow: hidden; }
.afb-prog[hidden] { display: none; }
.afb-prog i { display: block; height: 100%; width: 0; background: var(--afb-gold); transition: width 0.2s; }
/* eight-pointed star spinner: two squares, one turned 45° */
.afb-spin { position: relative; width: 34px; height: 34px; animation: afb-rot 2.4s linear infinite; }
.afb-spin::before, .afb-spin::after { content: ""; position: absolute; inset: 5px; border: 2px solid var(--afb-gold); }
.afb-spin::after { transform: rotate(45deg); border-color: var(--afb-turq); }
@keyframes afb-rot { to { transform: rotate(360deg); } }

.afb.afb-drop .afb-stage { box-shadow: inset 0 0 0 3px var(--afb-gold); }

.afb:fullscreen { --afb-height: calc(100vh - 52px); border-radius: 0; }
.afb:-webkit-full-screen { --afb-height: calc(100vh - 52px); border-radius: 0; }

@media (max-width: 560px) {
  .afb-bar { padding: 8px 10px; gap: 8px; }
  .afb-dir button span { display: none; }
  .afb-btn span { display: none; }
  .afb-mid { order: 3; flex-basis: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .afb-shift, .afb-pdf img { transition: none; }
  .afb-spin, .afb-ph { animation: none; }
}

/* Full-screen flipbook page: the book fills the screen under the theme header */
.afb-standalone { margin: 0; padding: 0; background: #0a1a26; }
.afb-fullscreen-page { position: relative; box-sizing: border-box; display: flex; flex-direction: column; width: 100%; max-width: none; min-height: 320px; margin: 0; padding: 0; height: calc(100vh - var(--afb-header-h, 0px)); height: calc(100dvh - var(--afb-header-h, 0px)); }
.afb-fullscreen-page .afb { flex: 1 1 auto; width: 100%; max-width: none; min-height: 0; height: auto; border-radius: 0; }
.afb-fullscreen-page .afb-stage { flex: 1 1 auto; height: auto; min-height: 0; }
.afb-empty { margin: auto; padding: 24px; color: #f3ead6; font: 16px/1.4 system-ui, sans-serif; }

/* Chapter menu in the bottom bar */
.afb-chapters {
  max-width: 200px;
  height: 34px;
  padding: 0 8px;
  border: 1px solid var(--afb-line);
  border-radius: 6px;
  background: var(--afb-bg);
  color: var(--afb-ink);
  font: inherit;
  font-size: 13px;
  color-scheme: dark;
  cursor: pointer;
}
.afb-chapters:focus-visible { outline: 2px solid var(--afb-gold-hi); outline-offset: 2px; }

/* Live reader count */
.afb-live { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--afb-muted); white-space: nowrap; }
.afb-live[hidden] { display: none; }
.afb-live i { width: 7px; height: 7px; border-radius: 50%; background: #3fbf7a; animation: afb-pulse 2s infinite; }
@keyframes afb-pulse { 0% { box-shadow: 0 0 0 0 rgba(63, 191, 122, 0.6); } 70% { box-shadow: 0 0 0 6px rgba(63, 191, 122, 0); } 100% { box-shadow: 0 0 0 0 rgba(63, 191, 122, 0); } }
@media (prefers-reduced-motion: reduce) { .afb-live i { animation: none; } }

/* Password box for protected books: centred, with the book's colours */
.afb-locked { flex: 1 1 auto; display: flex; align-items: center; justify-content: center; box-sizing: border-box; min-height: 320px; padding: 32px 16px; font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; color: var(--afb-ink, #f3ead6); }
.afb-lock-card { position: relative; box-sizing: border-box; width: 100%; max-width: 420px; padding: 36px 32px 32px; margin: 0; border: 1px solid rgba(200, 161, 75, 0.28); border-radius: 16px; background: linear-gradient(180deg, rgba(20, 46, 66, 0.92), rgba(10, 26, 38, 0.95)); box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45); text-align: center; animation: afb-lock-in 0.5s ease-out both; }
.afb-lock-cover { display: block; width: 100%; height: auto; max-height: 55vh; object-fit: contain; border-radius: 10px; margin: 0 auto 20px; }
.afb-lock-kicker { margin: 0 0 10px; font-size: 11px; font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; color: #c8a14b; }
.afb-lock-title { margin: 0 0 10px; font-size: 22px; line-height: 1.25; font-weight: 600; text-wrap: balance; color: #f3ead6; }
.afb-lock-text { margin: 0 0 24px; color: rgba(243, 234, 214, 0.72); }
.afb-lock-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.afb-lock-row { display: flex; flex-direction: column; gap: 10px; } .afb-lock-row input[type="password"], .afb-lock-row button { box-sizing: border-box; }
.afb-lock-row input[type="password"] { width: 100%; min-height: 48px; padding: 0 16px; border: 1px solid rgba(200, 161, 75, 0.4); border-radius: 10px; background: rgba(5, 15, 24, 0.7); color: #f3ead6; font: inherit; font-size: 16px; text-align: center; letter-spacing: 0.08em; transition: border-color 0.2s, box-shadow 0.2s; }
.afb-lock-row input[type="password"]::placeholder { color: rgba(243, 234, 214, 0.45); letter-spacing: normal; }
.afb-lock-row input[type="password"]:focus { outline: none; border-color: #e4c77f; box-shadow: 0 0 0 3px rgba(200, 161, 75, 0.25); }
.afb-lock-row button { min-height: 48px; padding: 0 20px; border: 0; border-radius: 10px; background: #c8a14b; color: #1b1408; font: inherit; font-size: 15px; font-weight: 600; cursor: pointer; transition: background 0.2s, transform 0.1s; }
.afb-lock-row button:hover { background: #e4c77f; }
.afb-lock-row button:active { transform: translateY(1px); }
.afb-lock-row button:focus-visible { outline: 2px solid #e4c77f; outline-offset: 3px; }
@keyframes afb-lock-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@media (min-width: 520px) { .afb-lock-row { flex-direction: row; } .afb-lock-row input[type="password"] { flex: 1 1 auto; text-align: left; letter-spacing: normal; } .afb-lock-row button { flex: 0 0 auto; } }
@media (prefers-reduced-motion: reduce) { .afb-lock-card { animation: none; } }

/* Whole-book print: the viewer's print button fills .afb-print-all with every page, marks <html> with .afb-printing,
   and opens the browser's print dialog. Ctrl+P on its own still prints the screen as normal. Margins and paper size
   stay with the print dialog; each page is scaled to fit inside the paper area. */
.afb-print-all { display: none; }
@media print {
  html.afb-printing body > *:not(.afb-print-all) { display: none !important; }
  html.afb-printing .afb-print-all { display: block !important; }
  html.afb-printing .afb-print-all img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100vh; margin: 0 auto; object-fit: contain; page-break-after: always; break-after: page; }
  html.afb-printing .afb-print-all img:last-child { page-break-after: auto; break-after: auto; }
}
