/**
 * Collection template: header, filter sidebar/drawer (facets), active
 * pills, dual-range price slider, product grid, pagination, empty state,
 * related-collections strip and the all-collections grid.
 */

/* ------------------------------------------------------------------ */
/* Header + layout                                                     */
/* ------------------------------------------------------------------ */
.collection-header {
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--color-line);
  margin-bottom: var(--space-5);
}

.collection-header__description {
  color: var(--color-muted);
  margin-top: var(--space-2);
  max-width: 60ch;
}

.collection-header__count {
  color: var(--color-muted);
  margin-top: var(--space-2);
}

.collection-layout {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

.facets-loading #ProductGrid {
  opacity: 0.5;
  transition: opacity 0.15s ease;
  pointer-events: none;
}

@media screen and (min-width: 990px) {
  .collection-layout {
    flex-direction: row;
    align-items: flex-start;
    gap: var(--space-7);
  }

  .collection-main {
    flex: 1;
    min-width: 0;
  }
}

/* ------------------------------------------------------------------ */
/* Facets drawer (mobile <details>, sticky sidebar desktop)            */
/* ------------------------------------------------------------------ */
/* Keeps the <form> out of the flex box model so .facets-drawer lays out
   directly against .collection-main — see the comment in
   sections/main-collection.liquid for why the form can't wrap the grid. */
.facets-form {
  display: contents;
}

.facets-drawer {
  border: 1px solid var(--color-line);
  border-radius: var(--radius-m);
}

.facets-drawer__toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4);
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  cursor: pointer;
  list-style: none;
}

.facets-drawer__toggle::-webkit-details-marker {
  display: none;
}

.facets-drawer__panel {
  padding: 0 var(--space-4) var(--space-4);
  border-top: 1px solid var(--color-line);
  padding-top: var(--space-4);
}

@media screen and (min-width: 990px) {
  .facets-drawer {
    flex: 0 0 260px;
    width: 260px;
    position: sticky;
    /* Clear of the sticky header, not just clear of the viewport top. At
       top: var(--space-5) the rail parked 24px down the page and the header
       sat over its first 88px, so Availability and Price were hidden behind
       the bar for the whole scroll. */
    top: calc(var(--header-height) + var(--space-5));
    border: none;
    border-radius: 0;
    max-height: calc(100svh - var(--space-6) * 2);
    overflow-y: auto;
  }

  .facets-drawer__toggle {
    display: none;
  }

  .facets-drawer__panel {
    padding: 0;
    border-top: none;
  }
}

/* ------------------------------------------------------------------ */
/* Sort + active pills                                                 */
/* ------------------------------------------------------------------ */
/* Count left, sort right, on one row above the grid - the conventional
   place for a sort control, and it frees the filter rail to be only
   filters. */
.collection-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3) var(--space-5);
  margin-bottom: var(--space-4);
}

.collection-toolbar .facets__sort-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
}

/* Inline beside the select up here, rather than stacked above it as it is
   in the rail. */
.collection-toolbar .facets__sort-label {
  margin-bottom: 0;
  white-space: nowrap;
}

.collection-toolbar .facets__sort-select {
  width: auto;
  min-width: 190px;
}

.facets__sort-label {
  display: block;
  margin-bottom: var(--space-2);
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
}

.facets__sort-row {
  margin-bottom: var(--space-4);
}

.facets__sort-select {
  width: 100%;
}

.facets__active-pills {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.facets__pill {
  display: flex;
}

.facets__pill-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  height: 32px;
  padding-inline: var(--space-3);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  font-size: 12px;
  text-decoration: none;
  color: var(--color-ink);
  transition: border-color 0.15s ease;
}

.facets__pill-link:hover {
  border-color: var(--color-ink);
}

.facets__pill--clear-all .facets__pill-link {
  color: var(--color-muted);
  text-decoration: underline;
  border-color: transparent;
}

/* ------------------------------------------------------------------ */
/* Filter groups                                                       */
/* ------------------------------------------------------------------ */
.facets__group {
  border-bottom: 1px solid var(--color-line);
}

.facets__group:first-child {
  border-top: 1px solid var(--color-line);
}

.facets__group-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-block: var(--space-3);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  list-style: none;
}

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

.facets__group-summary svg {
  transition: transform 0.15s ease;
}

.facets__group[open] .facets__group-summary svg {
  transform: rotate(180deg);
}

.facets__group-body {
  padding-bottom: var(--space-4);
}

.facets__checkbox-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding-block: var(--space-1);
  cursor: pointer;
  font-size: 14px;
}

.facets__checkbox-row--zero {
  color: var(--color-muted);
}

.facets__checkbox-input {
  position: absolute;
  opacity: 0;
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
}

.facets__checkbox-box {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-s);
  position: relative;
}

.facets__checkbox-input:checked + .facets__checkbox-box {
  background-color: var(--color-ink);
  border-color: var(--color-ink);
}

.facets__checkbox-input:checked + .facets__checkbox-box::after {
  content: '';
  position: absolute;
  left: 5px;
  top: 1px;
  width: 5px;
  height: 10px;
  border: solid var(--color-bg);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.facets__checkbox-input:focus-visible + .facets__checkbox-box {
  outline: 2px solid var(--color-ink);
  outline-offset: 2px;
}

.facets__checkbox-label {
  flex: 1;
}

.facets__checkbox-count {
  color: var(--color-muted);
  font-size: 12px;
}

/* ------------------------------------------------------------------ */
/* Price range slider                                                  */
/* ------------------------------------------------------------------ */
.facets__price-slider {
  position: relative;
  height: 20px;
  margin-block: var(--space-4) var(--space-3);
}

.facets__price-track,
.facets__price-track-fill {
  position: absolute;
  top: 9px;
  height: 2px;
  border-radius: var(--radius-pill);
}

.facets__price-track {
  left: 0;
  right: 0;
  background-color: var(--color-line);
}

.facets__price-track-fill {
  left: var(--min-percent, 0%);
  right: calc(100% - var(--max-percent, 100%));
  background-color: var(--color-ink);
}

.facets__price-range {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  margin: 0;
  appearance: none;
  background: none;
  pointer-events: none;
}

.facets__price-range::-webkit-slider-thumb {
  appearance: none;
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--color-bg);
  border: 2px solid var(--color-ink);
  cursor: pointer;
  margin-top: 2px;
}

