/* Add microinteractions to library page */

/* Clear button styling */
#lib-clear {
  margin-left: 0.5rem;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

#lib-clear:hover {
  opacity: 1;
}

/* Button ripple effect */
.library-add-btn {
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, background-color 0.2s ease;
}

.library-add-btn:active {
  transform: scale(0.95);
}

.ripple {
  position: absolute;
  border-radius: 50%;
  transform: scale(0);
  animation: ripple 0.6s linear;
  background-color: rgba(255, 255, 255, 0.7);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  @keyframes ripple {
    to {
      transform: scale(4);
      opacity: 0;
    }
  }
}

/* Confetti animation for adding to list */
.confetti-piece {
  position: fixed;
  font-size: 20px;
  pointer-events: none;
  z-index: 1000;
}

@media (prefers-reduced-motion: no-preference) {
  .confetti-piece {
    animation: confetti-fall 1.5s ease-out forwards;
  }

  @keyframes confetti-fall {
    0% { transform: translateY(0) rotate(0deg); opacity: 1; }
    100% { transform: translateY(100vh) rotate(720deg); opacity: 0; }
  }
}

@media (prefers-reduced-motion: reduce) {
  .confetti-piece {
    animation: none;
    opacity: 0.5;
  }
}

/* Index grid layout */
.lib-index-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.lib-index-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  rotate: var(--tilt, 0deg);
}

.lib-index-btn:hover {
  transform: translateY(-4px);
  box-shadow: 6px 8px 0 var(--shadow);
}

.lib-index-btn:active {
  transform: scale(0.95);
}

.lib-index-letter {
  font-size: 24px;
  font-weight: bold;
  margin-bottom: 6px;
  color: var(--accent);
}

.lib-index-count {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

/* Recent entries grid */
.lib-recent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin: 16px 0;
}

.lib-recent-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  rotate: var(--tilt, 0deg);
}

.lib-recent-item:hover {
  transform: translateY(-4px);
  box-shadow: 6px 8px 0 var(--shadow);
}

.lib-recent-item:active {
  transform: scale(0.95);
}

.lib-recent-img {
  width: 80px;
  height: 120px;
  background: var(--accent-soft);
  border-radius: 8px;
  margin-bottom: 8px;
  object-fit: cover;
}

.lib-recent-title {
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
  line-height: 1.2;
}

.lib-recent-author {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
}

/* Draggable list items */
.lib-list-item {
  cursor: grab;
  transition: background-color 0.2s, box-shadow 0.2s;
  padding: 12px;
  border-radius: 8px;
  background: var(--card);
  border: 3px solid var(--ink);
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 44px;
}

.lib-list-item:hover {
  transform: translateY(-2px);
  box-shadow: 4px 6px 0 var(--shadow);
}

.lib-list-item:active {
  cursor: grabbing;
  transform: scale(0.98);
}

.lib-list-item.dragging {
  opacity: 0.5;
  background-color: var(--accent-soft);
  box-shadow: none;
}

.lib-list-star {
  font-size: 12px;
  opacity: 0.8;
}

.lib-list-author {
  font-size: 13px;
  color: var(--muted);
}

.lib-list-status {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  display: inline-block;
  width: fit-content;
}

.lib-list-progress {
  margin-top: 4px;
}

.lib-list-progress-bar {
  height: 6px;
  background: var(--muted);
  border-radius: 3px;
  overflow: hidden;
}

.lib-list-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
}

.lib-list-progress-text {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.lib-list-link {
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
}

.lib-list-link:hover {
  text-decoration: underline;
}

.lib-list-remove {
  align-self: flex-start;
  padding: 4px 8px;
  font-size: 12px;
  opacity: 0.6;
  background: none;
  border: 2px solid var(--ink);
  border-radius: 4px;
  cursor: pointer;
}

.lib-list-remove:hover {
  opacity: 1;
  background: var(--accent-soft);
}

/* Progress bar on book cards */
.library-progress {
  margin-top: 12px;
  padding-top: 8px;
  border-top: 1px solid var(--ink);
}

.library-progress-bar {
  height: 8px;
  background: var(--muted);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.library-progress-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s ease;
  border-radius: 4px;
}

.library-progress-label {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
}

/* Modal */
.library-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.library-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.library-modal-content {
  position: relative;
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 16px;
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: 12px 16px 0 var(--shadow);
}

.library-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--bg);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, transform 0.2s;
}

.library-modal-close:hover {
  background: var(--accent-soft);
  transform: rotate(90deg);
}

.library-modal-spine {
  width: 100%;
  height: 8px;
  border-radius: 4px;
  margin-bottom: 16px;
}

.library-modal-title {
  margin: 0 0 4px;
  font-size: 22px;
  line-height: 1.3;
}

.library-modal-author {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 15px;
}

.library-modal-meta {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--muted);
}

.library-modal-blurb {
  margin: 0 0 20px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.library-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-status-select,
.library-progress-slider,
.library-notes-textarea {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--bg);
  color: var(--fg);
  font-family: inherit;
  font-size: 14px;
}

.library-progress-input label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--muted);
}

.library-notes-input label {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--muted);
}

.library-notes-textarea {
  min-height: 80px;
  resize: vertical;
}

/* Stats panel */
.library-stats-panel {
  background: var(--card);
  border: 3px solid var(--ink);
  border-radius: 12px;
  padding: 16px;
  margin-top: 16px;
}

.library-stats-summary {
  cursor: pointer;
  font-weight: bold;
  font-size: 16px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-stats-summary::-webkit-details-marker {
  display: none;
}

.library-stats-summary::before {
  content: '▸';
  transition: transform 0.2s;
  display: inline-block;
}

.library-stats-panel[open] .library-stats-summary::before {
  transform: rotate(90deg);
}

.library-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 12px;
  margin: 16px 0;
}

.library-stat {
  text-align: center;
  padding: 12px;
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: 8px;
}

.library-stat-value {
  display: block;
  font-size: 24px;
  font-weight: bold;
  color: var(--accent);
  line-height: 1;
}

.library-stat-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.library-goals {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--ink);
}

.library-goals h4 {
  margin: 0 0 12px;
  font-size: 14px;
}

.library-goal {
  margin-bottom: 12px;
}

.library-goal-label {
  display: block;
  font-size: 12px;
  margin-bottom: 4px;
  color: var(--muted);
}

.library-goal-bar {
  height: 8px;
  background: var(--muted);
  border-radius: 4px;
  overflow: hidden;
}

.library-goal-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.3s ease;
}

.library-genre-breakdown {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--ink);
}

.library-genre-breakdown h4 {
  margin: 0 0 8px;
  font-size: 14px;
}

.library-genre-tag {
  display: inline-block;
  padding: 4px 10px;
  margin: 2px 4px 2px 0;
  background: var(--accent-soft);
  border: 2px solid var(--ink);
  border-radius: 999px;
  font-size: 11px;
  color: var(--fg);
}

.library-import-export {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 2px solid var(--ink);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.lib-import-label {
  position: relative;
  cursor: pointer;
}

.lib-import-label input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* Import/Export buttons use controls__btn styles */
