/* flip.css — the flip-book reader (templates/flip.html, static/flip.js). The reader fills the viewport under the
   site header; the site footer follows below the fold. Colours and type: tokens.css. */
body.flip { background: var(--bg-3); }
.flip-app { display: flex; flex-direction: column; height: calc(100svh - var(--header-offset, 52px)); min-height: 420px; }
/* the top bar is the mode bar (base.css .mode-bar: back + title, the Study ⇄ Flip-book switch, the page counter) */
.flip-bar { flex: 0 0 auto; }
.flip-foot {
  flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) var(--gutter);
  background: var(--bg-2); border-top: 1px solid var(--border); font-size: var(--fs-small); color: var(--fg-2);
}
.flip-jump [lang="ur"] { font-size: var(--fs-ur-caption); line-height: 1.6; }
.flip-counter { min-width: 6.5em; text-align: end; }
.flip-stage { position: relative; -webkit-user-select: none; user-select: none; flex: 1 1 auto; min-height: 0; display: flex; align-items: center; justify-content: center; touch-action: pan-y; overflow: hidden; }
/* the book: two slots (a = first-read side, RIGHT in an RTL book; b = LEFT), the turning leaf, the crossfade ghost */
.flip-book {
  direction: ltr; position: relative; flex: 0 0 auto; width: var(--bw); height: var(--ph);
  transform: translateX(var(--shift, 0px)); perspective: calc(var(--pw) * 6);
  user-select: none; -webkit-user-select: none; cursor: grab;
  --page-edge-1: #e9e2d2; --page-edge-2: #d9d0bd;
}
.flip-book:active { cursor: grabbing; }
.flip-pg { position: absolute; top: 0; width: var(--pw); height: var(--ph); background: var(--paper); box-shadow: var(--shadow-book); overflow: hidden; }
.flip-pg img { width: 100%; height: 100%; display: block; mix-blend-mode: multiply; opacity: 0; transition: opacity 0.15s; }
.flip-pg img.ready { opacity: 1; }
.flip-pg.empty { visibility: hidden; }
[data-dir="rtl"] .slot-a { left: var(--pw); } [data-dir="rtl"] .slot-b { left: 0; }
[data-dir="ltr"] .slot-a { left: 0; }         [data-dir="ltr"] .slot-b { left: var(--pw); }
body.single .slot-a { display: none; }
body.single .slot-b { left: 0 !important; }
/* gutter: the curve into the binding, on the spine edge of each page */
.gutter { position: absolute; top: 0; bottom: 0; width: 14%; pointer-events: none; }
[data-dir="rtl"] .slot-a .gutter, [data-dir="ltr"] .slot-b .gutter { left: 0; background: linear-gradient(to right, rgba(60, 40, 20, 0.22), rgba(60, 40, 20, 0.06) 30%, transparent); }
[data-dir="rtl"] .slot-b .gutter, [data-dir="ltr"] .slot-a .gutter { right: 0; background: linear-gradient(to left, rgba(60, 40, 20, 0.22), rgba(60, 40, 20, 0.06) 30%, transparent); }
body.single .gutter { width: 5%; opacity: 0.6; }
/* the shadow the turning leaf casts, anchored at the spine and slid by transform */
.cast { position: absolute; top: 0; bottom: 0; width: 90px; opacity: 0; pointer-events: none; will-change: transform, opacity; }
[data-dir="rtl"] .slot-b .cast, [data-dir="ltr"] .slot-a .cast { right: 0; background: linear-gradient(to left, rgba(40, 25, 10, 0.38), transparent); }
[data-dir="rtl"] .slot-a .cast, [data-dir="ltr"] .slot-b .cast { left: 0; background: linear-gradient(to right, rgba(40, 25, 10, 0.38), transparent); }
/* the turning leaf: nested slices, each rotated a little more → a curved page */
.leaf { position: absolute; top: 0; width: var(--pw); height: var(--ph); transform-style: preserve-3d; pointer-events: none; display: none; z-index: 2; }
.leaf.on { display: block; }
[data-dir="rtl"] .leaf { left: 0; } [data-dir="ltr"] .leaf { left: var(--pw); }
body.single .leaf { left: 0 !important; }
.sl { position: absolute; top: 0; height: 100%; transform-style: preserve-3d; will-change: transform; }
[data-dir="rtl"] .sl { right: 0; transform-origin: right center; }
[data-dir="rtl"] .sl .sl { right: var(--sw); }
[data-dir="ltr"] .sl { left: 0; transform-origin: left center; }
[data-dir="ltr"] .sl .sl { left: var(--sw); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background-color: var(--paper); background-repeat: no-repeat; background-blend-mode: multiply;
}
.face.back { transform: rotateY(180deg); background-color: var(--paper-back, var(--paper)); }
.face i { position: absolute; inset: 0; background: rgb(30, 20, 8); opacity: 0; will-change: opacity; } /* shading, set by pose() */
/* reduced-motion crossfade layer */
.ghost { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 3; }
@media screen and (prefers-color-scheme: dark) { .flip-book { --page-edge-1: #c9ccc5; --page-edge-2: #aeb2aa; } .face.back { background-color: #dcdfd8; } }
@media (prefers-reduced-motion: reduce) { .flip-pg img { transition: none; } }
.flip-turn {
  position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 88px; border: 0; border-radius: var(--radius-m);
  background: transparent; color: var(--fg-2); font-size: 40px; cursor: pointer; opacity: 0.6; z-index: 3;
}
.flip-turn:hover { opacity: 1; background: var(--bg-2); }
.flip-turn:disabled { opacity: 0; pointer-events: none; }
.flip-next { left: 8px; } .flip-prev { right: 8px; }
.flip-jump { display: flex; align-items: center; gap: var(--space-2); }
.flip-jump input { width: 4.5em; font: inherit; font-variant-numeric: tabular-nums; color: var(--fg); background: var(--bg-3);
  border: 1px solid var(--border); border-radius: var(--radius-s); padding: 3px 6px; text-align: center; }
.flip-scrub { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); direction: rtl; }
.flip-hint kbd { font: var(--fs-caption) var(--font-en); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
.flip-noscript { text-align: center; padding: var(--space-5); }
@media (max-width: 760px) {
  .flip-hint { display: none; }
  .flip-counter { min-width: 0; }
  .flip-turn { width: 34px; height: 70px; font-size: 32px; opacity: 0.35; }
}
