/* ===========================
   Book Stack (mantle)
   Nintendo DS tavern vibe
   =========================== */

:root {
  /* If these already exist from guestbook.css, this will match them */
  --ds-bg: rgba(112, 108, 108, 0.1);
  --ds-panel: rgba(115, 108, 134, 0.25);
  --ds-panel-2: rgba(115, 108, 134, 0.2);
  --ds-border: rgb(208, 226, 184);
  --ds-text: rgb(208, 226, 184);

  --grid-a: rgba(208, 226, 184, 0.05);
  --grid-b: rgba(208, 226, 184, 0.02);

  --neon-pink: #ff4fd8;
}

/* Currently reading: book spine stack */
.book-stack-container {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 0;
  padding: 4px 2px;
  position: relative;
}

/* spines */
img.book-spine {
  /* Use max constraints (not hard width/height) so the spine never crops/squishes */
  width: auto;
  height: auto;
  max-height: 120px;
  max-width: 60px;
  object-fit: contain;
  display: block;
  image-rendering: auto;

  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.55));
  transform-origin: bottom center;

  cursor: pointer;
  transition: transform 180ms ease, filter 180ms ease;
}

img.book-spine:hover {
  transform: translateY(-5px) rotate(-0.5deg);
  filter: drop-shadow(0 14px 18px rgba(0, 0, 0, 0.65));
}

/* Hover label */
.book-stack-container::after {
  content: "currently reading";
  position: absolute;
  left: 50%;
  bottom: 100%;
  transform: translate(-50%, -8px);
  z-index: 50;

  padding: 6px 10px;
  border-radius: 10px;

  background: rgba(15, 10, 18, 0.92);
  color: #ffd4c0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: lowercase;
  white-space: nowrap;

  opacity: 0;
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;

  box-shadow:
    0 10px 24px rgba(0, 0, 0, 0.55),
    inset 0 0 0 1px rgba(255, 200, 170, 0.18);
}

.book-stack-container:hover::after {
  opacity: 1;
  transform: translate(-50%, -12px);
}

/* ===========================
   Reading Log Modal (Open Book)
   =========================== */

.readinglog-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
}

.readinglog-modal[hidden] {
  display: none;
}

.readinglog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 8, 12, 0.92);
  backdrop-filter: blur(8px);
}

/* Book wrapper */
.book-wrapper {
  position: relative;
  z-index: 2;
}

/* Close button */
.book-close {
  position: absolute;
  top: -50px;
  right: 0;
  width: 40px;
  height: 40px;
  border: 2px solid rgba(208, 226, 184, 0.4);
  background: rgba(20, 18, 24, 0.85);
  color: rgba(208, 226, 184, 0.9);
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.book-close:hover {
  background: rgba(30, 28, 34, 0.95);
  color: #ffd4c0;
  border-color: #ffd4c0;
  transform: rotate(90deg);
}

/* Main book container */
.book-container {
  perspective: 2000px;
  position: relative;
}

/* ===========================
   Cover View
   =========================== */

.book-cover-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 600px;
  animation: bookAppear 0.5s ease;
}

.book-cover-view[hidden] {
  display: none;
}

@keyframes bookAppear {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.book-cover-front {
  position: relative;
  cursor: pointer;
  transition: transform 0.4s ease;
  filter: drop-shadow(0 20px 40px rgba(0, 0, 0, 0.7));
}

.book-cover-front:hover {
  transform: translateY(-10px) rotate(-2deg);
}

.book-cover-front:hover .book-open-prompt {
  opacity: 1;
  transform: translateY(0);
}

.book-cover-image {
  max-width: 400px;
  max-height: 600px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.1),
    inset 0 0 30px rgba(0, 0, 0, 0.2);
}

.book-open-prompt {
  position: absolute;
  bottom: -60px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  opacity: 0;
  transition: all 0.4s ease;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;

  padding: 12px 24px;
  background: rgba(20, 18, 24, 0.92);
  border: 1px solid rgba(208, 226, 184, 0.3);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.book-open-icon {
  font-size: 24px;
  animation: bookPulse 2s ease infinite;
}

@keyframes bookPulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.1);
  }
}

