/* ABOUTME: Book catalogue styles: title band, today's featured book, the filter sidebar (a slide-in panel on phones) and the grid. */
/* ABOUTME: Book cards themselves are styled in base.css. */

.catalogue-hero {
  background: var(--cream);
  padding-block: clamp(1.5rem, 1rem + 2vw, 2.5rem) 0;
}

.catalogue-hero h1 {
  color: var(--plum);
  margin-bottom: 0.4rem;
}

.catalogue-hero .lead {
  max-width: 58ch;
  margin-bottom: 0;
}

/* Featured book */

.featured {
  background: linear-gradient(var(--cream) 0 55%, var(--paper) 55%);
  padding-block: clamp(1.5rem, 1rem + 2vw, 2.5rem) clamp(2rem, 1.5rem + 2vw, 3rem);
}

.featured__book {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(1.5rem, 1rem + 3vw, 3.5rem);
  align-items: center;
  padding: clamp(1.25rem, 1rem + 2vw, 2.5rem);
  border-radius: calc(var(--radius) * 1.4);
  background: var(--plum);
  background-image: radial-gradient(ellipse 70% 90% at 15% 50%, #6b2c65 0%, transparent 70%);
  color: var(--white);
  box-shadow: var(--shadow-md);
}

.featured__cover img {
  width: clamp(130px, 10rem + 6vw, 240px);
  border-radius: 3px;
  box-shadow: 0 2px 4px rgb(0 0 0 / 0.25), 0 24px 40px -14px rgb(0 0 0 / 0.6);
  rotate: -3deg;
  transition: rotate 0.5s var(--ease), transform 0.5s var(--ease);
}

.featured__cover:hover img {
  rotate: 0deg;
  transform: translateY(-4px);
}

.featured .eyebrow {
  color: var(--rose-300);
}

.featured h2 {
  font-size: var(--step-3);
  margin-bottom: 0.4rem;
}

.featured h2 a {
  color: var(--white);
  text-decoration: none;
}

.featured h2 a:hover {
  text-decoration: underline;
  text-decoration-thickness: 2px;
}

.featured__meta {
  font-size: 0.92rem;
  color: var(--rose-300);
  font-weight: 600;
}

.featured__excerpt {
  max-width: 62ch;
  color: rgb(255 255 255 / 0.84);
  margin-bottom: 1.5rem;
}

.featured .button {
  background: var(--cream);
  color: var(--plum);
}

.featured .button:hover {
  background: var(--white);
  color: var(--plum-800);
}

/* On phones the featured book is a compact strip, so the filters and Clear button stay near the top. */
@media (max-width: 600px) {
  .catalogue-hero .lead {
    font-size: 1rem;
  }

  .featured__book {
    grid-template-columns: 88px minmax(0, 1fr);
    gap: 1rem;
    padding: 1rem;
  }

  .featured__cover img {
    width: 88px;
    rotate: 0deg;
  }

  .featured .eyebrow {
    margin-bottom: 0.3rem;
    font-size: 0.7rem;
  }

  .featured .eyebrow::before {
    display: none;
  }

  .featured h2 {
    font-size: 1.15rem;
  }

  .featured__meta {
    font-size: 0.82rem;
    margin-bottom: 0.6rem;
  }

  .featured__excerpt {
    display: none;
  }

  .featured .button {
    min-height: 38px;
    padding: 0.4rem 0.9rem;
    font-size: 0.88rem;
  }
}

/* Layout */

.catalogue {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: clamp(2rem, 1rem + 3vw, 3.5rem);
  align-items: start;
  padding-bottom: clamp(3rem, 2rem + 4vw, 6rem);
}

html:not(.js) .catalogue {
  grid-template-columns: 1fr;
}

/* Filters */

.filters {
  position: sticky;
  top: calc(var(--header-height) + 1.5rem);
  max-height: calc(100vh - var(--header-height) - 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-right: 0.5rem;
  scrollbar-width: thin;
  scrollbar-color: var(--rose-300) transparent;
}

.filters__head,
.filters__foot {
  display: none;
}

.filter-group {
  margin: 0 0 1.5rem;
  padding: 0 0 1.5rem;
  border: 0;
  border-bottom: 1px solid var(--line);
}

.filter-group legend {
  padding: 0;
  margin-bottom: 0.6rem;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--plum-600);
}

.filter-group__options {
  margin: 0;
  padding: 0;
  list-style: none;
}

.filter-group__options.is-long:not(.is-open) .is-extra {
  display: none;
}

.filter-group__options.is-long:not(.is-open) .is-extra:has(input:checked) {
  display: list-item;
}

.filter-group__options li.is-empty {
  opacity: 0.45;
}

.filter-option {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.3rem 0.4rem;
  margin-inline: -0.4rem;
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1.3;
  cursor: pointer;
  transition: background-color 0.15s;
}

.filter-option:hover {
  background: var(--cream);
}

.filter-option input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.filter-option__box {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--plum-300);
  border-radius: 4px;
  background: var(--white) no-repeat center / 12px;
  transition: background-color 0.15s, border-color 0.15s;
}

