/* JBN Diamonds Flipbook 1.2.0 */
.jbnfb {
  --jbnfb-height: 88vh;
  --jbnfb-bg: radial-gradient(ellipse at 50% 35%, #2d3a8c 0%, #1b2160 45%, #0d1030 100%);
  --jbnfb-accent: #d9261c;
  --jbnfb-bar: rgba(10, 12, 35, 0.82);
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: var(--jbnfb-height);
  min-height: 420px;
  background: var(--jbnfb-bg);
  overflow: hidden;
  box-sizing: border-box;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #fff;
  -webkit-user-select: none;
  user-select: none;
  isolation: isolate;
}
.jbnfb *, .jbnfb *::before, .jbnfb *::after { box-sizing: border-box; }

.jbnfb--fullwidth {
  width: 100vw;
  max-width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

/* ---------- Stage & book ---------- */
.jbnfb-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  padding: 24px 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.jbnfb-book {
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity .5s ease;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, .45));
}
.jbnfb.is-ready .jbnfb-book { opacity: 1; }

.jbnfb .jbnfb-page {
  background: #fff;
  overflow: hidden;
}
.jbnfb .jbnfb-page img {
  display: block;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  object-fit: cover;
  pointer-events: none;
  background: #f4f5fa;
}
/* Blank inside back cover (only used in two-page view) */
.jbnfb .jbnfb-page--blank { background: linear-gradient(to right, #f3f4f8, #fbfbfd); }

/* Spine shading on inner edges */
.jbnfb .jbnfb-page.--left::after,
.jbnfb .jbnfb-page.--right::after {
  content: "";
  position: absolute;
  top: 0; bottom: 0;
  width: 7%;
  pointer-events: none;
}
.jbnfb .jbnfb-page.--left::after { right: 0; background: linear-gradient(to left, rgba(0,0,0,.18), rgba(0,0,0,0)); }
.jbnfb .jbnfb-page.--right::after { left: 0; background: linear-gradient(to right, rgba(0,0,0,.18), rgba(0,0,0,0)); }
.jbnfb .jbnfb-page.--hard::after { display: none; }

/* Loader */
.jbnfb-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity .3s;
}
.jbnfb-loader span {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 3px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  animation: jbnfb-spin .8s linear infinite;
}
.jbnfb.is-ready .jbnfb-loader { opacity: 0; }
@keyframes jbnfb-spin { to { transform: rotate(360deg); } }

/* ---------- Buttons ---------- */
.jbnfb .jbnfb-btn {
  all: unset;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .15s;
  -webkit-tap-highlight-color: transparent;
}
.jbnfb .jbnfb-btn svg {
  width: 22px; height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.jbnfb .jbnfb-btn:hover { background: rgba(255,255,255,.14); }
.jbnfb .jbnfb-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.jbnfb .jbnfb-btn:disabled { opacity: .3; cursor: default; background: none; }
.jbnfb .jbnfb-btn.is-on { background: var(--jbnfb-accent); }
.jbnfb .jbnfb-btn.is-off { opacity: .55; }

/* Side arrows */
.jbnfb .jbnfb-arrow {
  position: absolute;
  top: 50%;
  width: 52px;
  height: 88px;
  margin-top: -44px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  z-index: 5;
}
.jbnfb .jbnfb-arrow svg { width: 34px; height: 34px; stroke-width: 1.6; }
.jbnfb .jbnfb-arrow:hover { background: rgba(255,255,255,.2); }
.jbnfb .jbnfb-arrow:disabled { opacity: 0; pointer-events: none; }
.jbnfb .jbnfb-arrow--prev { left: 12px; }
.jbnfb .jbnfb-arrow--next { right: 12px; }

/* ---------- Toolbar ---------- */
.jbnfb-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 14px;
  background: var(--jbnfb-bar);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-top: 1px solid rgba(255,255,255,.08);
  z-index: 6;
}
.jbnfb-grp { display: flex; align-items: center; gap: 2px; }
.jbnfb-counter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 0 6px;
  font-size: 14px;
  line-height: 1;
  white-space: nowrap;
  cursor: text;
}
.jbnfb .jbnfb-counter input {
  all: unset;
  box-sizing: border-box;
  width: 64px;
  height: 32px;
  padding: 0 6px;
  border-radius: 6px;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  color: #fff;
  font: 600 14px/32px system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  text-align: center;
}
.jbnfb .jbnfb-counter input:focus { border-color: #fff; background: rgba(255,255,255,.2); }
.jbnfb-total { opacity: .75; }

/* ---------- Thumbnails drawer ---------- */
.jbnfb-drawer {
  position: absolute;
  top: 0; left: 0; bottom: 56px;
  width: min(340px, 86%);
  display: flex;
  flex-direction: column;
  background: rgba(10, 12, 35, .95);
  transform: translateX(-102%);
  transition: transform .3s ease;
  z-index: 8;
  box-shadow: 8px 0 30px rgba(0,0,0,.35);
}
.jbnfb.is-drawer .jbnfb-drawer { transform: none; }
.jbnfb-drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 8px 16px;
  font-weight: 600;
  font-size: 15px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.jbnfb-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 14px;
  align-content: start;
}
.jbnfb .jbnfb-thumb {
  all: unset;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  font-size: 12px;
  opacity: .85;
}
.jbnfb .jbnfb-thumb img {
  display: block;
  width: 100% !important;
  height: auto !important;
  aspect-ratio: 2245 / 3179;
  object-fit: cover;
  background: #fff;
  border: 2px solid transparent;
  border-radius: 3px;
  margin: 0 !important;
}
.jbnfb .jbnfb-thumb:hover { opacity: 1; }
.jbnfb .jbnfb-thumb.is-current { opacity: 1; }
.jbnfb .jbnfb-thumb.is-current img { border-color: var(--jbnfb-accent); }