.book-open-text {
  font-family: 'DotGothic16', monospace;
  font-size: 11px;
  color: #ffd4c0;
  letter-spacing: 0.1em;
  text-transform: lowercase;
}

/* ===========================
   Open Book View
   =========================== */

.book-open-view {
  display: flex;
  align-items: stretch;
  justify-content: center;
  position: relative;
  min-height: 700px;
  animation: bookOpen 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bookOpen {
  from {
    opacity: 0;
    transform: rotateY(-20deg) scale(0.8);
  }

  to {
    opacity: 1;
    transform: rotateY(0) scale(1);
  }
}

.book-open-view[hidden] {
  display: none;
}

/* Book spine (center) */
.book-open-view .book-spine {
  width: 40px;
  background: linear-gradient(to right,
      rgba(40, 35, 30, 0.9) 0%,
      rgba(50, 42, 35, 0.95) 20%,
      rgba(45, 38, 32, 0.98) 50%,
      rgba(50, 42, 35, 0.95) 80%,
      rgba(40, 35, 30, 0.9) 100%);
  box-shadow:
    inset -4px 0 12px rgba(0, 0, 0, 0.6),
    inset 4px 0 12px rgba(0, 0, 0, 0.6),
    inset 0 0 30px rgba(0, 0, 0, 0.4);
  position: relative;
  z-index: 2;
}

/* Book pages */
.book-page {
  width: 450px;
  min-height: 700px;
  padding: 60px 50px;
  position: relative;

  /* Aged paper texture */
  background:
    radial-gradient(ellipse at top left, rgba(255, 250, 240, 0.02) 0%, transparent 50%),
    radial-gradient(ellipse at bottom right, rgba(250, 240, 220, 0.02) 0%, transparent 50%),
    linear-gradient(180deg,
      #f4f1ea 0%,
      #f8f5ed 50%,
      #f4f1ea 100%);

  box-shadow:
    inset 0 0 40px rgba(210, 180, 140, 0.15),
    inset 0 0 100px rgba(255, 250, 240, 0.3);
}

/* Left page specific styling */
.book-page-left {
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
  box-shadow:
    -12px 0 30px rgba(0, 0, 0, 0.5),
    inset 20px 0 40px rgba(0, 0, 0, 0.08),
    inset 0 0 40px rgba(210, 180, 140, 0.15);
}

/* Right page specific styling */
.book-page-right {
  border-top-right-radius: 8px;
  border-bottom-right-radius: 8px;
  box-shadow:
    12px 0 30px rgba(0, 0, 0, 0.5),
    inset -20px 0 40px rgba(0, 0, 0, 0.08),
    inset 0 0 40px rgba(210, 180, 140, 0.15);
}

/* Paper texture overlay */
.book-page::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    repeating-linear-gradient(0deg,
      transparent,
      transparent 2px,
      rgba(210, 180, 140, 0.03) 2px,
      rgba(210, 180, 140, 0.03) 3px);
  pointer-events: none;
  opacity: 0.6;
}

/* Page content */
.book-page-content {
  height: 100%;
  overflow-y: auto;
  padding-right: 8px;
  color: #2c2416;
  font-family: 'Georgia', 'Garamond', serif;
  line-height: 1.8;
}

/* Custom scrollbar for pages */
.book-page-content::-webkit-scrollbar {
  width: 6px;
}

.book-page-content::-webkit-scrollbar-track {
  background: rgba(210, 180, 140, 0.2);
  border-radius: 3px;
}

.book-page-content::-webkit-scrollbar-thumb {
  background: rgba(139, 90, 43, 0.4);
  border-radius: 3px;
}

.book-page-content::-webkit-scrollbar-thumb:hover {
  background: rgba(139, 90, 43, 0.6);
}

/* Typography */
.book-title {
  font-family: 'Jacquard 12', cursive;
  font-size: 32px;
  color: #3d2817;
  margin: 0 0 12px 0;
  text-align: center;
  line-height: 1.3;
}

.book-author {
  font-family: 'Georgia', serif;
  font-size: 16px;
  font-style: italic;
  color: #5d4427;
  text-align: center;
  margin: 0 0 30px 0;
}

.book-meta {
  font-family: 'DotGothic16', monospace;
  font-size: 11px;
  color: #6d5437;
  line-height: 1.8;
  padding: 20px 0;
  border-top: 1px solid rgba(139, 90, 43, 0.3);
  border-bottom: 1px solid rgba(139, 90, 43, 0.3);
  margin-bottom: 20px;
}

.book-meta div {
  margin-bottom: 6px;
}

/* Entry cards on pages */
.readinglog-entry {
  margin-bottom: 30px;
  padding-bottom: 20px;
  border-bottom: 1px dashed rgba(139, 90, 43, 0.2);
}

.readinglog-entry:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.readinglog-row {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.readinglog-date {
  font-family: 'DotGothic16', monospace;
  font-size: 10px;
  color: #6d5437;
  font-weight: 600;
}

.readinglog-page {
  font-family: 'DotGothic16', monospace;
  font-size: 10px;
  color: #7d6447;
}

.readinglog-tag {
  font-family: 'DotGothic16', monospace;
  font-size: 9px;
  color: #8b4513;
  background: rgba(139, 69, 19, 0.08);
  border: 1px solid rgba(139, 69, 19, 0.2);
  padding: 3px 10px;
  border-radius: 12px;
}

.readinglog-text {
  font-family: 'Georgia', 'Garamond', serif;
  font-size: 14px;
  line-height: 1.8;
  color: #2c2416;
  margin-bottom: 12px;
}

.readinglog-quote {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(139, 90, 43, 0.04);
  border-left: 3px solid rgba(139, 90, 43, 0.4);
  font-style: italic;
  color: #3d2817;
  font-family: 'Georgia', 'Garamond', serif;
  font-size: 13px;
  line-height: 1.7;
}

/* Page numbers */
.page-number {
  position: absolute;
  bottom: 30px;
  font-family: 'Georgia', serif;
  font-size: 12px;
  color: #8b7355;
  font-style: italic;
}

.page-number-left {
  left: 50px;
}

.page-number-right {
  right: 50px;
}

/* Page turn corners */
.page-turn-corner {
  position: absolute;
  width: 60px;
  height: 60px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: #8b7355;
  transition: all 0.3s ease;
  opacity: 0;
}

.page-turn-corner:hover {
  opacity: 1 !important;
}

/* Next page corner (bottom right) */
#pageTurnNext {
  bottom: 0;
  right: 0;
  border-top-left-radius: 100%;
  background: linear-gradient(135deg,
      transparent 0%,
      rgba(210, 180, 140, 0.2) 50%,
      rgba(210, 180, 140, 0.4) 100%);
}

#pageTurnNext:hover {
  background: linear-gradient(135deg,
      transparent 0%,
      rgba(210, 180, 140, 0.3) 50%,
      rgba(210, 180, 140, 0.6) 100%);
  box-shadow: -4px -4px 12px rgba(0, 0, 0, 0.1);
}

