/* ============================================================
   BOOKS PAGE — 3D Bookshelf
   ============================================================ */

/* ── Top row: current read + most gifted ──────────────────── */
.books-top-row {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: var(--space-10);
  align-items: start;
  margin-bottom: var(--space-4);
}

/* ── Current Read ─────────────────────────────────────────── */
.current-read {
  min-width: 0;
}

.current-read-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-8);
  align-items: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-8);
  max-width: 640px;
}

/* Mini book face (current read) */
.current-book-face {
  width: 80px;
  height: 120px;
  border-radius: 4px 8px 8px 4px;
  box-shadow:
    inset -4px 0 8px rgba(0,0,0,0.3),
    4px 4px 16px rgba(0,0,0,0.4);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.current-book-face__title {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  text-align: center;
  line-height: 1.3;
  word-break: break-word;
}

.current-book-info { }

.current-book-title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-1);
}

.current-book-author {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}

.current-book-progress {
  margin-bottom: var(--space-4);
}

.progress-label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-bottom: var(--space-2);
  display: flex;
  justify-content: space-between;
}

.progress-bar-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.6s var(--ease-out);
}

.current-book-review {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.6;
  font-style: italic;
}

/* ── Most Gifted ──────────────────────────────────────────── */
.most-gifted { }

.gifted-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.gifted-item:last-child { border-bottom: none; }

.gifted-spine {
  width: 28px;
  height: 56px;
  border-radius: 2px 5px 5px 2px;
  flex-shrink: 0;
  box-shadow: inset -3px 0 6px rgba(0,0,0,0.3), 2px 2px 6px rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.gifted-spine__title {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-family: var(--font-mono);
  font-size: 0.45rem;
  color: rgba(255,255,255,0.85);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 48px;
  pointer-events: none;
}

.gifted-title {
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.gifted-author { margin-top: 2px; }

/* ── Up Next ──────────────────────────────────────────────── */
.upnext-section { }

#upnext-content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.upnext-item {
  display: grid;
  grid-template-columns: 32px 20px 1fr;
  gap: var(--space-4);
  align-items: start;
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--border-subtle);
}

.upnext-item:last-child { border-bottom: none; }

.upnext-num { padding-top: 3px; }

.upnext-face {
  width: 20px;
  height: 40px;
  border-radius: 1px 3px 3px 1px;
  box-shadow: inset -2px 0 4px rgba(0,0,0,0.3);
  flex-shrink: 0;
  margin-top: 2px;
}

.upnext-title {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}

.upnext-author { margin-bottom: var(--space-2); }

.upnext-note { line-height: 1.6; }

/* ── Bookshelf ────────────────────────────────────────────── */
.bookshelf-section { }

.bookshelf-wrap {
  position: relative;
  padding-bottom: 20px; /* room for shelf plank */
}

.bookshelf {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: var(--space-6) var(--space-4) 0;
  flex-wrap: wrap;
  min-height: 200px;
}

/* ── Individual Book Spine ────────────────────────────────── */
.book-spine {
  width: 50px;
  height: 190px;
  border-radius: 3px 6px 6px 3px;
  cursor: pointer;
  position: relative;
  transform: perspective(600px) rotateY(-15deg);
  transform-style: preserve-3d;
  transition:
    transform var(--duration-slow) var(--ease-out),
    box-shadow var(--duration-slow) var(--ease-out),
    filter var(--duration-slow) var(--ease-out);
  flex-shrink: 0;
  filter: brightness(1.8);
  box-shadow:
    inset -6px 0 12px rgba(0,0,0,0.35),
    2px 2px 8px rgba(0,0,0,0.3),
    0 0 0 1px rgba(255,255,255,0.08);
}

.book-spine:hover {
  transform: perspective(600px) rotateY(-5deg) translateY(-8px);
  box-shadow:
    inset -6px 0 12px rgba(0,0,0,0.35),
    4px 8px 20px rgba(0,0,0,0.4),
    0 0 0 1px rgba(255,255,255,0.12);
  filter: brightness(2.2);
}

.book-spine.is-open {
  transform: perspective(600px) rotateY(0deg) translateY(-20px) translateZ(16px);
  box-shadow:
    inset -6px 0 12px rgba(0,0,0,0.2),
    0 12px 40px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.15);
  filter: brightness(2.3);
  z-index: 10;
}

.book-spine__text {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  transform: rotate(180deg);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255,255,255,0.95);
  text-shadow: 0 1px 3px rgba(0,0,0,0.5);
  position: absolute;
  inset: 8px 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  padding: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.book-spine__title {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  max-height: 110px;
}

.book-spine__author {
  opacity: 0.75;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Shelf plank */
.shelf-plank {
  height: 16px;
  background: linear-gradient(
    to bottom,
    #5c3d1e 0%,
    #4a2e12 40%,
    #3a2410 100%
  );
  border-radius: 0 0 4px 4px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  margin-top: -2px;
}

[data-theme="light"] .shelf-plank {
  background: linear-gradient(
    to bottom,
    #8b5e3c 0%,
    #6d4828 40%,
    #5a3a20 100%
  );
}

/* ── Book detail panel ────────────────────────────────────── */
.book-detail-panel {
  margin-top: var(--space-6);
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--duration-slow) var(--ease-out);
}

.book-detail-panel.is-open {
  max-height: 280px;
}

.book-detail-inner {
  display: flex;
  gap: var(--space-6);
  align-items: flex-start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: var(--space-5) var(--space-6);
}

/* Book cover thumbnail in detail panel */
.book-detail-cover {
  flex-shrink: 0;
  width: 90px;
  height: 130px;
  border-radius: 3px 6px 6px 3px;
  box-shadow:
    inset -5px 0 10px rgba(0,0,0,0.25),
    4px 4px 16px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px 8px;
  gap: 6px;
  text-align: center;
  filter: brightness(1.5);
}

.book-detail-cover__title {
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1.35;
  word-break: break-word;
  hyphens: auto;
}

.book-detail-cover__author {
  font-family: var(--font-mono);
  font-size: 0.55rem;
  opacity: 0.8;
  line-height: 1.3;
}

.book-detail-review {
  font-size: var(--text-sm);
  color: var(--text-muted);
  line-height: 1.7;
  font-style: italic;
  flex: 1;
  min-width: 0;
}

/* ── Recommendations ──────────────────────────────────────── */
.recs-section { }

.recs-category {
  margin-bottom: var(--space-10);
}

.recs-category__label {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

/* Responsive */
@media (max-width: 768px) {
  .books-top-row {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .current-read-card {
    grid-template-columns: 1fr;
    gap: var(--space-5);
  }

  .bookshelf {
    gap: 4px;
  }

  .book-spine {
    width: 34px;
    height: 150px;
  }

  .upnext-item {
    grid-template-columns: 28px 16px 1fr;
    gap: var(--space-3);
  }
}
