/* Archive grids only: leave related products and cart recommendations alone. */
@media (max-width: 1180px) {
  .woocommerce .tm-shop-main > ul.products {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
  }

  .woocommerce .tm-shop-main > ul.products li.product {
    min-width: 0;
    float: none;
    width: auto;
    margin: 0;
  }

  .woocommerce .tm-shop-main > ul.products li.product .woocommerce-loop-product__title {
    padding: 14px 12px 8px;
    font-size: 15px;
    overflow-wrap: anywhere;
  }

  .woocommerce .tm-shop-main > ul.products li.product .price {
    padding: 0 12px 14px;
    font-size: 15px;
  }

  .woocommerce .tm-shop-main > ul.products li.product .button {
    width: calc(100% - 24px);
    min-height: 44px;
    margin: 0 12px 12px;
    padding: 10px 8px;
    font-size: 13px;
    line-height: 1.3;
    white-space: normal;
    text-align: center;
  }
}

@media (max-width: 700px) {
  .woocommerce .tm-shop-main > ul.products {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .woocommerce .tm-shop-main > ul.products li.product a img {
    padding: 12px;
  }
}

@media (max-width: 1180px) {
  .tm-shop-shell,
  .tm-storefront {
    --tm-shop-page-gutter: 28px;
    --tm-shop-section-space: 34px;
    --tm-shop-card-gap: 24px;
  }

  .tm-shop-shell {
    grid-template-columns: 1fr;
  }

  .tm-shop-shell--archive {
    grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  }

  .woocommerce ul.products,
  .tm-shop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .woocommerce div.product {
    grid-template-columns: minmax(0, 1fr);
  }

  .woocommerce div.product div.images {
    max-width: 760px;
    width: 100%;
  }

  .tm-product-archive-hero {
    min-height: 190px;
  }

  .tm-shop-term-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .woocommerce-cart .woocommerce,
  .woocommerce-checkout form.checkout {
    grid-template-columns: 1fr;
  }

  .woocommerce-checkout #customer_details,
  .woocommerce-checkout #order_review_heading,
  .woocommerce-checkout table.shop_table.woocommerce-checkout-review-order-table,
  .woocommerce-checkout #payment {
    grid-column: auto;
    grid-row: auto;
  }
}

