/* Separate the full-width delivery row from image actions, including wrapped labels. */
.product-miniature .thumbnail-container .product-image:has(> .product-flags) {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
}

.product-miniature .thumbnail-container .product-image > .product-flags:not(.xh-promotion-flags) {
    grid-area: 1 / 1;
    position: static;
    display: flex;
    flex-wrap: wrap;
    align-items: start;
    gap: 4px;
    width: 100%;
    margin: 0;
    padding: 0;
    min-height: 56px;
}

.product-miniature .thumbnail-container .product-image > .product-flags > .xh-in-stock,
.product-miniature .thumbnail-container .product-image > .product-flags > .xh-backorder,
.product-miniature .thumbnail-container .product-image > .product-flags > .out_of_stock {
    flex: 0 0 100%;
    width: 100%;
    box-sizing: border-box;
    white-space: normal;
    overflow-wrap: anywhere;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 56px;
    margin: 0;
    padding: 8px 12px;
    font-size: 11px;
    line-height: 1.4;
}

/* Promotional flags use image space instead of changing the delivery-row height. */
.product-miniature .thumbnail-container .product-image > .xh-promotion-flags {
    grid-area: 2 / 1;
    position: relative;
    align-self: start;
    justify-self: start;
    inset: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 12px;
    max-width: calc(100% - 76px);
    z-index: 1;
}

.product-miniature .thumbnail-container .product-image:has(> .product-flags) > .product-thumbnail,
.product-miniature .thumbnail-container .product-image:has(> .product-flags) > .product-list-images-mobile {
    grid-area: 2 / 1;
    min-width: 0;
    width: 100%;
}

.product-miniature .thumbnail-container .product-image:has(> .product-flags) > .functional-buttons {
    grid-area: 2 / 1;
    position: relative;
    align-self: start;
    justify-self: end;
    inset: auto;
    margin: 12px;
    z-index: 2;
}

/* All actions remain discoverable with mouse, keyboard, and touch. */
.product-miniature .thumbnail-container .functional-buttons > div:nth-child(n) {
    opacity: 1;
    visibility: visible;
}

.product-miniature .thumbnail-container .functional-buttons > .quickview.hidden-sm-down {
    display: block !important;
}

.product-miniature .thumbnail-container .functional-buttons a {
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Keep the complete name in the DOM and allocate three readable lines. */
.product-miniature .thumbnail-container .product-title {
    min-height: 72px;
    height: 72px;
}

.product-miniature .thumbnail-container .product-title a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    line-height: 24px;
    max-height: 72px;
    white-space: normal;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.product-miniature .thumbnail-container .category-default {
    min-height: 32px;
    height: 32px;
    overflow: hidden;
}

.product-miniature .thumbnail-container .category-default a {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-height: 16px;
}

/* Close each card below its price, reviews, and cart action. */
.product-miniature .thumbnail-container .product-meta .cart-price {
    border-top: 0;
    border-bottom: 1px solid #ddd;
    padding-bottom: 20px;
}

/* Keep prices together; let the cart action move below them on narrow cards. */
.product-miniature .thumbnail-container .product-meta .cart-price {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 12px;
}

.product-miniature .thumbnail-container .cart-price .price-review {
    flex: 1 1 176px;
    min-width: 0;
}

.product-miniature .thumbnail-container .cart-price > .button-container {
    flex: 0 0 auto;
}

/* Current and former price share one row; all hook content follows below. */
.product-miniature .thumbnail-container .cart-price .product-price-and-shipping {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    grid-template-rows: minmax(26px, auto);
    column-gap: 8px;
    align-items: baseline;
    min-height: 76px;
}

.product-miniature .thumbnail-container .cart-price .product-price-and-shipping > * {
    grid-column: 1 / -1;
}

.product-miniature .thumbnail-container .cart-price .regular-price {
    grid-area: 1 / 2;
    justify-self: start;
    margin: 0;
    font-size: 12px;
    line-height: 24px;
    white-space: nowrap;
}

/* The existing promotional flag above the image already carries the saving. */
.product-miniature .thumbnail-container .cart-price .discount-product {
    display: none;
}

.product-miniature .thumbnail-container .cart-price .price {
    grid-area: 1 / 1;
    margin: 0;
    line-height: 24px;
    white-space: nowrap;
}

.product-miniature .thumbnail-container .cart-price .aeuc_product_price_block {
    min-height: 52px;
    padding-top: 4px;
    line-height: 24px;
}

.product-miniature .product-flags li.product-flag.xh-in-stock {
    background-color: #28723b;
    border-color: #28723b;
    color: #fff;
    white-space: normal;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.product-miniature .product-flags li.product-flag.xh-backorder {
    background-color: #8a5700;
    border-color: #8a5700;
    color: #fff;
}
