.library {
  --library-gap: clamp(1.5rem, 3vw, 2.5rem);

  display: grid;
  gap: var(--library-gap);
  grid-template-columns: repeat(auto-fill, minmax(180px, 240px));
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
  justify-content: start;
}

/* Reading modal container - positioned outside normal flow */
turbo-frame#reading-modal-container {
  position: fixed;
  inset: 0;
  z-index: 9999;
  pointer-events: none;
}

turbo-frame#reading-modal-container:not(:empty) {
  pointer-events: auto;
}

/* Library Card - Just the Cover */
.library-card {
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  display: block;
  max-width: 240px;
  width: 100%;
}

.library-card__cover-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  transition: transform 300ms cubic-bezier(0.4, 0, 0.2, 1);
}

.library-card:hover .library-card__cover-wrapper {
  transform: translateY(-8px);
}

.library-card__cover {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  background: linear-gradient(135deg, 
    color-mix(in srgb, var(--color-selected) 30%, transparent) 0%, 
    color-mix(in srgb, var(--color-selected-dark) 30%, transparent) 100%);
}

.library-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

.library-card:hover .library-card__cover img {
  transform: scale(1.05);
}

.library-card__placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
  color: var(--color-ink);
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.4;
}

.library-card__placeholder span {
  display: block;
}

/* Overlay with Actions */
.library-card__overlay {
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--color-ink) 85%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 300ms cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

.library-card:hover .library-card__overlay {
  opacity: 1;
  pointer-events: auto;
}

.library-card__actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 80%;
  max-width: 180px;
  align-items: center;
}

.library-card__action-btn {
  width: 100%;
  justify-content: center;
  padding: 0.75rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
}


.library-card--new {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--color-border, rgba(15, 23, 42, 0.2)) 50%, transparent) inset;
}

.library-card__cover--empty {
  background: color-mix(in srgb, var(--color-panel, #fff) 80%, transparent);
  display: grid;
  place-items: center;
}

.library-card__new-button {
  align-items: center;
  background: var(--color-positive, #2563eb);
  border-radius: 999px;
  display: inline-flex;
  inline-size: 3rem;
  block-size: 3rem;
  justify-content: center;
  position: absolute;
  box-shadow: 0 10px 25px rgb(37 99 235 / 0.35);
}

/* Responsive */
@media (max-width: 600px) {
  .library {
    grid-template-columns: repeat(auto-fill, minmax(140px, 180px));
    gap: 1.25rem;
  }

  .library-card {
    max-width: 180px;
  }
}
