/*
  Book Open effect, module stylesheet (pairs with library.js). r5: two books.

  - Base styles ARE the finished open book. Without JavaScript, under prefers-reduced-motion,
    after Skip and after the sequence ends, the page shows this still state.
  - The opening plays only under the class "bk-play". library.js puts it on <html> for the first
    paint, then on the book itself (.bk), so two books can be on the page during a swap.
  - "bk-hold" freezes the opening at its first frame (the closed book) while the book slides in.
  - "bk-close" closes an open book (the swap): the leaves turn back and the cover shuts.
  - Phones: the page is taller than the cover. The closed book keeps the cover's shape; the paper
    grows to its full height when the art inks in (clip-path only; the layout never changes).
  - Only transform, opacity and visibility animate. No layout properties, no filters.
  - Two layouts: a two-page spread from 720 px up; below that the right-hand page alone,
    centred, with the left page off-screen (change the 720 px breakpoint in both media queries).
*/

.bk {
  /* ---- Inputs (override on .bk in the host stylesheet) ---- */
  --bk-ratio: 1.5;                  /* cover height / cover width */
  --bk-page-w: min(42vw, 360px);    /* width of one board = the closed book's width */
  --bk-board: #18231d;              /* cover board: rim around the pages, inside of the cover */
  --bk-board-hi: #26342c;
  --bk-paper: #efe4c8;
  --bk-paper-edge: #cdbd98;         /* lines along the stacked page edges */
  --bk-endpaper: #e2d3ae;
  --bk-tilt-x: 18deg;               /* how the closed book leans before it opens */
  --bk-tilt-y: -22deg;

  /* ---- Timeline (book-open.js reads these; keep them in seconds) ---- */
  --bk-t-open: 0.7s;     /* closed-book pause before the cover moves */
  --bk-d-open: 1.5s;     /* cover swing */
  --bk-t-leaves: 1.5s;   /* first paper leaf starts */
  --bk-step: 0.38s;      /* gap between leaves */
  --bk-d-leaf: 0.95s;      /* one leaf turn (the last one takes 1.2x) */
  --bk-d-ink: 0.9s;      /* final art inks in */
  --bk-d-tail: 1.7s;     /* time after the ink starts until every animation has ended */
  --bk-t-ink: 3.86s;     /* written by book-open.js from the page count */

  /* ---- Derived ---- */
  --bk-page-h: calc(var(--bk-page-w) * var(--bk-ratio));
  --bk-inset: max(4px, calc(var(--bk-page-w) * 0.018));
  --bk-leaf-w: calc(var(--bk-page-w) - var(--bk-inset));
  --bk-thick: calc(var(--bk-page-w) * 0.1);
  --bk-closed-x: calc(var(--bk-page-w) * -0.5);
  --bk-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.75' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .36 0 0 0 0 .26 0 0 0 0 .14 0 0 0 1.1 -.42'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  --bk-letters: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='360' height='264'%3E%3Cpath fill='%233a2814' fill-opacity='.17' d='M0 4h36v7h-36zM43 4h41v7h-41zM90 4h20v7h-20zM116 4h39v7h-39zM161 4h48v7h-48zM216 4h18v7h-18zM240 4h43v7h-43zM292 4h20v7h-20zM319 4h21v7h-21zM0 26h19v7h-19zM25 26h30v7h-30zM61 26h52v7h-52zM122 26h19v7h-19zM148 26h18v7h-18zM173 26h34v7h-34zM216 26h25v7h-25zM247 26h52v7h-52zM307 26h51v7h-51zM0 48h22v7h-22zM29 48h39v7h-39zM74 48h51v7h-51zM131 48h52v7h-52zM189 48h55v7h-55zM251 48h47v7h-47zM307 48h36v7h-36zM0 70h53v7h-53zM62 70h39v7h-39zM109 70h31v7h-31zM147 70h31v7h-31zM184 70h52v7h-52zM244 70h49v7h-49zM302 70h37v7h-37zM0 92h34v7h-34zM40 92h23v7h-23zM72 92h26v7h-26zM106 92h25v7h-25zM140 92h42v7h-42zM188 92h20v7h-20zM216 92h37v7h-37zM261 92h54v7h-54zM324 92h36v7h-36zM0 114h21v7h-21zM29 114h46v7h-46zM81 114h19v7h-19zM28 136h52v7h-52zM89 136h34v7h-34zM132 136h38v7h-38zM176 136h45v7h-45zM229 136h26v7h-26zM261 136h47v7h-47zM314 136h29v7h-29zM0 158h24v7h-24zM31 158h41v7h-41zM81 158h47v7h-47zM134 158h26v7h-26zM169 158h41v7h-41zM218 158h24v7h-24zM251 158h51v7h-51zM310 158h42v7h-42zM0 180h40v7h-40zM47 180h25v7h-25zM78 180h27v7h-27zM112 180h30v7h-30zM149 180h16v7h-16zM174 180h53v7h-53zM234 180h32v7h-32zM274 180h16v7h-16zM297 180h42v7h-42zM0 202h55v7h-55zM63 202h24v7h-24zM93 202h45v7h-45zM147 202h41v7h-41zM197 202h41v7h-41zM244 202h46v7h-46zM299 202h19v7h-19zM325 202h20v7h-20zM0 224h44v7h-44zM51 224h23v7h-23zM82 224h54v7h-54zM142 224h22v7h-22zM170 224h52v7h-52zM229 224h50v7h-50zM285 224h39v7h-39zM330 224h20v7h-20zM0 246h40v7h-40zM47 246h56v7h-56zM111 246h38v7h-38zM157 246h31v7h-31z'/%3E%3C/svg%3E");
  --bk-gutter-r: linear-gradient(to right, rgba(58, 38, 18, 0.30), rgba(58, 38, 18, 0.10) calc(var(--bk-page-w) * 0.05), rgba(58, 38, 18, 0) calc(var(--bk-page-w) * 0.13));
  --bk-gutter-l: linear-gradient(to left, rgba(58, 38, 18, 0.30), rgba(58, 38, 18, 0.10) calc(var(--bk-page-w) * 0.05), rgba(58, 38, 18, 0) calc(var(--bk-page-w) * 0.13));
  --bk-outer-r: linear-gradient(to left, rgba(58, 38, 18, 0.12), rgba(58, 38, 18, 0) calc(var(--bk-page-w) * 0.05));
  --bk-outer-l: linear-gradient(to right, rgba(58, 38, 18, 0.12), rgba(58, 38, 18, 0) calc(var(--bk-page-w) * 0.05));

  position: relative;
  width: 100%;
  height: var(--bk-page-h);
  overflow-x: clip;   /* the off-screen left page on phones never causes sideways scroll */
}

