/* assets/css/flipbook.css — document flipbook stage + chrome.
   Loaded only by pages that host a book (document.php, page.php), so the rest
   of the site never carries it. Mobile-first: single page by default, the
   two-page spread is switched on by JS at 64.0625em. */

.bt-fb {
  --bt-fb-ratio: 0.707;                    /* page w/h; replaced from page 1 */
  position: relative;
  display: block;
  padding: 20px 14px 16px;
  border-radius: 18px;
  /* Off-black with the brand radial glow — never flat #000. */
  background:
    radial-gradient(900px 420px at 18% -10%, rgba(238, 126, 34, 0.16), transparent 60%),
    radial-gradient(760px 380px at 88% 8%, rgba(13, 148, 153, 0.14), transparent 62%),
    var(--primary);
  outline: none;
}
.bt-fb:focus-visible { box-shadow: 0 0 0 3px rgba(238, 126, 34, 0.55); }

.bt-fb-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2200px;
  transition: opacity 180ms ease;
}
.bt-fb.is-fading .bt-fb-stage { opacity: 0; }

.bt-fb-book {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  transform-style: preserve-3d;
}

.bt-fb-side {
  position: relative;
  width: 100%;
  aspect-ratio: var(--bt-fb-ratio);
  background: #fff;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
.bt-fb-side.is-empty { display: none; }
.bt-fb-side img,
.bt-fb-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* A page missing from disk stays a blank sheet — never a broken-image glyph,
   and never a gap that breaks the spread. */
.bt-fb-side.is-missing img,
.bt-fb-face.is-missing img { visibility: hidden; }

/* Gutter shadow down the spine — only meaningful in a spread. */
.bt-fb-gutter {
  position: absolute;
  inset-block: 0;
  left: 50%;
  width: 26px;
  transform: translateX(-50%);
  pointer-events: none;
  opacity: 0;
  z-index: 4;
  background: linear-gradient(90deg, rgba(0,0,0,0), rgba(0,0,0,0.28), rgba(0,0,0,0));
}

/* ── The turning leaf ─────────────────────────────────────────────────── */
.bt-fb-leaf {
  position: absolute;
  inset-block: 0;
  width: 50%;
  transform-style: preserve-3d;
  will-change: transform;
  z-index: 5;
}
.bt-fb-leaf.is-fwd  { left: 50%; transform-origin: left center;  transform: rotateY(0deg); }
.bt-fb-leaf.is-back { left: 0;   transform-origin: right center; transform: rotateY(0deg); }
.bt-fb-leaf.is-turning       { transition: transform 620ms cubic-bezier(.25,.8,.3,1); }
.bt-fb-leaf.is-fwd.is-turning  { transform: rotateY(-180deg); }
.bt-fb-leaf.is-back.is-turning { transform: rotateY(180deg); }

.bt-fb-face {
  position: absolute;
  inset: 0;
  background: #fff;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}
/* The reverse of the sheet, un-mirrored. Correct for both directions. */
.bt-fb-back { transform: rotateY(180deg); }

/* Sweeping shade reads as the curl. */
.bt-fb-shade {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 620ms ease;
  background: linear-gradient(90deg,
    rgba(0,0,0,0.30), rgba(0,0,0,0) 38%, rgba(0,0,0,0) 62%, rgba(0,0,0,0.22));
}
.bt-fb-leaf.is-turning .bt-fb-shade,
.bt-fb-leaf.is-lit .bt-fb-shade { opacity: 1; }

/* ── Chrome ───────────────────────────────────────────────────────────── */
.bt-fb-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}
.bt-fb-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, opacity 160ms ease;
}
.bt-fb-nav svg { width: 20px; height: 20px; }
.bt-fb-nav:hover:not(:disabled) { background: var(--brand); border-color: var(--brand); }
.bt-fb-nav:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.bt-fb-nav:disabled { opacity: 0.35; cursor: default; }

.bt-fb-chip {
  min-width: 104px;
  padding: 9px 12px;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 13px;
  letter-spacing: 0.04em;
  color: var(--brand-2);
  border: 1px solid rgba(13, 148, 153, 0.30);
  border-radius: 999px;
  background: rgba(13, 148, 153, 0.12);
}

/* Announced to screen readers, invisible on screen. */
.bt-fb-live {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: 0;
  overflow: hidden;
  white-space: nowrap;
  clip-path: inset(50%);
}

/* ── Desktop: two-page spread ─────────────────────────────────────────── */
@media (min-width: 64.0625em) {
  .bt-fb { padding: 28px 20px 22px; }
  .bt-fb-book { max-width: 1360px; }
  .bt-fb.is-spread .bt-fb-side { width: 50%; }
  .bt-fb.is-spread .bt-fb-gutter { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .bt-fb-leaf.is-turning,
  .bt-fb-shade,
  .bt-fb-stage { transition: none; }
}
