/* ==========================================================================
   BOOK GRID & CARDS
   ========================================================================== */

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

.book-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--card-border);
}

.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-book);
}

.book-card__cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: var(--bg-warm);
}

.book-card__cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(145deg, var(--bg-warm) 0%, var(--bg-inset) 100%);
  color: var(--text-faint);
  font-size: 1.5rem;
}

.book-card__cover--broken { display: none; }

.book-card__info {
  padding: var(--space-sm) 10px 10px;
}

.book-card__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 2px;
}

.book-card__authors {
  font-size: 0.6875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: var(--space-xs);
}

.book-card__date {
  font-size: 0.6875rem;
  color: var(--text-faint);
  margin-top: 4px;
}

.book-card__series {
  font-size: 0.6875rem;
  color: var(--want-to-read);
  margin-top: 2px;
  font-weight: 500;
}

/* --- Rating Bar --- */

.book-card__rating { margin-top: 6px; }

.rating-bar {
  height: 3px;
  background: var(--bg-inset);
  border-radius: 2px;
  overflow: hidden;
}

.rating-bar__fill {
  height: 100%;
  background: var(--rated);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.rating-bar__label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  color: var(--rated);
  margin-top: 2px;
  display: block;
  font-weight: 600;
}

/* --- Progress Bar --- */

.book-card__progress { margin-top: 6px; }

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

.progress-bar__fill {
  height: 100%;
  background: var(--reading);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.progress-bar__fill--complete {
  background: var(--completed);
}

.progress-bar__label {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

/* --- Book Card Badges --- */

.book-card__badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.book-card__badge {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  color: var(--text-muted);
  background: var(--bg-warm);
  padding: 1px 5px;
  border-radius: 3px;
  white-space: nowrap;
}

.book-card__badge--notes { color: var(--accent); }
.book-card__badge--reread { color: var(--reread); }

.book-card__pace {
  font-family: var(--font-mono);
  font-size: 0.5625rem;
  color: var(--reading);
  margin-top: 2px;
}

/* --- Search Toolbar --- */

.list-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  flex-wrap: wrap;
  margin-bottom: var(--space-md);
}

.list-sort {
  font-family: var(--font-body);
  font-size: 0.8125rem;
  color: var(--text);
  background: var(--bg-surface);
  border: 1px solid var(--bg-inset);
  border-radius: var(--radius-sm);
  padding: 8px var(--space-md);
  cursor: pointer;
}

.list-sort:focus { outline: none; border-color: var(--accent); }

.list-search {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-surface);
  border: 1px solid var(--bg-inset);
  border-radius: var(--radius-md);
  padding: 8px var(--space-md);
  width: 100%;
  max-width: 360px;
  transition: var(--transition);
}

.list-search:focus {
  outline: none;
  border-color: var(--accent);
}

.list-search::placeholder {
  color: var(--text-faint);
}

/* book-card-wrap: transparent grid container for search filtering */

/* --- Series Group --- */

.series-group {
  margin-bottom: var(--space-xl);
}

.series-group__header {
  display: flex;
  align-items: baseline;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--bg-inset);
}

.series-group__name {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  font-variation-settings: 'opsz' 20;
}

.series-group__count {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.series-group__books {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: var(--space-sm);
}

/* --- Modal Reading Sessions --- */

.modal-book__sessions {
  margin-top: var(--space-md);
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.modal-book__sessions strong {
  color: var(--text);
  display: block;
  margin-bottom: var(--space-xs);
}

.modal-book__sessions ul {
  list-style: none;
  padding: 0;
}

.modal-book__sessions li {
  padding: 4px 0;
  border-bottom: 1px solid var(--bg-warm);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

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

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

/* ==========================================================================
   DNF LIST
   ========================================================================== */

.dnf-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.dnf-item {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--dnf);
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}

.dnf-item:hover { box-shadow: var(--shadow-md); }

.dnf-item__cover {
  width: 32px;
  height: 48px;
  object-fit: cover;
  border-radius: 2px;
  flex-shrink: 0;
}

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

.dnf-item__info { flex: 1; min-width: 0; }

.dnf-item__title {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
}

.dnf-item__authors {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.dnf-item__reason {
  font-size: 0.75rem;
  color: var(--dnf);
  font-style: italic;
  margin-top: 2px;
}

.dnf-item__date {
  font-size: 0.6875rem;
  color: var(--text-faint);
  flex-shrink: 0;
}

/* --- Book Actions --- */

.book-card-actionable {
  display: flex;
  flex-direction: column;
}

.book-card-actionable .book-card {
  flex: 1;
}

.book-actions {
  display: flex;
  gap: 4px;
  padding: 6px 6px 4px;
  background: var(--bg-surface);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border: 1px solid var(--card-border);
  border-top: none;
  margin-top: -1px;
}

.book-action {
  flex: 1;
  font-family: var(--font-body);
  font-size: 0.625rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-warm);
  border: none;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.book-action:hover {
  color: var(--accent);
  background: var(--accent-light);
}

.book-action--complete {
  color: var(--completed);
}

.book-action--complete:hover {
  color: #fff;
  background: var(--completed);
}

/* --- Action Modals --- */

.action-modal {
  max-width: 400px;
}

.action-modal h3 {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  margin-bottom: var(--space-md);
  font-variation-settings: 'opsz' 24;
  line-height: 1.3;
}

.action-modal__hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

.action-modal__field {
  margin-bottom: var(--space-md);
}

.action-modal__field label {
  display: block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.action-modal__input {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-surface);
  border: 1px solid var(--bg-inset);
  border-radius: var(--radius-sm);
  padding: 8px var(--space-md);
  width: 100%;
}

.action-modal__input:focus {
  outline: none;
  border-color: var(--accent);
}

.action-modal__textarea {
  font-family: var(--font-body);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--bg-surface);
  border: 1px solid var(--bg-inset);
  border-radius: var(--radius-sm);
  padding: var(--space-sm) var(--space-md);
  width: 100%;
  min-height: 120px;
  resize: vertical;
  line-height: 1.6;
}

.action-modal__textarea--short {
  min-height: 60px;
}

.action-modal__textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.action-modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: var(--space-md);
}

.action-modal__counter {
  font-family: var(--font-mono);
  font-size: 0.6875rem;
  color: var(--text-faint);
}

.action-modal__actions {
  display: flex;
  gap: var(--space-sm);
}

/* Rating grid */

.rate-grid {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rate-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-warm);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.rate-btn:hover {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}

.rate-btn--current {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-light);
}

