#mainContent .bookImage.is-3d-book {
  justify-content: center;
  perspective: 900px;
  transform: none;
}

.bookImage.is-3d-book .bookBackground {
  width: 176px;
  height: 220px;
  border: 1px solid color-mix(in srgb, var(--structureBorder) 75%, transparent);
  border-radius: 16px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, .96), rgba(255, 255, 255, .28) 68%),
    var(--lighter, #f4f4f4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .65);
}

html.theme_dark .bookImage.is-3d-book .bookBackground {
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, .08), transparent 68%),
    var(--headerBackground);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .08);
}

.bookScene {
  /* The 7 x 9.1 x 1-inch book is scaled to a 190px cover height. */
  --book-width: 146px;
  --book-height: 190px;
  --book-depth: 21px;
  width: var(--book-width);
  height: var(--book-height);
  display: block;
  grid-area: 1 / 1;
  position: relative;
  z-index: 2;
  color: inherit;
  background: none;
  outline: none;
  perspective: 900px;
  text-decoration: none;
  transform: translateY(0) scale(1);
  transform-origin: center;
  transition:
    transform 420ms cubic-bezier(.16, 1.45, .3, 1),
    filter 420ms ease;
  will-change: transform;
}

.bookScene:focus-visible {
  outline: 3px solid var(--primary, #ff6b00);
  outline-offset: 9px;
  border-radius: 2px;
}

.bookScene.is-interacting {
  filter: drop-shadow(0 12px 12px rgba(15, 18, 24, .18));
  transform: translateY(-3px) scale(1.08);
}

.book3d {
  width: 100%;
  height: 100%;
  display: block;
  position: relative;
  z-index: 1;
  animation: bookTurn 28s linear infinite;
  transform-style: preserve-3d;
  will-change: transform;
}

.bookScene:not(.is-pointer-driven):hover .book3d,
.bookScene:not(.is-pointer-driven):focus .book3d {
  animation-play-state: paused;
}

.bookScene.is-pointer-driven .book3d {
  animation: none;
}

.bookShadow {
  width: calc(var(--book-width) * .88);
  height: 18px;
  position: absolute;
  z-index: 0;
  bottom: -14px;
  left: 8%;
  border-radius: 50%;
  background: rgba(15, 18, 24, .34);
  filter: blur(8px);
  opacity: .62;
  transform: translateX(calc(var(--book-depth) * .25)) scaleX(.92);
  transition:
    opacity 320ms ease,
    transform 420ms cubic-bezier(.16, 1.45, .3, 1);
}

.bookScene.is-interacting .bookShadow {
  opacity: .78;
  transform: translateX(calc(var(--book-depth) * .25)) scaleX(1.08);
}

.bookFace {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  overflow: hidden;
  box-sizing: border-box;
  border: 1px solid rgba(25, 24, 24, .16);
  background: #f5f3ea;
  backface-visibility: hidden;
}

.bookFront,
.bookBack {
  width: var(--book-width);
  height: var(--book-height);
}

.bookFront {
  transform: translateZ(calc(var(--book-depth) / 2));
}

.bookBack {
  transform: rotateY(180deg) translateZ(calc(var(--book-depth) / 2));
}

.bookFaceImage {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: fill;
  transform: none;
}

.bookFront::after,
.bookBack:not(.bookSolidCover)::after,
.bookSpine:not(.bookSolidCover)::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(90deg, rgba(0, 0, 0, .09), transparent 8%, transparent 92%, rgba(255, 255, 255, .14));
  mix-blend-mode: multiply;
}

.bookSolidCover {
  background-image: none;
}

.bookSpine,
.bookForeEdge {
  width: var(--book-depth);
  height: var(--book-height);
  left: calc((var(--book-width) - var(--book-depth)) / 2);
}

.bookSpine {
  transform: rotateY(-90deg) translateZ(calc(var(--book-width) / 2));
}

.bookForeEdge {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, .14), transparent 30%, transparent 72%, rgba(0, 0, 0, .1)),
    repeating-linear-gradient(0deg, #fff 0 2px, #d8d8d3 2px 3px, #f8f8f5 3px 5px);
  transform: rotateY(90deg) translateZ(calc(var(--book-width) / 2));
}

.bookTop,
.bookBottom {
  width: var(--book-width);
  height: var(--book-depth);
  top: calc((var(--book-height) - var(--book-depth)) / 2);
  background:
    linear-gradient(0deg, rgba(0, 0, 0, .14), transparent 38%, transparent 72%, rgba(255, 255, 255, .3)),
    repeating-linear-gradient(90deg, #fff 0 2px, #d8d8d3 2px 3px, #f8f8f5 3px 5px);
}

.bookTop {
  transform: rotateX(90deg) translateZ(calc(var(--book-height) / 2));
}

.bookBottom {
  transform: rotateX(-90deg) translateZ(calc(var(--book-height) / 2));
}

.bookContentMain {
  flex-wrap: wrap;
  gap: 12px;
}

#mainContent .bookContentMain p.archiveBook3d {
  min-width: 160px;
  min-height: 230px;
  flex: 1 1 160px;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  margin: 0;
  padding: 24px 10px 18px;
  border: 1px solid var(--structureBorder);
  border-radius: 12px;
  background: var(--lighter, #f7f7f7);
}

html.theme_dark #mainContent .bookContentMain p.archiveBook3d {
  background: var(--headerBackground);
}

@keyframes bookTurn {
  from {
    transform: rotateX(-3deg) rotateY(24deg);
  }

  to {
    transform: rotateX(-3deg) rotateY(384deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  .book3d {
    animation: none;
    transform: rotateX(-3deg) rotateY(24deg);
  }

  .bookScene {
    transition-duration: 100ms;
  }

  .bookScene.is-interacting {
    transform: translateY(-1px) scale(1.03);
  }
}

@media all and (max-width: 700px) {
  #mainContent .bookContentMain {
    display: grid;
    grid-template-columns: 1fr;
  }
}
