/* Book lists (WS-02, archive-product.php): shop, subject, person,
   publisher, series, search. Colours only via tokens.css.
   Wide: filter sidebar | results. Phones (≤720px): one column, a sticky
   Sort / Filter bar, and the filters in a bottom sheet (popover). */

.list-main {
  padding-top: 16px;
  padding-bottom: 48px;
}

/* ---------- Top: title, photo, introduction, sub-subjects ---------- */

.list-head {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.list-head__photo {
  flex: none;
  width: 112px;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 50%;
  object-fit: cover;
}

.list-head__photo--letter {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--tint);
  color: var(--accent);
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
}

/* Publisher logo, series cover: shown whole */
.list-head--logo .list-head__photo {
  border-radius: var(--radius-lg);
  object-fit: contain;
  background: var(--surface);
}

.list-head--logo .list-head__photo--letter {
  background: var(--tint);
}

.list-head__text {
  min-width: 0;
  flex: 1;
}

.list-head__kicker {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
}

.list-head__title {
  margin: 0;
  font-size: 32px;
  font-weight: 700;
}

.list-head__other {
  margin: 2px 0 0;
  font-size: 16px;
  color: var(--muted);
}

.list-head__about {
  max-width: 72ch;
  margin-top: 10px;
  font-size: 15px;
}

.list-head__about > :first-child {
  margin-top: 0;
}

.list-head__about > :last-child {
  margin-bottom: 0;
}

/* list.js folds a long introduction to four lines */
.list-head__about.is-folded {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.list-head__more {
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-weight: 600;
}

.list-head__subjects {
  padding-bottom: 0;
}

/* ---------- Layout ---------- */

.list-layout {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 32px;
  align-items: start;
}

@media (max-width: 1080px) {
  .list-layout {
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 24px;
  }
}

/* No filters to offer (an empty search) */
.list-layout--plain {
  grid-template-columns: minmax(0, 1fr);
}

/* ---------- Filters ---------- */

.filters__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.filters__title {
  margin: 0;
  font-size: 18px;
}

.fgroup {
  min-width: 0;
  margin: 0;
  padding: 14px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

/* Floated, so the group's top line runs above the heading, not through it */
.fgroup__title {
  float: left;
  width: 100%;
  padding: 0;
  margin-bottom: 4px;
  font-size: 15px;
  font-weight: 700;
}

.fgroup__title + * {
  clear: both;
}

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

.fopt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 4px 0;
  font-size: 15px;
  line-height: 1.35;
  cursor: pointer;
}

.fopt input {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.fopt__name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.fopt:hover .fopt__name {
  color: var(--accent);
}

.fopt__n {
  flex: none;
  font-size: 13px;
  color: var(--muted);
}

/* "৮টি আরও": the rest of a long list */
.fgroup__more > summary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
}

.fgroup__more > summary::-webkit-details-marker {
  display: none;
}

.fgroup__more > summary::after {
  content: "";
  width: 7px;
  height: 7px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-2px) rotate(45deg);
}

.fgroup__more[open] > summary {
  order: 2;
}

.fgroup__more[open] > summary::after {
  transform: translateY(2px) rotate(-135deg);
}

/* Find a name in a long list (list.js) */
.fgroup__find {
  width: 100%;
  min-height: 40px;
  margin: 2px 0 6px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  font-size: 15px;
}

.fgroup__find:focus-visible {
  outline-offset: 0;
  border-color: var(--accent);
}

/* Price: ₹ [from] – ₹ [to] */
.price-range {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}

