
/**
 * VELARA — PVR 1.3.1 Media Grid / Stage 03
 * Astra Child Theme: pvr-media-reviews-for-woocommerce/assets/css/media-grid.css
 * Scope: WooCommerce Single Product only. Detail View Stage 01/02 untouched.
 * PVR owns native scrolling, AJAX batches, media click and video previews.
 */

/* 01. Gallery shell — match the approved Detail View */
@media (min-width: 901px) {
    body.single-product .pvr-media-grid-modal {
        --velara-grid-width: min(92vw, 1360px);
        --velara-grid-height: min(88dvh, 820px, calc(100dvh - 3rem));
        background: rgba(42, 39, 36, 0.42);
        backdrop-filter: blur(2px);
        -webkit-backdrop-filter: blur(2px);
        padding: 1.5rem;
    }

    body.single-product .velara-pvr-grid-shell {
        box-sizing: border-box;
        position: relative;
        width: var(--velara-grid-width);
        height: var(--velara-grid-height);
        max-width: 100%;
        max-height: calc(100dvh - 3rem);
        padding: 2.5rem 0 0;
        border: 1px solid rgba(42, 39, 36, 0.12);
        border-radius: 0.375rem;
        background: #FFFFFF;
        box-shadow: 0 20px 65px rgba(20, 18, 16, 0.16);
        overflow: hidden;
    }
}

