.bfd-gallery-badge-anchor {
    position: relative;
}

a.product-image-link:has(> .bfd-photo-badge),
a.woocommerce-LoopProduct-link:has(> .bfd-photo-badge) {
    position: relative;
    display: block;
}

.bfd-photo-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    z-index: 5;
    display: block;
    width: var(--bfd-badge-desktop, 84px);
    max-width: 50%;
    pointer-events: none;
    line-height: 0;
}

.bfd-photo-badge > img,
.woocommerce ul.products li.product .bfd-photo-badge > img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    max-height: 48px;
    margin: 0;
}

/* WoodMart stacks its existing labels underneath the campaign badge. */
.product-image-link:has(> .bfd-photo-badge) > .product-labels,
.product-element-top:has(> .product-image-link > .bfd-photo-badge) > .product-labels {
    top: 58px;
}

@media (max-width: 767px) {
    .bfd-photo-badge {
        top: 4px;
        left: 4px;
        width: var(--bfd-badge-mobile, 68px);
    }

    .bfd-photo-badge > img,
    .woocommerce ul.products li.product .bfd-photo-badge > img {
        max-height: 34px;
    }

    .product-image-link:has(> .bfd-photo-badge) > .product-labels,
    .product-element-top:has(> .product-image-link > .bfd-photo-badge) > .product-labels {
        top: 42px;
    }
}

.bfd-photo-badge.bfd-photo-discount {
    top: auto;
    bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    aspect-ratio: 480 / 117;
    max-height: 48px;
    border-radius: 4px;
    background: #111;
    color: #fff;
    font-size: 0.75rem;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    text-decoration: underline 2px #ff4b55;
    text-underline-offset: 0.15em;
}

@media (max-width: 767px) {
    .bfd-photo-badge.bfd-photo-discount {
        bottom: 4px;
        max-height: 34px;
        font-size: 0.625rem;
    }
}
