/* Promo badge painted over the product image on the storefront.
   Colours come from the rule and are set inline; this file only handles
   placement and sizing so a theme override stays easy. */

.trd-promo-badge {
    position: absolute;
    z-index: 9;
    display: inline-block;
    margin: 0;
    padding: .35em .7em;
    border-radius: 3px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-transform: none;
    white-space: nowrap;
    /* Up to 24 characters at 18px would otherwise run past the card and, when
       anchored right, push a horizontal scrollbar on mobile. */
    max-width: calc(100% - 20px);
    overflow: hidden;
    text-overflow: ellipsis;
    /* WooCommerce themes often style span.onsale as a circle; reset the bits
       that would distort a text badge. */
    min-height: 0;
    min-width: 0;
}

/* The badge is absolutely positioned, so it needs a positioned ancestor.
   On the single product page the sale flash is a SIBLING of the gallery, not a
   child of it, so div.product is the real containing block — positioning
   div.images instead would let the badge escape to the page corner on themes
   that drop WooCommerce's own stylesheet. */
.woocommerce ul.products li.product,
.woocommerce div.product {
    position: relative;
}

.trd-promo-badge--top-left {
    top: 10px;
    left: 10px;
    right: auto;
    bottom: auto;
}

.trd-promo-badge--top-right {
    top: 10px;
    right: 10px;
    left: auto;
    bottom: auto;
}

.trd-promo-badge--bottom-left {
    bottom: 10px;
    left: 10px;
    right: auto;
    top: auto;
}

.trd-promo-badge--bottom-right {
    bottom: 10px;
    right: 10px;
    left: auto;
    top: auto;
}

.trd-promo-badge--small {
    font-size: 11px;
}

.trd-promo-badge--medium {
    font-size: 14px;
}

.trd-promo-badge--large {
    font-size: 18px;
    padding: .4em .9em;
}

/* Block themes render the badge inside the image wrapper of the product-sale-badge
   block, which is already positioned, so the corner offsets apply cleanly there. */
.wc-block-grid__product-image .trd-promo-badge,
.wp-block-woocommerce-product-image .trd-promo-badge {
    z-index: 10;
}
