
.book-modal-wrapper {
  position: fixed;
  inset: 0;
  z-index: 9000;
    display: block;
  overflow-y: auto;
  padding: 2rem 1rem;
  box-sizing: border-box;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    visibility 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-modal-wrapper.is-open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.book-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.82);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 0;
}

.book-modal-container {
  position: relative;
  z-index: 1;
  width: 100%;
  /* Height-aware width cap: the paper's height scales with its width, so on
     short viewports the width shrinks until the whole modal fits on screen */
  max-width: min(1120px, 94vw, 118vh);
    margin: auto;
  display: flex;
  flex-direction: column;

  transform: translateY(16px) scale(0.97);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.book-modal-wrapper.is-open .book-modal-container {
  transform: translateY(0) scale(1);
}

.book-modal-header {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0 0.25rem 0.75rem 0.25rem;
}

.bm-header-text {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.bm-date {
  font-family: 'Open Sans', sans-serif;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.3px;
}

.bm-title {
  font-family: 'Volkhov', serif;
  font-size: 18px;
  font-weight: 400;
  color: #fff;
  line-height: 1.3;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
  margin: 0;
}

.modal-close-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.2rem;
  opacity: 0.75;
  transition: opacity 0.2s ease, transform 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close-btn:hover {
  opacity: 1;
  transform: rotate(90deg) scale(1.1);
}

.modal-close-btn img {
  width: 44px;   height: 44px;
  object-fit: contain;
}

.book-modal-paper {
  position: relative;
  width: 100%;
}

.paper-bg-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  z-index: 0;
}

.paper-full {
  width: 100%;
  height: 100%;
  display: block;
}

.paper-content {
  position: relative;
  /* No z-index: it would create a stacking context that isolates blend modes
     from the paper background in the sibling .paper-bg-layer (the content
     still paints above the paper via DOM order) */
        padding: 6.5% 14% 5% 14%;
  display: flex;
  flex-direction: column;
  text-align: center;
}

.paper-subtitle {
  display: block;
  font-family: 'Open Sans', sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 2.5px;
  color: #7a5c35;
  text-transform: uppercase;
  margin-bottom: 0.5rem;
}

.paper-title {
  font-family: 'Cinzel', serif;
  font-size: 40px;
  font-weight: 800;
  color: #331f16;
  line-height: 1.2;
  margin: 0 0 1.75rem 0;
}

.paper-content p {
  font-family: 'Volkhov', serif;
  font-size: 16px;
  color: #3a2610;
  line-height: 1.75;
  margin-bottom: 1rem;
  text-align: center;
}

.paper-footnote {
  font-family: 'Volkhov', serif;
  font-style: italic;
  color: #000000;
  opacity: 1;
    font-size: 16px !important;
  margin-bottom: 1.5rem !important;
}

.paper-image-wrapper {
  margin: 1rem auto 0.5rem auto;
  text-align: center;
  max-width: 100%;
  }

.paper-image-wrapper[hidden] {
  display: none;
  }

/* Book page engravings: portrait ink drawings on white, unlike the landscape
   photos the framed card was built for. Bypass the 16:9 crop box, the photo
   overlay/frame layers and the parallax transform, and multiply the white
   away so the ink prints straight onto the paper */
.paper-image-wrapper.book-art .framed-image-inner {
  aspect-ratio: auto;
  overflow: visible;
  }

.paper-image-wrapper.book-art .image-overlay,
.paper-image-wrapper.book-art .frame-border,
.paper-image-wrapper.book-art .frame-bottom-deco {
  display: none;
  }

.paper-image-wrapper.book-art .feature-img {
  height: min(calc(320px + var(--book-art-copy-room, 0px)), calc(30vh + var(--book-art-copy-room, 0px)));
  aspect-ratio: 40 / 53;
  width: auto;
  max-width: 100%;
  filter: none;
  mix-blend-mode: multiply;
  transform: none !important;
  }

.paper-image-wrapper .framed-card {
  display: inline-block;
  max-width: 100% !important;
  }

.paper-action {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
}

#book-modal .paper-action {
  display: flex;
}

.modal-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 0 0 0;
  flex-shrink: 0;
}

.modal-nav-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  opacity: 0.65;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.modal-nav-btn:hover {
  opacity: 1;
}

.modal-prev {
  flex-direction: row;
}

.modal-prev:hover {
  transform: translateX(-3px);
}

.modal-next {
  flex-direction: row; }

.modal-next .modal-nav-text {
  text-align: right;
}

.modal-next:hover {
  transform: translateX(3px);
}

.modal-nav-btn img {
  width: auto;
    height: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.modal-nav-text {
  font-family: 'Volkhov', serif;
  font-size: 16px;
  color: #A6A7A7;
  max-width: 200px;
  line-height: 1.4;
  /* Single line always: a wrapping label changes the modal height between pages */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 960px) {
  .book-modal-container {
    max-width: 95vw;
  }
}

@media (max-width: 768px) {
  .book-modal-wrapper {
    padding: 1rem;
    justify-content: flex-start;
  }

  .paper-content {
    padding: 90px 2.5rem 64px 2.5rem;
  }

  .bm-title {
    font-size: 15px;
  }

  .paper-title {
    font-size: 21px;
  }
}

@media (max-width: 480px) {
  .paper-content {
    padding: 80px 1.5rem 56px 1.5rem;
  }

  .paper-title {
    font-size: 18px;
  }

  .modal-nav-text {
    display: none;
  }
}
