/* HW Library — shelf grid, built on the main styles.css variables. */
.library-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  grid-auto-rows: 1fr;
  gap: 2.5rem 2rem;
  margin-top: 2rem;
}

.library-card {
  display: grid;
  grid-template-rows: 1fr auto;
  gap: 1rem;
}

.library-card > .library-cover-link {
  align-self: end;
}

.library-cover-link {
  display: block;
  border: 0;
  text-decoration: none;
  background: transparent;
  position: relative;
  isolation: isolate;
  line-height: 0;
}

.library-cover-link::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.42) 0%,
      rgba(0, 0, 0, 0.22) 1.2%,
      rgba(0, 0, 0, 0.05) 2.4%,
      rgba(255, 255, 255, 0.22) 3.4%,
      rgba(255, 255, 255, 0.08) 4.6%,
      rgba(0, 0, 0, 0) 7%,
      rgba(0, 0, 0, 0) 93%,
      rgba(0, 0, 0, 0.06) 96%,
      rgba(0, 0, 0, 0.18) 98.5%,
      rgba(0, 0, 0, 0.3) 100%
    ),
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.14) 0%,
      rgba(0, 0, 0, 0) 1.8%,
      rgba(0, 0, 0, 0) 98%,
      rgba(0, 0, 0, 0.18) 100%
    );
}

.library-cover-link::after {
  content: "";
  position: absolute;
  top: 1%;
  bottom: 1%;
  right: -2px;
  width: 3px;
  background: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.25) 0%,
    rgba(180, 170, 150, 0.5) 40%,
    rgba(120, 110, 95, 0.7) 100%
  );
  border-radius: 0 1px 1px 0;
  pointer-events: none;
  z-index: 0;
}

.library-cover {
  width: 100%;
  height: auto;
  display: block;
  border: 0;
  background: transparent;
  box-shadow:
    0 1px 1px rgba(0, 0, 0, 0.18),
    0 2px 4px rgba(0, 0, 0, 0.14),
    0 10px 22px rgba(0, 0, 0, 0.22);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  position: relative;
  z-index: 1;
}

.library-cover-link:hover .library-cover,
.library-cover-link:focus-visible .library-cover {
  transform: translateY(-4px);
  box-shadow:
    0 2px 2px rgba(0, 0, 0, 0.2),
    0 6px 10px rgba(0, 0, 0, 0.18),
    0 16px 32px rgba(0, 0, 0, 0.28);
}

.library-cover-link--empty .library-cover--empty {
  aspect-ratio: 3 / 4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 3rem;
  color: var(--muted);
  background: var(--panel);
  letter-spacing: -0.04em;
  font-weight: 400;
  width: 100%;
}

.library-text {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.library-title {
  font-size: 1.15rem;
  line-height: 1.25;
  margin: 0.1rem 0 0;
  font-weight: 400;
  letter-spacing: -0.015em;
}

.library-title a {
  text-decoration: none;
}

.library-title a:hover,
.library-title a:focus-visible {
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.library-year {
  color: var(--muted);
  font-size: 0.95rem;
}

.library-author {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.library-desc {
  margin: 0.4rem 0 0.6rem;
  font-size: 0.98rem;
  line-height: 1.5;
  max-width: none;
}

.library-meta {
  margin: 0;
}

.library-count {
  color: var(--muted);
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.text-link {
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid var(--line);
  padding-bottom: 2px;
  align-self: start;
}

.text-link:hover,
.text-link:focus-visible {
  color: var(--ink);
  border-bottom-color: var(--ink);
}

@media (max-width: 720px) {
  .library-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 2.25rem 1.25rem;
  }

  .library-card {
    gap: 0.55rem;
  }

  .library-cover {
    border: 0;
    box-shadow:
      0 1px 1px rgba(0, 0, 0, 0.2),
      0 3px 6px rgba(0, 0, 0, 0.18),
      0 10px 22px rgba(0, 0, 0, 0.24);
  }

  .library-text {
    gap: 0.15rem;
  }

  .library-meta,
  .library-desc,
  .library-text .text-link {
    display: none;
  }

  .library-title {
    font-size: 0.92rem;
    line-height: 1.2;
    margin: 0.35rem 0 0;
  }

  .library-year {
    display: none;
  }

  .library-author {
    font-size: 0.82rem;
  }
}

@media (max-width: 380px) {
  .library-grid {
    gap: 1.75rem 0.9rem;
  }

  .library-title {
    font-size: 0.85rem;
  }

  .library-author {
    font-size: 0.78rem;
  }
}