/* ---------- Zoom viewer ---------- */
.jbnfb-zoom {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(6, 8, 24, .97);
  overflow: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s, visibility .25s;
}
.jbnfb.is-zoom .jbnfb-zoom { opacity: 1; visibility: visible; }
.jbnfb-zoom-inner {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100%;
  padding: 24px;
  cursor: zoom-in;
}
.jbnfb .jbnfb-zoom-inner img {
  display: block;
  height: auto !important;
  max-width: none !important;
  margin: 0 !important;
  width: min(100%, 900px) !important;
  box-shadow: 0 10px 40px rgba(0,0,0,.5);
  background: #fff;
}
.jbnfb .jbnfb-zoom-inner.is-spread img { width: min(50%, 900px) !important; }
.jbnfb .jbnfb-zoom-inner.is-big { cursor: zoom-out; padding: 0; }
.jbnfb .jbnfb-zoom-inner.is-big img { width: 1800px !important; }
.jbnfb .jbnfb-zoom-inner.is-big.is-spread img { width: 1600px !important; }
.jbnfb .jbnfb-zoom-close {
  position: sticky;
  float: right;
  top: 12px;
  margin: 12px 12px -52px 0;
  background: rgba(255,255,255,.15);
  z-index: 2;
}
.jbnfb-zoom-hint {
  position: sticky;
  bottom: 12px;
  width: max-content;
  max-width: 90%;
  margin: -40px auto 0;
  padding: 7px 14px;
  border-radius: 20px;
  background: rgba(0,0,0,.6);
  font-size: 12px;
  text-align: center;
  pointer-events: none;
}

/* ---------- Toast ---------- */
.jbnfb-toast {
  position: absolute;
  left: 50%;
  bottom: 72px;
  transform: translate(-50%, 10px);
  padding: 9px 16px;
  border-radius: 20px;
  background: #fff;
  color: #111;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 30;
}
.jbnfb-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Full screen ---------- */
.jbnfb:fullscreen, .jbnfb.is-fs { height: 100vh !important; width: 100vw; max-width: none; margin: 0; }
.jbnfb:-webkit-full-screen { height: 100vh !important; width: 100vw; }
.jbnfb.is-fs-fallback {
  position: fixed !important;
  inset: 0;
  z-index: 2147483000;
  height: 100% !important;
  width: 100% !important;
  margin: 0 !important;
}
html.jbnfb-lock, html.jbnfb-lock body { overflow: hidden !important; }

/* ---------- Admin notice & no-JS ---------- */
.jbnfb-admin-notice {
  margin: 0 0 12px;
  padding: 10px 14px;
  border-left: 4px solid #d9261c;
  background: #fff4f3;
  color: #222;
  font-size: 14px;
}
.jbnfb-noscript { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 16px; overflow: auto; }
.jbnfb-noscript img { width: 100%; height: auto; }

/* ---------- Mobile ---------- */
@media (max-width: 720px) {
  .jbnfb { min-height: 480px; }
  .jbnfb-stage { padding: 12px 10px; }
  .jbnfb .jbnfb-arrow { display: none; }
  .jbnfb-bar { padding: 6px 6px; gap: 2px; }
  .jbnfb .jbnfb-btn { width: 34px; height: 36px; }
  .jbnfb .jbnfb-btn svg { width: 20px; height: 20px; }
  .jbnfb-counter { margin: 0 2px; font-size: 13px; }
  .jbnfb .jbnfb-counter input { width: 52px; font-size: 13px; }
  .jbnfb .jbnfb-first-last, .jbnfb .jbnfb-grp--nav > .jbnfb-btn:first-child,
  .jbnfb .jbnfb-grp--nav > .jbnfb-btn:last-child { display: none; }
  .jbnfb-drawer { bottom: 48px; }
  .jbnfb-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; padding: 10px; }
  .jbnfb .jbnfb-zoom-inner.is-spread { flex-direction: column; align-items: center; }
  .jbnfb .jbnfb-zoom-inner.is-spread img { width: 100% !important; }
  .jbnfb .jbnfb-zoom-inner.is-big img, .jbnfb .jbnfb-zoom-inner.is-big.is-spread img { width: 1200px !important; }
}
@media (max-width: 400px) {
  .jbnfb .jbnfb-btn[aria-label="Share this page"] { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .jbnfb-drawer, .jbnfb-zoom, .jbnfb-book { transition: none; }
}
