/* ============================================
   LIBRARY PAGE STYLES - Book Grid + Modal
   ============================================ */

.library-container {
  max-width: 1100px;
  padding: 0 40px;
}

.page-header {
  max-width: 720px;
  margin: 0 auto 60px;
}

.page-title {
  font-size: 42px;
  font-weight: 600;
  letter-spacing: -0.03em;
  margin-bottom: 16px;
}

.page-description {
  font-family: 'Inter', sans-serif;
  font-size: 17px;
  color: var(--text-mid);
  max-width: 600px;
}

/* Book grid */
.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 40px 28px;
  margin-bottom: 100px;
}

.book-card {
  display: flex;
  flex-direction: column;
  background: none;
  border: none;
  padding: 0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.book-cover-wrap {
  position: relative;
}

.book-cover {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 3px;
  overflow: hidden;
  background: var(--code-bg);
  box-shadow: 0 6px 18px -8px rgba(26, 21, 16, 0.45);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}

.book-card:hover .book-cover,
.book-card:focus-visible .book-cover {
  transform: translateY(-4px);
  box-shadow: 0 16px 32px -12px rgba(26, 21, 16, 0.5);
}

/* Stacked look for a collection (multiple works in one physical book) */
.book-card--collection .book-cover-wrap::before,
.book-card--collection .book-cover-wrap::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 3px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  transition: transform 0.25s ease;
  z-index: 0;
}

.book-card--collection .book-cover-wrap::before {
  transform: translate(6px, 6px);
}

.book-card--collection .book-cover-wrap::after {
  transform: translate(3px, 3px);
}

.book-card--collection .book-cover {
  position: relative;
  z-index: 1;
}

.book-card--collection:hover .book-cover-wrap::before {
  transform: translate(8px, 8px);
}

.book-card--collection:hover .book-cover-wrap::after {
  transform: translate(4px, 4px);
}

.collection-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 3px 7px;
  border-radius: 20px;
  background: var(--accent);
  color: #fff;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  box-shadow: 0 2px 6px -1px rgba(26, 21, 16, 0.4);
}

.collection-badge svg {
  display: block;
}

.book-collection-note {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-light);
  font-style: italic;
}

.book-partof {
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  color: var(--text-light);
  margin-top: 5px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.book-card:hover .book-partof,
.book-card:focus-visible .book-partof {
  opacity: 1;
}

.book-partof span {
  font-style: italic;
}

.book-modal-partof {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 18px;
  margin-top: -8px;
}

.book-modal-partof span {
  font-style: italic;
}

.book-modal-partof:empty {
  display: none;
}

.book-card:focus-visible {
  outline: none;
}

.book-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Fallback cover when no image is supplied */
.book-cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border: 1px solid var(--border);
}

.book-cover--placeholder span {
  font-family: 'Lora', Georgia, serif;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-mid);
  text-align: center;
}

.book-meta {
  margin-top: 11px;
}

.book-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 4px;
}

.book-author {
  font-family: 'Inter', sans-serif;
  font-size: 13px;
  color: var(--text-light);
  margin-bottom: 7px;
}

/* Stars */
.stars {
  display: inline-flex;
  gap: 2px;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 1px;
}

.stars .star {
  color: var(--border);
}

.stars .star.filled {
  color: var(--accent);
}

.stars .star.half {
  background: linear-gradient(90deg, var(--accent) 50%, var(--border) 50%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---- Modal ---- */
.book-modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(26, 21, 16, 0.6);
  z-index: 9999;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

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

.book-modal-content {
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  max-width: 640px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 40px;
  display: flex;
  gap: 32px;
  box-shadow: 0 30px 70px -20px rgba(26, 21, 16, 0.6);
}

.book-modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 30px;
  line-height: 1;
  color: var(--text-light);
  cursor: pointer;
  padding: 4px 8px;
  transition: color 0.2s;
}

.book-modal-close:hover {
  color: var(--accent);
}

.book-modal-cover {
  flex: 0 0 150px;
}

.book-modal-cover img {
  width: 100%;
  border-radius: 3px;
  box-shadow: 0 6px 18px -8px rgba(26, 21, 16, 0.45);
  display: block;
}

.book-modal-body {
  flex: 1;
  min-width: 0;
}

.book-modal-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

.book-modal-author {
  font-family: 'Inter', sans-serif;
  font-size: 15px;
  color: var(--text-light);
  margin-bottom: 16px;
}

.book-modal-translator {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 16px;
  margin-top: -10px;
}

.book-modal-translator:empty {
  display: none;
}

.book-modal-stars {
  margin-bottom: 6px;
  font-size: 18px;
}

.book-modal-date {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-light);
  margin-bottom: 20px;
}

.book-modal-works {
  list-style: none;
  margin: 0 0 4px;
  padding: 0;
}

.book-modal-works li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}

.book-modal-works li:last-child {
  border-bottom: none;
}

.book-modal-works .work-title {
  font-family: 'Lora', Georgia, serif;
  font-size: 16px;
  color: var(--text);
}

.book-modal-works .stars {
  flex: 0 0 auto;
  font-size: 14px;
}

.book-modal-review {
  font-family: 'Lora', Georgia, serif;
  font-size: 17px;
  line-height: 1.7;
  color: var(--text-mid);
}

.book-modal-review:empty {
  display: none;
}

/* Footer (matches photos page) */
.library-container footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 60px 0 80px;
  border-top: 1px solid var(--border);
}

.library-container .footer-links {
  font-family: 'Inter', sans-serif;
  display: flex;
  gap: 28px;
  margin-bottom: 16px;
}

.library-container .footer-links a {
  color: var(--text-mid);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  transition: color 0.2s;
}

.library-container .footer-links a:hover {
  color: var(--accent);
}

.library-container .footer-note {
  font-family: 'Inter', sans-serif;
  font-size: 14px;
  color: var(--text-light);
}

/* Responsive */
@media (max-width: 768px) {
  .library-container {
    padding: 0 20px;
  }

  .page-title {
    font-size: 34px;
  }

  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 40px 24px;
  }

  .book-modal-content {
    flex-direction: column;
    padding: 32px 24px;
    gap: 20px;
  }

  .book-modal-cover {
    flex: 0 0 auto;
    width: 120px;
  }
}

@media (max-width: 480px) {
  .library-container {
    padding: 0 16px;
  }

  .page-title {
    font-size: 28px;
  }

  .book-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 32px 16px;
  }
}
