/* flipbook.css — Red cloth art book on white (#portfolio) */

.fb-root {
  --ink: #121212;
  --cloth: #d43a4b;
  --paper: #ffffff;
  --fb-font: 'Inter Tight', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  position: fixed;
  inset: 0;
  z-index: 1000;
  overflow: hidden;
  color: var(--ink);
  font-family: var(--fb-font);
  user-select: none;
  -webkit-user-select: none;
  background: #ffffff;
}

/* ─── Header type (small bold grotesk caps, like the cover) ──────────────── */
.fb-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 18px 28px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
  line-height: 1;
}
.fb-head-btn {
  justify-self: start;
  background: none; border: 0; padding: 4px 0;
  font: inherit; letter-spacing: inherit; text-transform: inherit;
  color: var(--ink);
  opacity: .8;
  transition: opacity .2s;
}
.fb-head-btn:hover { opacity: 1; }
.fb-head-title { justify-self: center; }
.fb-head-count { justify-self: end; font-variant-numeric: tabular-nums; opacity: .8; }

/* ─── Arrows: thin chevrons at the edges ─────────────────────────────────── */
.fb-arrow {
  position: absolute;
  top: 50%;
  z-index: 5;
  background: none; border: 0;
  padding: 24px 18px;
  color: var(--ink);
  transform: translateY(-50%);
  transition: opacity .3s, transform .3s cubic-bezier(.3,.7,.4,1);
}
.fb-arrow svg { display: block; }
.fb-arrow-prev { left: max(14px, 2.4vw); }
.fb-arrow-next { right: max(14px, 2.4vw); }
.fb-arrow-prev:hover { transform: translate(-3px, -50%); }
.fb-arrow-next:hover { transform: translate(3px, -50%); }
.fb-arrow.is-hidden { opacity: 0; pointer-events: none; }

/* ─── Stage + book ───────────────────────────────────────────────────────── */
.fb-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 8px;
}
.fb-book {
  position: relative;
  width: calc(2 * (var(--W) + var(--o)));
  height: calc(var(--H) + 2 * var(--o));
  touch-action: none;
  transition: opacity .4s ease;
  will-change: transform;
}
.fb-book.is-fading { opacity: 0; }

/* Cover boards (bigger than the page block by --o) */
.fb-board {
  position: absolute;
  top: 0;
  width: calc(var(--W) + var(--o));
  height: calc(var(--H) + 2 * var(--o));
  box-shadow:
    0 0 0 .5px rgba(60,10,14,.30),
    1px 2px 3px rgba(0,0,0,.14),
    4px 12px 22px rgba(0,0,0,.09),
    14px 34px 60px -14px rgba(0,0,0,.18);
}
.fb-board-l { right: 50%; border-radius: 2px 0 0 2px; }
.fb-board-r { left: 50%;  border-radius: 0 2px 2px 0; }

/* A closed book is thicker: show the board edge + a deeper shadow */
.fb-book.is-closed .fb-board {
  box-shadow:
    1px 1px 0 #a42532,
    2px 2px 0 #8f1e2a,
    3px 3px 0 rgba(70,10,16,.55),
    3px 4px 4px rgba(0,0,0,.18),
    8px 18px 30px rgba(0,0,0,.11),
    22px 46px 80px -16px rgba(0,0,0,.20);
}

/* Page block on top of a board */
.fb-page {
  position: absolute;
  top: var(--o);
  width: var(--W);
  height: var(--H);
}
.fb-page-l { right: 50%; }
.fb-page-r { left: 50%; }

.fb-spine-shadow {
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  width: 46px;
  transform: translateX(-50%);
  pointer-events: none;
  background: linear-gradient(90deg,
    transparent 0%, rgba(0,0,0,.05) 35%, rgba(0,0,0,.22) 50%, rgba(0,0,0,.05) 65%, transparent 100%);
}

/* ─── Red book cloth ─────────────────────────────────────────────────────── */
.fb-cloth {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: var(--cloth);
  background-image:
    /* soft daylight from the top-left, like the photo */
    linear-gradient(170deg, rgba(255,255,255,.06) 0%, rgba(255,255,255,0) 40%, rgba(0,0,0,.08) 100%),
    /* fine woven threads */
    repeating-linear-gradient(0deg, rgba(0,0,0,.035) 0 1px, transparent 1px 2.5px),
    repeating-linear-gradient(90deg, rgba(255,255,255,.03) 0 1px, transparent 1px 2px),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0  0 0 0 0 0  0 0 0 0 0  0 0 0 .22 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  background-blend-mode: normal, multiply, screen, multiply;
}
/* slow blotchy dye variation */
.fb-cloth::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: .12;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='600' height='600'><filter id='m'><feTurbulence type='fractalNoise' baseFrequency='.012' numOctaves='3' seed='4'/><feColorMatrix values='0 0 0 0 .55  0 0 0 0 .1  0 0 0 0 .12  0 0 0 .55 0'/></filter><rect width='100%' height='100%' filter='url(%23m)'/></svg>");
  background-size: cover;
}

