/* =============================================
   DIGITAL POETRY BOOK — 3D PAGE-FLIP VIEWER
   ============================================= */

.btn-view-book {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  color: #d4af37;
  border: 1px solid rgba(212, 175, 55, 0.4);
  padding: 10px 20px;
  border-radius: 14px;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-view-book:hover {
  background: rgba(212, 175, 55, 0.12);
  border-color: #d4af37;
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(212, 175, 55, 0.2);
}

.poetry-gallery-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 40px;
}

.poetry-gallery-header h2 {
  margin-bottom: 0 !important;
}

/* ============ MODAL SHELL ============ */

.book-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 30px 20px;
}

.book-modal.open {
  display: flex;
}

.book-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 5, 7, 0.92);
  backdrop-filter: blur(10px);
  animation: bookBackdropFade 0.4s ease-out;
}

@keyframes bookBackdropFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.book-close {
  position: absolute;
  top: 24px;
  right: 28px;
  z-index: 100010;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.4);
  background: rgba(255, 255, 255, 0.05);
  color: #d4af37;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.book-close:hover {
  background: rgba(212, 175, 55, 0.15);
  transform: rotate(90deg);
}

/* ============ SCENE / PERSPECTIVE ============ */

.book-scene {
  position: relative;
  z-index: 100005;
  width: 100%;
  max-width: 980px;
  height: min(640px, 78vh);
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 2600px;
}

/* ============ COVER ============ */

