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

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(6px);
  justify-content: center;
  align-items: center;
  padding: var(--space-lg);
}

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

.modal {
  position: relative;
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: var(--space-xl);
}

.modal__close {
  position: absolute;
  top: var(--space-md);
  right: var(--space-md);
  font-size: 1.25rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--space-sm);
  line-height: 1;
  z-index: 1;
  transition: var(--transition);
}

.modal__close:hover { color: var(--text); }

/* --- Modal Book Detail --- */

.modal-book__top {
  display: flex;
  gap: var(--space-xl);
}

.modal-book__cover {
  width: 180px;
  min-height: 270px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: var(--shadow-book);
}

.modal-book__cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-warm);
  color: var(--text-faint);
  font-size: 2rem;
}

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

.modal-book__title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: var(--space-sm);
  font-variation-settings: 'opsz' 36;
}

.modal-book__authors {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-md);
}

.modal-book__detail {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
  line-height: 1.5;
}

.modal-book__detail strong { color: var(--text); }

.modal-book__categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--space-sm) 0;
}

.modal-book__notes,
.modal-book__description {
  margin-top: var(--space-md);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

.modal-book__notes strong,
.modal-book__description strong {
  color: var(--text);
  display: block;
  margin-bottom: 4px;
}

/* ==========================================================================
   TOAST
   ========================================================================== */

#toast-container {
  position: fixed;
  top: var(--space-lg);
  right: var(--space-lg);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px 14px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-inset);
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  color: var(--text);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(16px);
  transition: all 0.3s ease;
  cursor: pointer;
}

.toast--visible { opacity: 1; transform: translateX(0); }
.toast--error { border-color: var(--dnf); }
.toast--success { border-color: var(--completed); }
.toast__icon { font-weight: bold; }

/* ==========================================================================
   BOOK PAGE
   ========================================================================== */

.book-page {
  max-width: 800px;
}

.book-page__hero {
  display: flex;
  gap: var(--space-xl);
  margin-top: var(--space-lg);
  margin-bottom: var(--space-xl);
}

.book-page__cover {
  width: 200px;
  min-height: 300px;
  object-fit: cover;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  box-shadow: var(--shadow-book);
}

.book-page__cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-warm);
  color: var(--text-faint);
  font-size: 2.5rem;
}

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

.book-page__title {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 500;
  line-height: 1.2;
  margin-bottom: var(--space-sm);
  font-variation-settings: 'opsz' 48;
}

.book-page__authors {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-bottom: var(--space-lg);
}

.book-page__meta-item {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.book-page__meta-item strong {
  color: var(--text);
}

.book-page__categories {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--space-md) 0;
}

.book-page__stats {
  display: flex;
  gap: var(--space-xl);
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--bg-inset);
}

.book-page__stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.book-page__stat-value {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--text);
  font-variation-settings: 'opsz' 36;
}

.book-page__stat-label {
  font-size: 0.6875rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.book-page__description {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  margin-bottom: var(--space-xl);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--card-border);
  font-size: 0.875rem;
  color: var(--text-secondary);
  line-height: 1.7;
}

/* Readers section */
.book-page__readers {
  margin-bottom: var(--space-xl);
}

.book-page__section-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: var(--space-md);
  font-variation-settings: 'opsz' 24;
}

.book-page__reader {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: var(--space-md) var(--space-lg);
  margin-bottom: var(--space-sm);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--card-border);
}

.book-page__reader-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.book-page__reader-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
}

.book-page__reader-avatar--placeholder {
  background: var(--bg-inset);
}

.book-page__reader-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}

.book-page__reader-name:hover {
  color: var(--accent);
}

.book-page__reader-status {
  font-size: 0.75rem;
  font-weight: 500;
}

.book-page__reader-rating {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--rated);
  font-weight: 600;
}

.book-page__reader-date {
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-left: auto;
}

.book-page__reader-reason {
  font-size: 0.75rem;
  color: var(--dnf);
  font-style: italic;
}

.book-page__reader-notes {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid var(--bg-warm);
  font-size: 0.8125rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-style: italic;
}

/* Clickable author links */

.book-page__author-link {
  cursor: pointer;
  transition: var(--transition);
}

.book-page__author-link:hover {
  color: var(--accent);
  text-decoration: underline;
}

/* Related books (series & author) */

.book-page__series-section,
.book-page__related {
  margin-bottom: var(--space-xl);
}

.book-page__related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: var(--space-md);
}

.book-page__related-item {
  cursor: pointer;
  text-align: center;
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  transition: var(--transition);
}

.book-page__related-item:hover {
  background: var(--bg-hover);
}

.book-page__related-item--current {
  background: var(--accent-light);
  border: 1px solid var(--accent-medium);
}

.book-page__related-cover {
  width: 80px;
  height: 120px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  margin: 0 auto var(--space-xs);
  display: block;
}

.book-page__related-cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-warm);
  color: var(--text-faint);
  font-size: 1.25rem;
}

.book-page__related-title {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.book-page__related-meta {
  font-size: 0.625rem;
  color: var(--text-muted);
  margin-top: 2px;
}

@media (max-width: 768px) {
  .book-page__hero {
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
  }
  .book-page__cover {
    width: 160px;
    min-height: 240px;
  }
  .book-page__title { font-size: 1.375rem; }
  .book-page__stats { gap: var(--space-lg); }
}
