.product-freebies {
    padding: 0;
    margin: 0;
    border: 0;
    min-width: 0;
}

.product-freebies legend {
    width: auto;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.4;
    font-weight: 700;
}

.product-freebie-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 1rem;
    max-width: 320px;
}

.product-freebie-option {
    display: block;
    position: relative;
    height: 100%;
    cursor: pointer;
}

/* Keep the native radio available to keyboard and screen-reader users. */
.product-freebie-radio {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

.product-freebie-card {
    display: block;
    height: 100%;
    padding: 4px;
    color: inherit;
    text-align: center;
    border-radius: 3px;
}

.product-freebie-image {
    display: flex;
    position: relative;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 128px;
    height: 112px;
    margin: 0 auto 0.5rem;
}

.product-freebie-image img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-freebie-name {
    display: block;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.4;
    overflow-wrap: anywhere;
    text-wrap: pretty;
}

.product-freebie-tick {
    display: none;
    position: absolute;
    top: -10px;
    right: -10px;
    z-index: 1;
    width: 1em;
    height: 1em;
    border: 0;
    border-radius: 1em;
    background-color: #45CC45;
    color: #fff;
}

/* Override the earlier CSS-drawn tick if it is already compiled into app.css. */
.product-freebie-tick::after {
    content: none;
}

.product-freebie-radio:checked + .product-freebie-card .product-freebie-tick {
    display: block;
}

.product-freebie-option:hover .product-freebie-card {
    background: rgba(0, 0, 0, 0.025);
}

.product-freebie-radio:focus-visible + .product-freebie-card {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

.product-freebie-radio:disabled + .product-freebie-card {
    cursor: wait;
    opacity: 0.7;
}

.product-freebie-message:empty {
    display: none;
}

.product-freebie-message:not(:empty) {
    margin-bottom: 0.75rem;
}

/* Compact product-page upsells, separate from catalogue thumbnails. */
.product-upsells {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem 1.5rem;
    margin: 0 0 1.25rem;
}

.product-upsell-item {
    min-width: 0;
    /* Keep quantity rows aligned when a neighbouring product name wraps. */
    align-self: stretch;
}

.product-upsell-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
    text-align: center;
}

.product-upsell-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 200px;
    height: 200px;
    margin: 0 auto 0.5rem;
}

.product-upsell-image img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.product-upsell-name {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.4;
    overflow-wrap: anywhere;
    text-wrap: pretty;
}

.product-upsell-name a {
    color: inherit;
}

.product-upsell-purchase {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    margin-top: auto;
}

.product-upsell-input.form-control {
    flex: 0 0 56px;
    width: 56px;
    height: 36px;
    padding: 0.25rem;
    font-size: 0.75rem;
    text-align: center;
}

.product-upsell-price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 0.375rem;
    margin: 0;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.4;
}

.product-upsell-price s {
    font-size: 0.75rem;
}

@media (max-width: 575.98px) {
    .product-upsells {
        gap: 1rem 0.75rem;
    }

    .product-upsell-image {
        height: 160px;
    }

    .product-upsell-input.form-control {
        height: 44px;
        font-size: 1rem;
    }
}