/* Book page actions */

.book-page__actions {
  margin-top: var(--space-md);
}

/* Accent button variant */

.btn--accent {
  color: #fff;
  background: var(--accent);
  border: none;
}

.btn--accent:hover {
  background: var(--accent-hover);
}

/* --- Add Book Search --- */

.add-book-modal {
  max-width: 560px;
}

.add-book-search {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.add-book-search .action-modal__input {
  flex: 1;
}

.search-results__interpreted {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
  font-style: italic;
}

.search-results__interpreted strong {
  color: var(--accent);
  font-style: normal;
}

.search-results {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 400px;
  overflow-y: auto;
}

.search-result {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-inset);
  transition: var(--transition);
}

.search-result:hover {
  background: var(--bg-warm);
}

.search-result__cover {
  width: 48px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.search-result__cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-inset);
  color: var(--text-faint);
  font-size: 1rem;
}

.search-result__info {
  flex: 1;
  min-width: 0;
}

.search-result__title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.search-result__authors {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.search-result__meta {
  font-size: 0.6875rem;
  color: var(--text-faint);
  margin-top: 2px;
}

.search-result__actions {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
  justify-content: center;
}

.search-result__actions .btn {
  font-size: 0.625rem;
  padding: 4px 8px;
  white-space: nowrap;
}

/* --- DNF Button --- */

.book-action--dnf {
  color: var(--dnf);
}

.book-action--dnf:hover {
  color: #fff;
  background: var(--dnf);
}

/* --- Remove Button (inline on cards) --- */

.book-action--remove {
  flex: 0;
  min-width: 24px;
  color: var(--text-faint);
  font-size: 0.875rem;
  font-weight: bold;
}

.book-action--remove:hover {
  color: var(--dnf);
  background: rgba(184, 84, 80, 0.1);
}

.book-card-removable {
  position: relative;
}

.remove-book-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: bold;
  color: var(--text-faint);
  background: var(--bg-surface);
  border: 1px solid var(--card-border);
  border-radius: 50%;
  cursor: pointer;
  opacity: 0;
  transition: var(--transition);
  z-index: 2;
  line-height: 1;
  padding: 0;
}

.book-card-removable:hover .remove-book-btn,
.remove-book-btn:focus {
  opacity: 1;
}

.remove-book-btn:hover {
  color: #fff;
  background: var(--dnf);
  border-color: var(--dnf);
}

.remove-book-btn--inline {
  position: static;
  opacity: 0;
  flex-shrink: 0;
}

.dnf-item:hover .remove-book-btn--inline {
  opacity: 1;
}

/* --- Export Dropdown --- */

.export-dropdown {
  position: relative;
  display: inline-block;
}

.export-dropdown__menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  background: var(--bg-surface);
  border: 1px solid var(--bg-inset);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 10;
  min-width: 80px;
}

.export-dropdown--open .export-dropdown__menu {
  display: block;
}

.export-dropdown__item {
  display: block;
  padding: 8px 16px;
  font-size: 0.8125rem;
  color: var(--text);
  text-decoration: none;
  transition: var(--transition);
}

.export-dropdown__item:hover {
  background: var(--bg-warm);
  color: var(--accent);
}

/* --- Recommendations --- */

.recommendations {
  margin-top: var(--space-xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--bg-inset);
}

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

.book-card__rec-reason {
  font-size: 0.625rem;
  color: var(--want-to-read);
  font-style: italic;
  margin-top: 4px;
  line-height: 1.3;
}

/* --- Batch Rate --- */

.batch-rate {
  max-width: 400px;
  text-align: center;
}

.batch-rate__progress {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: var(--space-sm);
}

.batch-rate__progress-bar {
  height: 3px;
  background: var(--bg-inset);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: var(--space-lg);
}

.batch-rate__progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}

.batch-rate__book {
  display: flex;
  gap: var(--space-lg);
  text-align: left;
  margin-bottom: var(--space-lg);
}

.batch-rate__cover {
  width: 100px;
  height: 150px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  box-shadow: var(--shadow-book);
}

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

.batch-rate__info {
  flex: 1;
  min-width: 0;
}

.batch-rate__title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  font-variation-settings: 'opsz' 24;
}

.batch-rate__authors {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.batch-rate__date {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 4px;
}

.batch-rate__actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-md);
}

/* --- Challenge Join --- */

.challenge-card__join {
  margin: var(--space-sm) 0;
}
