/* BR Commerce: natural product media, no decorative card around real photos.
   Scoped to V8 product pages WITH genuine media. The empty-photo artwork
   keeps its existing rounded background, border and fixed placeholder size. */
[data-reference-fidelity="v8"]
[data-commerce-gallery][data-gallery-empty="false"]
[data-product-main-image] {
    position: relative !important;
    display: flex;
    width: 100%;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: auto !important;
    overflow: visible !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

/* Both the published cover and the merchant's unsaved Live Preview cover
   follow the photo's native aspect ratio, without artificial padding.
   This explicitly overrides the old premium product card rules and the
   preview's inline absolute-positioned cover. */
[data-reference-fidelity="v8"]
[data-commerce-gallery][data-gallery-empty="false"]
[data-product-main-image] > img {
    position: relative !important;
    inset: auto !important;
    flex: 0 1 auto;
    display: block;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: min(74vh, 640px);
    margin: 0 auto !important;
    padding: 0 !important;
    object-fit: contain !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    transform: none !important;
}

/* Do not re-display an image hidden by the live preview while another
   unsaved image is being shown or after the gallery is cleared. */
[data-reference-fidelity="v8"]
[data-commerce-gallery][data-gallery-empty="false"]
[data-product-main-image] > img[hidden] {
    display: none !important;
}

@media (max-width: 639px) {
    [data-reference-fidelity="v8"]
    [data-commerce-gallery][data-gallery-empty="false"]
    [data-product-main-image] > img {
        max-height: min(74vh, 520px);
    }
}
