/* Theme Adapter CSS — совместимость с популярными темами */

/* WooCommerce Default */
.woocommerce-product-gallery.mc-gallery-replaced {
    position: relative;
}

.woocommerce-product-gallery.mc-gallery-replaced .woocommerce-product-gallery__image {
    text-align: center;
}

.woocommerce-product-gallery.mc-gallery-replaced .woocommerce-product-gallery__image img {
    max-width: 100%;
    height: auto;
}

/* Astra */
.ast-theme-transparent-header-break-point .woocommerce-product-gallery.mc-gallery-replaced {
    margin-bottom: 2em;
}

/* Blocksy */
.cs-flash-bar + .woocommerce-product-gallery.mc-gallery-replaced {
    margin-top: 1em;
}

/* Flatsome */
.flatsome-content-markup .woocommerce-product-gallery.mc-gallery-replaced {
    margin-bottom: 30px;
}

.flatsome-content-markup .woocommerce-product-gallery.mc-gallery-replaced .woocommerce-product-gallery__image {
    text-align: left;
}

/* Woodmart */
.woodmart-product-gallery.mc-gallery-replaced {
    margin-bottom: 30px;
}

/* Storefront */
.storefront-product-gallery.mc-gallery-replaced {
    margin-bottom: 2em;
}

/* Общие стили для gallery adapter */
.mc-gallery-replaced .mc-gallery-placeholder {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px dashed rgba(200, 169, 107, .32);
    border-radius: var(--radius, 10px);
    background:
        linear-gradient(145deg, rgba(200, 169, 107, .08), rgba(255, 255, 255, .02)),
        var(--bg, #111111);
}

.mc-gallery-replaced .mc-gallery-placeholder img {
    max-width: 100%;
    max-height: 300px;
}

/* Lazy loading indicators */
.mc-lazy-loading {
    opacity: 0.5;
}

.mc-lazy-loaded {
    opacity: 1;
    transition: opacity 0.3s ease;
}

/* Preview image */
.mc-preview-image {
    display: block;
    max-width: 100%;
    height: auto;
}

/* Thumbnails grid */
.mc-thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.mc-thumbnails-grid a {
    display: block;
    text-align: center;
}

.mc-thumbnails-grid img {
    max-width: 100%;
    height: auto;
    border: 1px solid rgba(200, 169, 107, .26);
    border-radius: calc(var(--radius, 10px) - 2px);
    padding: 2px;
}

.mc-thumbnails-grid a.mc-thumbnail-primary {
    border-color: var(--gold-hover, #f4e4b8);
    box-shadow: 0 0 16px rgba(200, 169, 107, .28);
}

/* Premium horizontal WooCommerce gallery thumbnails */
.woocommerce-product-gallery.mc-premium-gallery-enabled {
    --mc-gallery-bg: var(--bg, #111111);
    --mc-gallery-gold: var(--gold, #c8a96b);
    --mc-gallery-gold-hover: var(--gold-hover, #f4e4b8);
    --mc-gallery-gold-border: rgba(200, 169, 107, .55);
    --mc-gallery-text: var(--text, #d9d9d9);
    --mc-gallery-inactive: rgba(217, 217, 217, .46);
    --mc-gallery-thumb-size: 82px;
    --mc-gallery-gap: 12px;
    position: relative;
}

.woocommerce-product-gallery.mc-premium-gallery-enabled .flex-control-nav {
    display: none !important;
    visibility: hidden;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

.woocommerce-product-gallery.mc-premium-gallery-enabled .flex-viewport {
    border: 1px solid rgba(200, 169, 107, .18);
    border-radius: calc(var(--radius, 10px) + 2px);
    overflow: hidden;
    background: var(--mc-gallery-bg);
    box-shadow: 0 18px 42px rgba(0, 0, 0, .24);
}

.woocommerce-product-gallery.mc-premium-gallery-enabled .woocommerce-product-gallery__image,
.woocommerce-product-gallery.mc-premium-gallery-enabled .woocommerce-product-gallery__image a {
    text-align: center;
}

.woocommerce-product-gallery.mc-premium-gallery-enabled .woocommerce-product-gallery__image img {
    display: inline-block;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* MC_PROJECTION_HERO_HEIGHT_FIT_V2
 * Projection files retain the complete native scene (for example 16:9), but
 * the storefront gallery is a fixed-height window. Size the image by that
 * window's height and keep its intrinsic width: this fills the vertical space
 * without stretching pixels. Any needed horizontal crop is performed only by
 * the existing slide overflow container, never by scaling the source into a
 * different aspect ratio. */
html body .woocommerce-product-gallery.mc-premium-gallery-enabled
.woocommerce-product-gallery__image.mc-static-initial-projection-server > a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 100% !important;
    height: 100% !important;
    overflow: hidden;
}

html body .woocommerce-product-gallery.mc-premium-gallery-enabled
.woocommerce-product-gallery__image.mc-static-initial-projection-server > a > img.mc-visual-projection-consumer:not(.zoomImg) {
    width: auto !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
    object-position: center center !important;
}

.mc-premium-thumbs {
    display: grid;
    grid-template-columns: 100%; /*42px minmax(0, 1fr) 42px;*/
    align-items: center;
    gap: 14px;
    margin-top: 18px;
    /*padding: 14px;*/
    /*border: 1px solid rgba(200, 169, 107, .24);*/
    /*border-radius: calc(var(--radius, 10px) + 4px);*/
    /*background:*/
    /*    linear-gradient(135deg, rgba(200, 169, 107, .07), rgba(255, 255, 255, .02) 44%),*/
    /*    linear-gradient(180deg, rgba(26, 26, 26, .96), rgba(10, 10, 10, .92));*/
    /*box-shadow: 0 18px 42px rgba(0, 0, 0, .26), inset 0 1px 0 rgba(255, 255, 255, .05);*/
}

.mc-premium-thumbs__track {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: var(--mc-gallery-thumb-size);
    gap: var(--mc-gallery-gap);
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    padding: 4px;
    cursor: grab;
    max-width: 100%;
    user-select: none;
    touch-action: pan-x;
}

.mc-premium-thumbs__track.is-dragging {
    cursor: grabbing;
}

.mc-premium-thumbs__track::-webkit-scrollbar {
    display: none;
}

.mc-premium-thumbs__track:focus-visible {
    outline: 2px solid var(--mc-gallery-gold);
    outline-offset: 4px;
    border-radius: 12px;
}

.mc-premium-thumbs__item {
    width: var(--mc-gallery-thumb-size) !important;
    min-width: var(--mc-gallery-thumb-size);
    max-width: var(--mc-gallery-thumb-size);
    height: var(--mc-gallery-thumb-size) !important;
    min-height: var(--mc-gallery-thumb-size);
    max-height: var(--mc-gallery-thumb-size);
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    border: 1px solid rgba(200, 169, 107, .18);
    border-radius: var(--radius, 10px) !important;
    background: var(--mc-gallery-bg) !important;
    cursor: pointer;
    overflow: hidden;
    box-shadow: 0 10px 24px rgba(0, 0, 0, .22);
    transition: transform 220ms ease, border-color 220ms ease, box-shadow 220ms ease, opacity 220ms ease, background 220ms ease;
    user-select: none;
    -webkit-user-drag: none;
}

.mc-premium-thumbs__item img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 10px;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* MC_PROJECTION_THUMB_HEIGHT_FIT_V2
 * Square thumbnail carriers show a height-filled, proportional crop of wide
 * projection scenes. The WebP itself remains untouched and is never stretched. */
.mc-premium-thumbs__item--projection img {
    width: auto !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: contain !important;
    object-position: center !important;
}

.mc-premium-thumbs__item:hover {
    /*transform: translateY(-1px);*/
    border-color: var(--mc-gallery-gold-border);
    background: rgba(200, 169, 107, .08) !important;
    box-shadow: 0 14px 30px rgba(0, 0, 0, .3), 0 0 18px rgba(200, 169, 107, .2);
}

.mc-premium-thumbs__item.is-active {
    border-color: var(--mc-gallery-gold-hover);
    background: rgba(200, 169, 107, .11) !important;
    box-shadow: 0 14px 34px rgba(0, 0, 0, .34), 0 0 0 1px rgba(200, 169, 107, .24), 0 0 20px rgba(200, 169, 107, .32);
}

.mc-premium-thumbs__item:focus-visible {
    outline: 2px solid var(--mc-gallery-gold-hover);
    outline-offset: 3px;
}

.mc-premium-thumbs__arrow {
    z-index: 1;
    position: absolute;
    width: 42px !important;
    min-width: 42px;
    max-width: 42px;
    height: 42px !important;
    min-height: 42px;
    max-height: 42px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(200, 169, 107, .3);
    border-radius: 999px;
    background: rgba(0, 0, 0, .65) !important;
    color: var(--mc-gallery-text);
    cursor: pointer;
    font-size: 30px !important;
    line-height: 1;
    box-shadow: 0 10px 28px rgba(0, 0, 0, .28), 0 0 14px rgba(200, 169, 107, .1);
    opacity: 1;
    transition: background-color 220ms ease, color 220ms ease, border-color 220ms ease, opacity 220ms ease, transform 220ms ease, visibility 220ms ease;
}
.mc-premium-thumbs__arrow--next{
    right:5px;
}
.mc-premium-thumbs__arrow--prev{
    left:5px;
}
@supports ((-webkit-backdrop-filter: blur(8px)) or (backdrop-filter: blur(8px))) {
    .mc-premium-thumbs__arrow {
        -webkit-backdrop-filter: blur(8px);
        backdrop-filter: blur(8px);
    }
}

.mc-premium-thumbs__arrow:hover:not(:disabled),
.mc-premium-thumbs__arrow:focus-visible:not(:disabled) {
    background: var(--mc-gallery-gold-hover) !important;
    border-color: var(--mc-gallery-gold-hover);
    color: #111;
    transform: translateY(-1px);
}

.mc-premium-thumbs__arrow:focus-visible {
    outline: 2px solid var(--mc-gallery-gold-hover);
    outline-offset: 3px;
}

.mc-premium-thumbs__arrow:disabled {
    opacity: .48;
    cursor: default;
    filter: saturate(.72);
    transform: none;
}

.mc-premium-thumbs.mc-premium-thumbs--fit .mc-premium-thumbs__arrow {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

@media (min-width: 1400px) {
    .woocommerce-product-gallery.mc-premium-gallery-enabled {
        --mc-gallery-thumb-size: 82px;
    }

    .mc-premium-thumbs__track {
        /*max-width: calc((82px * 7) + (var(--mc-gallery-gap) * 6) + 8px);*/
        justify-self: center;
    }
}

@media (max-width: 1199px) {
    .mc-premium-thumbs__track {
        /*max-width: calc((82px * 6) + (var(--mc-gallery-gap) * 5) + 8px);*/
        justify-self: center;
    }
}

@media (max-width: 991px) {
    .mc-premium-thumbs__track {
        /*max-width: calc((82px * 5) + (var(--mc-gallery-gap) * 4) + 8px);*/
    }
}

@media (max-width: 767px) {
    .mc-premium-thumbs__track {
        /*max-width: calc((82px * 4) + (var(--mc-gallery-gap) * 3) + 8px);*/
    }
}

@media (max-width: 575px) {
    .woocommerce-product-gallery.mc-premium-gallery-enabled {
        --mc-gallery-thumb-size: 64px;
        --mc-gallery-gap: 10px;
    }

    .mc-premium-thumbs {
        /*grid-template-columns: 36px minmax(0, 1fr) 36px;*/
        gap: 10px;
        padding: 10px;
        margin-top: 14px;
    }

    .mc-premium-thumbs__track {
        /*max-width:100%;*/
        /*max-width: calc((64px * 2.5) + (var(--mc-gallery-gap) * 2) + 8px);*/
    }

    .mc-premium-thumbs__arrow {
        width: 36px !important;
        min-width: 36px;
        max-width: 36px;
        height: 36px !important;
        min-height: 36px;
        max-height: 36px;
        font-size: 26px !important;
    }
}

/* ==========================================================
 * MC_PROJECTION_SHOP_SQUARE_FIRST_V1
 * Canonical projection cards use a stable 1:1 viewport, like native Woo
 * thumbnails. The theme's generic loop hover zoom must not rescale the image
 * while its hover-gallery script changes src between generated/attachment
 * images.
 * ========================================================== */
.woocommerce ul.products li.product .kb-hover-gallery[data-mc-projection-consumer="shop-gallery-480"] {
    aspect-ratio: 1 / 1;
    width: 100%;
    overflow: hidden;
}
.woocommerce ul.products li.product .kb-hover-gallery[data-mc-projection-consumer="shop-gallery-480"] > img {
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    object-fit: cover;
    object-position: center;
    transform: none !important;
    transition: none !important;
}
.woocommerce ul.products li.product a.woocommerce-loop-product__link:hover
.kb-hover-gallery[data-mc-projection-consumer="shop-gallery-480"] > img {
    transform: none !important;
}

/* ==========================================================
 * MC_PROJECTION_SHOPPINGCART_GRID_SQUARE_V1
 * ShoppingCart's custom home-grid gallery bypasses the normal Woo loop
 * classes. Keep its projection-enhanced cards on the same 1:1 viewport while
 * custom.js changes src across generated and attachment images.
 * ========================================================== */
.sc-grid-product-img[data-mc-projection-consumer="shoppingcart-grid-480"] {
    aspect-ratio: 1 / 1;
    width: 100%;
    overflow: hidden;
}
.sc-grid-product-img[data-mc-projection-consumer="shoppingcart-grid-480"] > a,
.sc-grid-product-img[data-mc-projection-consumer="shoppingcart-grid-480"] > a > img {
    width: 100% !important;
    height: 100% !important;
}
.sc-grid-product-img[data-mc-projection-consumer="shoppingcart-grid-480"] > a > img {
    max-width: none;
    object-fit: cover;
    object-position: center;
}

/* ==========================================================
 * MC_PROJECTION_WC_BLOCK_GRID_SQUARE_V1
 * Legacy Woo Product Grid blocks render their own attachment image element.
 * Once replaced with Projection Core, keep the same physical square viewport
 * and prevent a stale responsive srcset from influencing layout.
 * ========================================================== */
.wc-block-grid__product-image[data-mc-projection-consumer="wc-block-grid-480"] {
    aspect-ratio: 1 / 1;
    width: 100%;
    overflow: hidden;
}
.wc-block-grid__product-image[data-mc-projection-consumer="wc-block-grid-480"] > img {
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    object-fit: cover;
    object-position: center;
}

/* ==========================================================
 * MC_PRODUCT_CARD_GALLERY_STABLE_VIEWPORT_V2
 * A card gallery can switch between a square attachment and a full-scene
 * projection with a different native aspect ratio.  Its visible stage must
 * belong to the card, not to the currently selected <img>; otherwise the
 * title, price and the whole grid jump on every slide change.
 *
 * Keep the familiar square card stage for every ShoppingCart/Woo gallery,
 * while images cover that stage from the centre.  `object-fit: cover` crops
 * only the excess and never distorts the source.
 * ========================================================== */
.sc-grid-product-img,
.kb-hover-gallery,
.wc-block-grid__product-image[data-images] {
    box-sizing: border-box;
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
}

.sc-grid-product-img > a,
.kb-hover-gallery > a,
.wc-block-grid__product-image[data-images] > a {
    display: block;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.sc-grid-product-img > img,
.sc-grid-product-img > a > img,
.kb-hover-gallery > img,
.kb-hover-gallery > a > img,
.wc-block-grid__product-image[data-images] > img,
.wc-block-grid__product-image[data-images] > a > img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover !important;
    object-position: center center;
}
