.cfw-product-image,
.wp-block-woocommerce-product-image:has(.cfw-loop-badges),
.wp-block-woocommerce-product-image:has(.cfw-single-badges),
.woocommerce-product-gallery__image:has(.cfw-single-badges),
.woocommerce-product-gallery__image--placeholder:has(.cfw-single-badges) {
    position: relative;
}
.cfw-product-image { display: block; margin-bottom: 1em; }
.woocommerce ul.products li.product .cfw-product-image > img { display: block; width: 100%; margin-bottom: 0; }

.cfw-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    width: fit-content;
    max-width: calc(100% - 24px);
    padding: 6px 10px;
    border-radius: 6px;
    background: var(--cfw-badge-bg);
    color: var(--cfw-badge-color);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.4;
    letter-spacing: .03em;
    text-align: center;
    overflow-wrap: anywhere;
    box-sizing: border-box;
    vertical-align: middle;
}

.cfw-loop-badges,
.cfw-single-badges {
    position: absolute;
    inset: 0;
    z-index: 5;
    pointer-events: none;
}

.cfw-badge-stack {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-width: 0;
    max-width: calc(50% - 18px);
}
.cfw-badge-stack--top_left { top: 12px; left: 12px; }
.cfw-badge-stack--top_right { top: 12px; right: 12px; align-items: flex-end; }
.cfw-badge-stack--bottom_left { bottom: 12px; left: 12px; flex-direction: column-reverse; }
.cfw-badge-stack--bottom_right { bottom: 12px; right: 12px; align-items: flex-end; flex-direction: column-reverse; }
.cfw-badge-stack .cfw-badge { max-width: 100%; }

.cfw-badge--live::before,
.cfw-badge--closed::before,
.cfw-badge--future::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}

.cfw-badge img {
    display: block;
    width: auto;
    max-width: 72px;
    max-height: 56px;
    margin: 0;
}

.cfw-badge:has(img) { padding: 0; background: transparent; }

.cfw-single-badges:empty { display: none; }
.cfw-single-badges .cfw-badge { max-width: 100%; }
