/* Scale the storybook itself to 80%, then reclaim the unused flow space so
   the controls and footer stay composed around the smaller book. */
.masthead { margin-top: 64px; }
.work #book {
  transform: scale(.8) !important;
  transform-origin: center top;
  margin-bottom: calc(var(--leaf-height, 840px) * -.2);
}

.work #book.is-closed {
  --leaf-height: 790px;
  transform: translateX(-25%) scale(.72) rotateZ(-3deg) !important;
  margin-bottom: calc(var(--leaf-height, 840px) * -.28);
}

.work #book.is-closed.lifted {
  transform: translateX(-25%) scale(.8) !important;
  margin-bottom: calc(var(--leaf-height, 840px) * -.2);
}

.work .edition {
  display: none !important;
}

.work .turn-hint,
.work .book-controls,
.work .bottom-note {
  width: 80%;
  max-width: 992px;
  margin-left: auto;
  margin-right: auto;
}

@media (min-width: 761px) and (max-width: 1050px) {
  .work #book.is-closed { --leaf-height: 960px; }
}

@media (max-width: 760px) {
  :root {
    --leaf-height: clamp(540px, 74svh, 680px);
  }

  .masthead {
    min-height: 56px;
    padding: 11px 72px 8px 16px;
    align-items: center;
  }

  .topnav {
    max-width: none;
    flex-wrap: nowrap;
    gap: clamp(12px, 4vw, 18px);
    font-size: 8px;
  }

  .topnav #readAll,
  .topnav .motion-toggle {
    display: none;
  }

  .work {
    width: 100%;
    max-width: 540px;
    margin: 4px auto 0;
    padding: 0 12px;
  }

  .work #book {
    width: 100%;
    scroll-margin-top: 68px;
    transform: scale(.8) !important;
    transform-origin: center top;
    margin-bottom: calc(var(--leaf-height) * -.2);
  }

  .work #book.is-closed {
    --leaf-height: clamp(510px, 69svh, 640px);
    transform: scale(.76) rotateZ(-1deg) !important;
    margin-bottom: calc(var(--leaf-height) * -.24);
  }

  .work #book.is-closed.lifted {
    transform: scale(.8) !important;
    margin-bottom: calc(var(--leaf-height) * -.2);
  }

  .book-controls {
    grid-template-columns: 58px minmax(0, 1fr) 58px;
    gap: 7px;
    padding: 12px 0 0;
  }

  .progress {
    gap: clamp(6px, 2vw, 11px);
  }

  .bottom-note {
    padding: 13px 2px 20px;
  }

  .prose-page .chapter-title { font-size: calc(33px * var(--story-fit, 1)); margin-bottom: calc(18px * var(--story-fit, 1)); }
  .prose-page .eyebrow { margin-bottom: calc(20px * var(--story-fit, 1)); }
  .prose-page .prose { font-size: calc(15.5px * var(--story-fit, 1)); line-height: 1.5; }
  .prose-page .prose p { margin-bottom: calc(14px * var(--story-fit, 1)); }
  .prose-page .quote { font-size: calc(16px * var(--story-fit, 1)); margin: calc(16px * var(--story-fit, 1)) 0; padding-top: calc(12px * var(--story-fit, 1)); }
  .prose-page .memory-actions { margin-top: calc(14px * var(--story-fit, 1)); }
  .prose-page .folio { padding-top: calc(16px * var(--story-fit, 1)); }
}

@media (max-width: 380px) {
  .masthead {
    padding-right: 64px;
    padding-left: 13px;
  }

  .topnav {
    gap: 10px;
    font-size: 7px;
  }

  .work {
    padding-inline: 8px;
  }

  .work #book.is-closed {
    transform: scale(.72) rotateZ(-1deg) !important;
  }
}

@media (max-width: 760px) {
  .work #book.is-closed {
    transform: scale(.76) rotateZ(-1deg) !important;
    margin-bottom: calc(var(--leaf-height, 940px) * -.24);
  }

  .work #book.is-closed.lifted {
    transform: scale(.8) !important;
    margin-bottom: calc(var(--leaf-height, 940px) * -.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .work #book.is-closed {
    transform: translateX(-25%) scale(.72) !important;
  }
}

@media (prefers-reduced-motion: reduce) and (max-width: 760px) {
  .work #book.is-closed {
    transform: scale(.76) !important;
  }
}

/* Match the open spread before turning the cover; keep all size rules together. */
.work #book.is-closed.presenting {
  --leaf-height: inherit;
  transform: scale(.8) rotateZ(0deg) !important;
  margin-bottom: calc(var(--leaf-height) * -.2);
  transition: transform .9s cubic-bezier(.22,.65,.25,1), height .9s ease,
    margin-bottom .9s ease !important;
}
.work #book.presenting > .spread,
.work #book.presenting > .spread > .page {
  transition: height .9s ease;
}
.work #book[aria-busy="true"] > .spread { pointer-events: none; }
.turn-stage .page::before { display: none; }
.turn-stage .page::after { box-shadow: none; }
.mobile-turn-stage { overflow: hidden; perspective: 1200px; }
.turn-stage .mobile-turn-sheet {
  position: absolute;
  inset: 0;
  min-height: 0;
  margin: 0;
  contain: layout paint;
  will-change: transform, opacity;
  backface-visibility: hidden;
  border-radius: 8px 11px 13px 8px;
}
.mobile-turn-sheet > .page { height: 100% !important; }
.mobile-turn-sheet::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset -7px 0 12px -9px #4a3f32;
}
@media (max-width: 760px) {
  .work #book.mobile-turning { transform: scale(.8) !important; }
}
@media (prefers-reduced-motion: reduce) {
  .work #book.is-closed.presenting,
  .work #book.presenting > .spread,
  .work #book.presenting > .spread > .page { transition: none !important; }
}
