/* Listing card prices: keep the discount beside the current price in both views.
   Price hooks and the former price retain their own full-width rows. */
body.ma-product-listing-page #products .psvc-product-card__price-wrap .product-price-and-shipping {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 5px 8px;
}

body.ma-product-listing-page #products .psvc-product-card__price-wrap .product-price-and-shipping > :where(:not(meta)) {
  flex: 0 0 100%;
  order: 3;
}

body.ma-product-listing-page #products .psvc-product-card__price-wrap .psvc-product-card__price-link {
  flex: 0 1 auto;
  order: 0;
  min-width: 0;
}

body.ma-product-listing-page #products .psvc-product-card__price-wrap .price {
  font-weight: 600;
  overflow-wrap: anywhere;
}

body.ma-product-listing-page #products .psvc-product-card__price-wrap .psvc-product-card__discount-badge {
  flex: 0 0 auto;
  order: 1;
  margin-top: 0 !important;
  font-weight: 400 !important;
  white-space: nowrap;
}

body.ma-product-listing-page #products .psvc-product-card__price-wrap .regular-price {
  order: 2;
  margin: 0;
}

/* Text view selector. Only enhanced listing toolbars opt into the new wrapping. */
body.ma-product-listing-page .ma-listing-view[hidden] {
  display: none;
}

body.ma-product-listing-page .ma-listing-view {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 7px;
  margin-left: 16px;
}

body.ma-product-listing-page .ma-listing-view label {
  margin: 0;
  color: #617287;
  font-size: 12px;
  font-weight: 650;
}

body.ma-product-listing-page .ma-listing-view select,
body.ma-product-listing-page .ma-sort-order__select {
  width: clamp(128px, 12vw, 166px);
  height: 28px;
  margin: 0;
  padding: 0 24px 0 10px;
  border: 1px solid #d7e1eb;
  border-radius: 7px;
  background-color: #f8fafc;
  color: #073c5e;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
  cursor: pointer;
}

body.ma-product-listing-page .ma-listing-view select:focus-visible,
body.ma-product-listing-page .ma-sort-order__select:focus-visible {
  outline: 2px solid #f76300;
  outline-offset: 2px;
}

body.ma-product-listing-page .ma-sort-order__select {
  width: clamp(180px, 18vw, 260px);
}

body.ma-product-listing-page .ma-sort-order__select[hidden],
body.ma-product-listing-page .ma-listing-control--sort.is-native .products-sort-order {
  display: none;
}

/* Wrap only when the actual listing column cannot fit the controls. A viewport
   breakpoint cannot account for the sidebar or translated labels. */
body.ma-product-listing-page .tvleft-penal-product-top .ma-listing-toolbar--view {
  flex-wrap: wrap;
  gap: 8px 16px;
}

body.ma-product-listing-page .ma-listing-toolbar--view::before,
body.ma-product-listing-page .ma-listing-toolbar--view::after {
  display: none;
}

body.ma-product-listing-page .ma-listing-toolbar--view .ma-listing-toolbar__summary {
  flex: 1 0 auto;
}

body.ma-product-listing-page .ma-listing-toolbar--view .ma-listing-view {
  margin-left: 0;
}

body.ma-product-listing-page .ma-listing-toolbar--view .ma-listing-toolbar__controls {
  flex: 0 0 auto;
  margin-left: auto;
  justify-content: flex-end;
}

@media (max-width: 767.98px) {
  body.ma-product-listing-page .tvleft-penal-product-top .ma-listing-toolbar--view {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 8px;
  }

  body.ma-product-listing-page .ma-listing-toolbar--view::before,
  body.ma-product-listing-page .ma-listing-toolbar--view::after,
  body.ma-product-listing-page .ma-listing-toolbar--view .sort-by-row::before,
  body.ma-product-listing-page .ma-listing-toolbar--view .sort-by-row::after {
    display: none;
  }

  body.ma-product-listing-page .ma-listing-toolbar--view .ma-listing-toolbar__controls,
  body.ma-product-listing-page .ma-listing-toolbar--view .tvall-page-shortby,
  body.ma-product-listing-page .ma-listing-toolbar--view .sort-by-row {
    display: contents;
  }

  body.ma-product-listing-page .ma-listing-toolbar--view .ma-listing-control,
  body.ma-product-listing-page .ma-listing-toolbar--view .ma-listing-view {
    width: 100%;
    min-width: 0;
    margin: 0;
  }

  body.ma-product-listing-page .ma-listing-toolbar--view .ma-listing-view label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  body.ma-product-listing-page .ma-listing-toolbar--view .ma-listing-view select,
  body.ma-product-listing-page .ma-listing-toolbar--view .ma-sort-order__select,
  body.ma-product-listing-page .ma-listing-toolbar--view .products-sort-order,
  body.ma-product-listing-page .ma-listing-toolbar--view .ma-products-per-page__select {
    width: 100%;
    min-width: 0;
    height: 28px;
  }

  body.ma-product-listing-page .ma-listing-toolbar--view .products-sort-order .select-title {
    height: 28px;
  }
}

/* New density uses the very same product DOM and commerce data as the grid.
   Do not use the legacy list/list-2 classes or change the default card rules. */
