.scroll-library {
  --library-ink: #292e26;
  --library-paper: #f7f0e3;
  --library-rule: #cbbda6;
  --library-red: #8c3429;
  --library-serif: "Jianghu Noto Serif SC", var(--serif);
  padding-block: clamp(48px, 7vw, 100px);
  border-top: 1px solid #d8cbb4;
  color: var(--library-ink);
  background: radial-gradient(ellipse at 14% 1%, #fcf6eb, transparent 64%), var(--library-paper);
}

.scroll-library__inner {
  width: min(calc(100% - 112px), 1240px);
  margin-inline: auto;
}

.scroll-library__header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 32px;
  margin-bottom: clamp(24px, 4vw, 43px);
}

.scroll-library__header h2 {
  margin: 0;
  font: 700 clamp(34px, 4.8vw, 62px)/1.1 var(--library-serif);
  letter-spacing: .075em;
}

.scroll-library__filters {
  display: inline-flex;
  justify-content: start;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--library-rule);
  background: #ece1cf;
}

.scroll-library__filters button {
  min-width: 57px;
  min-height: 41px;
  padding: 6px 10px;
  border: 0;
  background: transparent;
  color: #574839;
  font: 650 13px/1.25 var(--sans);
  white-space: nowrap;
}

.scroll-library__filters button:hover {
  background: #f8efe0;
  color: var(--library-red);
}

.scroll-library__filters button[aria-pressed="true"] {
  background: var(--library-red);
  color: #fff4e5;
}

.scroll-library__layout {
  display: grid;
  grid-template-columns: minmax(0, 1.63fr) minmax(340px, 1fr);
  align-items: start;
  gap: clamp(24px, 3.55vw, 54px);
}

.scroll-library__shelf {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 3px;
  min-height: 238px;
  margin: 0;
  padding: 8px 4px 12px;
  border-bottom: 4px double #ad997c;
  background: linear-gradient(0deg, #7b57342a, transparent 31%), #dfd2bc48;
  box-shadow: 0 8px 14px -13px #53331884;
  list-style: none;
}

.scroll-library__shelf li {
  min-width: 0;
}

.scroll-library__spine {
  --spine-color: #796749;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: start;
  width: 100%;
  height: 214px;
  padding: 25px 0 32px;
  border: 1px solid #bda98b;
  border-color: color-mix(in srgb, var(--spine-color) 44%, #e1ccaa);
  border-radius: 2px 1px 1px 2px;
  background: linear-gradient(90deg, #ffffff49 2%, transparent 14% 87%, #54401e27 100%), #e7d8bb;
  background: linear-gradient(90deg, #ffffff49 2%, transparent 14% 87%, #54401e27 100%), color-mix(in srgb, var(--spine-color) 17%, #f4e8cf);
  box-shadow: inset 2px 0 0 #fff6de4b, inset -1px 0 0 #74563336;
  color: #342a20;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
}

.scroll-library__spine::before,
.scroll-library__spine::after {
  position: absolute;
  right: 7px;
  left: 7px;
  border-top: 1px solid currentColor;
  opacity: .33;
  content: "";
}

.scroll-library__spine::before { top: 12px; }
.scroll-library__spine::after { bottom: 13px; }

.scroll-library__spine:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 6px #5a3c2336, inset 2px 0 0 #fff6de4b, inset -1px 0 0 #74563336;
}

.scroll-library__spine[aria-pressed="true"] {
  border-color: #79332b;
  background: linear-gradient(90deg, #ffddaa22 2%, transparent 15% 86%, #4b1c1766 100%), #903a2e;
  box-shadow: 0 4px 6px #5a3c2336, inset 2px 0 0 #f5bc8d3b;
  color: #fff3dc;
  transform: translateY(-5px);
}

.scroll-library__spine:focus-visible,
.scroll-library__filters button:focus-visible {
  outline: 2px solid #273d35;
  outline-offset: 1px;
  z-index: 1;
}

.scroll-library__spine-title {
  writing-mode: vertical-rl;
  text-orientation: upright;
  font: 670 clamp(16px, 1.6vw, 21px)/1 var(--library-serif);
  letter-spacing: .13em;
  white-space: nowrap;
}

.scroll-library__feature {
  position: relative;
  min-width: 0;
  min-height: 270px;
  padding: 24px clamp(18px, 3vw, 38px) 16px;
  border: 1px solid #d7c3a7;
  border-inline-start: 3px solid var(--library-red);
  background: linear-gradient(120deg, #fcf6e9, #f1e4cf);
  box-shadow: 5px 6px 0 -3px #dbc9aa, 8px 9px 0 -5px #e3d4b8;
}

.scroll-library__feature-page--turn {
  animation: scroll-library-page-in .26s ease-out both;
}

@keyframes scroll-library-page-in {
  from { opacity: .82; transform: translateX(-4px); }
  to { opacity: 1; transform: translateX(0); }
}

.scroll-library__book-heading h3 {
  margin: 0;
  color: var(--library-ink);
  font: 400 clamp(33px, 3.4vw, 47px)/1.13 "Jianghu Ma Shan Zheng", var(--library-serif);
  letter-spacing: .05em;
}

.scroll-library__book-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 14px;
  margin: 10px 0 17px;
  color: #644f37;
  font: 650 12px/1.55 var(--sans);
  font-variant-numeric: tabular-nums;
}

.scroll-library__book-meta span + span {
  padding-inline-start: 14px;
  border-inline-start: 1px solid var(--library-rule);
}

.scroll-library__plots {
  margin: 0;
  padding: 0;
  list-style: none;
}

.scroll-library__plots li {
  border-top: 1px solid #dfceb3;
}

.scroll-library__plots a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 7px 12px;
  min-height: 42px;
  padding-block: 8px;
  color: var(--library-ink);
  text-decoration: none;
}

.scroll-library__plots a:hover {
  color: var(--library-red);
}

.scroll-library__plot-name {
  font: 650 14px/1.5 var(--library-serif);
  text-wrap: pretty;
}

.scroll-library__plot-year {
  color: #6b5439;
  font: 550 11px/1.4 var(--sans);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.scroll-library__plot-arrow {
  color: var(--library-red);
  font-size: 16px;
  line-height: 1;
}

@media (max-width: 1080px) {
  .scroll-library__shelf {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    row-gap: 8px;
    min-height: 168px;
  }

  .scroll-library__spine {
    height: 146px;
    padding-block: 20px;
  }

  .scroll-library__spine::before { top: 8px; }
  .scroll-library__spine::after { bottom: 9px; }
}

@media (max-width: 950px) {
  .scroll-library__inner {
    width: calc(100% - 64px);
  }
}

@media (max-width: 770px) {
  .scroll-library__layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 22px;
  }
}

@media (max-width: 480px) {
  .scroll-library__inner {
    width: calc(100% - 42px);
  }

  .scroll-library__header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }

  .scroll-library__filters button {
    min-width: 52px;
  }

  .scroll-library__shelf {
    min-height: 137px;
  }

  .scroll-library__spine {
    height: 115px;
    padding-block: 16px;
  }

  .scroll-library__spine-title {
    font-size: 15px;
    letter-spacing: .08em;
  }

  .scroll-library__feature {
    min-height: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .scroll-library__spine { transition: none; }
  .scroll-library__feature-page--turn { animation: none; }
}
