/* Flipbook viewer. No dependencies.
   Without JavaScript the pages are a plain vertical list; the rules under
   ".js" turn that list into a book. */

:root {
  --fb-bg: #1d2136;          /* backdrop behind the book */
  --fb-bar: #444;            /* toolbar */
  --fb-dur: .65s;            /* page-turn time */
  --fb-ease: cubic-bezier(.45, 0, .55, 1);   /* symmetric, so the turn is edge-on at half time */
  --pw: 300px;               /* page width and height, set by flipbook.js */
  --ph: 388px;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--fb-bg);
  color: #e6e6e6;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
.js body { overflow: hidden; overscroll-behavior: none; }

.fb { display: flex; flex-direction: column; min-height: 100%; }
.js .fb { height: 100vh; height: 100dvh; }
html:not(.js) .fb-js { display: none; }

/* Read by screen readers and search engines, not shown. */
.fb-sr, .fb-text {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ---------- Toolbar ---------- */
.fb-bar {
  flex: none; position: relative; z-index: 5;
  display: flex; align-items: center; justify-content: center; gap: 4px;
  height: 48px; padding: 0 8px;
  background: var(--fb-bar); border-top: 3px solid #333;
  box-shadow: 0 1px 5px rgba(0, 0, 0, .45);
}
.fb-btn {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; padding: 0; border: 0; border-radius: 6px;
  background: none; color: #ddd; cursor: pointer;
}
.fb-btn[hidden] { display: none; }
.fb-btn svg, .fb-side svg {
  fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round;
}
.fb-btn svg { width: 26px; height: 26px; }
.fb-btn:hover { background: rgba(255, 255, 255, .13); color: #fff; }
.fb-btn:focus-visible, .fb-pagebox:focus-visible { outline: 2px solid #9cc4ff; outline-offset: -2px; }
.fb-btn:disabled { opacity: .35; cursor: default; background: none; }
.fb-fs-exit, .fb-btn.is-on .fb-fs-enter { display: none; }
.fb-btn.is-on .fb-fs-exit { display: block; }
.fb-pagebox {
  flex: none; width: 5.4em; height: 32px; margin: 0 6px; padding: 0; border: 0; border-radius: 5px;
  background: #fff; color: #222; font: inherit; font-size: 15px; text-align: center;
}
.fb-gap { flex: none; width: 12px; }

/* ---------- Book area with previous / next bars ---------- */
.fb-main { flex: 1; min-height: 0; position: relative; display: flex; overflow: hidden; }
.fb-side {
  flex: none; position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 56px; padding: 0; border: 0;
  background: rgba(255, 255, 255, .13); color: #fff; cursor: pointer;
  transition: background .15s;
}
.fb-side svg { width: 44px; height: 44px; stroke-width: 2.6; }
.fb-side:hover { background: rgba(255, 255, 255, .24); }
.fb-side:active { background: rgba(255, 255, 255, .32); }
.fb-side:disabled { cursor: default; background: rgba(255, 255, 255, .13); color: rgba(255, 255, 255, .22); }
.fb-stage {
  flex: 1; min-width: 0; padding: 16px;
  display: flex; align-items: center; justify-content: center;
  touch-action: manipulation;
}

/* ---------- Without JavaScript: a simple column of pages ---------- */
html:not(.js) .fb-book { display: flex; flex-direction: column; align-items: center; gap: 16px; }
html:not(.js) .fb-page img { display: block; width: 800px; max-width: 100%; height: auto; }

/* ---------- The book ---------- */
.js .fb-clip {
  position: relative; flex: none;
  width: calc(var(--pw) * 2); height: var(--ph);
  transition: opacity .15s;
}
.js .fb-single .fb-clip { width: var(--pw); clip-path: inset(-50vh 0); }   /* show one page of the spread */
.js .fb-clip.is-fading { opacity: 0; }

.js .fb-book {
  position: absolute; left: 0; top: 0;
  width: calc(var(--pw) * 2); height: var(--ph);
  perspective: calc(var(--pw) * 7);
  transition: transform var(--fb-dur) var(--fb-ease);
  visibility: hidden;
}
.js .is-ready .fb-book { visibility: visible; }
.js .fb-book > .fb-page { display: none; }           /* until flipbook.js files them into sheets */

/* Each sheet is one leaf of paper: a front page and a back page, hinged at the spine.
   z-index switches at half time, exactly when the turning sheet is edge-on. */
.fb-sheet {
  position: absolute; left: 50%; top: 0; width: 50%; height: 100%;
  display: none;
  transform-origin: left center; transform-style: preserve-3d;
  transition: transform var(--fb-dur) var(--fb-ease), z-index 0s linear calc(var(--fb-dur) / 2);
}
.fb-sheet.is-near { display: block; }
.fb-sheet.is-turned { transform: rotateY(-180deg); }

.fb-sheet .fb-page {
  position: absolute; inset: 0; overflow: hidden;
  background: #fff; cursor: pointer;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
.fb-sheet .fb-front { transform: rotateY(0deg); }
.fb-sheet .fb-back { transform: rotateY(180deg); }
.fb-sheet .fb-page img {
  position: absolute; inset: 0; display: block; width: 100%; height: 100%;
  -webkit-user-drag: none; pointer-events: none;
}

/* Spine shadow (and a faint gloss on left-hand pages). */
.fb-sheet .fb-page::after, .fb-sheet .fb-page::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
.fb-sheet .fb-front::after {
  background: linear-gradient(to right, rgba(0, 0, 0, .30), rgba(0, 0, 0, .13) 3%, rgba(0, 0, 0, .04) 8%, transparent 13%);
}
.fb-sheet .fb-back::after {
  background:
    linear-gradient(to left, rgba(0, 0, 0, .30), rgba(0, 0, 0, .13) 3%, rgba(0, 0, 0, .04) 8%, transparent 13%),
    linear-gradient(135deg, rgba(0, 0, 0, .13), transparent 24%);
}
/* A turning page darkens as it lifts. */
.fb-sheet .fb-page::before { z-index: 1; background: #000; opacity: 0; }
.fb-sheet.is-turning .fb-page::before { animation: fb-shade var(--fb-dur) var(--fb-ease); }
@keyframes fb-shade { 50% { opacity: .28; } }

/* What lies under each half: the drop shadow and the page-edge thickness. */
.fb-under {
  position: absolute; top: 0; width: 50%; height: 100%; z-index: 0;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .6);
  opacity: 0; transition: opacity calc(var(--fb-dur) / 2) linear;
}
.fb-under.is-on { opacity: 1; transition-delay: calc(var(--fb-dur) / 2); }
.fb-under-l { left: 0; }
.fb-under-r { left: 50%; }
.fb-under::after {
  content: ""; position: absolute; top: 2px; bottom: 2px; width: var(--edge, 0px);
  background: repeating-linear-gradient(to right, #f2f2f2 0 1px, #b4b4b4 1px 2px);
}
.fb-under-l::after { right: 100%; }
.fb-under-r::after { left: 100%; }

.fb-noanim .fb-book, .fb-noanim .fb-sheet, .fb-noanim .fb-under { transition: none !important; }

/* ---------- Small screens ---------- */
@media (max-width: 600px) {
  .fb-bar { gap: 2px; padding: 0 4px; }
  .fb-btn { width: 34px; height: 38px; }
  .fb-btn svg { width: 24px; height: 24px; }
  .fb-pagebox { width: 4.6em; margin: 0 4px; }
  .fb-gap { width: 6px; }
  .fb-side { width: 30px; }
  .fb-side svg { width: 28px; height: 28px; }
  .fb-stage { padding: 10px 4px; }
}
@media (max-width: 380px) {
  .fb-ends { display: none; }
}
@media (max-height: 420px) {
  .fb-bar { height: 40px; border-top-width: 0; }
  .fb-btn { height: 34px; }
  .fb-stage { padding: 8px; }
}