body.ma-product-listing-page #products.ma-list-compact #js-product-list .products {
  row-gap: 8px;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-listing-card.tv-grid-list-wrapper-info-box {
  flex: 0 0 100% !important;
  width: 100% !important;
  max-width: 100% !important;
  margin-bottom: 0;
}

/* Portrait promotions must not stretch to the height of a full-width image.
   Keep the complete artwork, link and owner tracking in the compact flow. */
body.ma-product-listing-page #products.ma-list-compact :is(.mch-category-product-card-item, .mch-brand-product-card-item) > .mch-creative {
  height: 180px;
  min-height: 0;
  aspect-ratio: auto !important;
  box-shadow: none;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card {
  display: grid !important;
  grid-template-columns: 64px minmax(0, 1fr);
  align-content: start;
  align-items: start;
  gap: 8px 12px;
  min-height: 0;
  height: auto;
  padding: 12px;
  border-color: #dce5ee;
  box-shadow: none;
  transform: none;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card:hover {
  border-color: #a9bac8;
  background: #fcfdfe;
  box-shadow: none;
  transform: none;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__media-stack {
  display: contents;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__media {
  grid-column: 1;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: 0;
  padding: 0;
  gap: 4px;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__image-link {
  order: -1;
  height: 64px;
  width: 64px;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__image {
  width: 100%;
  height: 100%;
  max-height: 100%;
  object-fit: contain;
}

body.ma-product-listing-page #products.ma-list-compact :is(.psvc-product-card__badge, .mk-listing-badge) {
  position: static;
  min-height: 0;
  max-width: 100%;
  margin: 0;
  padding: 4px;
  font-size: 9px;
  line-height: 1.2;
  text-align: center;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__body {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  padding: 0;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__description {
  min-width: 0;
  gap: 5px;
}

body.ma-product-listing-page #products.ma-list-compact :is(.psvc-product-card__brand, .psvc-product-card__title, .psvc-product-card__title a, .psvc-product-card__title h6, .psvc-product-card__reference, .psvc-product-card__compat-text) {
  text-align: left !important;
  overflow-wrap: anywhere;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__title h6 {
  font-size: 14px;
  line-height: 1.4 !important;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__reference {
  margin: 0;
}

body.ma-product-listing-page #products.ma-list-compact .ma-sku-copyline--listing {
  justify-content: flex-start;
  flex-wrap: wrap;
}

body.ma-product-listing-page #products.ma-list-compact .ma-sku-copyline__value {
  overflow-wrap: anywhere;
  white-space: normal;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__compat {
  align-self: flex-start !important;
  justify-self: start !important;
  min-height: 0;
  margin: 0;
  padding: 3px 6px;
  font-size: 11px;
  border-radius: 4px;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__delivery {
  margin: 0;
  line-height: 1.4;
  text-align: left !important;
}

body.ma-product-listing-page #products.ma-list-compact :is(.psvc-product-card__excerpt, .psvc-product-card__separator) {
  display: none !important;
}

body.ma-product-listing-page #products.ma-list-compact .product-price-and-shipping {
  justify-content: start;
  gap: 4px 8px;
  min-height: 0;
  text-align: left;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__price-wrap .price {
  font-size: 21px;
  line-height: 1.3;
}

body.ma-product-listing-page #products.ma-list-compact :is(.regular-price, .psvc-product-card__discount-badge) {
  margin-top: 0 !important;
}

body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__price-wrap::after {
  display: none !important;
}

/* Variants remain usable below the row, without reserving image-sized slots. */
body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__color-thumbs {
  grid-column: 1 / -1;
  order: 3;
  min-width: 0;
  width: 100%;
  margin: 0;
  padding: 0;
  justify-content: flex-start;
}

body.ma-product-listing-page #products.ma-list-compact .ma-color-thumbs__viewport {
  justify-content: flex-start;
  padding-inline: 1px;
  margin-inline: -1px;
}

/* Reserve space only for arrows that are visible, without indenting short rows. */
body.ma-product-listing-page #products.ma-list-compact .ma-color-thumbs__arrow {
  position: static;
  flex: 0 0 24px;
  transform: none;
}

body.ma-product-listing-page #products.ma-list-compact .thumbnail-container > .motareasearch-badge {
  position: static;
  align-self: flex-start;
  margin: 0 0 5px;
}

body.ma-product-listing-page #products.ma-list-compact .thumbnail-container {
  flex-direction: column;
}

@media (min-width: 768px) {
  body.ma-product-listing-page #products.ma-list-compact .psvc-product-card {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: 8px 18px;
    padding: 12px 16px;
  }

  body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__image-link {
    width: 72px;
    height: 72px;
  }

  body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__description {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) 200px;
    column-gap: 16px;
    align-content: start;
  }

  body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__description > * {
    grid-column: 1;
  }

  body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__price-wrap {
    grid-column: 2;
    grid-row: 1 / span 5;
    align-self: center;
    padding-left: 12px;
    border-left: 1px solid #e6ecf1;
  }

  body.ma-product-listing-page #products.ma-list-compact .product-price-and-shipping {
    justify-content: flex-end;
    text-align: right;
  }

  body.ma-product-listing-page #products.ma-list-compact .psvc-product-card__color-thumbs {
    grid-column: 2;
  }
}