/* Native PVR scroll target, restricted to the media area. */
body.single-product .pvr-media-grid-modal__dialog {
    box-sizing: border-box;
    position: static;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: none;
    margin: 0;
    padding: 0 1rem 1rem;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* 02. Four-column grid */
body.single-product .pvr-media-grid-modal__grid {
    box-sizing: border-box;
    display: grid;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    column-gap: 0.625rem;
    row-gap: 0.625rem;
    align-content: start;
    align-items: start;
    grid-auto-rows: max-content;
    flex: 1 0 auto;
}

/* Header remains fixed above the visible scroll area. */
body.single-product .pvr-media-grid-modal__grid > .velara-pvr-grid-header {
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    box-sizing: border-box;
    position: absolute;
    top: 0;
    left: 1rem;
    right: 1rem;
    width: auto;
    height: 2.5rem;
    min-height: 2.5rem;
    margin: 0;
    padding: 0 0 0 0.75rem;
    z-index: 20;
    background: #FFFFFF;
}

body.single-product .pvr-media-grid-modal__title {
    position: static;
    grid-column: auto;
    display: inline-flex;
    flex: 1 1 auto;
    min-width: 0;
    align-items: center;
    gap: 0.5rem;
    box-sizing: border-box;
    height: 2rem;
    min-height: 2rem;
    margin: 0;
    padding: 0;
    background: transparent;
    color: #575757;
    font-family: "Source Sans 3", Arial, sans-serif;
    font-size: 0.8125rem;
    font-weight: 400;
    line-height: 1.3;
}

/* Gallery count hidden; Detail View counter remains unchanged. */
body.single-product .pvr-media-grid-modal__title-count {
    display: none;
}

/* 03. Close shares the Header row. */
body.single-product .pvr-media-grid-modal__close {
    position: static;
    inset: auto;
    z-index: 21;
    display: inline-flex;
    flex: 0 0 2rem;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 2rem;
    height: 2rem;
    min-height: 2rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent !important;
    box-shadow: none !important;
    color: #575757 !important;
    transition: color 0.2s ease;
}

body.single-product .pvr-media-grid-modal__close:hover {
    background: transparent !important;
    color: #2A2724 !important;
}

body.single-product .pvr-media-grid-modal__close .pvr-media-grid-modal__close-icon {
    width: 1.1875rem;
    height: 1.1875rem;
    color: currentColor;
    fill: currentColor;
}

/* 04. Square media cards */
body.single-product .pvr-media-grid-modal__grid .pvr-grid-media-item,
body.single-product .pvr-media-grid-modal__grid .pvr-grid-skeleton {
    aspect-ratio: 1 / 1;
    height: auto;
    border: 0;
    border-radius: 0.25rem;
    box-shadow: none;
    background-color: #F8F8F8;
}

body.single-product .pvr-media-grid-modal__grid .pvr-grid-media-item::before,
body.single-product .pvr-media-grid-modal__grid .pvr-grid-skeleton::before {
    padding-top: 100%;
}

body.single-product .pvr-media-grid-modal__grid .pvr-grid-media-thumb {
    object-fit: cover;
    object-position: center;
    transition: transform 0.25s ease;
    will-change: auto;
}

body.single-product .pvr-media-grid-modal__grid .pvr-grid-media-item:hover .pvr-grid-media-thumb {
    transform: none;
}

/* Subtle Hover — mouse/trackpad devices only. */
@media (hover: hover) and (pointer: fine) {
    body.single-product .pvr-media-grid-modal__grid .pvr-grid-media-item:hover .pvr-grid-media-thumb {
        transform: scale(1.03);
    }
}

/* 05. Match the approved VELARA scrollbar */
body.single-product .pvr-media-grid-modal__dialog {
    scrollbar-width: auto !important;
    scrollbar-color: auto !important;
}

body.single-product .pvr-media-grid-modal__dialog::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

body.single-product .pvr-media-grid-modal__dialog::-webkit-scrollbar-track {
    background: #FFFFFF;
}

body.single-product .pvr-media-grid-modal__dialog::-webkit-scrollbar-thumb {
    background-color: rgba(114, 114, 114, 0.55);
    border: 2px solid #FFFFFF;
    border-radius: 999px;
    background-clip: padding-box;
}

body.single-product .pvr-media-grid-modal__dialog::-webkit-scrollbar-thumb:hover {
    background-color: #575757;
}

body.single-product .pvr-media-grid-modal__dialog::-webkit-scrollbar-button {
    display: none;
    width: 0;
    height: 0;
}

/* Desktop-only refinements */
@media (min-width: 901px) {

    /* Full dialog width places scrollbar closer to Modal edge. */
    body.single-product .pvr-media-grid-modal__dialog {
        padding-right: 0.5rem;
    }

    body.single-product .pvr-media-grid-modal__grid > .velara-pvr-grid-header {
        padding-left: 0;
    }

    body.single-product .pvr-media-grid-modal__title {
        font-size: 0.875rem;
    }

    /* Desktop Close: button width equals SVG width. */
    body.single-product .pvr-media-grid-modal__close {
        width: 1.1875rem;
        min-width: 1.1875rem;
        height: 1.75rem;
        min-height: 1.75rem;
        flex-basis: 1.1875rem;
    }
}

/* 06. Tablet / Mobile */
@media (max-width: 900px) {
    body.single-product .pvr-media-grid-modal {
        padding: 0;
        background: #FFFFFF;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    body.single-product .velara-pvr-grid-shell {
        box-sizing: border-box;
        width: 100vw;
        height: 100dvh;
        max-height: none;
        padding: calc(0.75rem + 2.5rem) 0 0;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }

    body.single-product .pvr-media-grid-modal__dialog {
        padding: 0 0.75rem 0.75rem;
    }

    body.single-product .pvr-media-grid-modal__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 0.5rem;
    }

    body.single-product .pvr-media-grid-modal__grid > .velara-pvr-grid-header {
        top: 0.75rem;
        left: 0.75rem;
        right: 0.75rem;
        height: 2.5rem;
        min-height: 2.5rem;
    }

    body.single-product .pvr-media-grid-modal__close {
        width: 2.5rem;
        height: 2.5rem;
        min-height: 2.5rem;
        flex-basis: 2.5rem;
    }

    body.single-product .pvr-media-grid-modal__title {
        height: 2.5rem;
        min-height: 2.5rem;
        font-size: 0.8125rem;
    }
}

@media (max-width: 640px) {
    body.single-product .pvr-media-grid-modal__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}


/* 07. Desktop — PVR Background Scroll Lock */
@media (min-width: 901px) {

    /* Preserve PVR native modal scroll locking. */
    html.pvr-modal-open,
    body.single-product.pvr-modal-open {
        overflow: hidden !important;
    }

    /* Keep background locked while Media Gallery is visible. */
    html:has(body.single-product .pvr-media-grid-modal:not([style*="display: none"])),
    body.single-product:has(.pvr-media-grid-modal:not([style*="display: none"])) {
        overflow: hidden !important;
    }
}

}


