/* Shared product loops on Shop, product taxonomies and the related products section. */
:is(#agape-inner .agape-catalog, body.single-product .related.products) ul.products {
  --card-image-height: clamp(138px, 12vw, 166px);
  --card-padding: 16px;
  --card-gap: 8px;
  --card-title-size: 14px;
  --card-price-size: 16px;

  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-auto-flow: row;
  align-content: start;
  align-items: stretch;
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;

  &::before, &::after { display: none; }

  &.products-list-view { grid-template-columns: minmax(0, 1fr); }

  & > li.type-product {
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: var(--card-gap);
    float: none;
    width: auto;
    min-width: 0;
    height: auto;
    min-height: 0;
    margin: 0;
    padding: var(--card-padding);
    border: 1px solid #dce2ec;
    border-radius: 12px;
    background: linear-gradient(135deg, #fff, #f4f7fb);
    box-shadow: 0 2px 3px #0d234208;
    text-align: left;
    cursor: pointer;
  }

  & .woocommerce-loop-image-link:has(img) {
    display: block;
    flex: none;
    height: var(--card-image-height);
    margin: 0;
    padding: 0;
    overflow: hidden;

    & img {
      width: 100%;
      height: 100%;
      object-fit: contain;
      margin: 0;
    }
    & .kb-is-ratio-image {
      height: 100%;
      padding: 0;
      aspect-ratio: auto;
    }
    & .kb-is-ratio-image::before, & .secondary-product-image { display: none; }
  }

  & .woocommerce-loop-image-link:empty { display: none; }
  & li.type-product .product-details {
    display: flex;
    flex: 1 0 auto;
    flex-direction: column;
    gap: var(--card-gap);
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    background: transparent;
    box-shadow: none;
  }
  & .woocommerce-loop-product__title {
    margin: 0;
    padding: 0;
    color: #0d2342;
    font-family: inherit;
    font-size: var(--card-title-size);
    font-weight: 700;
    line-height: 1.4;
    overflow-wrap: anywhere;
  }
  & .woocommerce-loop-product__title a, & .agape-product-attributes {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  & .woocommerce-loop-product__title a {
    -webkit-line-clamp: 3;
    color: inherit;
    text-decoration: none;
  }
  & .agape-product-attributes {
    -webkit-line-clamp: 2;
    margin: 0;
    color: #334563;
    font-size: 12px;
    line-height: 1.45;
  }
  & .price {
    display: block;
    margin: auto 0 0;
    color: #071a34;
    font-size: var(--card-price-size);
    font-weight: 700;
    line-height: 1.4;
  }
  & .price del { opacity: .6; font-size: 12px; }
  & .price ins { background: transparent; }

  & li.product .product-action-wrap {
    position: static;
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    margin: 0;
    padding: 0;
    opacity: 1;
    transform: none;
  }
  /* The archive inserts Gutenberg spacing between the purchase action and notice. */
  & .product-action-wrap > .wp-block-spacer,
  & .product-action-wrap > p.wp-block-paragraph:empty {
    display: none;
  }
  & .product-action-wrap a.button {
    position: relative;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 9px 8px;
    border: 1px solid #d9ae36;
    border-radius: 7px;
    background: var(--ag-btn-gold, linear-gradient(180deg, #f6d878, #dfa92c));
    color: #081c35;
    font-size: var(--card-button-size, 14px);
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
    text-decoration: none;
    white-space: normal;
    transform: none;
  }
  & .product-action-wrap a.button:hover { background: var(--ag-btn-gold-hover, linear-gradient(180deg, #ffe39a, #e9b73d)); }
  & a:focus-visible { outline: 3px solid #b1841a; outline-offset: 2px; }
  & a.added_to_cart.wc-forward,
  & .product-action-wrap .kadence-svg-iconset,
  & .product-action-wrap a.button::before,
  & .product-action-wrap a.button::after { display: none; }

  /* Loading appearance is centralized in woocommerce-ui.css. */
  & .product-compliance-text {
    position: static;
    margin: 0;
    padding: 0;
    color: #334563;
    font-size: 10px;
    line-height: 1.4;
    text-align: center;
  }
  & .product-compliance-text p { margin: 0; }
  & .onsale { position: absolute; inset: 6px auto auto 6px; z-index: 1; }

  @media (max-width: 1100px) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  @media (max-width: 700px) {
    --card-image-height: 135px;
    --card-padding: 12px 10px;
    --card-gap: 7px;
    --card-title-size: 13px;
    --card-price-size: 14px;
    --card-button-size: 11px;
    gap: 12px;
  }
  @media (min-width: 701px) {
    &.products-list-view > li.type-product {
      display: grid;
      grid-template-columns: minmax(140px, 22%) minmax(0, 1fr);
      align-items: start;
    }
  }
}

