@layer hpds-commerce {
  .hpds-product-grid {
    display: grid;
    gap: clamp(var(--hpds-space-5), 3vw, var(--hpds-space-7));
    grid-template-columns: repeat(var(--hpds-product-columns, 4), minmax(0, 1fr));
  }

  .hpds-product-card,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__item {
    display: flex;
    flex-direction: column;
    min-inline-size: 0;
  }

  .hpds-product-card__media,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__thumb-wrap {
    aspect-ratio: 1 / 1;
    background: var(--hpds-color-surface-subtle);
    border-radius: var(--hpds-radius-sm);
    overflow: hidden;
    position: relative;
  }

  .hpds-product-card__media img,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__thumb {
    block-size: 100%;
    inline-size: 100%;
    object-fit: contain;
    transition: transform var(--hpds-duration-normal) var(--hpds-ease-standard);
  }

  .hpds-product-card:hover .hpds-product-card__media img,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__item:hover .c-product-grid__thumb {
    transform: scale(1.025);
  }

  .hpds-product-card__body,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__details {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--hpds-space-3);
    padding-block-start: var(--hpds-space-4);
  }

  .hpds-product-card__title,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__title-wrap {
    color: var(--hpds-color-text);
    font-size: var(--hpds-font-size-300);
    font-weight: var(--hpds-weight-semibold);
    line-height: 1.4;
    margin: 0;
    min-block-size: 2.8em;
    overflow-wrap: anywhere;
  }

  body.hpds-enabled.hpds-module-commerce .c-product-grid__title-wrap .woocommerce-loop-product__title {
    color: inherit;
    font-family: var(--hpds-font-sans);
    font-size: inherit;
    font-weight: inherit;
    letter-spacing: 0;
    line-height: inherit;
    margin: 0;
    min-block-size: 2.8em;
  }

  .hpds-product-card__actions { margin-block-start: auto; padding-block-start: var(--hpds-space-3); }

  .hpds-price-stack,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__price-wrap,
  body.hpds-enabled.hpds-module-commerce .hairport-club-pricing {
    display: grid;
    gap: var(--hpds-space-1);
    min-block-size: 3.75rem;
  }

  .hpds-price { align-items: baseline; display: flex; flex-wrap: wrap; gap: var(--hpds-space-2); }
  .hpds-price--regular { color: var(--hpds-color-text); font-size: var(--hpds-font-size-300); font-weight: var(--hpds-weight-semibold); }
  .hpds-price--sale { color: var(--hpds-color-sale); font-size: var(--hpds-font-size-400); font-weight: var(--hpds-weight-bold); }
  .hpds-price--club,
  body.hpds-enabled.hpds-module-commerce .hairport-club-member-price { color: var(--hpds-color-club); font-size: var(--hpds-font-size-300); font-weight: var(--hpds-weight-bold); }
  .hpds-price--unit,
  body.hpds-enabled.hpds-module-commerce .hairport-club-member-unit-price { color: var(--hpds-color-text-muted); font-size: var(--hpds-font-size-100); font-weight: var(--hpds-weight-regular); }
  .hpds-price__label { color: inherit; }
  .hpds-price__amount { white-space: nowrap; }
  .hpds-price__compare { color: var(--hpds-color-text-muted); font-size: var(--hpds-font-size-200); text-decoration: line-through; }

  body.hpds-enabled.hpds-module-commerce .hairport-club-member-price__label,
  body.hpds-enabled.hpds-module-commerce .hairport-club-member-unit-price__label { color: inherit; }

  body.hpds-enabled.hpds-module-commerce .hairport-club-member-price__amount,
  body.hpds-enabled.hpds-module-commerce .hairport-club-member-unit-price__amount { color: inherit; white-space: nowrap; }

  body.hpds-enabled.hpds-module-commerce .hairport-club-pricing {
    border-block-start: 1px solid color-mix(in srgb, var(--hpds-color-club) 35%, transparent);
    margin-block-start: var(--hpds-space-3);
    padding-block-start: var(--hpds-space-2);
  }

  body.hpds-enabled.hpds-module-commerce .entry-summary > .hairport-club-pricing {
    background: color-mix(in srgb, var(--hpds-color-club) 7%, var(--hpds-color-surface));
    border: 1px solid color-mix(in srgb, var(--hpds-color-club) 35%, var(--hpds-color-border));
    border-inline-start: 3px solid var(--hpds-color-club);
    padding: var(--hpds-space-4);
  }

  /* One visual slot per price type. Business logic remains in Partners Core. */
  body.hpds-enabled.hpds-module-commerce .hairport-club-pricing > .hairport-club-member-price ~ .hairport-club-member-price,
  body.hpds-enabled.hpds-module-commerce .hairport-club-pricing > .hairport-club-member-unit-price ~ .hairport-club-member-unit-price,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__price-wrap > .hairport-club-pricing ~ .hairport-club-pricing,
  body.hpds-enabled.hpds-module-commerce .summary > .hairport-club-pricing ~ .hairport-club-pricing {
    display: none;
  }

  .hpds-badges,
  body.hpds-enabled.hpds-module-commerce .c-product-grid__badges,
  body.hpds-enabled.hpds-module-commerce .c-product__badges {
    display: flex;
    flex-wrap: wrap;
    gap: var(--hpds-space-2);
    inset: var(--hpds-space-3) var(--hpds-space-3) auto auto;
    position: absolute;
    z-index: var(--hpds-z-base);
  }

  .hpds-product-badge {
    background: var(--hpds-color-brand);
    border-radius: var(--hpds-radius-sm);
    color: var(--hpds-color-surface);
    font-size: var(--hpds-font-size-100);
    font-weight: var(--hpds-weight-bold);
    line-height: 1;
    padding: 0.45rem 0.6rem;
  }

  .hpds-product-badge--sale { background: var(--hpds-color-sale); }
  .hpds-product-badge--club { background: var(--hpds-color-club); color: #111111; }
  .hpds-product-badge--stock { background: var(--hpds-color-success); }

  .hpds-stock { align-items: center; color: var(--hpds-color-success); display: inline-flex; font-size: var(--hpds-font-size-200); font-weight: var(--hpds-weight-semibold); gap: var(--hpds-space-2); }
  .hpds-stock::before { background: currentColor; block-size: 0.5rem; border-radius: 50%; content: ""; inline-size: 0.5rem; }
  .hpds-stock--out { color: var(--hpds-color-error); }
  .hpds-stock--low { color: var(--hpds-color-warning); }

  .hpds-product-detail,
  body.hpds-enabled.hpds-module-commerce .c-product__wrap {
    align-items: start;
    display: grid;
    gap: clamp(var(--hpds-space-6), 6vw, var(--hpds-space-9));
    grid-template-columns: minmax(0, 1.08fr) minmax(20rem, 0.92fr);
  }

  body.hpds-enabled.hpds-module-commerce .c-product__title {
    color: var(--hpds-color-text);
    font-family: var(--hpds-font-display);
    font-size: var(--hpds-font-size-700);
    font-weight: var(--hpds-weight-black);
    letter-spacing: 0;
    line-height: var(--hpds-line-tight);
    overflow-wrap: anywhere;
  }

  body.hpds-enabled.hpds-module-commerce .c-product__gallery { min-inline-size: 0; }
  body.hpds-enabled.hpds-module-commerce .entry-summary { display: grid; gap: var(--hpds-space-4); min-inline-size: 0; }

  body.hpds-enabled.hpds-module-commerce .c-product__gallery :where(.c-product__slider-item, .c-product__thumbs-item) {
    background: var(--hpds-color-surface);
    border: var(--hpds-border);
    border-radius: 0;
  }

  body.hpds-enabled.hpds-module-commerce .c-product__gallery img {
    object-fit: contain;
  }

  body.hpds-enabled.hpds-module-commerce .entry-summary :where(.price, .stock, .product_meta) {
    margin-block: 0;
  }

  body.hpds-enabled.hpds-module-commerce .entry-summary .price {
    color: var(--hpds-color-text);
    font-size: var(--hpds-font-size-500);
    font-weight: var(--hpds-weight-bold);
  }

  body.hpds-enabled.hpds-module-commerce .entry-summary .cart {
    align-items: stretch;
    display: flex;
    flex-wrap: wrap;
    gap: var(--hpds-space-3);
  }

  .hpds-quantity,
  body.hpds-enabled.hpds-module-commerce .c-product__quantity {
    align-items: stretch;
    border: var(--hpds-border);
    border-radius: var(--hpds-radius-sm);
    display: inline-grid;
    grid-template-columns: 2.75rem minmax(3rem, auto) 2.75rem;
    overflow: hidden;
  }

  .hpds-quantity__button,
  body.hpds-enabled.hpds-module-commerce :is(.c-product__quantity-minus, .c-product__quantity-plus) {
    align-items: center;
    background: var(--hpds-color-surface-subtle);
    border: 0;
    color: var(--hpds-color-text);
    cursor: pointer;
    display: flex;
    justify-content: center;
    min-block-size: 2.75rem;
  }

  .hpds-quantity__input,
  body.hpds-enabled.hpds-module-commerce .c-product__quantity-value {
    border: 0;
    color: var(--hpds-color-text);
    inline-size: 100%;
    min-block-size: 2.75rem;
    text-align: center;
  }

  .hpds-commerce-toolbar,
  body.hpds-enabled.hpds-module-commerce .c-catalog-ordering {
    align-items: center;
    border-block: var(--hpds-border);
    display: flex;
    flex-wrap: wrap;
    gap: var(--hpds-space-4);
    justify-content: space-between;
    margin-block-end: var(--hpds-space-6);
    padding-block: var(--hpds-space-3);
  }

  .hpds-commerce-panel,
  body.hpds-enabled.hpds-module-commerce :where(.cart_totals, .woocommerce-checkout-review-order) {
    background: var(--hpds-color-surface-subtle);
    border: var(--hpds-border);
    border-radius: var(--hpds-radius-sm);
    padding: var(--hpds-space-5);
  }

  body.hpds-enabled.hpds-module-commerce :where(.woocommerce-cart-form table, .woocommerce-checkout-review-order-table, .woocommerce-orders-table) {
    border-collapse: collapse;
    inline-size: 100%;
  }

  body.hpds-enabled.hpds-module-commerce :where(.woocommerce-cart-form th, .woocommerce-cart-form td, .woocommerce-checkout-review-order-table th, .woocommerce-checkout-review-order-table td, .woocommerce-orders-table th, .woocommerce-orders-table td) {
    border-block-end: var(--hpds-border);
    padding: var(--hpds-space-3);
    text-align: start;
    vertical-align: middle;
  }

  body.hpds-enabled.hpds-module-commerce :where(.woocommerce-message, .woocommerce-info, .woocommerce-error) {
    border: var(--hpds-border);
    border-inline-start: 0.25rem solid var(--hpds-color-info);
    border-radius: var(--hpds-radius-sm);
    color: var(--hpds-color-text);
    margin-block: 0 var(--hpds-space-5);
    padding: var(--hpds-space-4);
  }

  body.hpds-enabled.hpds-module-commerce .woocommerce-message { border-inline-start-color: var(--hpds-color-success); }
  body.hpds-enabled.hpds-module-commerce .woocommerce-error { border-inline-start-color: var(--hpds-color-error); }

  body.hpds-enabled.hpds-module-commerce :where(.woocommerce-cart-form, .woocommerce-checkout, .woocommerce-account .woocommerce) {
    color: var(--hpds-color-text);
    font-family: var(--hpds-font-sans);
    letter-spacing: 0;
  }

  body.hpds-enabled.hpds-module-commerce :where(.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper) {
    display: grid;
    gap: var(--hpds-space-4);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  body.hpds-enabled.hpds-module-commerce :where(.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper) > .form-row {
    float: none;
    inline-size: auto;
    margin: 0;
  }

  body.hpds-enabled.hpds-module-commerce :where(.form-row-wide, #billing_address_1_field, #shipping_address_1_field) {
    grid-column: 1 / -1;
  }

  body.hpds-enabled.hpds-module-commerce .woocommerce-checkout-review-order {
    position: sticky;
    inset-block-start: var(--hpds-space-6);
  }

  body.hpds-enabled.hpds-module-commerce .woocommerce-MyAccount-navigation ul {
    border-block-start: var(--hpds-border);
    list-style: none;
    margin: 0;
    padding: 0;
  }

  body.hpds-enabled.hpds-module-commerce .woocommerce-MyAccount-navigation li {
    border-block-end: var(--hpds-border);
  }

  body.hpds-enabled.hpds-module-commerce .woocommerce-MyAccount-navigation a {
    color: var(--hpds-color-text);
    display: flex;
    min-block-size: 3rem;
    padding: var(--hpds-space-3);
    text-decoration: none;
  }

  body.hpds-enabled.hpds-module-commerce .woocommerce-MyAccount-navigation .is-active a {
    background: var(--hpds-color-mist);
    border-inline-start: 3px solid var(--hpds-color-accent);
    font-weight: var(--hpds-weight-bold);
  }

  body.hpds-enabled.hpds-module-commerce :where(.tinv-wishlist table, .wishlist_table) {
    border-collapse: collapse;
    inline-size: 100%;
  }

  body.hpds-enabled.hpds-module-commerce :where(.tinv-wishlist table, .wishlist_table) :is(th, td) {
    border-block-end: var(--hpds-border);
    padding: var(--hpds-space-3);
    text-align: start;
  }

  @media (max-width: 1024px) {
    .hpds-product-grid { --hpds-product-columns: 3; }
    .hpds-product-detail, body.hpds-enabled.hpds-module-commerce .c-product__wrap { grid-template-columns: minmax(0, 1fr) minmax(18rem, 0.8fr); }
  }

  @media (max-width: 767px) {
    .hpds-product-grid { --hpds-product-columns: 2; --hpds-product-columns-gap: var(--hpds-space-3); }
    .hpds-product-detail, body.hpds-enabled.hpds-module-commerce .c-product__wrap { grid-template-columns: 1fr; }
    body.hpds-enabled.hpds-module-commerce .c-product__title { font-size: var(--hpds-font-size-600); }
    body.hpds-enabled.hpds-module-commerce :where(.woocommerce-cart-form, .woocommerce-orders-table) { display: block; overflow-x: auto; }
    body.hpds-enabled.hpds-module-commerce :where(.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper) { grid-template-columns: 1fr; }
    body.hpds-enabled.hpds-module-commerce :where(.woocommerce-billing-fields__field-wrapper, .woocommerce-shipping-fields__field-wrapper, .woocommerce-address-fields__field-wrapper) > .form-row { grid-column: 1; }
    body.hpds-enabled.hpds-module-commerce .woocommerce-checkout-review-order { position: static; }
  }
}