/* The spread: two boards wide, centred on the spine. */
.bk__book {
  position: absolute;
  top: 0;
  left: 50%;
  width: calc(var(--bk-page-w) * 2);
  height: 100%;
  margin-left: calc(var(--bk-page-w) * -1);
}

.bk__body,
.bk__spread,
.bk__content { position: absolute; inset: 0; }

/* Soft shadow on the surface, one half under each board (static; the left half fades in). */
.bk__shadow {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  box-shadow:
    0 calc(var(--bk-page-w) * 0.07) calc(var(--bk-page-w) * 0.12) calc(var(--bk-page-w) * -0.03) rgba(0, 0, 0, 0.78),
    0 3px 10px rgba(0, 0, 0, 0.45);
}
.bk__shadow--left { left: 0; border-radius: 6px 0 0 6px; }
.bk__shadow--right { right: 0; border-radius: 0 6px 6px 0; }

/* Boards: the cover's inside on the left, the back board on the right. */
.bk__board {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background: linear-gradient(160deg, var(--bk-board-hi), var(--bk-board) 55%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
}
.bk__board--left { left: 0; border-radius: 6px 2px 2px 6px; }
.bk__board--right { right: 0; border-radius: 2px 6px 6px 2px; }

/* Paper pages. Layers: gutter, outer edge, fibre noise, paper. */
.bk__page {
  position: absolute;
  top: var(--bk-inset);
  bottom: var(--bk-inset);
  width: calc(50% - var(--bk-inset));
  background-color: var(--bk-paper);
  background-size: auto, auto, 220px 220px;
}
.bk__page--left {
  left: var(--bk-inset);
  background-image: var(--bk-gutter-l), var(--bk-outer-l), var(--bk-noise);
  /* stacked page edges along the outer side */
  box-shadow: -1px 0 0 var(--bk-paper-edge), -2px 0 0 var(--bk-paper), -3px 0 0 var(--bk-paper-edge);
}
.bk__page--right {
  right: var(--bk-inset);
  background-image: var(--bk-gutter-r), var(--bk-outer-r), var(--bk-noise);
  box-shadow: 1px 0 0 var(--bk-paper-edge), 2px 0 0 var(--bk-paper), 3px 0 0 var(--bk-paper-edge);
}

/* Final content: art on the left page, words on the right page. */
.bk__content {
  inset: var(--bk-inset);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  grid-template-areas: "art words";
}
.bk__art { grid-area: art; min-width: 0; }
.bk__words { grid-area: words; min-width: 0; container-type: inline-size; }

/* Leaves and edges exist only while the opening plays. */
.bk__leaves,
.bk__edges { display: none; }

/* ---------- Phones: the right-hand page alone ---------- */
@media (max-width: 719.98px) {
  .bk { --bk-closed-x: 0px; }
  .bk__book { margin-left: calc(var(--bk-page-w) * -1.5); }
  .bk__content {
    grid-template-areas: ". art" ". words";
    grid-template-rows: auto auto;
    align-content: center;
  }
}

/* =====================  The opening (html.bk-play)  ===================== */

.bk-play .bk__book,
.bk-close .bk__book {
  perspective: calc(var(--bk-page-w) * 7);
  perspective-origin: 50% 35%;
}
:is(.bk-play, .bk-close) :is(.bk__body, .bk__edges, .bk__leaves, .bk__leaf, .bk__seg) { transform-style: preserve-3d; }

:is(.bk-play, .bk-close) :is(.bk__leaves, .bk__edges) { display: block; }

.bk-play .bk__body {
  animation: bk-settle 1.3s calc(var(--bk-t-open) - 0.1s) cubic-bezier(0.45, 0, 0.2, 1) both;
}
.bk-play .bk__shadow--left {
  animation: bk-fade 0.6s calc(var(--bk-t-open) + var(--bk-d-open) * 0.55) ease-out both;
}

/* Until the cover has landed, nothing shows to the left of the spine. */
.bk-play .bk__board--left,
.bk-play .bk__page--left {
  animation: bk-show 1ms calc(var(--bk-t-open) + var(--bk-d-open)) both;
}

/* The final art inks in once the last leaf has landed. */
.bk-play .bk__art {
  animation: bk-ink var(--bk-d-ink) var(--bk-t-ink) cubic-bezier(0.25, 0.6, 0.3, 1) both;
}

/* Edges of the closed book block, seen while it leans. */
.bk__edges { position: absolute; inset: 0; }
.bk__edge { position: absolute; }
.bk__edge--fore {
  top: var(--bk-inset);
  bottom: var(--bk-inset);
  left: calc(100% - 1px);
  width: var(--bk-thick);
  transform-origin: 0 50%;
  transform: rotateY(90deg);
  background:
    linear-gradient(to right, transparent 82%, var(--bk-board) 82%),
    repeating-linear-gradient(to right, var(--bk-paper) 0 1.5px, var(--bk-paper-edge) 1.5px 2.5px);
}
.bk__edge--foot {
  left: 50%;
  width: calc(50% - var(--bk-inset));
  top: calc(100% - 1px);
  height: var(--bk-thick);
  transform-origin: 50% 0;
  transform: rotateX(-90deg);
  background:
    linear-gradient(to bottom, transparent 82%, var(--bk-board) 82%),
    repeating-linear-gradient(to bottom, #e6d9b9 0 1.5px, #bfae88 1.5px 2.5px);
}

/* Leaves sit over the right-hand board and turn on the spine. */
.bk__leaves { position: absolute; top: 0; bottom: 0; left: 50%; width: 50%; }
.bk__leaf { position: absolute; transform-origin: 0 50%; }
.bk__leaf--cover { inset: 0; }
.bk__leaf--paper { top: var(--bk-inset); bottom: var(--bk-inset); left: 0; right: var(--bk-inset); }

.bk__face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.bk__face--back { transform: rotateY(180deg); }

/* Shading that deepens as a face turns away from the light. */
.bk__face::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}
.bk__face--front::after { background: rgba(34, 20, 8, 0.34); }
.bk__face--back::after  { background: rgba(34, 20, 8, 0.26); }
.bk__leaf--cover .bk__face--front::after { background: linear-gradient(to right, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0.3)); }

