:root {
  color-scheme: dark;
  --ink: #fbf3dd;
  --muted: #cfc0a6;
  --shadow: #08070b;
  --wood: #3a2418;
  --wood-dark: #160d0b;
  --brass: #d3a841;
  --green: #73e0b5;
  --wine: #6e2939;
  --night: #11131c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 19% 12%, rgba(211, 168, 65, .18), transparent 23%),
    linear-gradient(135deg, #11131c 0%, #26172a 42%, #071013 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(255, 255, 255, .04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, .035) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(90deg, transparent, #000 20%, #000 80%, transparent);
}

.app-shell {
  min-height: 100vh;
}

.kicker,
.category-pill {
  margin: 0 0 10px;
  color: var(--brass);
  font-size: .76rem;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.library-header .kicker {
  padding-left: 24px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: none;
  margin-bottom: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 3.4vw, 4rem);
  line-height: .98;
  font-weight: 700;
  text-wrap: balance;
}

.intro {
  max-width: 520px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.book-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background:
    radial-gradient(circle at 50% 46%, rgba(115, 224, 181, .16), transparent 30%),
    rgba(8, 7, 11, .78);
  cursor: zoom-out;
  backdrop-filter: blur(8px);
}

.featured-book {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(170px, 250px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(20px, 3vw, 34px);
  width: min(880px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid rgba(211, 168, 65, .48);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(25, 17, 28, .96), rgba(16, 11, 11, .96)),
    radial-gradient(circle at 20% 20%, rgba(115, 224, 181, .2), transparent 35%);
  box-shadow: 0 34px 90px rgba(0, 0, 0, .62), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  border: 1px solid rgba(211, 168, 65, .5);
  border-radius: 50%;
  background: rgba(8, 7, 11, .54);
  color: var(--ink);
  font-size: 1.55rem;
  line-height: 1;
  cursor: pointer;
}

.close-button:hover,
.close-button:focus-visible {
  background: rgba(211, 168, 65, .18);
  outline: 2px solid rgba(115, 224, 181, .45);
  outline-offset: 3px;
}

.cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  min-width: 0;
  border-radius: 6px;
  perspective: 1200px;
}

#featuredCover {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .48), -10px 0 0 rgba(0, 0, 0, .22) inset;
  transform: rotateY(-8deg);
}

.cover-glow {
  position: absolute;
  inset: 8% -10% -8%;
  background: color-mix(in srgb, var(--green), transparent 72%);
  filter: blur(34px);
}

.featured-copy {
  min-width: 0;
}

.category-pill {
  color: var(--accent);
}

.featured-copy h2 {
  margin-bottom: 10px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.55rem, 2.4vw, 2.55rem);
  line-height: 1.04;
}

.author {
  margin-bottom: 20px;
  color: #f4dca1;
  font-weight: 700;
}

.comment {
  max-width: 42rem;
  color: #e8dbc3;
  font-size: 1rem;
  line-height: 1.65;
}

.book-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-top: 8px;
  padding: 0 18px;
  border: 1px solid rgba(211, 168, 65, .7);
  border-radius: 6px;
  background: rgba(211, 168, 65, .12);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.book-link:hover,
.book-link:focus-visible {
  background: rgba(211, 168, 65, .22);
  outline: 2px solid rgba(211, 168, 65, .36);
  outline-offset: 3px;
}

.bookcase {
  position: relative;
  min-width: 0;
  min-height: 100vh;
  padding: clamp(20px, 2.4vw, 34px) clamp(18px, 2.8vw, 46px) 72px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .03), transparent 20%),
    radial-gradient(circle at 85% 8%, rgba(182, 156, 255, .22), transparent 25%),
    linear-gradient(180deg, #21140f 0%, #100b0b 100%);
}

.library-header {
  position: sticky;
  z-index: 4;
  top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  align-items: center;
  gap: 24px;
  min-height: 96px;
  margin-bottom: 28px;
  padding: 16px clamp(18px, 2.5vw, 28px);
  border: 1px solid rgba(211, 168, 65, .35);
  border-radius: 6px;
  background: rgba(22, 13, 11, .78);
  backdrop-filter: blur(14px);
}

.library-header::before,
.library-header::after {
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.library-header::before {
  content: "✦";
  position: absolute;
  left: 14px;
  top: 12px;
}

.library-header::after {
  content: "✦";
  position: absolute;
  right: 14px;
  bottom: 12px;
}

.library-header .intro {
  margin: 0;
  max-width: none;
  justify-self: end;
  font-size: calc(1rem * var(--intro-scale, 1));
  text-align: right;
  white-space: nowrap;
}

.shelves {
  display: flex;
  flex-direction: column;
  gap: 34px;
}

.shelf-section {
  position: relative;
}

.shelf-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  color: #f6e7bf;
}

