#library {
  --library-display: var(--header-font, 'Roboto Condensed', 'Arial Narrow', sans-serif);
  --library-rule: #a8b8ab;
  --library-inset-line: #a4bca45c;
  padding-block: clamp(16px, 2.75vw, 30px) 30px;
}

#library .library-heading {
  display: flex;
  flex-flow: row wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 18px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--library-rule);
}

#library .library-heading h1 {
  font: 500 clamp(2.65rem, 6vw, 5.1rem)/.98 var(--library-display);
  letter-spacing: -.045em;
}

.library-heading-actions {
  display: flex;
  flex: 0 1 246px;
  justify-content: flex-end;
  min-width: 0;
  margin-inline-start: auto;
}

#library .library-search {
  width: 100%;
  min-height: 42px;
  padding-inline: 10px;
  border-color: var(--library-rule);
}

#library .library-search:focus-within { border-color: var(--forest); }

#library .featured {
  position: relative;
  isolation: isolate;
  grid-template-columns: minmax(0, 1.06fr) minmax(0, 1fr);
  min-height: clamp(395px, 43vw, 528px);
  overflow: hidden;
  border: 1px solid #274135;
  border-radius: var(--radius);
  background: #14271e;
}
#library .featured::before {
  position: absolute;
  z-index: -1;
  inset: 0;
  background:
    linear-gradient(90deg, #091b13eb 0%, #0d2018b5 31%, #12251c32 59%, #13271e12 100%),
    linear-gradient(0deg, #0c1d17ab, #0c1d1700 40%),
    url('./assets/night-ridge.jpg') 70% 57% / cover;
  content: '';
}

#library .featured-copy {
  align-items: flex-start;
  padding: clamp(28px, 5.7vw, 76px);
  color: var(--paper);
}

#library .featured h2 {
  max-width: 15ch;
  font: 500 clamp(3rem, 6.3vw, 6.25rem)/.96 var(--library-display);
  letter-spacing: -.04em;
  text-wrap: pretty;
}

#library .featured-details {
  align-items: center;
  gap: 6px 12px;
  margin-top: 9px;
  color: #d3e1d2;
}

#library .featured-author { font-size: .9rem; line-height: 1.4; }
#library .featured-kind {
  border-color: var(--library-inset-line);
  background: #e4f2db1a;
  color: #e3f0df;
}

.featured-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  width: 100%;
  margin-top: clamp(18px, 3vw, 33px);
}

#library .featured .button {
  margin: 0;
  min-height: 46px;
  padding-inline: 17px;
  border-color: transparent;
  background: var(--paper);
  color: var(--dark);
  font-size: .87rem;
}

#library .featured .button:enabled:hover { background: var(--lime); }
#library .featured .button:focus-visible { outline-color: var(--lime); }

#library .featured-showcase {
  grid-row: auto;
  min-height: 320px;
  padding: 36px 30px 43px;
  background: transparent;
  --book-height: clamp(225px, 26vw, 350px);
  --book-depth: 34px;
}