/* Cover: a stiff board, so it does not curl. */
.bk__leaf--cover .bk__face--front {
  overflow: hidden;
  border-radius: 2px 6px 6px 2px;
  background: var(--bk-board);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.06);
}
.bk__leaf--cover .bk__face--front img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bk__leaf--cover .bk__face--front::before {   /* the hinge groove along the spine */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(to right, rgba(0, 0, 0, 0.45), rgba(255, 255, 255, 0.10) 2.2%, rgba(0, 0, 0, 0.18) 3.6%, transparent 7%);
}
.bk__leaf--cover .bk__face--front::after { z-index: 2; }
.bk__leaf--cover .bk__face--back {
  border-radius: 6px 2px 2px 6px;
  background: linear-gradient(200deg, var(--bk-board-hi), var(--bk-board) 55%);
}
.bk__leaf--cover .bk__face--back::before {     /* pasted-down endpaper */
  content: "";
  position: absolute;
  top: var(--bk-inset);
  bottom: var(--bk-inset);
  left: var(--bk-inset);
  right: 0;
  background: var(--bk-gutter-l), var(--bk-noise) 0 0 / 220px 220px, var(--bk-endpaper);
}

/* Paper leaf: three hinged segments give the page a believable curl. */
.bk__seg { position: absolute; top: 0; bottom: 0; transform-origin: 0 50%; }
.bk__seg--a { left: 0; width: 50%; --x: 0; --bx: 0.5; }
/* b and c overlap their parent by 1px so no hairline seam shows. */
.bk__seg--b { left: calc(100% - 1px); width: calc(56% + 1px); --x: 0.5; --bx: 0.22; }        /* 28% of the leaf */
.bk__seg--c { left: calc(100% - 1px); width: calc(78.5714% + 1px); --x: 0.78; --bx: 0; }     /* 22% of the leaf */

