/**
 * Shop archive: two-column layout (filter sidebar + product grid),
 * nested inside Blocksy's own `.ct-container > section` wrapper (see
 * inc/hooks/shop-hooks.php) so page width/spacing stays consistent with
 * the rest of the site.
 */

.hs-shop__layout {
  display: flex;
  align-items: flex-start;
  gap: var(--hs-space-32);
  padding-block: var(--hs-space-24) var(--hs-space-64);
}

.hs-shop__main {
  flex: 1 1 auto;
  min-width: 0;
}

/* ---------- Sidebar: static column on desktop ---------- */

.hs-shop__sidebar {
  flex: 0 0 17rem;
  width: 17rem;
}

.hs-shop__sidebar-backdrop {
  display: none;
}

.hs-shop__sidebar-header {
  display: none;
}

.hs-shop__sidebar-panel {
  position: sticky;
  top: var(--hs-space-24);
}

.hs-shop-filter-group {
  border: 0;
  padding: 0;
  margin: 0 0 var(--hs-space-24);
}

.hs-shop-filter-group legend {
  font-size: var(--hs-font-size-body);
  font-weight: var(--hs-font-weight-semibold);
  color: var(--hs-color-text);
  margin-block-end: var(--hs-space-12);
  padding: 0;
}

.hs-shop-filter__cat-list,
.hs-shop-filter__checkbox-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--hs-space-8);
}

.hs-shop-filter__cat-list a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hs-space-8);
  color: var(--hs-color-text-muted);
  font-size: var(--hs-font-size-body-sm);
  text-decoration: none;
  transition: color var(--hs-transition-fast) var(--hs-ease);
}

.hs-shop-filter__cat-list a:hover {
  color: var(--hs-color-primary-600);
}

.hs-shop-filter__cat-list a.is-active {
  color: var(--hs-color-primary-600);
  font-weight: var(--hs-font-weight-semibold);
}

.hs-shop-filter__count {
  color: var(--hs-color-text-muted);
  font-size: var(--hs-font-size-caption);
}

.hs-shop-filter__checkbox-list label {
  display: flex;
  align-items: center;
  gap: var(--hs-space-8);
  font-size: var(--hs-font-size-body-sm);
  color: var(--hs-color-text);
  cursor: pointer;
}

.hs-shop-filter__checkbox-list input {
  accent-color: var(--hs-color-primary-500);
  width: 1.1em;
  height: 1.1em;
  flex-shrink: 0;
}

.hs-shop-filter__price-inputs {
  display: flex;
  align-items: flex-end;
  gap: var(--hs-space-8);
}

.hs-shop-filter__price-inputs label {
  display: flex;
  flex-direction: column;
  gap: var(--hs-space-4);
  flex: 1 1 0;
  font-size: var(--hs-font-size-caption);
  color: var(--hs-color-text-muted);
}

.hs-shop-filter__price-inputs input {
  padding: var(--hs-space-8) var(--hs-space-8);
}

.hs-shop-filter__price-sep {
  color: var(--hs-color-text-muted);
  padding-block-end: var(--hs-space-8);
}

.hs-shop-filter__toggle {
  display: flex;
  align-items: center;
  gap: var(--hs-space-8);
  font-size: var(--hs-font-size-body-sm);
  color: var(--hs-color-text);
  cursor: pointer;
}

.hs-shop-filter__toggle input {
  accent-color: var(--hs-color-primary-500);
  width: 1.1em;
  height: 1.1em;
}

.hs-shop-filter__actions {
  display: flex;
  flex-direction: column;
  gap: var(--hs-space-12);
}

.hs-shop-filter__reset {
  text-align: center;
  font-size: var(--hs-font-size-body-sm);
  color: var(--hs-color-text-muted);
  text-decoration: underline;
}

.hs-shop-filter__reset:hover {
  color: var(--hs-color-danger-600);
}

/* No-JS fallback only: shop-filters.js adds .is-enhanced once it takes
   over (filters then submit on change instead), hiding this button so
   it doesn't sit there as a redundant control. */
.hs-shop-filter-form.is-enhanced [data-hs-shop-filter-submit] {
  display: none;
}

/* ---------- Toolbar ---------- */

.hs-shop__toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hs-space-16);
  margin-block-end: var(--hs-space-16);
}

.hs-shop__filter-trigger {
  display: none;
  align-items: center;
  gap: var(--hs-space-8);
}

.hs-shop__view-toggle {
  display: flex;
  gap: var(--hs-space-4);
  margin-inline-start: auto;
}

.hs-shop__view-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--hs-radius-md);
  color: var(--hs-color-text-muted);
  border: 1px solid transparent;
  transition: background-color var(--hs-transition-fast) var(--hs-ease),
    color var(--hs-transition-fast) var(--hs-ease);
}

.hs-shop__view-btn:hover {
  background: var(--hs-color-surface-sunken);
}

.hs-shop__view-btn.is-active {
  background: color-mix(in srgb, var(--hs-color-primary-500) 12%, var(--hs-color-surface));
  color: var(--hs-color-primary-500);
  border-color: var(--hs-color-primary-500);
}

/* WooCommerce/Blocksy's own result-count + sort dropdown row */
.woo-listing-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--hs-space-16);
  flex-wrap: wrap;
  margin-block-end: var(--hs-space-20);
  padding-block-end: var(--hs-space-16);
  border-block-end: 1px solid var(--hs-color-border);
}

.woo-listing-top .woocommerce-result-count {
  font-size: var(--hs-font-size-body-sm);
  color: var(--hs-color-text-muted);
  margin: 0;
}

