/* One catalogue layout for native WooCommerce loops, including home tabs,
   archives and related products. Cart/checkout and navigation tiles are excluded. */
body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products {
  --tkw-product-columns: 3;
  width: 100%;
  margin-left: 0;
  display: grid;
  grid-template-columns: repeat(var(--tkw-product-columns), minmax(0, 1fr));
  column-gap: 0;
  row-gap: 0;
}

/* WooCommerce's float clearfix must not become an empty grid cell. This only
   removes list pseudo-elements; the native card hover background is retained. */
body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products::before,
body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products::after {
  content: none;
  display: none;
}

body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products > li.product {
  box-sizing: border-box;
  float: none;
  clear: none;
  width: 100%;
  min-width: 0;
  max-width: none;
  margin-bottom: 24px;
}

/* Match the story Banner switch; keep navigation and sidebar breakpoints separate. */
@media (min-width: 768px) {
  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products {
    --tkw-product-columns: 4;
  }
}

@media (min-width: 1200px) {
  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results):not(.no-woocommerce-sidebar):has(#secondary) #page #main ul.products {
    --tkw-product-columns: 3;
  }
}

@media (min-width: 1440px) {
  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products {
    --tkw-product-columns: 5;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results):not(.no-woocommerce-sidebar):has(#secondary) #page #main ul.products {
    --tkw-product-columns: 4;
  }
}

@media (max-width: 992px) {
  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products {
    padding: 0;
    column-gap: 16px;
    row-gap: 20px;
    overflow: visible;
    scroll-snap-type: none;
  }

  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products > li.product {
    margin-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    scroll-snap-align: none;
  }

  /* The native mobile related/upsell carousel uses a 320px minimum card.
     These lists now share the same responsive catalogue grid. */
  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main :is(.related.products, .upsells.products) .woocommerce-card__header {
    padding: .75rem 0 0;
    box-shadow: none;
  }
}

@media (max-width: 600px) {
  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products {
    column-gap: 10px;
    row-gap: 18px;
  }

  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products .woocommerce-loop-product__title {
    font-size: 13px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products .product__categories {
    font-size: 11px;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }

  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products .price {
    font-size: 13px;
    line-height: 1.5;
  }

  body:not(.woocommerce-cart):not(.woocommerce-checkout) #page #main ul.products > li.product .button {
    padding-right: 5px;
    padding-left: 5px;
    font-size: 12px;
  }
}

/* Extend Shoptimizer's existing filter drawer to the shared compact breakpoint.
   Its native toggle, overlay, close button, form and JS remain in use. */
@media (min-width: 993px) and (max-width: 1199px) {
  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results) #page .content-area {
    float: none;
    width: 100%;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results) #page .mobile-filter {
    display: block;
    position: sticky;
    z-index: 3;
    top: 0;
    box-sizing: border-box;
    width: 100%;
    min-height: 44px;
    margin: 0 0 20px;
    padding: 10px 16px 10px 42px;
    border: 1px solid var(--tk-border, #d5d8dc);
    border-radius: 0;
    background: var(--tk-bg, #fff);
    color: var(--tk-text, #25292f);
    font-size: 12px;
    font-weight: 600;
    line-height: 22px;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: .03em;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results) #page .mobile-filter svg {
    position: absolute;
    top: 50%;
    left: 21px;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results) #page #secondary {
    box-sizing: border-box;
    visibility: hidden;
    overflow-y: auto;
    position: fixed;
    z-index: 102;
    top: 0;
    left: -300px;
    width: 300px !important;
    height: 100%;
    margin: 0;
    padding: 1.5rem;
    opacity: 0;
    background: var(--tk-bg, #fff);
    color: var(--tk-text, #25292f);
    -webkit-overflow-scrolling: touch;
    transition: left .35s, opacity .35s, visibility .35s;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results).filter-open #page #secondary {
    visibility: visible;
    left: 0;
    opacity: 1;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results) .mobile-overlay {
    visibility: hidden;
    position: fixed;
    z-index: 101;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    background: rgb(52 53 55 / 40%);
    transition: opacity .35s, visibility .35s;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results).filter-open {
    overflow: hidden;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results).filter-open .mobile-overlay {
    visibility: visible;
    opacity: 1;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results) #page .filters.close-drawer {
    display: none;
    visibility: hidden;
  }

  body:is(.woocommerce.archive, .page-template-template-woocommerce-archives, .wc-active.search-results).filter-open #page .filters.close-drawer {
    display: block;
    visibility: visible;
    position: fixed;
    z-index: 299;
    top: 10px;
    left: 310px;
    width: 40px;
    height: 40px;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
  }
}

/* Share the native content width with Elementor's default boxed sections. */
body .elementor-section.elementor-section-boxed > .elementor-container {
    max-width: var(--tkwatch-content-width, 1170px);
}
