/* Book Plugins flip-book (src/market/bookshelf.js + web/pk/bookshelf.js): Zigzaggle's "Flip through a real book" look and
   motion (PuzzlePress Cloud app/offer/v3/flipbook.ts, FLIPBOOK_CSS), in Book Plugins' lime and pink. State lives in data
   attributes. --ar / --ar1: the book's spread and page ratios (set per book). Reduced motion: nothing tilts, pages fade. */
.fb { --fb-p: 440px; --fb-t: .9s cubic-bezier(.45, .05, .3, 1); --fb-gap: clamp(14px, 2.6vw, 36px); --fb-hi: var(--accent, #d4f53c); --fb-hi-a: rgb(var(--accent-rgb, 212 245 60) / .45);
  --ar: 1546/1000; --ar1: 773/1000; position: relative; margin: 0 auto; padding-top: 6px; overflow-x: clip; }

/* the shelf: books standing on a wooden ledge (each book draws its stretch of it, half a gap past each side) */
.fb-shelf { display: flex; justify-content: center; align-items: flex-start; gap: var(--fb-gap); max-width: 1010px; margin: 0 auto; padding: 22px 12px 4px; }
.fb-sb { position: relative; flex: 0 1 190px; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 20px; margin: 0; padding: 0; border: 0; background: none; color: inherit; font: inherit; text-align: center; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.fb-sb:focus-visible { outline: none; }
.fb-cw { position: relative; display: block; width: 100%; aspect-ratio: var(--ar1); perspective: 900px; }
.fb-cw::after { content: ""; position: absolute; left: calc(var(--fb-gap) / -2 - 1px); right: calc(var(--fb-gap) / -2 - 1px); top: 100%; height: 14px; background: linear-gradient(#c8925c 0 3px, #8d5b33 3px 11px, #6a4224 11px); box-shadow: 0 12px 18px -8px rgba(0, 0, 0, .65); }
.fb-sb:first-child > .fb-cw::after { border-radius: 4px 0 0 4px; } .fb-sb:last-child > .fb-cw::after { border-radius: 0 4px 4px 0; }
.fb-3d { position: absolute; inset: 0; display: block; transform-style: preserve-3d; transform-origin: 50% 100%; transition: transform .5s cubic-bezier(.2, .75, .25, 1); }
.fb-3d > img { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; border-radius: 2px 4px 4px 2px; transform: translateZ(7px); background: #fff; box-shadow: var(--fb-ring, 0 0 0 0 transparent), 0 12px 16px -6px rgba(0, 0, 0, .55); transition: box-shadow .5s cubic-bezier(.2, .75, .25, 1); }
.fb-3d::before { content: ""; position: absolute; top: 1.6%; bottom: 1.6%; right: -6px; width: 12px; transform: rotateY(90deg); background: repeating-linear-gradient(90deg, #fdfbf4 0 1px, #d9d2c3 1px 2px); }
.fb-3d::after { content: ""; position: absolute; inset: 0; border-radius: 4px 2px 2px 4px; transform: translateZ(-7px); background: #22252b; }
.fb-sb[aria-pressed=true] > .fb-cw > .fb-3d { transform: translateY(-8px); }
.fb-sb[aria-pressed=true] > .fb-cw > .fb-3d > img { --fb-ring: 0 0 0 3px var(--fb-hi), 0 0 26px 2px var(--fb-hi-a); }
@media (hover: hover) { .fb-sb:hover > .fb-cw > .fb-3d { transform: translateY(-12px) rotateY(-26deg) rotateX(5deg); } .fb-sb:hover > .fb-cw > .fb-3d > img { box-shadow: var(--fb-ring, 0 0 0 0 transparent), 0 26px 24px -10px rgba(0, 0, 0, .6); } }
.fb-sb:focus-visible > .fb-cw > .fb-3d { transform: translateY(-12px) rotateY(-26deg) rotateX(5deg); }
.fb-sb:focus-visible > .fb-cw > .fb-3d > img { --fb-ring: 0 0 0 3px #ff3e9a, 0 0 22px 2px rgba(255, 62, 154, .5); box-shadow: var(--fb-ring), 0 26px 24px -10px rgba(0, 0, 0, .6); }
.fb-sn { display: block; max-width: 100%; font: 800 .88rem/1.25 var(--display, system-ui, sans-serif); opacity: .78; transition: opacity .25s, color .25s; text-wrap: balance; }
.fb-sb:hover > .fb-sn, .fb-sb:focus-visible > .fb-sn { opacity: 1; }
.fb-sb[aria-pressed=true] > .fb-sn { opacity: 1; color: var(--fb-hi); }
.fb-hint { margin: 14px auto 0; text-align: center; font-size: .9rem; opacity: .75; } .fb-hint[hidden] { display: none; }

/* the desk */
.fb-stage { position: relative; isolation: isolate; width: min(100%, calc(2 * var(--fb-p))); margin: 34px auto 0; aspect-ratio: var(--ar); touch-action: pan-y pinch-zoom; -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none; cursor: pointer; }
.fb-stage::before { content: ""; position: absolute; z-index: -1; inset: -14% -10%; background: radial-gradient(closest-side, rgb(var(--accent-rgb, 212 245 60) / .15), rgba(255, 62, 154, .05) 55%, rgb(var(--accent-rgb, 212 245 60) / 0)); pointer-events: none; }
.fb-stage:focus-visible { outline: 3px solid var(--fb-hi); outline-offset: 10px; border-radius: 8px; }
.fb-book { position: absolute; inset: 0; perspective: 3000px; transition: transform var(--fb-t), opacity .22s; }
.fb[data-swap] .fb-book { opacity: 0; }
.fb-book[data-pos=cover] { transform: translateX(-25%); } .fb-book[data-pos=back] { transform: translateX(25%); }
.fb-book::before { content: ""; position: absolute; z-index: 0; bottom: -2.6%; height: 7%; left: calc(50% - 50% * min(var(--l, 0), 1)); right: calc(50% - 50% * min(var(--r, 1), 1)); border-radius: 50%; background: rgba(0, 0, 0, .5); filter: blur(14px); transition: left var(--fb-t), right var(--fb-t); }
.fb-book::after { content: ""; position: absolute; z-index: 0; top: .5%; bottom: .5%; left: calc(var(--l, 0) * -.55px); right: calc(var(--r, 1) * -.55px); border-radius: 2px; background: repeating-linear-gradient(90deg, #f7f2e8 0 1px, #d3c8b2 1px 2px) 0 0 / calc(var(--l, 0) * .55px) 100% no-repeat, repeating-linear-gradient(90deg, #f7f2e8 0 1px, #d3c8b2 1px 2px) 100% 0 / calc(var(--r, 1) * .55px) 100% no-repeat; }
.fb-leaf { position: absolute; top: 0; left: 50%; width: 50%; height: 100%; transform-origin: 0 50%; transform-style: preserve-3d; transition: transform var(--fb-t); }
.fb-leaf[data-turned] { transform: rotateY(-180deg); }
.fb-leaf[data-peek] { transform: rotateY(-11deg); transition-duration: .45s; } .fb-leaf[data-peek][data-turned] { transform: rotateY(-169deg); }
.fb-f, .fb-b { position: absolute; inset: 0; overflow: hidden; background: #fffefa; -webkit-backface-visibility: hidden; backface-visibility: hidden; }
.fb-b { transform: rotateY(180deg); }
.fb-f > img, .fb-b > img { display: block; width: 100%; height: 100%; max-width: none; object-fit: cover; }
.fb-f[data-k=back], .fb-b[data-k=back] { background: var(--fb-board, #22252b); }
.fb-f::before, .fb-b::before, .fb-f::after, .fb-b::after { content: ""; position: absolute; inset: 0; pointer-events: none; }
.fb-f::after { background: linear-gradient(90deg, rgba(40, 25, 5, .26), rgba(40, 25, 5, .08) 3.5%, rgba(40, 25, 5, 0) 10%); }
.fb-b::after { background: linear-gradient(270deg, rgba(40, 25, 5, .26), rgba(40, 25, 5, .08) 3.5%, rgba(40, 25, 5, 0) 10%); }
.fb-f[data-k=cover]::after { background: linear-gradient(90deg, rgba(0, 0, 0, .22), rgba(255, 255, 255, .24) 1.2%, rgba(255, 255, 255, 0) 2.4%, rgba(0, 0, 0, .1) 3.4%, rgba(0, 0, 0, 0) 6%); }
.fb-b[data-k=back]::after { background: linear-gradient(270deg, rgba(0, 0, 0, .22), rgba(255, 255, 255, .24) 1.2%, rgba(255, 255, 255, 0) 2.4%, rgba(0, 0, 0, .1) 3.4%, rgba(0, 0, 0, 0) 6%); }
.fb-f::before, .fb-b::before { z-index: 1; opacity: 0; }
.fb-f::before { background: linear-gradient(90deg, rgba(0, 0, 0, .04), rgba(0, 0, 0, .4)); } .fb-b::before { background: linear-gradient(270deg, rgba(0, 0, 0, .04), rgba(0, 0, 0, .4)); }
.fb-leaf[data-turning=f] > .fb-f::before, .fb-leaf[data-turning=b] > .fb-b::before { animation: fb-dim var(--fb-t) both; }
.fb-leaf[data-turning=f] > .fb-b::before, .fb-leaf[data-turning=b] > .fb-f::before { animation: fb-lit var(--fb-t) both; }
@keyframes fb-dim { 50%, to { opacity: 1; } } @keyframes fb-lit { 0%, 50% { opacity: 1; } to { opacity: 0; } }

/* the controls */
.fb-bar { display: flex; align-items: center; justify-content: center; gap: 16px; margin: 30px auto 0; } .fb-bar[hidden] { display: none; }
.fb-btn { flex: none; display: grid; place-items: center; width: 48px; height: 48px; padding: 0; border: 0; border-radius: 50%; background: linear-gradient(180deg, var(--accent-3, #e9ff7a), var(--accent, #c4ea1f)); color: #10130a; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255, 255, 255, .6), 0 3px 0 var(--accent-deep, #7d9a06), 0 10px 22px -8px rgb(var(--accent-rgb, 212 245 60) / .55); transition: transform .15s; }
.fb-btn:active { transform: translateY(2px); } .fb-btn[aria-disabled=true] { opacity: .38; cursor: default; box-shadow: none; transform: none; }
.fb-btn:focus-visible { outline: 3px solid #ff3e9a; outline-offset: 3px; }
.fb-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.fb-count { min-width: 9.5em; text-align: center; font: 800 .95rem/1.2 var(--display, system-ui, sans-serif); font-variant-numeric: tabular-nums; }
.fb-cap { max-width: 40em; margin: 16px auto 0; text-align: center; font-size: .95rem; line-height: 1.5; opacity: .82; text-wrap: balance; }

/* tabs: small covers under the desk */
.fb-tabs { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin: 18px auto 0; }
.fb-tab { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border: 1px solid rgba(255, 255, 255, .14); border-radius: 999px; background: rgba(255, 255, 255, .04); color: inherit; font: 700 12.5px/1 var(--sans, system-ui, sans-serif); cursor: pointer; transition: border-color .2s, background .2s; }
.fb-tab img { width: 22px; height: auto; aspect-ratio: var(--ar1); border-radius: 3px; object-fit: cover; }
.fb-tab:hover { border-color: rgb(var(--accent-rgb, 212 245 60) / .5); }
.fb-tab[aria-pressed=true] { border-color: var(--fb-hi); background: rgb(var(--accent-rgb, 212 245 60) / .12); color: var(--fb-hi); }
.fb-tab:focus-visible { outline: 3px solid #ff3e9a; outline-offset: 2px; }

/* a phone: the shelf scrolls sideways inside itself (never the page) and the desk shows one page at a time */
@media (max-width: 699px) {
  .fb { --fb-gap: 16px; }
  .fb-shelf { justify-content: flex-start; max-width: none; padding: 20px 10px 6px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scroll-padding: 0 10px; scrollbar-width: none; }
  .fb-shelf::-webkit-scrollbar { display: none; }
  .fb-sb { flex: 0 0 38%; scroll-snap-align: start; } .fb-sn { font-size: .76rem; }
  .fb-stage { width: min(100%, var(--fb-p)); aspect-ratio: var(--ar1); margin-top: 26px; overflow: hidden; }
  @supports (overflow: clip) { .fb-stage { overflow: visible; overflow-x: clip; } }
  .fb-book, .fb-book[data-pos] { right: auto; width: 200%; transform: translateX(-50%); }
  .fb-book[data-pos][data-side=left] { transform: none; }
  /* one page at a time (Kevin 26/11/2026: the phone flip-book broke after a few taps): the half of the spread that is off the
     stage is not painted at all, so nothing can show beside the page or widen the page even where a browser (iOS Safari)
     does not clip 3D-turned leaves; contain: paint clips the stage in every engine */
  .fb-stage { contain: paint; }
  .fb-book[data-side=right] > .fb-leaf[data-turned]:not([data-turning]), .fb-book[data-side=left] > .fb-leaf:not([data-turned]):not([data-turning]) { visibility: hidden; transition: transform var(--fb-t), visibility 0s 1s; }
  .fb-book::after { display: none; }
  .fb-tab span { display: none; } .fb-tab { padding: 5px; }
}
@media (prefers-reduced-motion: reduce) {
  .fb-3d, .fb-sn { transition: none; }
  .fb-sb:hover > .fb-cw > .fb-3d, .fb-sb:focus-visible > .fb-cw > .fb-3d, .fb-sb[aria-pressed=true] > .fb-cw > .fb-3d { transform: none; }
  .fb-book, .fb-leaf, .fb-book::before { transition: none; }
  .fb-leaf, .fb-leaf[data-turned], .fb-leaf[data-peek] { transform: none; }
  .fb-b { transform: translateX(-100%); }
  .fb-f, .fb-b { transition: opacity .35s, visibility 0s !important; }
  .fb-leaf[data-turned] > .fb-f, .fb-leaf:not([data-turned]) > .fb-b { opacity: 0; visibility: hidden; transition: opacity .35s, visibility 0s .35s !important; }
}

/* two books of one plugin: wide labelled tabs (also on phones) */
.fb-tabs.n2 { gap: 10px; }
.fb-tabs.n2 .fb-tab { padding: 6px 16px 6px 6px; font-size: 13.5px; }
.fb-tabs.n2 .fb-tab img { width: 30px; }
@media (max-width: 699px) { .fb-tabs.n2 .fb-tab { flex: 1 1 46%; padding: 6px 10px 6px 6px; } .fb-tabs.n2 .fb-tab span { display: inline; font-size: 11.5px; line-height: 1.25; text-align: left; } }

/* "All pages": every page of a whole book as thumbs (src/market/bookshelf.js full books); a click goes there */
.fb-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 14px 12px; max-width: 1080px; max-height: min(560px, 70vh); margin: 18px auto 0; padding: 16px; overflow-y: auto; overscroll-behavior: contain; border-radius: 18px; border: 1px solid rgba(255, 255, 255, .1); background: rgba(255, 255, 255, .025); }
.fb-grid[hidden] { display: none; }
.fb-th { display: grid; gap: 6px; justify-items: center; padding: 0; border: 0; background: none; color: inherit; font: 600 11.5px/1.2 var(--sans, system-ui, sans-serif); cursor: pointer; }
.fb-th img { width: 100%; height: auto; aspect-ratio: var(--ar1); object-fit: contain; background: #fff; border-radius: 3px; box-shadow: 0 6px 14px -8px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .08); transition: transform .2s, box-shadow .2s; }
.fb-th span { opacity: .7; }
.fb-th.mark span { opacity: 1; color: var(--fb-hi); font-weight: 800; }
.fb-th:hover img { transform: translateY(-2px); box-shadow: 0 0 0 2px var(--fb-hi), 0 10px 18px -8px rgba(0, 0, 0, .8); }
.fb-th:focus-visible { outline: 3px solid #ff3e9a; outline-offset: 3px; border-radius: 4px; }
@media (max-width: 699px) { .fb-grid { grid-template-columns: repeat(auto-fill, minmax(74px, 1fr)); gap: 10px 8px; padding: 10px; max-height: 60vh; } }

/* Phones: fast taps on Next / Previous, the chips, the tabs or the shelf must turn pages, never zoom the whole page in and
   out (a double tap zooms in iOS Safari and Chrome unless touch-action says otherwise). The desk keeps pan-y pinch-zoom. */
.fb-bar, .fb-btn, .fb-jump, .fb-chip, .fb-skim, .fb-tabs, .fb-tab, .fb-shelf, .fb-sb, .fb-grid, .fb-th, .fb-notes, .pp-picks, .pp-pick { touch-action: manipulation; }

/* iPhone: only the leaves near the open spread are drawn (bookshelf.js trim) */
.fb-leaf.fb-far { display: none; }