.woo-listing-top select {
  padding: var(--hs-space-8) var(--hs-space-12);
  border: 1px solid var(--hs-color-border-strong);
  border-radius: var(--hs-radius-md);
  background: var(--hs-color-surface);
  font-size: var(--hs-font-size-body-sm);
  color: var(--hs-color-text);
}

.woo-listing-top select:focus {
  outline: none;
  border-color: var(--hs-color-primary-500);
  box-shadow: 0 0 0 3px var(--hs-color-primary-100);
}

/* ---------- Product grid / list ---------- */

#hs-shop-results {
  position: relative;
  min-height: 12rem;
}

#hs-shop-results.is-loading {
  opacity: .5;
  pointer-events: none;
}

/* Base .hs-shop-grid rules live in components/product-card.css (loaded
   sitewide wherever a product grid can appear, not just here) - only the
   list-view toggle, a shop-archive-only UI feature, stays in this file. */
.hs-shop-grid[data-view="list"] {
  grid-template-columns: 1fr;
}

/* The card has three direct children (media/body/footer) - a plain
   2-column grid would wrap the footer onto its own full-width row, so
   template areas are used instead to keep the image spanning the full
   card height alongside a stacked body+footer column. */
.hs-shop-grid[data-view="list"] .hs-product-card {
  display: grid;
  grid-template-columns: 12rem 1fr;
  grid-template-areas: "media body" "media footer";
  align-items: start;
  gap: 0 var(--hs-space-24);
}

.hs-shop-grid[data-view="list"] .hs-product-card__media {
  grid-area: media;
  align-self: stretch;
  /* Without an explicit width, align-self: stretch sets this element's
     height to match the (tall) body+footer row, and aspect-ratio: 1/1
     from the base .hs-product-card__media rule then computes width from
     that stretched height instead of from the 7rem/12rem grid column -
     on narrow viewports this made the image balloon to ~226px wide,
     overlapping the body column and squeezing product titles down to a
     sliver. Pinning width: 100% forces the aspect-ratio to size from the
     grid column's actual width instead. */
  width: 100%;
  min-width: 0;
}

.hs-shop-grid[data-view="list"] .hs-product-card__media img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}

.hs-shop-grid[data-view="list"] .hs-product-card__body {
  grid-area: body;
  min-width: 0;
}

.hs-shop-grid[data-view="list"] .hs-product-card__footer {
  grid-area: footer;
  align-self: end;
}

.hs-shop-empty {
  padding: var(--hs-space-64) var(--hs-space-16);
  text-align: center;
  color: var(--hs-color-text-muted);
  font-size: var(--hs-font-size-body);
}

/* ---------- Pagination (paginate_links() markup) ---------- */

.hs-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--hs-space-8);
  flex-wrap: wrap;
}

.hs-pagination .page-numbers {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding-inline: var(--hs-space-8);
  border-radius: var(--hs-radius-md);
  font-size: var(--hs-font-size-body-sm);
  font-weight: var(--hs-font-weight-medium);
  color: var(--hs-color-text);
  transition: background-color var(--hs-transition-fast) var(--hs-ease),
    color var(--hs-transition-fast) var(--hs-ease);
}

.hs-pagination a.page-numbers:hover {
  background: var(--hs-color-surface-sunken);
}

.hs-pagination .page-numbers.current {
  background: var(--hs-color-primary-fill);
  color: #fff;
}

.hs-pagination .page-numbers.dots {
  color: var(--hs-color-text-muted);
}

/* ---------- Mobile: sidebar becomes an off-canvas drawer ---------- */

@media (max-width: 61.9375rem) {
  .hs-shop__layout {
    display: block;
  }

  .hs-shop__filter-trigger {
    display: inline-flex;
  }

  .hs-shop__sidebar {
    width: auto;
  }

  .hs-shop__sidebar-panel {
    position: fixed;
    inset-block: 0;
    inset-inline-end: 0;
    width: min(22rem, 88vw);
    background: var(--hs-color-surface);
    box-shadow: var(--hs-shadow-large);
    z-index: var(--hs-z-drawer);
    overflow-y: auto;
    padding: var(--hs-space-24);
    transform: translateX(100%);
    transition: transform var(--hs-transition-normal) var(--hs-ease);
  }

  :root[dir="rtl"] .hs-shop__sidebar-panel {
    transform: translateX(-100%);
  }

  .hs-shop__sidebar.is-open .hs-shop__sidebar-panel {
    transform: translateX(0);
  }

  .hs-shop__sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, .5);
    z-index: calc(var(--hs-z-drawer) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--hs-transition-normal) var(--hs-ease);
  }

  .hs-shop__sidebar.is-open .hs-shop__sidebar-backdrop {
    opacity: 1;
    visibility: visible;
  }

  .hs-shop__sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-block-end: var(--hs-space-20);
    padding-block-end: var(--hs-space-16);
    border-block-end: 1px solid var(--hs-color-border);
  }

  .hs-shop__sidebar-header h2 {
    font-size: var(--hs-font-size-h6);
    margin: 0;
  }

  .hs-shop__sidebar-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    color: var(--hs-color-text-muted);
    border-radius: var(--hs-radius-md);
  }

  .hs-shop__sidebar-close:hover {
    background: var(--hs-color-surface-sunken);
  }
}

@media (max-width: 48rem) {
  .hs-shop-grid {
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: var(--hs-space-16);
  }

  .hs-shop-grid[data-view="list"] .hs-product-card {
    grid-template-columns: 7rem 1fr;
    gap: var(--hs-space-12);
  }

  .woo-listing-top {
    flex-direction: column;
    align-items: stretch;
  }
}