.shelf-label h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.15rem, 2vw, 1.85rem);
  line-height: 1.1;
}

.shelf-label span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}

.shelf-row {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  min-height: 286px;
  padding: 24px 22px 38px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, .09);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .05), transparent 26%),
    linear-gradient(90deg, rgba(0, 0, 0, .2), transparent 10%, transparent 90%, rgba(0, 0, 0, .22)),
    #28170f;
  box-shadow: inset 0 -22px 0 #4a2d1b, inset 0 -28px 0 rgba(0, 0, 0, .35), 0 22px 50px rgba(0, 0, 0, .26);
}

.shelf-row::before {
  position: absolute;
  right: 18px;
  bottom: 8px;
  left: 18px;
  height: 12px;
  content: "";
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent), #fff 18%), transparent);
  opacity: .36;
}

.book-spine {
  position: relative;
  isolation: isolate;
  display: flex;
  flex: 0 0 var(--width);
  align-items: center;
  justify-content: center;
  width: var(--width);
  height: var(--height);
  min-width: 34px;
  padding: 12px 7px;
  border: 0;
  border-radius: 4px 4px 2px 2px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, .18), transparent 18%, rgba(0, 0, 0, .34) 80%),
    var(--spine),
    linear-gradient(180deg, color-mix(in srgb, var(--accent), #111 22%), #181018);
  background-position: center;
  background-size: cover;
  color: #fff9df;
  box-shadow: inset 8px 0 10px rgba(255, 255, 255, .12), inset -9px 0 16px rgba(0, 0, 0, .42), 0 12px 18px rgba(0, 0, 0, .32);
  cursor: pointer;
  transform-origin: bottom center;
  transition: transform .18s ease, filter .18s ease, box-shadow .18s ease;
}

.book-spine::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  border-radius: inherit;
  background: color-mix(in srgb, var(--accent), #111 38%);
  mix-blend-mode: multiply;
  opacity: .54;
}

.book-spine:hover,
.book-spine:focus-visible,
.book-spine.is-selected {
  z-index: 2;
  filter: brightness(1.13) saturate(1.12);
  transform: translateY(-12px);
  outline: 2px solid #7451cf;
  outline-offset: 3px;
  box-shadow: inset 8px 0 10px rgba(255, 255, 255, .12), inset -9px 0 16px rgba(0, 0, 0, .42), 0 0 0 4px rgba(116, 81, 207, .18), 0 16px 24px rgba(0, 0, 0, .38);
}

.spine-text {
  position: absolute;
  left: 50%;
  top: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: calc(var(--height) - 12px);
  max-width: calc(var(--height) - 12px);
  height: calc(var(--width) - 10px);
  overflow: visible;
  text-align: center;
  text-shadow: 0 1px 5px rgba(0, 0, 0, .85);
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center;
  white-space: normal;
}

.spine-title {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 58%;
  height: 100%;
  overflow: hidden;
  min-width: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: calc(.96rem * var(--label-scale, 1));
  font-weight: 800;
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.spine-author {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 42%;
  height: 100%;
  overflow: hidden;
  min-width: 0;
  color: #f7dfa1;
  font-size: calc(.72rem * var(--label-scale, 1));
  font-weight: 900;
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.completion-mark {
  position: absolute;
  right: 50%;
  bottom: -24px;
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border: 1px solid rgba(19, 12, 8, .65);
  border-radius: 50%;
  background: #e6c15a;
  color: #181008;
  font-size: .8rem;
  font-weight: 1000;
  transform: translateX(50%);
  box-shadow: 0 4px 9px rgba(0, 0, 0, .38);
}

[hidden] {
  display: none !important;
}

.modal-open .bookcase {
  filter: saturate(.88) brightness(.7);
}

@media (max-width: 980px) {
  .library-header {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .library-header .intro {
    justify-self: start;
    text-align: left;
  }

  .featured-book {
    grid-template-columns: minmax(138px, 190px) minmax(0, 1fr);
  }
}

@media (max-width: 650px) {
  .bookcase {
    padding: 18px 14px 56px;
  }

  .library-header {
    position: relative;
    margin-bottom: 24px;
    padding: 20px 18px;
  }

  .featured-book {
    grid-template-columns: 1fr;
    gap: 16px;
    width: min(420px, calc(100vw - 28px));
    padding: 22px;
  }

  .cover-wrap {
    width: min(190px, 72vw);
    justify-self: center;
  }

  .comment {
    font-size: .94rem;
  }

  .shelf-row {
    min-height: 222px;
    padding-right: 12px;
    padding-left: 12px;
  }
}