.price-range__field {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.price-range__field:focus-within {
  border-color: var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.price-range__sign,
.price-range__to {
  color: var(--muted);
}

.price-range input {
  width: 100%;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 15px;
  appearance: textfield;
  -moz-appearance: textfield;
}

.price-range input:focus-visible {
  outline: none;
}

.price-range input::-webkit-inner-spin-button,
.price-range input::-webkit-outer-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.filters__foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.filters__foot .btn {
  flex: 1 1 auto;
  padding: 0 16px;
}

/* Wide: the sheet is an ordinary sidebar; with JS changes apply at once */
@media (min-width: 721px) {
  .filters[popover] {
    display: block;
    position: static;
    inset: auto;
    width: auto;
    height: auto;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    overflow: visible;
  }

  .filters__head {
    padding-bottom: 8px;
  }

  .filters__close,
  .filters__form.is-live .filters__foot {
    display: none;
  }
}

/* ---------- Results ---------- */

.list-results {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "meta bar"
    "first first"
    "grid grid"
    "more more";
  column-gap: 16px;
  align-items: start;
  min-width: 0;
}

.list-bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-meta {
  grid-area: meta;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  min-height: 44px;
  margin-bottom: 16px;
}

.list-meta__count {
  margin: 0;
  font-weight: 600;
}

/* Sort */
.list-sort {
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-sort__label {
  font-size: 14px;
  color: var(--muted);
}

.list-sort__box {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.list-sort__box .ic {
  position: absolute;
  left: 12px;
  color: var(--muted);
  pointer-events: none;
}

/* the select's arrow */
.list-sort__box::after {
  content: "";
  position: absolute;
  right: 14px;
  width: 7px;
  height: 7px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-2px) rotate(45deg);
  pointer-events: none;
}

.list-sort select {
  min-height: 44px;
  max-width: 100%;
  padding: 0 34px 0 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-size: 15px;
  appearance: none;
  cursor: pointer;
}

.list-sort select:hover {
  border-color: var(--accent);
}

.list-sort__go {
  min-height: 44px;
  padding: 0 14px;
}

/* Filters in use */
.list-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 40px;
  padding: 0 10px 0 14px;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: var(--tint);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.list-chip:hover {
  text-decoration: none;
  background: var(--soft);
}

.list-chips__clear {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 6px;
  font-size: 14px;
  font-weight: 600;
}

.list-first {
  grid-area: first;
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-height: 44px;
  margin-bottom: 8px;
  font-weight: 600;
}

/* Books (phones: the two-column grid from main.css) */
.list-grid {
  grid-area: grid;
  transition: opacity 0.2s ease;
}

@media (min-width: 721px) {
  .list-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }
}

.list-results[aria-busy="true"] .list-grid {
  opacity: 0.55;
}

/* Show more */
.list-more {
  grid-area: more;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-top: 28px;
}

.list-more__progress {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
}

.list-more__btn {
  min-width: min(260px, 100%);
}

.list-more__btn[aria-busy="true"] {
  opacity: 0.6;
  pointer-events: none;
}

/* Nothing found */
.list-empty {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  padding: 40px 0 56px;
}

.list-empty__title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
}

.list-empty__tip {
  margin: 0;
  color: var(--muted);
}

/* ---------- Phones ---------- */

@media (max-width: 720px) {
  .list-main {
    padding-top: 12px;
  }

  .list-head {
    gap: 14px;
    margin-bottom: 16px;
  }

  .list-head__photo {
    width: 72px;
    height: 72px;
  }

  .list-head__photo--letter {
    font-size: 30px;
  }

  .list-head__title {
    font-size: 24px;
  }

  .list-head__other {
    font-size: 15px;
  }

  /* Person: photo beside the name, the introduction below both */
  .list-head--person {
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    column-gap: 14px;
    align-items: center;
  }

  .list-head--person .list-head__text {
    display: contents;
  }

  .list-head--person .list-head__photo {
    grid-column: 1;
    grid-row: 1 / 4;
  }

  .list-head--person :is(.list-head__kicker, .list-head__title, .list-head__other) {
    grid-column: 2;
  }

  .list-head--person :is(.list-head__about, .list-head__more) {
    grid-column: 1 / -1;
    justify-self: start;
  }

  .list-layout {
    display: block;
  }

  .list-results {
    display: block;
  }

  /* Sort | Filter: full width, sticky under the header once list.js knows its height */
  .list-bar {
    margin: 0 calc(var(--gutter) * -1) 12px;
    padding: 8px var(--gutter);
    border-bottom: 1px solid var(--line);
    background: var(--bg);
  }

  .list-main.is-live .list-bar {
    position: sticky;
    top: var(--list-bar-top, 0px);
    z-index: 15;
  }

  .list-sort,
  .list-sort__box,
  .list-sort select {
    flex: 1;
    min-width: 0;
    width: 100%;
  }

  .list-sort__box .ic {
    left: 10px;
  }

  .list-sort__box::after {
    right: 12px;
  }

  .list-sort select {
    padding: 0 28px 0 34px;
    text-overflow: ellipsis;
  }

  .list-sort__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .list-bar__filter {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 0;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--ink);
    font-size: 15px;
    font-weight: 600;
  }

  .list-bar__on {
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 10px;
    background: var(--accent);
    color: var(--on-accent);
    font-size: 12px;
    line-height: 20px;
    text-align: center;
  }

  .list-meta {
    min-height: 0;
    margin-bottom: 12px;
  }

  .list-meta__count {
    font-size: 14px;
    color: var(--muted);
  }

  .list-chip {
    min-height: 36px;
    font-size: 13px;
  }

  .list-more__btn {
    width: 100%;
  }

  /* Filters: bottom sheet (see the @supports block below) */
  .filters__form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
  }

  .filters__head {
    padding: 6px 6px 6px 20px;
    border-bottom: 1px solid var(--line);
  }

  .filters__body {
    flex: 1;
    min-height: 0;
    padding: 0 20px;
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .filters__body > :first-child {
    border-top: 0;
  }

  .fopt {
    min-height: 44px;
  }

  .filters__foot {
    padding: 12px 20px calc(12px + env(safe-area-inset-bottom));
    background: var(--surface);
  }

  .filters__foot .filters__apply {
    flex: 2 1 auto;
  }
}

/* Phones: the filters as a bottom sheet where popovers work; elsewhere
   they stay a block above the results and the Filter button is hidden. */
@media (max-width: 720px) {
  @supports selector(:popover-open) {
    .filters[popover] {
      position: fixed;
      inset: auto 0 0;
      width: 100%;
      max-width: 100%;
      height: auto;
      max-height: 88vh;
      max-height: 88dvh;
      margin: 0;
      padding: 0;
      border: 0;
      border-radius: var(--radius-xl) var(--radius-xl) 0 0;
      background: var(--surface);
      color: var(--ink);
      box-shadow: var(--shadow-lg);
      overflow: hidden;
    }

    .filters:popover-open {
      display: flex;
      flex-direction: column;
      animation: sheet-up 0.28s ease-out;
    }

    .filters::backdrop {
      background: var(--overlay);
    }

    /* the page behind the open sheet stays put */
    html:has(.filters:popover-open) {
      overflow: hidden;
    }
  }

  @supports not selector(:popover-open) {
    .filters {
      margin-bottom: 16px;
    }

    .filters__close,
    .list-bar__filter {
      display: none;
    }
  }
}

@keyframes sheet-up {
  from {
    transform: translateY(100%);
  }
}
