.library-page { color: #142d29; padding-bottom: 35px; }
.library-hero { display: grid; grid-template-columns: 1fr 1.05fr; margin-top: clamp(16px, 2vw, 32px); }
.library-intro { background: #143e35; color: #f8f7ee; padding: clamp(28px, 4.2vw, 74px); }
.library-intro .kicker { color: #c0ceb1; }
.library-intro h1, .collection-heading h2, .gallery-tile strong { font-family: "Helvetica Neue", Arial, sans-serif; font-weight: 500; letter-spacing: -.055em; }
.library-intro h1 { font-size: clamp(3.5rem, 6.2vw, 6.5rem); line-height: .98; }
.library-intro em { font-family: "Iowan Old Style", Palatino, Georgia, serif; color: #dce5bc; }
.library-intro p:last-child { max-width: 38ch; margin-top: 16px; color: #e3e9df; line-height: 1.45; }
.library-hero > img { width: 100%; height: 100%; min-height: 0; object-fit: cover; }
.collection-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin: clamp(32px, 4vw, 55px) 0 20px; }
.collection-heading h2 { font-size: clamp(2rem, 3.4vw, 3.5rem); }
.collection-heading span { white-space: nowrap; font-size: .8rem; }
.gallery-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 30px 16px; }
.gallery-tile { text-decoration: none; align-self: start; }
.gallery-tile .cover-plate { aspect-ratio: 1.08; margin-bottom: 12px; }
.gallery-topic { display: block; color: #496153; font: 650 .65rem/1.4 Arial, sans-serif; text-transform: uppercase; letter-spacing: .105em; }
.gallery-tile strong { display: block; font-size: clamp(1.08rem, 1.5vw, 1.5rem); letter-spacing: -.03em; line-height: 1.18; margin: 4px 0; }
.gallery-author { display: block; color: #536158; font-size: .88rem; line-height: 1.4; }
.book-details { display: none; }
.book-details:target, .dialog-content .book-details { display: grid; grid-template-columns: .83fr 1fr; }
.book-dialog { width: min(800px, calc(100% - 30px)); max-height: 88dvh; padding: 0; border: 0; background: #f9f8f3; color: #142d29; }
.book-dialog::backdrop { background: #12231edc; }
.detail-art { background: var(--tone); display: grid; place-items: center; }
.detail-art img { width: 62%; max-height: 350px; object-fit: contain; filter: drop-shadow(5px 7px 6px #25251930); }
.detail-copy { padding: 52px 32px 32px; }
.detail-copy h2 { font-size: clamp(2rem, 3.4vw, 3.5rem); margin: 9px 0; }
.detail-copy h3 { font: bold .87rem var(--sans); letter-spacing: normal; margin: 16px 0 4px; }
.detail-copy .reflection { border-left: 2px solid #96a184; padding-left: 12px; font: italic 1.25rem/1.4 var(--serif); }
.close-book { position: absolute; top: 12px; right: 12px; padding: 7px 15px; background: #fff; color: #193b27; border: 1px solid #bbc6bd; border-radius: 18px; }
.back-to-books { display: inline-block; margin-top: 18px; }
.has-book-dialog .book-notes, .dialog-content .back-to-books { display: none; }
@media (max-width: 850px) { .gallery-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 600px) {
  .library-hero { grid-template-columns: 1fr; }
  .library-intro { padding: 25px 22px; }
  .library-intro h1 { font-size: clamp(2.8rem, 10vw, 3.8rem); }
  .library-intro br { display: none; }
  .library-hero > img { height: 155px; }
  .collection-heading h2 { font-size: 1.85rem; }
  .gallery-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px 10px; }
  .gallery-tile .cover-plate { aspect-ratio: .87; }
  .book-details:target, .dialog-content .book-details { grid-template-columns: 1fr; }
  .detail-art { padding: 15px; }
  .detail-art img { width: auto; height: 145px; }
  .detail-copy { padding: 20px; }
}
/* A slight turn around the spine connects the shelf to the open book. */
.close-book { z-index: 1; }
@media (prefers-reduced-motion: no-preference) {
  .library-page, .book-dialog { --book-ease: cubic-bezier(.2, .75, .2, 1); }
  .gallery-tile .cover-plate img {
    transform-origin: 18% 84%;
    transition: transform 300ms var(--book-ease);
  }
  .gallery-tile:focus-visible .cover-plate img {
    transform: perspective(620px) translateY(-5px) rotateY(-7deg) rotate(-1deg);
  }
  @media (hover: hover) and (pointer: fine) {
    .gallery-tile:hover .cover-plate img {
      transform: perspective(620px) translateY(-5px) rotateY(-7deg) rotate(-1deg);
    }
  }

  .book-dialog[open] .detail-art img {
    transform-origin: 14% 82%;
    animation: open-cover 420ms var(--book-ease) both;
  }
  .book-dialog[open] .detail-copy {
    animation: turn-to-notes 340ms var(--book-ease) both;
  }
  @supports (transition-behavior: allow-discrete) {
    .book-dialog {
      opacity: 0;
      transform: translateY(5px) scale(.99);
      transition: opacity 160ms ease-out, transform 200ms var(--book-ease),
                  display 200ms allow-discrete, overlay 200ms allow-discrete;
    }
    .book-dialog[open] { opacity: 1; transform: none; }
    .book-dialog::backdrop {
      opacity: 0;
      transition: opacity 200ms ease-out, display 200ms allow-discrete, overlay 200ms allow-discrete;
    }
    .book-dialog[open]::backdrop { opacity: 1; }
    @starting-style {
      .book-dialog[open] { opacity: 0; transform: translateY(5px) scale(.99); }
      .book-dialog[open]::backdrop { opacity: 0; }
    }
  }
  .gallery-tile.returning .cover-plate img {
    animation: reshelve-cover 340ms var(--book-ease);
  }
}
@keyframes open-cover {
  from { transform: perspective(750px) translateY(6px) rotateY(-13deg) rotate(-2deg) scale(.975); }
  to { transform: none; }
}
@keyframes turn-to-notes {
  from { opacity: .65; transform: translateX(-6px); }
  to { opacity: 1; transform: none; }
}
@keyframes reshelve-cover {
  from { transform: perspective(620px) translateY(-8px) rotateY(-9deg) rotate(-1.5deg); }
}
@media (prefers-reduced-motion: reduce), (hover: none) {
  .gallery-tile:hover .cover-plate img { transform: none; }
}