.book-cover {
  position: relative;
  width: min(420px, 88vw);
  height: 100%;
  border-radius: 6px 14px 14px 6px;
  background:
    linear-gradient(135deg, #1c1610 0%, #241b12 45%, #16110c 100%);
  border: 1px solid rgba(212, 175, 55, 0.35);
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(212, 175, 55, 0.08),
    inset 8px 0 20px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: coverFadeIn 0.5s ease-out;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

@keyframes coverFadeIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.book-cover.hidden {
  opacity: 0;
  transform: scale(0.95) rotateY(-25deg);
  pointer-events: none;
  position: absolute;
}

.book-cover::before {
  content: '';
  position: absolute;
  left: 26px;
  top: 26px;
  right: 26px;
  bottom: 26px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 2px;
  pointer-events: none;
}

.cover-inner {
  text-align: center;
  padding: 40px 34px;
}

.cover-ornament {
  font-size: 34px;
  margin-bottom: 18px;
  opacity: 0.85;
}

.cover-inner h1 {
  font-family: 'Playfair Display', serif;
  font-size: 40px;
  color: #f2d479;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  line-height: 1.2;
}

.cover-inner p {
  color: #cbb98a;
  font-size: 14px;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 30px;
}

.cover-author {
  display: block;
  color: #8a8578;
  font-size: 13px;
  margin-bottom: 34px;
  font-style: italic;
}

.btn-open-book {
  background: #d4af37;
  color: #09090b;
  border: none;
  padding: 14px 32px;
  border-radius: 30px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-open-book:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 30px rgba(212, 175, 55, 0.35);
}

/* ============ OPEN BOOK ============ */

.book {
  position: relative;
  width: min(900px, 92vw);
  height: 100%;
  display: flex;
  transform-style: preserve-3d;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.book.visible {
  opacity: 1;
  pointer-events: auto;
}

.book-spine {
  position: absolute;
  left: 50%;
  top: 2%;
  bottom: 2%;
  width: 26px;
  margin-left: -13px;
  background: linear-gradient(90deg,
    rgba(0,0,0,0) 0%,
    rgba(0,0,0,0.35) 45%,
    rgba(0,0,0,0.35) 55%,
    rgba(0,0,0,0) 100%);
  z-index: 15;
  pointer-events: none;
}

.book-page {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  background: linear-gradient(135deg, #f8f3e6 0%, #f1e9d6 100%);
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.book-page-left {
  left: 0;
  border-radius: 8px 2px 2px 8px;
}

.book-page-right {
  right: 0;
  border-radius: 2px 8px 8px 2px;
}

.book-leaf {
  position: absolute;
  top: 0;
  width: 50%;
  height: 100%;
  z-index: 20;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(.45,.05,.35,1);
  display: none;
  pointer-events: none;
}

.book-leaf.at-right {
  right: 0;
  left: auto;
  transform-origin: 0% 50%;
  border-radius: 2px 8px 8px 2px;
}

.book-leaf.at-left {
  left: 0;
  transform-origin: 100% 50%;
  border-radius: 8px 2px 2px 8px;
}

.leaf-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: linear-gradient(135deg, #f8f3e6 0%, #f1e9d6 100%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

.leaf-face.back {
  transform: rotateY(180deg);
}

/* subtle shading that sweeps across the leaf while it turns, for depth */
.leaf-face::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.18), transparent 40%);
  pointer-events: none;
}

.leaf-face.back::after {
  background: linear-gradient(270deg, rgba(0,0,0,0.18), transparent 40%);
}

/* ============ PAGE CONTENT ============ */

.page-inner {
  position: relative;
  height: 100%;
  padding: 44px 38px;
  display: flex;
  flex-direction: column;
  color: #2b2416;
}

.page-inner::before {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(120, 100, 60, 0.18);
  pointer-events: none;
}

.cover-inner.page-inner {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.page-ornament {
  font-size: 26px;
  margin-bottom: 16px;
  opacity: 0.75;
}

.page-inner h2 {
  font-family: 'Playfair Display', serif;
  font-size: 24px;
  color: #7a5c1e;
  margin-bottom: 14px;
}

.page-quote {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-size: 15px;
  color: #4a4030;
  max-width: 320px;
  line-height: 1.7;
}

.page-signature {
  margin-top: 20px;
  font-size: 12px;
  color: #8a7a4f;
  letter-spacing: 1px;
}

.page-tagrow {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.page-edit-btn {
  margin-left: auto;
  background: transparent;
  border: 1px solid rgba(122, 92, 30, 0.35);
  color: #7a5c1e;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.page-edit-btn:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: #7a5c1e;
}

.page-delete-btn {
  background: transparent;
  border: 1px solid rgba(178, 42, 42, 0.4);
  color: #a52a2a;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.page-delete-btn:hover {
  background: rgba(178, 42, 42, 0.15);
  border-color: #a52a2a;
}

.page-tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: #8a6d1e;
  background: rgba(212, 175, 55, 0.18);
  border: 1px solid rgba(138, 109, 30, 0.25);
  padding: 4px 10px;
  border-radius: 12px;
}

.page-poem-title {
  font-family: 'Playfair Display', serif;
  font-size: 22px;
  color: #3a2f18;
  margin-bottom: 18px;
  line-height: 1.3;
}

.page-poem-body {
  font-family: 'Playfair Display', serif;
  font-size: 14.5px;
  line-height: 1.85;
  color: #3a3222;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-y: auto;
  flex: 1;
  padding-right: 6px;
}

.page-poem-body::-webkit-scrollbar {
  width: 5px;
}

.page-poem-body::-webkit-scrollbar-thumb {
  background: rgba(138, 109, 30, 0.3);
  border-radius: 10px;
}

.page-date {
  margin-top: 14px;
  font-size: 11px;
  color: #9a8c60;
}

.page-number {
  position: absolute;
  bottom: 16px;
  font-size: 11px;
  color: #9a8c60;
}

.book-page-left .page-number,
.book-leaf.at-left .page-number {
  left: 30px;
}

.book-page-right .page-number,
.book-leaf.at-right .page-number {
  right: 30px;
}

.blank-page {
  background: repeating-linear-gradient(
    transparent, transparent 27px,
    rgba(120, 100, 60, 0.08) 28px
  );
}

/* ============ NAV ============ */

.book-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 1px solid rgba(212, 175, 55, 0.4);
  background: rgba(255, 255, 255, 0.06);
  color: #d4af37;
  font-size: 24px;
  cursor: pointer;
  z-index: 100008;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.book-nav:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.18);
  transform: translateY(-50%) scale(1.08);
}

.book-nav:disabled {
  opacity: 0.25;
  cursor: default;
}

.book-nav.prev { left: -8px; }
.book-nav.next { right: -8px; }

/* ============ FOOTER ============ */

.book-footer {
  position: relative;
  z-index: 100005;
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 22px;
  color: #9c9ca3;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.btn-close-book {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cfcfcf;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-close-book:hover {
  border-color: #d4af37;
  color: #d4af37;
}

/* ============ RESPONSIVE ============ */

@media (max-width: 760px) {
  .book-scene {
    height: min(560px, 74vh);
  }

  .book-nav {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }

  .book-nav.prev { left: -4px; }
  .book-nav.next { right: -4px; }

  .page-inner {
    padding: 30px 22px;
  }

  .page-poem-title {
    font-size: 18px;
  }

  .page-poem-body {
    font-size: 13.5px;
  }

  .cover-inner h1 {
    font-size: 30px;
  }
}

@media (max-width: 560px) {
  .book,
  .book-page,
  .book-leaf.at-right,
  .book-leaf.at-left {
    width: 100%;
  }

  /* The left page slot is always empty in single-page mode (see book.js),
     so we can hide it. The left-flip *leaf* is different — it still plays
     the backward page-turn animation — so instead of hiding it, move it
     onto the same visible slot as the right leaf. */
  .book-page-left {
    display: none !important;
  }

  .book-page-right {
    left: 0;
    right: 0;
    border-radius: 8px;
  }

  .book-leaf.at-right,
  .book-leaf.at-left {
    left: 0;
    right: auto;
    border-radius: 8px;
  }

  .book-spine {
    display: none;
  }
}