/* hinge groove next to the spine */
.fb-hinge {
  position: absolute;
  top: 0; bottom: 0;
  left: 3.4%;
  width: 5px;
  background: linear-gradient(90deg,
    rgba(0,0,0,.0) 0%, rgba(0,0,0,.22) 35%, rgba(0,0,0,.08) 60%, rgba(255,255,255,.10) 80%, rgba(255,255,255,0) 100%);
}
.fb-hinge-r { left: auto; right: 3.4%; transform: scaleX(-1); }
.fb-cloth-front::before {
  /* spine edge rolls away */
  content: "";
  position: absolute; top: 0; bottom: 0; left: 0; width: 3.4%;
  background: linear-gradient(90deg, rgba(0,0,0,.20), rgba(0,0,0,.02));
}
.fb-cloth-back::before {
  content: "";
  position: absolute; top: 0; bottom: 0; right: 0; width: 3.4%;
  background: linear-gradient(270deg, rgba(0,0,0,.20), rgba(0,0,0,.02));
}

/* Cover type — tiny, bold, black foil */
.fb-cover-word {
  position: absolute;
  left: 51.5%;
  transform: translate(-50%, -50%);
  font-family: var(--fb-font);
  font-weight: 700;
  font-size: max(7px, calc(var(--H) * .0135));
  letter-spacing: .01em;
  line-height: 1;
  text-transform: uppercase;
  color: #161012;
  opacity: .92;
  text-shadow: 0 .5px 0 rgba(255,255,255,.12);
  white-space: nowrap;
}
.fb-cover-top    { top: 27.3%; }
.fb-cover-bottom { top: 74.2%; }

/* Inset / debossed photo window */
.fb-tipin {
  position: absolute;
  left: 51.5%;
  top: 37.2%;
  width: 26.5%;
  aspect-ratio: 94 / 130;
  transform: translateX(-50%);
  background: #1a1416;
  box-shadow:
    0 0 0 1px rgba(60,6,12,.55),
    0 1px 0 1px rgba(255,255,255,.14),
    0 -1px 0 1px rgba(0,0,0,.18);
}
.fb-tipin img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 42% 50%;
  display: block;
  filter: contrast(1.04) brightness(.96);
}
.fb-tipin::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 2px 3px rgba(0,0,0,.55), inset 0 0 1px rgba(0,0,0,.8);
  background: linear-gradient(160deg, rgba(255,255,255,.06), transparent 40%);
}