.filter-option input:checked + .filter-option__box {
  background-color: var(--plum);
  border-color: var(--plum);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m2.5 6.2 2.3 2.3 4.7-5'/%3E%3C/svg%3E");
}

.filter-option input:focus-visible + .filter-option__box {
  outline: 3px solid var(--blue);
  outline-offset: 2px;
}

.filter-option input:disabled ~ * {
  cursor: default;
}

.filter-option__count {
  font-size: 0.8rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.filter-group__more {
  margin-top: 0.4rem;
  padding: 0;
  border: 0;
  background: none;
  color: var(--blue-700);
  font: 600 0.9rem var(--font-body);
  cursor: pointer;
}

.filter-group__more:hover {
  text-decoration: underline;
}

/* Results bar */

.results__bar {
  position: sticky;
  top: var(--header-height);
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  margin-bottom: 1rem;
  padding-block: 0.9rem;
  background: rgb(252 250 248 / 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.results__count {
  margin: 0;
  font-size: var(--step-1);
  font-variant-numeric: tabular-nums;
}

.results__actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.results__filter-toggle {
  display: none;
  min-height: 42px;
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
}

.results__filter-count {
  display: inline-grid;
  place-items: center;
  min-width: 1.4rem;
  height: 1.4rem;
  padding-inline: 0.35rem;
  border-radius: 999px;
  background: var(--plum);
  color: var(--white);
  font-size: 0.78rem;
}

.results__filter-toggle:hover .results__filter-count {
  background: var(--white);
  color: var(--plum);
}

.results__clear {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-height: 42px;
  padding: 0.45rem 1rem;
  border: 1.5px solid var(--rose);
  border-radius: 999px;
  background: var(--rose-100);
  color: var(--plum);
  font: 600 0.95rem var(--font-body);
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s, border-color 0.2s;
}

.results__clear::before {
  content: "×";
  font-size: 1.2em;
  line-height: 1;
}

.results__clear:hover:not(:disabled) {
  background: var(--rose-300);
}

.results__clear:disabled {
  opacity: 0.4;
  cursor: default;
  border-color: var(--line);
  background: transparent;
}

.active-filters {
  display: flex;
  flex-wrap: wrap;
  flex-basis: 100%;
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.active-filters:empty {
  display: none;
}

.active-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.5rem 0.3rem 0.8rem;
  border: 0;
  border-radius: 999px;
  background: var(--plum-100);
  color: var(--plum);
  font: 600 0.88rem var(--font-body);
  cursor: pointer;
  transition: background-color 0.2s;
}

.active-filter span:last-child {
  display: grid;
  place-items: center;
  width: 1.2rem;
  height: 1.2rem;
  border-radius: 50%;
  background: rgb(78 25 74 / 0.12);
}

.active-filter:hover {
  background: var(--rose-100);
}

.catalogue-grid {
  grid-template-columns: repeat(auto-fill, minmax(min(150px, 40vw), 1fr));
  /* Filtering moves cards around; the page shouldn't try to hold the reader's place on one of them. */
  overflow-anchor: none;
}

.catalogue-grid > li[hidden] {
  display: none;
}

.catalogue-grid .book-card__title {
  font-size: 0.98rem;
}

.no-results {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--ink-soft);
}

/* Small screens: filters become a slide-in panel opened from the results bar. */

@media (max-width: 900px) {
  .catalogue {
    grid-template-columns: 1fr;
  }

  .results__filter-toggle {
    display: inline-flex;
  }

  .filters {
    position: fixed;
    inset: 0 0 0 auto;
    z-index: 70;
    width: min(380px, 90vw);
    max-height: none;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: var(--paper);
    box-shadow: -20px 0 50px rgb(34 10 32 / 0.25);
    transform: translateX(105%);
    visibility: hidden;
    transition: transform 0.35s var(--ease), visibility 0s 0.35s;
  }

  .filters.is-open {
    transform: none;
    visibility: visible;
    transition: transform 0.35s var(--ease);
  }

  .filters__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--line);
  }

  .filters__title {
    margin: 0;
    font-size: var(--step-1);
  }

  .filters__close {
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: var(--cream);
    color: var(--plum);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
  }

  .filters__form {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
  }

  .filters__foot {
    display: flex;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--line);
  }

  .filters__foot .button {
    flex: 1;
    min-height: 46px;
    padding-inline: 0.75rem;
  }

  .filter-option {
    padding-block: 0.5rem;
  }

  .filters-backdrop {
    position: fixed;
    inset: 0;
    z-index: 65;
    background: rgb(34 10 32 / 0.45);
  }

  body.filters-open {
    overflow: hidden;
  }
}

@media (min-width: 901px) {
  .filters-backdrop {
    display: none;
  }
}
