/* Stedman Flipbook
   Load order: bootstrap.min.css → your style.css → flipbook.css (set in config.php).
   Font, text colour and borders follow Bootstrap's variables (and so your style.css);
   the fallback values are used without Bootstrap. Adjust colours here. */
:root {
  --fb-bg: #ffffff;                                        /* stage background */
  --fb-surface: var(--bs-body-bg, #ffffff);               /* top bar, menus, dialogs */
  --fb-line: var(--bs-border-color, #dedcd7);             /* borders */
  --fb-ink: var(--bs-body-color, #1a1a1a);                /* main text */
  --fb-muted: var(--bs-secondary-color, #5c5a55);         /* secondary text */
  --fb-focus: var(--bs-primary, #2b6cd4);                 /* keyboard focus ring */
  --fb-bar: #141414;                                       /* floating toolbar */
  --fb-bar-ink: #ffffff;
  --fb-radius: 14px;
  --fb-font: var(--bs-body-font-family, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif);
  --fb-topbar-h: 55px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--fb-bg); color: var(--fb-ink); font-family: var(--fb-font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
.fb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--fb-focus); outline-offset: 2px; }

/* neutralise Bootstrap defaults that would affect the viewer */
.fb-app h2, .fb-list h1 { line-height: 1.25; }
.fb-app label { margin-bottom: 0; }
.fb-app svg { vertical-align: initial; }
.fb-app a.fb-tb, .fb-app a.fb-back { text-decoration: none; }
.fb-app .fb-tb:focus, .fb-app .fb-side:focus { box-shadow: none; }

/* ---------- app layout ---------- */
.fb-app { position: relative; display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

.fb-topbar {
  height: var(--fb-topbar-h); flex-shrink: 0; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 0 24px; background: var(--fb-surface); border-bottom: 1px solid var(--fb-line); position: relative; z-index: 20;
}
.fb-topbar-left { display: flex; align-items: center; gap: 16px; min-width: 0; }
.fb-back {
  display: inline-flex; align-items: center; gap: 8px; height: 35px; padding: 0 14px 0 10px; border: none;
  border-radius: 0; color: var(--fb-ink); text-decoration: none; font-size: 14px; font-weight: 500; white-space: nowrap;
}
.fb-back:hover { border-color: var(--fb-ink); }
.fb-back svg { width: 18px; height: 18px; }
.fb-divider { width: 1px; height: 28px; background: var(--fb-line); }
.fb-logo { height: 26px; width: auto; display: block; border-radius: 0px; }
.fb-logo-text { font-weight: 800; font-size: 20px; letter-spacing: .08em; }
.fb-title { font-size: 14px; color: var(--fb-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }

/* language switch */
.fb-lang { position: relative; flex-shrink: 0; }
.fb-lang-btn {
  display: flex; align-items: center; gap: 10px; height: 35px; padding: 0 14px;
  border: none; background: var(--fb-surface); font-size: 14px; font-weight: 500;
}
.fb-lang-btn svg { width: 18px; height: 18px; stroke-width: 1.8; }
.fb-lang-btn .fb-chev { width: 14px; height: 14px; stroke-width: 2; transition: transform .2s; }
.fb-lang-btn[aria-expanded="true"] .fb-chev { transform: rotate(180deg); }
.fb-lang-code { display: none; font-weight: 600; }
.fb-lang-menu {
  position: absolute; right: 0; top: 52px; width: 248px; max-height: calc(100dvh - 90px); overflow: auto;
  background: var(--fb-surface); border: 1px solid var(--fb-line); border-radius: var(--fb-radius);
  box-shadow: 0 16px 40px rgba(20,20,20,.14); padding: 8px; display: flex; flex-direction: column; gap: 2px;
}
.fb-menu-label { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--fb-muted); padding: 8px 10px 6px; }
.fb-lang-menu button {
  display: flex; align-items: center; gap: 12px; min-height: 35px; padding: 0 10px; border: 0; border-radius: 0;
  background: transparent; font-size: 14px; text-align: left;
}
.fb-lang-menu button:hover { background: #f5f4f1; }
.fb-lang-menu .fb-code { width: 30px; font-size: 12px; font-weight: 600; color: var(--fb-muted); }
.fb-lang-menu .fb-name { flex: 1; }
.fb-lang-menu .fb-check { width: 16px; height: 16px; visibility: hidden; }
.fb-lang-menu button[aria-checked="true"] { background: #f2f1ee; font-weight: 600; }
.fb-lang-menu button[aria-checked="true"] .fb-check { visibility: visible; }

.fb-progress { height: 3px; background: var(--fb-line); flex-shrink: 0; }
.fb-progress div { height: 100%; width: 0; background: var(--fb-ink); transition: width .4s ease; }

/* ---------- stage & book ---------- */
.fb-stage { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 12px 24px 84px; position: relative; }
.fb-book-area { flex: 1; align-self: stretch; min-width: 0; position: relative; display: flex; align-items: center; justify-content: center; }
.fb-book-host { display: flex; align-items: center; justify-content: center; }
.fb-book::before { content: ""; position: absolute; inset: 0; z-index: -1; box-shadow: 0 24px 50px rgba(20,20,20,.18), 0 4px 12px rgba(20,20,20,.08); }
.fb-book[data-single="right"]::before { left: 50%; } .fb-book[data-single="left"]::before { right: 50%; }
.fb-page { background: #fff; overflow: hidden; }
.fb-book { transition: transform .45s ease; }
.fb-page canvas { display: block; }
.fb-page.fb-left::before, .fb-page.fb-right::before { content: ""; position: absolute; top: 0; bottom: 0; width: 10%; z-index: 1; pointer-events: none; }
.fb-page.fb-left::before { right: 0; background: linear-gradient(to left, rgba(0,0,0,.13), rgba(0,0,0,0)); }
.fb-page.fb-right::before { left: 0; background: linear-gradient(to right, rgba(0,0,0,.13), rgba(0,0,0,0)); }
.fb-page.is-blank::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, #f7f6f3 0, #fff 50%, #f7f6f3 100%); background-size: 200% 100%; animation: fb-shimmer 1.4s linear infinite; }
@keyframes fb-shimmer { to { background-position: -200% 0; } }
.fb-links { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.fb-links a { position: absolute; pointer-events: auto; border-radius: 2px; }
.fb-links a:hover { background: rgba(43,108,212,.12); outline: 1px solid rgba(43,108,212,.35); }

.fb-side {
  width: 52px; height: 52px; flex-shrink: 0; border-radius: 26px; border: 1px solid #d4d2cc; background: var(--fb-surface);
  display: flex; align-items: center; justify-content: center; transition: opacity .2s, transform .2s; z-index: 5;
}
.fb-side:hover:not(:disabled) { transform: scale(1.06); border-color: var(--fb-ink); }
.fb-side:disabled, .fb-tb:disabled { opacity: .3; cursor: default; }
.fb-side svg { width: 22px; height: 22px; }

.fb-loading { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--fb-muted); font-size: 14px; }
.fb-spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--fb-line); border-top-color: var(--fb-ink); animation: fb-spin .8s linear infinite; }
.fb-loading.is-error .fb-spinner { display: none; }
@keyframes fb-spin { to { transform: rotate(360deg); } }

.fb-hint {
  position: absolute; left: 50%; bottom: 96px; transform: translateX(-50%); display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 20px; background: rgba(255,255,255,.92); font-size: 13px; color: var(--fb-muted);
  box-shadow: 0 4px 14px rgba(0,0,0,.08); pointer-events: none; animation: fb-fade 5s forwards;
}
.fb-hint svg { width: 18px; height: 18px; }
@keyframes fb-fade { 0%, 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- floating toolbar ---------- */
.fb-toolbar {
  position: absolute; left: 50%; bottom: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; flex-wrap: nowrap; align-items: center; gap: 4px; padding: 6px; width: max-content; max-width: calc(100vw - 16px);
  border-radius: 30px; background: var(--fb-bar); color: var(--fb-bar-ink); box-shadow: 0 14px 34px rgba(20,20,20,.28); z-index: 15; white-space: nowrap;
}
.fb-tb {
  width: 30px; height: 30px; border-radius: 22px; border: 0; background: transparent; color: inherit;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; flex-shrink: 0;
}
.fb-tb:hover:not(:disabled) { background: rgba(255,255,255,.12); }
.fb-tb-text { width: auto; padding: 0 16px; font-size: 14px; font-weight: 500; }
.fb-tb-text svg { width: 18px; height: 18px; }
.fb-tb-primary { background: var(--fb-bar-ink); color: var(--fb-bar); font-weight: 600; }
.fb-tb-primary:hover:not(:disabled) { background: #e9e7e2; }
.fb-sep { width: 1px; height: 24px; background: rgba(255,255,255,.2); margin: 0 4px; flex-shrink: 0; }
.fb-pagebox { display: flex; align-items: center; gap: 4px; height: 30px; padding: 0 14px; border-radius: 22px; background: rgba(255,255,255,.12); font-size: 14px; font-variant-numeric: tabular-nums; margin: 0; }
.fb-pagebox input { width: 4.2ch; background: transparent; border: 0; color: inherit; font-weight: 600; text-align: right; padding: 0; }
.fb-pagebox input:focus { outline: none; text-decoration: underline; }
.fb-total { color: #bdbab3; }

/* ---------- overlays ---------- */
.fb-overlay { position: absolute; inset: 0; z-index: 30; background: var(--fb-bg); display: flex; flex-direction: column; }
.fb-overlay-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 24px; background: var(--fb-surface); border-bottom: 1px solid var(--fb-line); }
.fb-overlay-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.fb-close { width: 44px; height: 44px; border-radius: 22px; border: 0; background: #f2f1ee; display: flex; align-items: center; justify-content: center; }
.fb-close:hover { background: #e7e5e0; }
.fb-thumbs { flex: 1; overflow: auto; padding: 24px; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 24px 18px; align-content: start; }
.fb-thumb { border: 0; padding: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 8px; font-size: 12px; color: var(--fb-muted); }
.fb-thumb-img { width: 100%; background: #fff; box-shadow: 0 4px 12px rgba(0,0,0,.1); position: relative; overflow: hidden; border-radius: 2px; outline: 2px solid transparent; outline-offset: 3px; transition: outline-color .15s, transform .15s; }
.fb-thumb-img canvas { width: 100%; height: 100%; display: block; }
.fb-thumb:hover .fb-thumb-img { transform: translateY(-2px); }
.fb-thumb.is-current .fb-thumb-img { outline-color: var(--fb-ink); }
.fb-thumb.is-current { color: var(--fb-ink); font-weight: 600; }

.fb-zoom-overlay { background: #2a2927; }
.fb-zoom-scroll { flex: 1; overflow: auto; touch-action: pan-x pan-y; -webkit-overflow-scrolling: touch; }
.fb-zoom-pages { display: flex; justify-content: center; padding: 24px 24px 100px; margin: 0 auto; width: max-content; min-width: 100%; }
.fb-zoom-pages canvas { display: block; background: #fff; }
.fb-zoom-bar { position: absolute; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 30px; background: var(--fb-bar); color: var(--fb-bar-ink); box-shadow: 0 14px 34px rgba(0,0,0,.4); }
.fb-zoom-level { min-width: 52px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }

/* ---------- embed dialog ---------- */
.fb-modal-backdrop { position: absolute; inset: 0; z-index: 40; background: rgba(18,18,18,.55); display: flex; align-items: center; justify-content: center; padding: 16px; }
.fb-modal { width: 100%; max-width: 600px; max-height: 100%; overflow: auto; background: var(--fb-surface); border-radius: 0; box-shadow: 0 30px 80px rgba(0,0,0,.35); }
.fb-modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 24px 24px 8px; }
.fb-modal-head h2 { margin: 0 0 4px; font-size: 20px; font-weight: 600; }
.fb-modal-sub { font-size: 14px; color: var(--fb-muted); }
.fb-tabs { display: flex; gap: 4px; margin: 12px 24px 0; padding: 4px; background: #f2f1ee; border-radius: 12px; }
.fb-tabs button { flex: 1; height: 40px; border: 0; border-radius: 9px; background: transparent; font-size: 14px; font-weight: 500; color: var(--fb-muted); }
.fb-tabs button[aria-selected="true"] { background: var(--fb-surface); color: var(--fb-ink); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.1); }
.fb-modal-body { display: flex; flex-direction: column; gap: 18px; padding: 20px 24px 24px; }
.fb-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.fb-opts label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--fb-muted); }
.fb-opts select { min-height: 44px; font-size: 14px; font-weight: 400; color: var(--fb-ink); }
.fb-opts select:not(.form-select) { border: 1px solid #d4d2cc; border-radius: 10px; padding: 0 10px; background: var(--fb-surface); }
.fb-check-row { display: flex; align-items: center; gap: 10px; font-size: 14px; min-height: 44px; }
.fb-check-row input { width: 18px; height: 18px; margin: 0; flex-shrink: 0; accent-color: var(--fb-ink); }
.fb-code-wrap { display: flex; flex-direction: column; gap: 8px; }
.fb-code-label { font-size: 12px; font-weight: 600; color: var(--fb-muted); }
#fb-code { width: 100%; resize: none; padding: 14px 16px; background: #141414; color: #e9e7e2; border: 0; border-radius: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6; word-break: break-all; }
.fb-modal-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.fb-note { font-size: 13px; color: var(--fb-muted); }
/* Copy button: uses Bootstrap .btn .btn-primary, so the colour comes from your style.css */
.fb-btn { display: inline-flex; align-items: center; gap: 8px; padding-left: 20px; padding-right: 20px; font-weight: 600; }
.fb-btn:not(.btn) { border: 0; border-radius: 22px; background: var(--fb-bar); color: var(--fb-bar-ink); }
.fb-btn svg { width: 18px; height: 18px; }
.fb-modal.is-link .fb-opt-size { display: none; }

.fb-toast { position: absolute; left: 50%; top: 84px; transform: translate(-50%, -8px); padding: 10px 16px; border-radius: 20px; background: var(--fb-bar); color: var(--fb-bar-ink); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 50; }
.fb-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ---------- embed mode (?embed=1) ---------- */
.fb-embed .fb-topbar, .fb-embed .fb-progress { display: none; }
.fb-embed .fb-stage { padding: 16px 16px 88px; }
.fb-embed .fb-toolbar { bottom: 14px; }

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  .fb-title { display: none; }
  .fb-tb-text { width: 44px; padding: 0; }
  .fb-tb-text span { display: none; }
}
@media (max-width: 760px) {
  :root { --fb-topbar-h: 60px; }
  .fb-topbar { padding: 0 12px; gap: 8px; }
  .fb-topbar-left { gap: 10px; }
  .fb-back { width: 44px; padding: 0; justify-content: center; }
  .fb-back span, .fb-divider { display: none; }
  .fb-lang-name { display: none; }
  .fb-lang-code { display: inline; }
  .fb-lang-btn { gap: 6px; padding: 0 12px; }
  .fb-lang-btn > svg:first-child { display: none; }
  .fb-side, .fb-hide-s { display: none; }
  .fb-stage { padding: 8px 8px 80px; }
  .fb-thumbs { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); padding: 16px; gap: 18px 12px; }
}
@media (max-width: 360px) {
  .fb-pagebox { padding: 0 10px; }
  .fb-toolbar { gap: 0; }
}

/* ---------- overview page ---------- */
.fb-overview-page { height: auto; min-height: 100%; }
.fb-list { max-width: 760px; margin: 0 auto; padding: 40px 20px; }
.fb-list h1 { font-size: 28px; margin: 0 0 24px; }
.fb-list ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.fb-list a { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 20px; background: rgb(250,250,250); border-radius: 20px; color: var(--fb-ink); text-decoration: none; }
.fb-list a:hover { background: rgb(245,245,245); }
.fb-list a span { font-size: 13px; color: var(--fb-muted); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- more space for the document ---------- */
.fb-stage { padding: 8px 16px 80px; gap: 0; }
.fb-toolbar { bottom: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); }
@media (min-width: 761px) {
  /* arrows float over the background instead of taking width */
  .fb-side { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.88); }
  .fb-side-prev { left: 16px; }
  .fb-side-next { right: 16px; }
  .fb-side:hover:not(:disabled) { transform: translateY(-50%) scale(1.06); }
}
@media (max-width: 760px) {
  .fb-stage { padding: 6px 6px 76px; }
}
/* toolbar auto-hide (desktop): book uses the full height, toolbar fades in on mouse move */
.fb-autohide .fb-stage { padding-bottom: 8px; }
.fb-toolbar, .fb-side { transition: opacity .3s ease, transform .2s ease; }
.fb-ui-idle .fb-toolbar, .fb-ui-idle .fb-side { opacity: 0; pointer-events: none; }
/* ---------- zoom: page navigation + drag to pan ---------- */
.fb-zoom-page { min-width: 64px; text-align: center; font-size: 14px; font-variant-numeric: tabular-nums; }
.fb-zoom-scroll { cursor: grab; }
.fb-zoom-scroll.is-panning { cursor: grabbing; user-select: none; }
.fb-zoom-pages canvas { box-shadow: 0 10px 30px rgba(0,0,0,.35); }
/* ---------- pages keep their own proportions (e.g. a cover with another size) ---------- */
.fb-page canvas, .fb-thumb-img canvas { object-fit: contain; }