@media (max-width: 782px) {
  .tm-shop-shell,
  .tm-storefront {
    --tm-shop-page-gutter: 16px;
    --tm-shop-section-space: 22px;
    --tm-shop-card-gap: 18px;
    padding-top: 10px;
    padding-bottom: 48px;
  }

  .woocommerce div.product {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .tm-shop-shell--archive {
    display: grid;
    grid-template-columns: 1fr;
  }

  .tm-product-category-menu {
    position: static;
    max-height: none;
  }

  .tm-shop-filter-pills {
    display: flex;
    flex-wrap: wrap;
    overflow: visible;
  }

  .tm-shop-filter-pill {
    max-width: 100%;
    white-space: normal;
  }

  .tm-shop-filters {
    position: fixed;
    top: auto;
    inset: 0;
    z-index: 9999;
    display: none;
    padding: 18px;
    background: rgba(23, 32, 51, 0.52);
    overflow-y: auto;
  }

  .tm-shop-filters.is-open {
    display: block;
  }

  .tm-shop-filters__form {
    max-height: none;
    overflow: visible;
    max-width: 420px;
    margin: 0 auto;
  }

  .tm-shop-filters__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .woocommerce .woocommerce-message,
  .woocommerce .woocommerce-info,
  .woocommerce .woocommerce-error {
    align-items: flex-start;
    flex-direction: column;
    padding: 15px 15px 15px 52px;
  }

  .woocommerce .woocommerce-message::before,
  .woocommerce .woocommerce-info::before,
  .woocommerce .woocommerce-error::before {
    top: 16px;
    left: 15px;
    transform: none;
  }

  .woocommerce .woocommerce-message .button,
  .woocommerce .woocommerce-info .button,
  .woocommerce .woocommerce-error .button {
    align-self: flex-start;
    margin: 4px 0 0;
  }

  .woocommerce ul.products,
  .tm-shop-grid,
  .tm-shop-term-grid {
    grid-template-columns: 1fr;
  }

  /* WooCommerce's small-screen stylesheet applies percentage widths to loop
   * items. Once the theme's product list is a grid, the grid track owns item
   * sizing instead. Keep this reset alongside the grid breakpoint so global
   * responsive styles cannot create a second, conflicting layout system. */
  .woocommerce ul.products[class*="columns-"] li.product,
  .woocommerce-page ul.products[class*="columns-"] li.product {
    float: none;
    width: auto;
    margin: 0;
  }

  .tm-shop-section__header {
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }

  .tm-product-archive-hero {
    min-height: 0;
    padding: 22px 20px;
  }

  .tm-product-archive-hero__content {
    min-height: 190px;
  }

  .tm-shop-results-bar {
    align-items: stretch;
    flex-direction: column;
    padding: 16px;
  }

  .tm-shop-results-bar .woocommerce-ordering,
  .tm-shop-results-bar .woocommerce-ordering select {
    width: 100%;
  }

  .tm-shop-term-card {
    grid-template-columns: 96px minmax(0, 1fr);
  }

  .woocommerce .woocommerce-products-header__title,
  .woocommerce div.product .product_title {
    font-size: clamp(30px, 10vw, 42px);
  }

  .woocommerce div.product .summary,
  .woocommerce div.product .woocommerce-tabs,
  .tm-shop-section {
    border-radius: 8px;
  }

  .woocommerce div.product form.cart {
    align-items: stretch;
    flex-direction: column;
    padding: 18px;
  }

  .woocommerce div.product form.cart .variations_button,
  .woocommerce div.product form.cart:not(.variations_form) {
    grid-template-columns: 1fr;
  }

  .woocommerce div.product form.cart .button,
  .woocommerce div.product form.cart div.quantity,
  .woocommerce div.product form.cart .quantity .qty {
    width: 100%;
  }

  .woocommerce-cart table.shop_table.cart,
  .woocommerce-cart table.shop_table.cart tbody,
  .woocommerce-cart table.shop_table.cart tr,
  .woocommerce-cart table.shop_table.cart td {
    display: block;
    width: 100%;
  }

  .woocommerce-cart table.shop_table.cart thead {
    display: none;
  }

  .woocommerce-cart table.shop_table.cart tr.cart_item {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 12px 16px;
    padding: 20px 0;
    border-bottom: 1px solid var(--tm-color-border);
  }

  .woocommerce-cart table.shop_table.cart tbody td {
    padding: 0;
    border: 0;
    text-align: left;
  }

  .woocommerce-cart table.shop_table.cart .product-remove {
    grid-column: 2;
    grid-row: 4;
  }

  .woocommerce-cart table.shop_table.cart .product-thumbnail {
    grid-row: 1 / span 4;
  }

  .woocommerce-cart table.shop_table.cart .product-name,
  .woocommerce-cart table.shop_table.cart .product-price,
  .woocommerce-cart table.shop_table.cart .product-quantity,
  .woocommerce-cart table.shop_table.cart .product-subtotal {
    grid-column: 2;
  }

  .woocommerce-cart table.shop_table.cart .product-price::before,
  .woocommerce-cart table.shop_table.cart .product-subtotal::before {
    content: attr(data-title) ": ";
    color: var(--tm-color-muted);
    font-weight: 700;
  }

  .woocommerce-cart table.shop_table.cart td.actions .coupon {
    align-items: stretch;
    flex-direction: column;
    max-width: none;
  }

  .woocommerce-cart table.shop_table.cart td.actions .button,
  .woocommerce-cart table.shop_table.cart td.actions .coupon .input-text {
    width: 100%;
  }

  .woocommerce-checkout form.checkout {
    gap: 30px;
  }
}

@media (max-width: 520px) {
  .tm-shop-price-fields {
    grid-template-columns: 1fr;
  }

  .tm-shop-term-card {
    grid-template-columns: 1fr;
  }

  .tm-shop-term-card__media {
    min-height: 150px;
  }

  .tm-product-archive-hero__actions,
  .tm-shop-section__header {
    align-items: stretch;
  }

  .tm-product-archive-hero__actions .tm-shop-button,
  .tm-shop-section__header a {
    width: 100%;
  }
}