.bk__leaf--paper .bk__face {
  background-color: var(--bk-paper);
  background-image: var(--bk-noise);
  background-size: 220px 220px;
}
/* Noise lines up with the still pages underneath, so the hand-off at the end is seamless. */
.bk__leaf--paper .bk__face--front { background-position: calc(var(--bk-leaf-w) * var(--x) * -1) 0; }
.bk__leaf--paper .bk__face--back  { background-position: calc(var(--bk-leaf-w) * var(--bx) * -1) 0; }
.bk__seg--a > .bk__face--front {
  background-image: var(--bk-gutter-r), var(--bk-noise);
  background-size: auto, 220px 220px;
  background-position: 0 0, 0 0;
}
.bk__seg--a > .bk__face--back {
  background-image: var(--bk-gutter-l), var(--bk-noise);
  background-size: auto, 220px 220px;
  background-position: 0 0, calc(var(--bk-leaf-w) * -0.5) 0;
}
.bk__seg--c > .bk__face--front {
  background-image: var(--bk-outer-r), var(--bk-noise);
  background-size: auto, 220px 220px;
  background-position: 0 0, calc(var(--bk-leaf-w) * -0.78) 0;
}
.bk__seg--c > .bk__face--back {
  background-image: var(--bk-outer-l), var(--bk-noise);
  background-size: auto, 220px 220px;
  background-position: 0 0, 0 0;
}
/* Faint lettering on some leaves: two blocks of word-shaped strokes. */
.bk__leaf--lettered .bk__face--front::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--bk-letters), var(--bk-letters);
  background-repeat: no-repeat;
  background-size: calc(var(--bk-leaf-w) * 0.74) auto;
  background-position:
    calc(var(--bk-leaf-w) * (0.14 - var(--x))) calc(var(--bk-page-h) * 0.11),
    calc(var(--bk-leaf-w) * (0.14 - var(--x))) calc(var(--bk-page-h) * 0.11 + var(--bk-leaf-w) * 0.57);
}