/* Previous page corner (bottom left) */
.page-turn-prev {
  bottom: 0;
  left: 40px;
  /* Account for spine width */
  border-top-right-radius: 100%;
  background: linear-gradient(225deg,
      transparent 0%,
      rgba(210, 180, 140, 0.2) 50%,
      rgba(210, 180, 140, 0.4) 100%);
}

.page-turn-prev:hover {
  background: linear-gradient(225deg,
      transparent 0%,
      rgba(210, 180, 140, 0.3) 50%,
      rgba(210, 180, 140, 0.6) 100%);
  box-shadow: 4px -4px 12px rgba(0, 0, 0, 0.1);
}

/* Show corners when there are pages to navigate */
.book-open-view[data-has-next="true"] #pageTurnNext {
  opacity: 0.4;
}

.book-open-view[data-has-prev="true"] .page-turn-prev {
  opacity: 0.4;
}

/* Responsive design */
@media (max-width: 1200px) {
  .book-page {
    width: 350px;
    min-height: 600px;
    padding: 50px 40px;
  }

  .book-title {
    font-size: 26px;
  }
}

@media (max-width: 900px) {
  .book-open-view {
    flex-direction: column;
    min-height: auto;
  }

  .book-spine {
    display: none;
  }

  .book-page {
    width: 100%;
    max-width: 500px;
    min-height: 500px;
    border-radius: 8px !important;
  }

  .book-page-left {
    margin-bottom: 20px;
  }

  .page-turn-prev {
    left: 0;
  }
}