#library .featured-showcase::before {
  width: min(92%, 435px);
  border: 0;
  background: radial-gradient(ellipse at center, #ebf5ce22 0%, #dbe9c511 43%, transparent 69%);
}
#library .featured-showcase::after { display: none; }
#library .featured-showcase .book-model::before { box-shadow: 17px 28px 32px #08150fa8; }
#library .featured-showcase:focus-visible { outline-color: var(--lime); }
#library .shelf { margin-top: clamp(25px, 4vw, 42px); }
#library .shelf h2 { font: 600 clamp(1.45rem, 2.3vw, 2rem)/1.07 var(--library-display); letter-spacing: -.025em; }
#library .book-list {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 154px), 1fr));
  gap: 12px;
  margin-top: 11px;
}
.book-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border: 1px solid var(--frame);
  border-radius: var(--radius);
  background: var(--paper);
}
.book-card:focus-within { border-color: #809787; }
.book-card-open {
  display: grid;
  flex: 1;
  align-content: start;
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
}
.book-card-preview {
  display: grid;
  place-items: center;
  padding: 16px 10px 21px;
  overflow: hidden;
  perspective: 640px;
  border-bottom: 1px solid var(--frame);
  background: radial-gradient(ellipse at 47% 36%, #f3f7ee 0%, #e1eadf 75%);
  --book-height: 131px;
  --book-depth: 16px;
}
.book-card .book-meta { padding: 11px 12px 12px; }
.restore-cover {
  align-self: start;
  min-height: 36px;
  padding: 4px 0;
  border: 0;
  background: transparent;
  font-size: .82rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.featured-actions .restore-cover { align-self: center; color: #e3f0df; }
.featured-actions .restore-cover:focus-visible { outline-color: var(--lime); }
.book-card .restore-cover { margin: -3px 12px 6px; color: var(--forest); }

.book-model {
  --book-half-depth: calc(var(--book-depth) / 2);
  position: relative;
  display: block;
  height: var(--book-height);
  aspect-ratio: var(--book-ratio, .71);
  transform-style: preserve-3d;
  transform: rotateX(8deg) rotateY(-28deg);
  transition: transform 220ms var(--settle);
  pointer-events: none;
}
.book-model > span {
  position: absolute;
  display: block;
  backface-visibility: hidden;
}
.book-front, .book-back {
  inset: 0;
  border-radius: 2px 3px 3px 2px;
  background: #29463a;
}
.book-front {
  overflow: hidden;
  transform: translateZ(var(--book-half-depth));
  color: #f4f1df;
  text-align: left;
}
.book-front::after {
  position: absolute;
  inset: 0 auto 0 0;
  width: 8%;
  background: linear-gradient(90deg, #14281d58, #f1f5e328 45%, transparent);
  content: '';
}
.book-back {
  transform: translateZ(calc(-1 * var(--book-half-depth))) rotateY(180deg);
}
.book-model::before {
  position: absolute;
  inset: 6% 0 2%;
  transform: translateZ(calc(-1 * var(--book-half-depth)));
  box-shadow: 9px 15px 18px #20342b51;
  content: '';
}
.book-page-edge, .book-spine {
  inset-block: 0;
  width: var(--book-depth);
}
.book-page-edge, .book-head, .book-foot {
  background: repeating-linear-gradient(90deg, #ece6d7 0 1px, #c7c0af 2px, #ddd6c4 3px 4px);
  border-inline: 2px solid #354d3c;
}
.book-page-edge {
  inset-inline-start: calc(100% - var(--book-half-depth));
  transform: rotateY(90deg);
}
.book-spine {
  inset-inline-start: calc(-1 * var(--book-half-depth));
  transform: rotateY(-90deg);
  background: linear-gradient(90deg, #1c372b 0%, #3c5c4b 34%, #29463a 84%, #243a2d 100%);
}
.book-head, .book-foot {
  inset-inline: 0;
  height: var(--book-depth);
  border-inline: 0;
  border-block: 2px solid #354d3c;
  background: repeating-linear-gradient(0deg, #eee9da 0 1px, #c7c0af 2px, #ddd6c4 3px 4px);
}
.book-head {
  inset-block-start: calc(-1 * var(--book-half-depth));
  transform: rotateX(90deg);
}
.book-foot {
  inset-block-start: calc(100% - var(--book-half-depth));
  transform: rotateX(-90deg);
  filter: brightness(.9);
}
.book-cover-art {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.book-sample-cover .book-cover-art { object-fit: cover; object-position: 51% center; }
.book-sample-cover::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, transparent 28%, #172e28d9 100%);
  content: '';
}
.book-cover-label {
  position: absolute;
  inset: auto 10% 10% 13%;
  display: grid;
  gap: .36em;
  overflow-wrap: anywhere;
  font-size: .82rem;
}
.book-cover-label strong {
  display: -webkit-box;
  overflow: hidden;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  hyphens: auto;
  font: 600 1em/1.05 var(--serif);
}
.book-cover-label small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .65em;
}
.featured-showcase .book-cover-label { font-size: clamp(1.18rem, 2vw, 1.85rem); }
.book-original-cover .book-cover-label { display: none; }

@media (hover: hover) and (pointer: fine) and (prefers-reduced-motion: no-preference) {
  .featured-showcase:hover .book-model, .book-card-open:hover .book-model {
    transform: translateY(-3px) rotateX(var(--book-hover-x, 6deg)) rotateY(var(--book-hover-y, -14deg));
  }
  .featured-showcase:active .book-model, .book-card-open:active .book-model {
    transform: translateY(1px) rotateX(8deg) rotateY(-28deg);
  }
}

@media (prefers-reduced-motion: no-preference) {
  #library .featured::before { animation: alpine-ridge-in 860ms cubic-bezier(.16, 1, .3, 1) both; }
}
@keyframes alpine-ridge-in {
  from { transform: scale(1.065); opacity: .55; }
  to { transform: none; opacity: 1; }
}

#library .library-empty { margin: 0; padding: 17px; border: 1px solid var(--frame); border-radius: var(--radius); background: var(--paper); }
#library .library-footer { margin-top: 22px; padding-block: 12px 0; }

@media (max-width: 610px) {
  #library .library-heading-actions { flex-basis: 175px; }
  #library .featured { grid-template-columns: minmax(0, 1fr); min-height: auto; }
  #library .featured::before {
    background:
      linear-gradient(0deg, #101f17 0%, #102118d9 36%, #13251c22 71%),
      url('./assets/night-ridge.jpg') 68% 44% / cover;
  }
  #library .featured-copy { padding: 9px 23px 26px; }
  #library .featured-showcase {
    grid-row: 1;
    min-height: 237px;
    padding: 23px 17px 20px;
    --book-height: 185px;
    --book-depth: 23px;
  }
  #library .featured h2 { max-width: none; font-size: clamp(2.65rem, 10vw, 4.05rem); }
  #library .book-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .book-card-preview { --book-height: 112px; --book-depth: 13px; }
}

@media (max-width: 365px) {
  #library .library-heading-actions { flex: 1 1 100%; }
}