/* Timing: each leaf carries --bk-delay, --bk-dur, --bk-zr (resting on the right) and --bk-zl (landed on the left). */
/* --bk-show / --bk-hide limit each leaf to the time it can actually be seen (covered sheets
   are not drawn), which keeps compositing light on weak devices. */
.bk-play .bk__leaf {
  animation:
    bk-turn var(--bk-dur, 1s) var(--bk-delay, 1.5s) cubic-bezier(0.55, 0.05, 0.35, 1) both,
    bk-show 1ms var(--bk-show, 0s) both,
    bk-gone 1ms var(--bk-hide, 99s) forwards;
}
.bk-play .bk__leaf--cover {
  --bk-show: -1s;   /* the cover is there from the first frame, also while the opening is held */
  --bk-dur: var(--bk-d-open);
  --bk-delay: var(--bk-t-open);
  animation-timing-function: cubic-bezier(0.6, 0.02, 0.3, 1), linear, linear;
}
/* The still right-hand page is covered until the last leaf lifts. */
.bk-play .bk__page--right,
.bk-play .bk__words { animation: bk-show 1ms var(--bk-t-reveal, 2.7s) both; }
.bk-play .bk__seg--b { animation: bk-curl-b var(--bk-dur) var(--bk-delay) linear both; }
.bk-play .bk__seg--c { animation: bk-curl-c var(--bk-dur) var(--bk-delay) linear both; }
.bk-play .bk__face--front::after { animation: bk-shade-front var(--bk-dur) var(--bk-delay) cubic-bezier(0.55, 0.05, 0.35, 1) both; }
.bk-play .bk__face--back::after  { animation: bk-shade-back  var(--bk-dur) var(--bk-delay) cubic-bezier(0.55, 0.05, 0.35, 1) both; }

/* Every leaf has landed: hand over to the still pages underneath (each leaf also hides itself, see --bk-hide). */
.bk-play .bk__leaves { animation: bk-gone 1ms var(--bk-t-ink) forwards; }

