/**
 * Discount Badge v1.0.0
 *
 * Renders a compact "-XX%" pill in the top-left corner of product image
 * wrappers. Works with:
 *
 *   moderi_custom theme:
 *     .product-image   (category cards)
 *     .featured-image  (featured module)
 *
 *   OpenCart default theme:
 *     .product-thumb .image
 *
 * Uses CSS variables from moderi_custom theme.css when available
 * (--color-discount), with traditional red fallback for any other theme.
 *
 * To customise:
 *   - Change badge color: edit `background` in .discount-badge below
 *   - Hide on mobile: add `display: none` inside the mobile media query
 *   - Move to top-right: swap `left` → `right` in positioning rules
 */

/* Ensure parents are positioning contexts so the badge's absolute
   positioning anchors to the correct container. Harmless if already set. */
.product-image,
.featured-image,
.product-thumb,
.product-thumb .image {
    position: relative;
}

.discount-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 3;

    display: inline-block;
    padding: 4px 10px;
    min-width: 38px;

    background: var(--color-discount, #dc2626);
    color: #fff;

    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
    text-align: center;
    white-space: nowrap;

    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);

    pointer-events: none;
    user-select: none;
}

/* Smaller on mobile so it doesn't dominate the card */
@media (max-width: 575px) {
    .discount-badge {
        top: 8px;
        left: 8px;
        padding: 3px 8px;
        min-width: 34px;
        font-size: 11px;
        letter-spacing: 0;
    }
}

/* Inside default-theme `.product-thumb .image`, the anchor wraps the img
   tightly — nudge the badge slightly inward so it doesn't overlap the
   image border. */
.product-thumb .image .discount-badge {
    top: 8px;
    left: 8px;
}
