/* mira's library - soft, playful, clean */

:root {
  --bg: #faf8f5;
  --card-bg: #ffffff;
  --text: #3d3d3d;
  --text-light: #6b6b6b;
  --accent: #e8b4b8; /* soft pink */
  --accent-hover: #dfa0a5;
  --sage: #b8c9b8; /* soft green */
  --lavender: #c5b8d9; /* soft purple */
  --peach: #f5d5c8; /* soft peach */
  --sky: #b8d4e3; /* soft blue */
  --shadow: rgba(0, 0, 0, 0.06);
  --shadow-hover: rgba(0, 0, 0, 0.1);
  --border-radius: 16px;
  --border-radius-sm: 8px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Nunito', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* header */
header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.subtitle {
  color: var(--text-light);
  font-size: 1.1rem;
}

/* category sections */
.category-section {
  margin-bottom: 3rem;
}

.category-header {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.25rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--peach);
}

.category-subtitle {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* books grid */
.books-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 1.5rem;
}

/* book card */
.book-card {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1rem;
  box-shadow: 0 4px 12px var(--shadow);
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.book-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px var(--shadow-hover);
}

.book-cover.placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--text-light);
}

.book-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.book-author {
  font-size: 0.8rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.book-mira-name {
  font-size: 0.75rem;
  color: var(--accent);
  font-style: italic;
  margin-bottom: 0.5rem;
}

.book-stats {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.stat {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--border-radius-sm);
  background: var(--bg);
  color: var(--text-light);
}

.status-badge {
  background: var(--sage);
  color: var(--text);
}

.status-badge.current_favorite {
  background: var(--accent);
  color: white;
}

.status-badge.currently_reading {
  background: var(--sage);
}

.status-badge.all_time_classic {
  background: var(--sky);
  color: var(--text);
}

.status-badge.read_50_plus {
  background: var(--lavender);
}

.status-badge.not_a_fan {
  background: var(--peach);
}

/* series badge */
.series-badge {
  font-size: 0.65rem;
  padding: 0.15rem 0.4rem;
  border-radius: var(--border-radius-sm);
  background: var(--lavender);
  color: var(--text);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* loading state - blur to clear */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-text {
  color: var(--text-light);
  font-size: 1rem;
  animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* blur-to-clear effect for book covers */
.book-cover {
  width: 120px;
  height: 160px;
  object-fit: cover;
  border-radius: var(--border-radius-sm);
  margin-bottom: 0.75rem;
  background: var(--peach);
  transition: filter 0.4s ease;
}

.book-cover.loading {
  filter: blur(10px);
}

.book-cover.loaded {
  filter: blur(0);
}

/* recommendation badges */
.rec-status {
  margin-top: 0.5rem;
  padding: 0.25rem 0.75rem;
  border-radius: var(--border-radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.rec-status.yay {
  background: var(--sage);
  color: var(--text);
}

.rec-status.nay {
  background: var(--peach);
  color: var(--text);
}

/* modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal.active {
  display: flex;
}

.modal-content {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--text-light);
  transition: color 0.2s;
}

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

.modal-body {
  display: flex;
  gap: 1.5rem;
}

.modal-cover {
  flex-shrink: 0;
}

.modal-cover img {
  width: 150px;
  height: 200px;
  object-fit: cover;
  border-radius: var(--border-radius-sm);
  background: var(--peach);
}

.modal-info {
  flex: 1;
}

.modal-info h2 {
  font-size: 1.5rem;
  margin-bottom: 0.25rem;
}

.modal-author {
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.modal-mira-name {
  color: var(--accent);
  font-style: italic;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.modal-stats {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.modal-notes-section label,
.modal-recommendation-section label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-light);
}

.modal-notes-section textarea,
.modal-recommendation-section textarea {
  width: 100%;
  min-height: 80px;
  padding: 0.75rem;
  border: 2px solid var(--bg);
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  resize: vertical;
  transition: border-color 0.2s;
}

.modal-notes-section textarea:focus,
.modal-recommendation-section textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.save-notes-btn {
  margin-top: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--sage);
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.save-notes-btn:hover {
  background: var(--accent);
  color: white;
}

/* yay/nay buttons */
.yay-nay-buttons {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.yay-btn, .nay-btn {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.yay-btn {
  background: var(--sage);
  color: var(--text);
}

.yay-btn:hover, .yay-btn.active {
  background: #8fb08f;
  color: white;
}

.nay-btn {
  background: var(--peach);
  color: var(--text);
}

.nay-btn:hover, .nay-btn.active {
  background: #e6a896;
  color: white;
}

/* add book button */
.add-book-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  padding: 1rem 1.5rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--border-radius);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 12px var(--shadow-hover);
  transition: all 0.2s;
}

.add-book-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
}

/* add book form */
#add-modal .modal-content {
  max-width: 500px;
}

#add-modal h2 {
  margin-bottom: 1.5rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.25rem;
  color: var(--text-light);
  font-size: 0.9rem;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--bg);
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-group textarea {
  min-height: 60px;
  resize: vertical;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.checkbox-group input {
  width: auto;
}

.checkbox-group label {
  margin-bottom: 0;
}

.submit-btn {
  width: 100%;
  padding: 0.75rem;
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--border-radius-sm);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

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

/* empty state */
.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
}

/* responsive - tablet */
@media (max-width: 768px) {
  .books-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 1rem;
  }
}

/* responsive - mobile: one book at a time with color strip */
@media (max-width: 480px) {
  header h1 {
    font-size: 1.75rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .category-section {
    margin-bottom: 2rem;
  }

  .category-header {
    font-size: 1.1rem;
    text-align: center;
    border-bottom: none;
    margin-bottom: 0.5rem;
  }

  .category-subtitle {
    font-size: 0.75rem;
    text-align: center;
    margin-bottom: 1rem;
  }

  /* horizontal scroll for books - one at a time */
  .books-grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    gap: 1rem;
    padding: 0.5rem 0 1rem 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .books-grid::-webkit-scrollbar {
    display: none;
  }

  /* book card with color strip */
  .book-card {
    flex: 0 0 calc(100vw - 3rem);
    scroll-snap-align: center;
    padding: 1rem;
    border-radius: var(--border-radius);
    position: relative;
    overflow: hidden;
  }

  /* color strip at bottom */
  .book-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: var(--peach);
  }

  /* category-specific color strips */
  #grid-current-favorites .book-card::after {
    background: var(--accent);
  }

  #grid-currently-reading .book-card::after {
    background: var(--sage);
  }

  #grid-all-time-classics .book-card::after {
    background: var(--sky);
  }

  #grid-read-50-plus .book-card::after {
    background: var(--lavender);
  }

  #grid-not-a-fan .book-card::after {
    background: var(--peach);
  }

  #grid-recommendations .book-card::after {
    background: var(--sage);
  }

  .book-cover {
    width: 140px;
    height: 190px;
  }

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

  .book-author {
    font-size: 0.85rem;
  }

  .book-mira-name {
    font-size: 0.8rem;
  }

  .modal-body {
    flex-direction: column;
    align-items: center;
  }

  .modal-info {
    text-align: center;
  }

  .modal-stats {
    justify-content: center;
  }

  .add-book-btn {
    bottom: 1rem;
    right: 1rem;
    padding: 0.75rem 1rem;
  }
}