@keyframes bk-settle {
  from { transform: translateX(calc(var(--bk-closed-x) + var(--bk-closed-shift, 0px))) rotateX(var(--bk-tilt-x)) rotateY(var(--bk-tilt-y)) scale(var(--bk-closed-scale, 1)); }
  to   { transform: translateX(0) rotateX(0deg) rotateY(0deg) scale(1); }
}
@keyframes bk-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes bk-turn {
  from { transform: translateZ(var(--bk-zr, 1px)) rotateY(0deg); }
  to   { transform: translateZ(var(--bk-zl, 1px)) rotateY(-180deg); }
}
/* Outer part leads while the page lifts, then trails as it falls. */
@keyframes bk-curl-b {
  0%   { transform: rotateY(0deg); }
  25%  { transform: rotateY(-9deg); }
  55%  { transform: rotateY(-3deg); }
  80%  { transform: rotateY(7deg); }
  100% { transform: rotateY(0deg); }
}
@keyframes bk-curl-c {
  0%   { transform: rotateY(0deg); }
  25%  { transform: rotateY(-13deg); }
  55%  { transform: rotateY(-4deg); }
  80%  { transform: rotateY(9deg); }
  100% { transform: rotateY(0deg); }
}
@keyframes bk-shade-front {
  0%   { opacity: 0; }
  50%  { opacity: 1; }
  100% { opacity: 1; }
}
@keyframes bk-shade-back {
  0%, 50% { opacity: 1; }
  100%    { opacity: 0; }
}
@keyframes bk-show { from { visibility: hidden; } to { visibility: visible; } }
/* Visibility interpolates as "visible" whenever one end is visible, so a hide must be hidden at both ends
   (and fill forwards only), or a 1 ms step that ends at progress 0.9999 would stay visible. */
@keyframes bk-gone { from, to { visibility: hidden; } }
@keyframes bk-ink {
  from { opacity: 0; transform: scale(1.02); }
  to   { opacity: 1; transform: none; }
}

@media (max-width: 719.98px) {
  .bk { --bk-tilt-x: 12deg; --bk-tilt-y: -14deg; }
  .bk-play .bk__book,
  .bk-close .bk__book { perspective-origin: 75% calc(var(--bk-page-h) * 0.35); }
}

/* Held at the first frame: the closed book, waiting to open (while it slides in). */
.bk-hold .bk__book,
.bk-hold .bk__book *,
.bk-hold .bk__book *::before,
.bk-hold .bk__book *::after { animation-play-state: paused !important; }

/* =====================  Closing (bk-close): the opening, backwards and brisk  =====================
   0 to 0.2 s the page's content fades; then two leaves turn back and the cover shuts (ends 1.1 s). */
.bk-close .bk__content { animation: bk-fade 0.2s reverse both; }
.bk-close .bk__board--left,
.bk-close .bk__page--left { animation: bk-gone 1ms 0.2s forwards; }
.bk-close .bk__shadow--left { animation: bk-fade 0.45s 0.5s reverse both; }
.bk-close .bk__body { animation: bk-settle 0.7s 0.4s cubic-bezier(0.45, 0, 0.2, 1) reverse both; }
.bk-close .bk__leaf {
  animation:
    bk-turn var(--bk-c-dur, 0.5s) var(--bk-c-delay, 0.2s) cubic-bezier(0.55, 0.05, 0.35, 1) reverse both,
    bk-show 1ms 0.2s both;
}
.bk-close .bk__leaf--cover { --bk-c-dur: 0.7s; --bk-c-delay: 0.4s; }
.bk-close .bk__seg--b { animation: bk-curl-b var(--bk-c-dur, 0.5s) var(--bk-c-delay, 0.2s) linear reverse both; }
.bk-close .bk__seg--c { animation: bk-curl-c var(--bk-c-dur, 0.5s) var(--bk-c-delay, 0.2s) linear reverse both; }
.bk-close .bk__face--front::after { animation: bk-shade-front var(--bk-c-dur, 0.5s) var(--bk-c-delay, 0.2s) cubic-bezier(0.55, 0.05, 0.35, 1) reverse both; }
.bk-close .bk__face--back::after  { animation: bk-shade-back  var(--bk-c-dur, 0.5s) var(--bk-c-delay, 0.2s) cubic-bezier(0.55, 0.05, 0.35, 1) reverse both; }

