/* UG School flipbook viewer (pdf.js + StPageFlip) */

/* --- StPageFlip base styles (not bundled in page-flip.browser.js) --- */
.stf__parent { position: relative; display: block; box-sizing: border-box; transform: translateZ(0); touch-action: pan-y; }
.stf__wrapper { position: relative; width: 100%; box-sizing: border-box; }
.stf__parent canvas.stf__canvas { position: absolute; width: 100%; height: 100%; left: 0; top: 0; }
.stf__block { position: absolute; width: 100%; height: 100%; box-sizing: border-box; perspective: 2000px; }
.stf__item { display: none; position: absolute; transform-style: preserve-3d; }
.stf__outerShadow, .stf__innerShadow, .stf__hardShadow, .stf__hardInnerShadow { position: absolute; left: 0; top: 0; }

/* --- Viewer --- */
:root {
  --fb-bg: #2c2f33;
  --fb-bg-2: #1f2124;
  --fb-bar: rgba(22, 23, 26, .92);
  --fb-fg: #f2f2f2;
  --fb-muted: #a9adb3;
  --fb-accent: #e0282f;
  --fb-hover: rgba(255, 255, 255, .1);
  --fb-panel: #232528;
  --fb-line: rgba(255, 255, 255, .1);
}

html, body.fb-body { height: 100%; margin: 0; }
body.fb-body {
  background: radial-gradient(ellipse at center, var(--fb-bg) 0%, var(--fb-bg-2) 100%);
  color: var(--fb-fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans Georgian", Helvetica, Arial, sans-serif;
  font-size: 14px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

.fb { position: fixed; inset: 0; display: flex; flex-direction: column; }

.fb button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
.fb svg { width: 20px; height: 20px; display: block; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* bars */
.fb-bar {
  flex: 0 0 auto; display: flex; align-items: center; gap: 4px;
  height: 52px; padding: 0 10px; background: var(--fb-bar);
  position: relative; z-index: 30;
}
.fb-top { border-bottom: 1px solid var(--fb-line); }
.fb-bottom { border-top: 1px solid var(--fb-line); justify-content: center; }
.fb-logo { display: flex; align-items: center; gap: 10px; color: var(--fb-fg); text-decoration: none; min-width: 0; margin-right: auto; }
.fb-logo:hover { color: var(--fb-fg); text-decoration: none; }
.fb-logo img { height: 34px; filter: brightness(0) invert(1); }
.fb-logo span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; letter-spacing: .2px; }
.fb-group { display: flex; align-items: center; gap: 2px; }
.fb-sep { width: 1px; height: 24px; background: var(--fb-line); margin: 0 6px; }

.fb-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 8px; color: var(--fb-fg) !important;
  transition: background-color .15s;
  text-decoration: none !important; position: relative;
}
.fb-btn:hover, .fb-btn.is-active { background: var(--fb-hover); }
.fb-btn.is-active { color: #fff; box-shadow: inset 0 -2px 0 var(--fb-accent); }
.fb-btn:disabled { opacity: .35; cursor: default; background: none; }
.fb-btn:focus-visible, .fb-nav:focus-visible, .fb-page input:focus-visible { outline: 2px solid var(--fb-accent); outline-offset: 1px; }
.fb-btn[data-tip]:hover::after {
  content: attr(data-tip); position: absolute; left: 50%; transform: translateX(-50%);
  white-space: nowrap; background: #000; color: #fff; font-size: 12px; padding: 4px 8px; border-radius: 4px;
  pointer-events: none; z-index: 50;
}
.fb-top .fb-btn[data-tip]:hover::after { top: 44px; }
.fb-bottom .fb-btn[data-tip]:hover::after { bottom: 44px; }
.fb-top .fb-group > .fb-btn:last-child[data-tip]:hover::after { left: auto; right: 0; transform: none; }
.fb-btn.fb-close { background: var(--fb-accent); margin-left: 6px; }
.fb-btn.fb-close:hover { background: #c41f25; }

.fb-page { display: flex; align-items: center; gap: 6px; margin: 0 6px; color: var(--fb-muted); white-space: nowrap; }
.fb-page input {
  width: 64px; height: 30px; text-align: center; border-radius: 6px; border: 1px solid var(--fb-line);
  background: rgba(255,255,255,.06); color: var(--fb-fg); font: inherit; padding: 0 4px;
}
.fb-zoom-val { min-width: 44px; text-align: center; color: var(--fb-muted); font-variant-numeric: tabular-nums; }

/* stage */
.fb-stage {
  flex: 1 1 auto; position: relative; overflow: auto; display: flex;
  padding: 24px 64px; box-sizing: border-box;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent;
}
.fb-bookwrap { margin: auto; flex: 0 0 auto; position: relative; opacity: 0; transition: opacity .4s, transform .6s ease; }
.fb.is-ready .fb-bookwrap { opacity: 1; }
.fb-bookwrap .stf__parent { filter: drop-shadow(0 12px 28px rgba(0,0,0,.45)); }
.fb-pan { position: absolute; inset: 0; z-index: 20; cursor: grab; display: none; }
.fb.is-zoomed .fb-pan { display: block; }
.fb-pan.is-dragging { cursor: grabbing; }

.fb-pageel { background: #fff; overflow: hidden; }
.fb-pageel canvas { position: absolute; left: 0; top: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.fb-pageel::after { /* subtle paper gradient near the spine */
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
.fb-pageel.--left::after { background: linear-gradient(to left, rgba(0,0,0,.14), rgba(0,0,0,0) 7%); }
.fb-pageel.--right::after { background: linear-gradient(to right, rgba(0,0,0,.14), rgba(0,0,0,0) 7%); }
.fb-hl { position: absolute; inset: 0; pointer-events: none; }
.fb-hl i { position: absolute; background: rgba(255, 214, 0, .45); border-radius: 2px; mix-blend-mode: multiply; }

.fb-nav {
  position: fixed; top: 50%; z-index: 25; width: 48px; height: 48px; margin-top: -24px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; color: #fff;
  background: rgba(0,0,0,.35) !important; transition: background-color .15s, opacity .15s;
}
.fb-nav:hover { background: rgba(0,0,0,.6) !important; }
.fb-nav svg { width: 26px; height: 26px; stroke-width: 2.2; }
.fb-nav.prev { left: 10px; }
.fb-nav.next { right: 10px; }
.fb-nav:disabled { opacity: 0; pointer-events: none; }

/* loading / errors */
.fb-loading {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 14px;
  align-items: center; justify-content: center; color: var(--fb-muted); z-index: 5;
}
.fb.is-ready .fb-loading { display: none; }
.fb-spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(255,255,255,.15); border-top-color: var(--fb-accent); animation: fb-spin .9s linear infinite; }
.fb-loading a { color: #fff; text-decoration: underline; }
@keyframes fb-spin { to { transform: rotate(360deg); } }

.fb-toast {
  position: fixed; left: 50%; bottom: 70px; transform: translate(-50%, 20px); opacity: 0;
  background: #000; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 60;
  transition: opacity .2s, transform .2s; pointer-events: none; max-width: calc(100% - 32px); text-align: center;
}
.fb-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* side panels */
.fb-panel {
  position: fixed; top: 52px; bottom: 52px; width: 300px; max-width: 86vw; z-index: 28;
  background: var(--fb-panel); border-right: 1px solid var(--fb-line);
  transform: translateX(-102%); transition: transform .25s ease; display: flex; flex-direction: column;
  box-shadow: 8px 0 24px rgba(0,0,0,.3);
}
.fb-panel.is-open { transform: none; }
.fb-panel-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 8px 10px 16px; border-bottom: 1px solid var(--fb-line); }
.fb-panel-head b { font-weight: 600; }
.fb-panel-body { overflow-y: auto; flex: 1; padding: 14px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }

.fb-thumbs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 12px; }
.fb-thumb { display: block; width: 100%; padding: 0; text-align: center; color: var(--fb-muted) !important; }
.fb-thumb-img { position: relative; background: #fff; border-radius: 2px; overflow: hidden; outline: 2px solid transparent; outline-offset: 2px; transition: outline-color .15s; }
.fb-thumb-img canvas { display: block; width: 100%; height: 100%; object-fit: contain; }
.fb-thumb:hover .fb-thumb-img { outline-color: rgba(255,255,255,.4); }
.fb-thumb.is-current .fb-thumb-img { outline-color: var(--fb-accent); }
.fb-thumb.is-current { color: #fff !important; }
.fb-thumb span { display: block; margin-top: 6px; font-size: 12px; }

.fb-search-form { display: flex; gap: 6px; }
.fb-search-form input {
  flex: 1; min-width: 0; height: 36px; border-radius: 8px; border: 1px solid var(--fb-line);
  background: rgba(255,255,255,.06); color: var(--fb-fg); padding: 0 10px; font: inherit;
}
.fb-search-form .fb-btn { width: 36px; height: 36px; background: var(--fb-accent); }
.fb-search-status { color: var(--fb-muted); font-size: 12px; margin: 12px 0 6px; }
.fb-result { display: block; width: 100%; text-align: left !important; padding: 10px; border-radius: 8px; line-height: 1.45; color: var(--fb-fg) !important; }
.fb-result:hover { background: var(--fb-hover); }
.fb-result small { display: block; color: var(--fb-accent); font-weight: 600; margin-bottom: 2px; }
.fb-result mark { background: rgba(255, 214, 0, .35); color: #fff; padding: 0 1px; border-radius: 2px; }

/* share popover */
.fb-pop {
  position: fixed; top: 58px; right: 10px; z-index: 40; width: 230px; padding: 6px;
  background: var(--fb-panel); border: 1px solid var(--fb-line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0,0,0,.45); display: none;
}
.fb-pop.is-open { display: block; }
.fb-pop a, .fb-pop button {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 6px;
  color: var(--fb-fg) !important; text-decoration: none !important; text-align: left;
}
.fb-pop a:hover, .fb-pop button:hover { background: var(--fb-hover); }

/* print: only rendered page images */
.fb-print { display: none; }
@media print {
  @page { margin: 0; }
  html, body.fb-body { height: auto; overflow: visible; background: #fff !important; }
  .fb { display: none !important; }
  .fb-print { display: block; }
  .fb-print img { display: block; width: 100%; height: auto; page-break-after: always; break-after: page; }
  .fb-print img:last-child { page-break-after: auto; break-after: auto; }
}

/* small screens */
@media (max-width: 720px) {
  .fb-stage { padding: 12px; }
  .fb-logo span, .fb-hide-sm { display: none; }
  .fb-sep { margin: 0 2px; }
  .fb-btn { width: 36px; height: 36px; }
  .fb-bar { padding: 0 6px; gap: 0; }
  .fb-page { margin: 0 2px; }
  .fb-page input { width: 56px; }
  .fb-nav { display: none; }
  .fb-btn[data-tip]:hover::after { display: none; }
}
