.bh-book-motion-frame {
  position: relative;
  display: block;
  overflow: hidden;
  isolation: isolate;
}

.bh-book-motion-frame > .bh-book-motion-primary {
  transition: opacity 300ms ease, transform 380ms cubic-bezier(.2, .75, .3, 1);
}

.bh-book-motion-frame > img.bh-book-motion-alt {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  pointer-events: none;
  transform: scale(1.035);
  transition: opacity 300ms ease, transform 380ms cubic-bezier(.2, .75, .3, 1);
}

.bh-book-motion-card .product-tag { z-index: 1; }
.book-cover .bh-book-motion-frame { cursor: zoom-in; }
.book-gallery [data-book-zoom] { cursor: zoom-in; }

@media (hover: hover) {
  .bh-book-motion-card:hover .bh-book-motion-primary,
  .bh-book-motion-frame:hover > .bh-book-motion-primary {
    transform: scale(1.035);
  }
  .bh-book-motion-card:hover [data-book-alt-ready] > img.bh-book-motion-alt,
  .bh-book-motion-frame[data-book-alt-ready]:hover > img.bh-book-motion-alt {
    opacity: 1;
    transform: none;
  }
  .bh-book-motion-card:hover [data-book-alt-ready] > .bh-book-motion-primary,
  .bh-book-motion-frame[data-book-alt-ready]:hover > .bh-book-motion-primary {
    opacity: 0;
  }
}

.bh-book-motion-card:focus-visible [data-book-alt-ready] > img.bh-book-motion-alt,
.bh-book-motion-frame[data-book-alt-ready]:focus-visible > img.bh-book-motion-alt,
.bh-book-motion-frame[data-book-alt-ready][data-book-alt-selected] > img.bh-book-motion-alt {
  opacity: 1;
  transform: none;
}

.bh-book-motion-card:focus-visible [data-book-alt-ready] > .bh-book-motion-primary,
.bh-book-motion-frame[data-book-alt-ready]:focus-visible > .bh-book-motion-primary,
.bh-book-motion-frame[data-book-alt-ready][data-book-alt-selected] > .bh-book-motion-primary {
  opacity: 0;
}

.bh-book-preview {
  display: grid;
  gap: .7rem;
  max-width: 23rem;
  margin: 1rem 0;
}

.bh-book-preview[hidden], .bh-book-viewer [hidden] { display: none; }
.bh-book-preview .bh-book-motion-frame {
  display: grid;
  aspect-ratio: 1;
  place-items: center;
  border: 1px solid #53603c;
  background: #151a12;
}
.bh-book-preview .bh-book-motion-primary {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.bh-book-preview button { justify-self: start; }

.admin-body:has([data-book-admin-preview]) .media-picker {
  box-sizing: border-box;
  width: min(58rem, calc(100% - 1.5rem));
  max-height: 85dvh;
  margin: auto;
  overflow: auto;
  padding: 1rem;
  border: 1px solid #53603c;
  background: #141a10;
  color: #f3f0e5;
}
.admin-body:has([data-book-admin-preview]) .media-picker::backdrop { background: #000b; }
.admin-body:has([data-book-admin-preview]) .media-picker .hero-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  margin-bottom: .85rem;
}
.admin-body:has([data-book-admin-preview]) .media-picker .hero-edit-header h2 { margin: 0; }
.admin-body:has([data-book-admin-preview]) .media-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 9rem), 1fr));
  gap: .65rem;
}
.admin-body:has([data-book-admin-preview]) .media-picker-grid .media-pick-item {
  display: grid;
  gap: .45rem;
  min-width: 0;
  padding: .4rem;
  border: 1px solid #53603c;
  background: #1b2217;
  color: inherit;
  font: inherit;
  cursor: pointer;
  overflow-wrap: anywhere;
}
.admin-body:has([data-book-admin-preview]) .media-picker-grid .media-pick-item:hover {
  border-color: #c3d696;
}
.admin-body:has([data-book-admin-preview]) .media-picker-grid img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #090c07;
}

.bh-book-viewer {
  box-sizing: border-box;
  width: min(70rem, calc(100% - 1.5rem));
  max-width: none;
  height: min(54rem, calc(100dvh - 2rem));
  max-height: none;
  margin: auto;
  padding: clamp(.7rem, 2vw, 1.4rem);
  border: 1px solid #53603c;
  color: #f3f0e5;
  background: #10130f;
  box-shadow: 0 20px 80px #000a;
}
.bh-book-viewer::backdrop { background: rgb(3 5 2 / 88%); }
.bh-book-viewer[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  animation: bh-book-viewer-enter 220ms ease-out both;
}
@keyframes bh-book-viewer-enter {
  from { opacity: 0; transform: translateY(8px) scale(.985); }
  to { opacity: 1; transform: none; }
}
.bh-book-viewer-toolbar, .bh-book-viewer-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
}
.bh-book-viewer-toolbar { margin-bottom: .65rem; }
.bh-book-viewer-nav { margin-top: .65rem; }
.bh-book-viewer-toolbar :is(p, form) { margin: 0; padding: 0; }
.bh-book-viewer button {
  min-width: 44px;
  min-height: 44px;
  padding: .35rem .7rem;
  border: 1px solid #53603c;
  background: #191f14;
  color: inherit;
  font: inherit;
  cursor: pointer;
}
.bh-book-viewer button:is(:hover, :focus-visible) { border-color: #c3d696; }
.bh-book-viewer button:focus-visible { outline: 2px solid #c3d696; outline-offset: 2px; }
.bh-book-viewer-stage {
  display: grid;
  min-height: 0;
  place-items: center;
  background: #070906;
  overflow: hidden;
  touch-action: pan-y pinch-zoom;
}
.bh-book-viewer-stage img { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.bh-book-viewer-count { text-align: center; }
html:has(.bh-book-viewer[open]) { overflow: hidden; }

@media (prefers-reduced-motion: reduce) {
  .bh-book-motion-frame > img { transition: none !important; transform: none !important; }
  .bh-book-viewer[open] { animation: none; }
}