/* ---------- Phones: a page taller than the cover ---------- */
@media (max-width: 719.98px) {
  .bk { height: auto; min-height: var(--bk-page-h); }
  .bk__book { position: relative; height: auto; min-height: var(--bk-page-h); }
  .bk__body,
  .bk__spread { position: relative; inset: auto; min-height: var(--bk-page-h); }
  .bk__content {
    position: relative;
    inset: auto;
    margin: var(--bk-inset);
    min-height: calc(var(--bk-page-h) - 2 * var(--bk-inset));
  }
  /* The closed book, its leaves and its edges keep the cover's shape at the top. */
  .bk__edges,
  .bk__leaves { bottom: auto; height: var(--bk-page-h); }
  .bk__body { transform-origin: 50% calc(var(--bk-page-h) * 0.5); }
  /* While the book opens the paper is cut to the cover's height, then grows as the art inks in. */
  .bk-play .bk__shadow--right,
  .bk-play .bk__board--right { animation: bk-grow 0.7s var(--bk-t-ink) cubic-bezier(0.3, 0.6, 0.3, 1) both; }
  .bk-play .bk__page--right {
    animation:
      bk-show 1ms var(--bk-t-reveal, 2.7s) both,
      bk-grow-page 0.7s var(--bk-t-ink) cubic-bezier(0.3, 0.6, 0.3, 1) both;
  }
  .bk-close .bk__shadow--right,
  .bk-close .bk__board--right { animation: bk-grow 0.3s reverse both; }
  .bk-close .bk__page--right { animation: bk-grow-page 0.3s reverse both; }
}
/* Phones, owner 2026-12-04 (DL-6936): the left board and page wait too. Until the opening has finished
   they are cut to the cover's height, then grow together with the right side, so no strip of the
   left page runs down past the book while the leaves are still turning. */
@media (max-width: 719.98px) {
  .bk-play .bk__board--left {
    animation:
      bk-show 1ms calc(var(--bk-t-open) + var(--bk-d-open)) both,
      bk-grow 0.7s var(--bk-t-ink) cubic-bezier(0.3, 0.6, 0.3, 1) both;
  }
  .bk-play .bk__page--left {
    animation:
      bk-show 1ms calc(var(--bk-t-open) + var(--bk-d-open)) both,
      bk-grow-page 0.7s var(--bk-t-ink) cubic-bezier(0.3, 0.6, 0.3, 1) both;
  }
  .bk-play .bk__shadow--left {
    animation:
      bk-fade 0.6s calc(var(--bk-t-open) + var(--bk-d-open) * 0.55) ease-out both,
      bk-grow 0.7s var(--bk-t-ink) cubic-bezier(0.3, 0.6, 0.3, 1) both;
  }
  /* Closing (DL-6942): the left side shrinks with the right page, so the strip never stands alone. */
  .bk-close .bk__shadow--left { animation: bk-fade 0.45s 0.5s reverse both, bk-grow 0.3s reverse both; }
  .bk-close .bk__board--left { animation: bk-gone 1ms 0.2s forwards, bk-grow 0.3s reverse both; }
  .bk-close .bk__page--left { animation: bk-gone 1ms 0.2s forwards, bk-grow-page 0.3s reverse both; }
}
@keyframes bk-grow-page {
  from { clip-path: inset(-40px -40px calc(100% - var(--bk-page-h) + 2 * var(--bk-inset)) -40px); }
  to   { clip-path: inset(-40px -40px -80px -40px); }
}
@keyframes bk-grow {
  from { clip-path: inset(-40px -40px calc(100% - var(--bk-page-h)) -40px); }
  to   { clip-path: inset(-40px -40px -80px -40px); }
}

/* Belt and braces: library.js never adds these classes under reduced motion. */
@media (prefers-reduced-motion: reduce) {
  :is(.bk-play, .bk-close) :is(.bk__leaves, .bk__edges) { display: none; }
  :is(.bk-play, .bk-close) .bk__book *,
  :is(.bk-play, .bk-close) .bk__book *::before,
  :is(.bk-play, .bk-close) .bk__book *::after { animation: none !important; }
}