/* Inside of covers: red turn-in + paper pastedown */
.fb-endpaper {
  position: absolute;
  top: var(--o);
  bottom: var(--o);
  background-color: #f5f4f1;
  background-image:
    linear-gradient(90deg, rgba(0,0,0,.05), transparent 30%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .3  0 0 0 0 .27  0 0 0 0 .22  0 0 0 .12 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
  box-shadow: 0 0 0 .5px rgba(0,0,0,.12);
}
.fb-endpaper-verso .fb-endpaper { left: var(--o); right: 0; }
.fb-endpaper-recto .fb-endpaper { right: var(--o); left: 0; }
.fb-endpaper-verso .fb-endpaper { background-image:
    linear-gradient(270deg, rgba(0,0,0,.16), rgba(0,0,0,.03) 8%, transparent 20%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .3  0 0 0 0 .27  0 0 0 0 .22  0 0 0 .12 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>"); }
.fb-endpaper-recto .fb-endpaper { background-image:
    linear-gradient(90deg, rgba(0,0,0,.16), rgba(0,0,0,.03) 8%, transparent 20%),
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .3  0 0 0 0 .27  0 0 0 0 .22  0 0 0 .12 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>"); }

/* ─── Paper pages ────────────────────────────────────────────────────────── */
.fb-paper {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: var(--paper);
  background-image:
    url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='260' height='260'><filter id='p'><feTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 .3  0 0 0 0 .3  0 0 0 0 .3  0 0 0 .05 0'/></filter><rect width='100%' height='100%' filter='url(%23p)'/></svg>");
}
.fb-gutter {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
/* the page curves down into the spine; outer edge catches a little light */
.fb-paper-recto .fb-gutter {
  background: linear-gradient(90deg,
    rgba(0,0,0,.20) 0%, rgba(0,0,0,.08) 2.5%, rgba(0,0,0,.025) 7%, rgba(255,255,255,0) 12%,
    rgba(255,255,255,0) 22%, rgba(0,0,0,0) 90%, rgba(0,0,0,.035) 100%);
}
.fb-paper-verso .fb-gutter {
  background: linear-gradient(270deg,
    rgba(0,0,0,.20) 0%, rgba(0,0,0,.08) 2.5%, rgba(0,0,0,.025) 7%, rgba(255,255,255,0) 12%,
    rgba(255,255,255,0) 22%, rgba(0,0,0,0) 90%, rgba(0,0,0,.035) 100%);
}

.fb-photo-box {
  position: absolute;
  top: 8.5%;
  bottom: 10.5%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fb-paper-recto .fb-photo-box { left: 8%; right: 7%; }
.fb-paper-verso .fb-photo-box { left: 7%; right: 8%; }
.fb-photo-box img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: multiply; /* ink sits in the paper */
  pointer-events: none;
}

.fb-folio {
  position: absolute;
  bottom: 4.2%;
  font-size: max(7px, calc(var(--H) * .012));
  font-weight: 600;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  color: rgba(18,18,18,.7);
}
.fb-paper-recto .fb-folio { right: 7%; }
.fb-paper-verso .fb-folio { left: 7%; }

.fb-title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5em;
  font-weight: 700;
  font-size: max(8px, calc(var(--H) * .0145));
  letter-spacing: .02em;
  line-height: 1;
  text-transform: uppercase;
}
.fb-title span + span { font-weight: 500; opacity: .6; }

/* ─── Turning leaf ───────────────────────────────────────────────────────── */
.fb-leaf-host {
  position: absolute;
  left: 50%;
  top: var(--o);
  width: 0;
  height: var(--H);
  perspective: calc(var(--H) * 3.4);
  perspective-origin: 0 50%;
  pointer-events: none;
}
.fb-leaf {
  position: absolute;
  left: 0;
  transform-style: preserve-3d;
}
.fb-strip {
  position: absolute;
  top: 0;
  transform-origin: 0 50%;
  transform-style: preserve-3d;
}
.fb-face {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.fb-face-back { transform: rotateY(180deg); }
.fb-face-inner { position: absolute; top: 0; }
.fb-shade, .fb-shine {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.fb-shine {
  background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.28) 50%, rgba(255,255,255,0));
  mix-blend-mode: screen;
}

/* Shadow the turning page throws on the page below */
.fb-cast-clip {
  position: absolute;
  left: 0; right: 0;
  top: var(--o);
  height: var(--H);
  overflow: hidden;
  pointer-events: none;
}
.fb-cast { position: absolute; top: -2%; bottom: -2%; }
.fb-cast-r { background: linear-gradient(90deg, rgba(0,0,0,.42), rgba(0,0,0,.12) 35%, transparent); }
.fb-cast-l { background: linear-gradient(270deg, rgba(0,0,0,.42), rgba(0,0,0,.12) 35%, transparent); }

/* ─── Hint ───────────────────────────────────────────────────────────────── */
.fb-hint {
  position: absolute;
  left: 0; right: 0;
  bottom: 16px;
  margin: 0;
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--ink);
  opacity: .62;
  transition: opacity .8s ease;
  pointer-events: none;
}
.fb-hint.is-gone { opacity: 0; }

/* Custom cursor stays visible on the red cloth */
body.fb-on .cursor-dot {
  width: 14px !important;
  height: 14px !important;
  margin: -7px 0 0 -7px !important;
  mix-blend-mode: normal !important;
  box-shadow: 0 0 0 1.5px rgba(255,255,255,.95), 0 1px 4px rgba(0,0,0,.35);
}

@media (max-width: 900px) {
  .fb-header { padding: 16px 16px; font-size: 10px; }
  .fb-arrow { padding: 16px 6px; }
  .fb-arrow svg { width: 14px; height: 28px; }
  .fb-arrow-prev { left: 4px; }
  .fb-arrow-next { right: 4px; }
}
@media (prefers-reduced-motion: reduce) {
  .fb-arrow, .fb-hint, .fb-book { transition: none; }
}
