/* Layout and component styling for the personal library catalogue. */

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  transition: background-color 0.15s ease, color 0.15s ease;
}

a {
  color: var(--color-accent);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 3rem;
}

/* Header / footer */

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}

.site-title {
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--color-text);
}

#theme-toggle {
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  border-radius: 999px;
  font-size: 1.1rem;
  width: 2.5rem;
  height: 2.5rem;
  cursor: pointer;
}

.site-footer {
  text-align: center;
  color: var(--color-text-muted);
  font-size: 0.85rem;
  padding: 2rem 1rem;
}

/* Catalogue header + controls */

.catalogue-header h1 {
  margin-bottom: 0.25rem;
}

.catalogue-counts {
  color: var(--color-text-muted);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: end;
  margin: 1.5rem 0;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

#search-input {
  flex: 1 1 260px;
  padding: 0.6rem 0.8rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 1rem;
}

.controls select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface);
  color: var(--color-text);
}

.results-count {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Book grid + cards */

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-top: 1rem;
}

.book-card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  overflow: hidden;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.book-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.book-cover {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  background: var(--color-border);
}

.book-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.75rem;
}

.book-title {
  font-size: 1rem;
  margin: 0;
}

.book-author,
.book-genre,
.book-shelf {
  margin: 0;
  font-size: 0.85rem;
  color: var(--color-text-muted);
}

/* Pagination */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 2rem 0 1rem;
}

.pagination button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.9rem;
  cursor: pointer;
}

.pagination button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.pagination-status {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

/* Status badges */

.status-badge {
  display: inline-block;
  align-self: flex-start;
  margin-top: 0.4rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-available {
  background: var(--status-available-bg);
  color: var(--status-available-text);
}

.status-on-loan {
  background: var(--status-on-loan-bg);
  color: var(--status-on-loan-text);
}

.status-reserved {
  background: var(--status-reserved-bg);
  color: var(--status-reserved-text);
}

/* Book detail page */

.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  text-decoration: none;
}

.book-detail {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.book-detail-cover {
  width: 240px;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  border-radius: 0.75rem;
  border: 1px solid var(--color-border);
  flex-shrink: 0;
}

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

.book-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 1.25rem 0;
}

.book-meta dt {
  color: var(--color-text-muted);
  font-weight: 600;
}

.book-meta dd {
  margin: 0;
}

.tag-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 0;
  margin: 1rem 0;
}

.tag-pill {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.book-description {
  line-height: 1.5;
  margin: 1rem 0;
  white-space: pre-line;
}

.book-notes {
  line-height: 1.5;
}

/* Credits page */

.credits-group {
  margin: 1.5rem 0;
}

.credits-group h2 {
  font-size: 1.05rem;
  margin-bottom: 0.5rem;
}

.credits-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

/* Responsive breakpoints */

@media (max-width: 900px) {
  .book-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 600px) {
  main {
    padding: 1rem;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .book-detail {
    flex-direction: column;
  }

  .book-detail-cover {
    width: 160px;
  }
}
