@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&display=swap");

:root {
  color-scheme: light;
  --ink: #2d2926;
  --muted: #746d66;
  --paper: #f5f0e8;
  --surface: #fffdf9;
  --surface-soft: #eee6db;
  --accent: #a64f3e;
  --accent-dark: #78382d;
  --sage: #71877a;
  --line: rgba(45, 41, 38, 0.14);
  --shadow: 0 1rem 2.5rem rgba(67, 55, 45, 0.13);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(circle at 92% 4%, rgba(211, 176, 143, 0.24), transparent 28rem),
    linear-gradient(180deg, #faf7f1 0%, var(--paper) 38%, #eee7dc 100%);
  color: var(--ink);
  font-family: "DM Sans", system-ui, sans-serif;
}

button,
dialog {
  font: inherit;
}

button {
  color: inherit;
}

.page-shell {
  width: min(100% - 2rem, 76rem);
  margin: 0 auto;
  padding: clamp(2rem, 5vw, 5rem) 0 3rem;
}

.masthead {
  position: relative;
  display: block;
  padding: 0 0 clamp(3rem, 8vw, 6.5rem);
  border-bottom: 1px solid var(--line);
  text-align: center;
}

.monogram {
  position: absolute;
  top: 0;
  left: 0;
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.72);
  color: var(--accent);
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 1.65rem;
  font-style: normal;
  font-weight: 400;
  text-decoration: none;
}

h1,
.section-heading h2,
.book-details-panel h3 {
  color: var(--accent-dark);
  font-family: "DM Sans", system-ui, sans-serif;
  font-weight: 300;
  text-align: center;
  text-transform: uppercase;
}

h1 {
  max-width: 15ch;
  margin: 0 auto;
  font-size: clamp(2.9rem, 9vw, 6.8rem);
  letter-spacing: 0.055em;
  line-height: 1;
  text-wrap: balance;
}

.shelf {
  padding: clamp(3.5rem, 8vw, 6.5rem) 0;
  border-bottom: 1px solid var(--line);
}

.shelf-current {
  padding-top: clamp(2.75rem, 6vw, 4.5rem);
}

.section-heading {
  display: flex;
  justify-content: center;
  gap: 1rem;
  align-items: end;
  margin-bottom: clamp(1.5rem, 4vw, 2.5rem);
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0.075em;
  line-height: 1.08;
}

.section-note {
  margin: 0 0 0.2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(9.5rem, 42vw), 1fr));
  gap: clamp(1rem, 2.6vw, 1.8rem);
  align-items: start;
}

.current-grid:has(.empty-state) {
  display: block;
}

.current-grid {
  display: block;
}

.current-book-feature {
  display: grid;
  grid-template-columns: minmax(12rem, 0.7fr) minmax(24rem, 1.3fr);
  gap: clamp(2rem, 5vw, 5rem);
  align-items: center;
}

.current-book-feature .book-card {
  width: min(100%, 20rem);
}

.current-book-feature .current-book-details {
  grid-column: 2;
  margin: 0;
}

.book-card {
  min-width: 0;
}

.cover-button {
  position: relative;
  display: block;
  width: 100%;
  padding: 0;
  border: 0;
  border-radius: 0.42rem;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transform-origin: center bottom;
  transition: transform 180ms ease, filter 180ms ease;
}

.cover-button::after {
  position: absolute;
  inset: 0;
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px rgba(45, 41, 38, 0.06), var(--shadow);
  content: "";
  pointer-events: none;
}

.cover-button:hover {
  filter: saturate(1.04);
  transform: translateY(-0.45rem) rotate(-0.35deg);
}

.cover-button:active {
  transform: translateY(-0.15rem) scale(0.99);
}

.book-card.is-expanded .cover-button {
  outline: 3px solid var(--accent);
  outline-offset: 5px;
  filter: saturate(1.08);
  transform: translateY(-0.35rem);
}

.book-card.is-expanded .cover-button::after {
  box-shadow:
    inset 0 0 0 1px rgba(45, 41, 38, 0.06),
    0 1.15rem 2.8rem rgba(120, 56, 45, 0.24);
}

.cover-button:focus-visible,
.dialog-close:focus-visible,
.monogram:focus-visible {
  outline: 3px solid rgba(166, 79, 62, 0.46);
  outline-offset: 4px;
}

.book-cover {
  display: block;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: inherit;
  background: var(--surface-soft);
  object-fit: cover;
}

.cover-badges {
  position: absolute;
  z-index: 1;
  top: 0.62rem;
  right: 0.62rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.42rem;
  pointer-events: none;
}

.tag {
  display: inline-flex;
  min-height: 1.8rem;
  align-items: center;
  justify-content: center;
  padding: 0.32rem 0.62rem;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 999px;
  box-shadow: 0 0.28rem 0.8rem rgba(45, 41, 38, 0.14);
  background: rgba(255, 253, 249, 0.92);
  color: var(--ink);
  font-size: 0.72rem;
  font-weight: 600;
  line-height: 1;
  backdrop-filter: blur(8px);
}

.tag.priority {
  min-width: 1.8rem;
  padding-inline: 0.48rem;
}

.tag.hold {
  background: rgba(113, 135, 122, 0.94);
  color: white;
}

.tag.loved {
  min-width: 1.8rem;
  padding-inline: 0.48rem;
  background: rgba(166, 79, 62, 0.95);
  color: white;
  font-size: 0.86rem;
}

.book-details-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(12rem, 0.65fr) minmax(18rem, 1.35fr);
  gap: clamp(1.25rem, 4vw, 4rem);
  margin: 0.2rem 0 0.8rem;
  padding: clamp(1.4rem, 4vw, 2.5rem);
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: rgba(255, 253, 249, 0.72);
  box-shadow: 0 0.7rem 1.8rem rgba(67, 55, 45, 0.07);
}