.facets__price-range::-moz-range-thumb {
  pointer-events: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background-color: var(--color-bg);
  border: 2px solid var(--color-ink);
  cursor: pointer;
}

.facets__price-range::-webkit-slider-runnable-track {
  height: 2px;
  background: none;
}

.facets__price-inputs {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.facets__price-field {
  flex: 1;
}

.facets__price-number {
  height: 40px;
  font-size: 14px;
}

.facets__noscript-submit {
  margin-top: var(--space-4);
  width: 100%;
}

/* ------------------------------------------------------------------ */
/* Product grid + empty state                                          */
/* ------------------------------------------------------------------ */
.collection-grid {
  display: grid;
  grid-template-columns: repeat(var(--columns-mobile, 2), minmax(0, 1fr));
  gap: var(--space-4);
}

@media screen and (min-width: 990px) {
  .collection-grid {
    grid-template-columns: repeat(var(--columns-desktop, 4), minmax(0, 1fr));
    gap: var(--space-5);
  }
}

.collection-empty {
  padding-block: var(--space-9);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.collection-empty__text {
  color: var(--color-muted);
  max-width: 40ch;
}

/* ------------------------------------------------------------------ */
/* Pagination                                                          */
/* ------------------------------------------------------------------ */

.pagination__link--ellipsis {
  color: var(--color-muted);
}

.pagination__link--disabled {
  color: var(--color-line);
  pointer-events: none;
}

/* Base 'arrow' icon points right by default (icon.liquid); previous needs
   the opposite direction. */
.pagination__item--prev .pagination__link--arrow svg {
  transform: rotate(180deg);
}

/* Gentle 2px nudge in the pointing direction on hover. */
@media (prefers-reduced-motion: no-preference) {
  .pagination__link--arrow svg {
    transition: transform 0.15s ease;
  }

  .pagination__item--prev .pagination__link--arrow:hover svg {
    transform: rotate(180deg) translateX(-2px);
  }

  .pagination__item--next .pagination__link--arrow:hover svg {
    transform: translateX(2px);
  }
}

/* ------------------------------------------------------------------ */
/* Related collections strip                                           */
/* ------------------------------------------------------------------ */
.related-collections__strip {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-inline: calc(var(--page-margin) * -1);
  padding-inline: var(--page-margin);
}

.related-collections__strip::-webkit-scrollbar {
  display: none;
}

.related-collections__tile {
  flex: 0 0 140px;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  text-decoration: none;
  color: inherit;
}

.related-collections__media {
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-m);
  background-color: var(--color-line);
  overflow: hidden;
}

.related-collections__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.related-collections__tile:hover .related-collections__image {
  transform: scale(1.04);
}

.related-collections__title {
  margin: 0;
  text-align: center;
  text-transform: none;
}

@media screen and (min-width: 750px) {
  .related-collections__strip {
    margin-inline: 0;
    padding-inline: 0;
    flex-wrap: wrap;
  }

  .related-collections__tile {
    flex: 0 0 180px;
  }
}

/* ------------------------------------------------------------------ */
/* All-collections grid                                                */
/* ------------------------------------------------------------------ */
.list-collections__heading {
  margin-bottom: var(--space-6);
}

.list-collections__grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

@media screen and (min-width: 750px) {
  .list-collections__grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media screen and (min-width: 990px) {
  /* The merchant's column count, with 4 as the fallback for a template saved
     before the setting existed. minmax(0, 1fr) rather than a bare 1fr: 1fr
     means minmax(auto, 1fr), so a single long collection title would refuse to
     wrap and push the whole row wider than the grid. */
  /* Wide gaps: at 24px these tiles read as one dense wall of artwork rather
     than as separate brands, because almost every tile is a full-bleed image
     that runs to its own edge - there is no card padding or border to
     separate one from the next, so the only separation is this gap. 40px is
     what stops the grid clustering. Rows get a touch more than columns
     because each tile's caption sits in the vertical space, so an equal
     value reads tighter down the page than across. */
  .list-collections__grid {
    grid-template-columns: repeat(var(--columns-desktop, 4), minmax(0, 1fr));
    column-gap: var(--space-7);
    row-gap: var(--space-8);
  }
}

/* ------------------------------------------------------------------ */
/* Infinite loading                                                    */
/* ------------------------------------------------------------------ */
/* The numbered links stay in the DOM whether or not this is on - they are
   the no-JS experience, they keep page two crawlable, and infinite-scroll.js
   reads the next URL out of them. Hiding them is purely presentational, so
   it happens here, only once the script has actually taken over (it sets
   .has-infinite-scroll on <html>, and removes it again if a fetch fails so
   the visitor is never stranded). */
.has-infinite-scroll .pagination {
  display: none;
}

.infinite-scroll {
  display: flex;
  justify-content: center;
  padding-block: var(--space-7);
}

.infinite-scroll__button[disabled] {
  cursor: progress;
}

.infinite-scroll__button.is-loading {
  opacity: 0.6;
}