.book-details-panel[hidden] {
  display: none;
}

.book-details-panel h3 {
  grid-column: 1;
  margin: 0.32rem 0 0;
  font-size: clamp(1.65rem, 3vw, 2.3rem);
  letter-spacing: 0.055em;
  line-height: 1.08;
}

.book-meta {
  grid-column: 1;
  margin: 0;
  color: var(--muted);
  font-size: 0.67rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.book-author {
  grid-column: 1;
  margin: 0.5rem 0 0;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 600;
}

.book-description {
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  max-width: 60ch;
  margin: 0;
  color: var(--muted);
  font-size: clamp(0.95rem, 1.6vw, 1.08rem);
  line-height: 1.65;
  text-wrap: pretty;
}

.current-progress {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.5rem;
  margin-top: 1rem;
}

.mobile-current-progress {
  display: none;
}

.current-progress-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.current-progress progress {
  width: 100%;
  height: 0.72rem;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--accent);
}

.current-progress progress::-webkit-progress-bar {
  border-radius: 999px;
  background: var(--surface-soft);
}

.current-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #c57a61);
}

.current-progress progress::-moz-progress-bar {
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #c57a61);
}

.empty-state {
  margin: 0;
  padding: 1.4rem 1.5rem;
  border: 1px dashed rgba(45, 41, 38, 0.2);
  border-radius: 0.8rem;
  background: rgba(255, 253, 249, 0.46);
  color: var(--muted);
  line-height: 1.55;
}

.empty-state.error {
  color: var(--accent-dark);
}

.book-dialog {
  width: min(58rem, calc(100% - 2rem));
  max-height: min(48rem, calc(100dvh - 2rem));
  padding: 0;
  overflow: hidden auto;
  border: 1px solid rgba(45, 41, 38, 0.16);
  border-radius: 1.25rem;
  background: var(--surface);
  box-shadow: 0 2rem 6rem rgba(45, 41, 38, 0.28);
  color: var(--ink);
}

.book-dialog::backdrop {
  background: rgba(34, 29, 26, 0.58);
  backdrop-filter: blur(6px);
}

.dialog-layout {
  display: grid;
  grid-template-columns: minmax(14rem, 0.8fr) minmax(0, 1.2fr);
  min-height: 31rem;
}

.dialog-cover-wrap {
  display: grid;
  place-items: center;
  padding: clamp(2rem, 5vw, 4rem);
  background: var(--surface-soft);
}

.dialog-cover {
  display: block;
  width: min(100%, 17rem);
  max-height: 31rem;
  border-radius: 0.35rem;
  box-shadow: 0 1.4rem 3rem rgba(45, 41, 38, 0.2);
  object-fit: contain;
}

.dialog-copy {
  align-self: center;
  padding: clamp(2.2rem, 5vw, 4.5rem);
}

.dialog-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.3rem;
}

.dialog-tags .tag {
  border-color: var(--line);
  box-shadow: none;
  background: var(--paper);
}

.dialog-tags .tag.loved {
  background: var(--accent);
  color: white;
}

.dialog-tags .tag.hold {
  background: var(--sage);
  color: white;
}

.dialog-year {
  margin: 0 0 0.55rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.dialog-copy h2 {
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  letter-spacing: -0.045em;
  line-height: 0.98;
  text-wrap: balance;
}

.dialog-author {
  margin: 1rem 0 0;
  color: var(--accent);
  font-weight: 600;
}

.dialog-description {
  margin: 1.7rem 0 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.12rem);
  line-height: 1.7;
  text-wrap: pretty;
}

.dialog-close {
  position: sticky;
  z-index: 2;
  top: 0.8rem;
  float: right;
  width: 2.7rem;
  height: 2.7rem;
  margin: 0.8rem 0.8rem -3.5rem 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 253, 249, 0.94);
  color: var(--ink);
  cursor: pointer;
  font-size: 1.7rem;
  line-height: 1;
}

.dialog-open {
  overflow: hidden;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 2rem;
  color: rgba(45, 41, 38, 0.5);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

footer a {
  color: inherit;
  text-underline-offset: 0.2em;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 680px) {
  .page-shell {
    width: min(100% - 1.25rem, 76rem);
    padding-top: 1.3rem;
  }

  .masthead {
    padding-top: 4.25rem;
  }

  .monogram {
    width: 3rem;
    height: 3rem;
  }

  .section-heading {
    align-items: end;
  }

  .book-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem 0.78rem;
  }

  .current-book-feature {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .current-book-feature .book-card {
    width: min(100%, 13rem);
    margin-inline: auto;
  }

  .current-book-feature .current-book-details {
    grid-column: 1;
  }

  .mobile-current-progress {
    display: grid;
  }

  .current-book-details .current-progress {
    display: none;
  }

  .current-book-details h3 {
    text-align: center;
  }

  .book-details-panel {
    grid-template-columns: 1fr;
    gap: 0.25rem;
  }

  .book-description {
    grid-column: 1;
    grid-row: auto;
    margin-top: 0.9rem;
  }

  .dialog-layout {
    grid-template-columns: 1fr;
  }

  .dialog-cover-wrap {
    padding: 2.25rem 3.5rem;
  }

  .dialog-cover {
    width: min(100%, 13rem);
    max-height: 20rem;
  }

  .dialog-copy {
    padding: 2rem 1.5rem 2.5rem;
  }

  footer {
    flex-direction: column;
  }
}

@media (max-width: 380px) {
  .page-shell {
    width: min(100% - 1rem, 76rem);
  }

  .book-grid {
    gap: 0.8rem 0.6rem;
  }

  .tag {
    font-size: 0.66rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .cover-button {
    transition: none;
  }
}
