/* EG Image Fit — the layout side of the job.
   The white around a product photo is drawn here, in CSS, not baked into the file:
   the picture keeps 15 % of its box as breathing room (the theme's own value was 20 %).
   Because the files are no longer square, everything that relied on square files gets
   its proportions from here too: the gallery, the thumbnail strip and the zoom. */

/* ── product page gallery ─────────────────────────────────────────────── */
.pgr-gallery-main img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

/* thumbnail strip: equal squares again (the carousel steps by thumb width) */
.pgr-gallery-thumbs .pgr-thumb {
    flex: 0 0 calc((100% - 4 * 8px) / 5);
    width: calc((100% - 4 * 8px) / 5);
    aspect-ratio: 1 / 1;
    height: auto;
}
.pgr-gallery-thumbs .pgr-thumb img {
    width: 85%;
    height: 85%;
    object-fit: contain;
}

/* ── zoom modal ───────────────────────────────────────────────────────────
   The theme's modal is built around a cover that is always 800 px wide, with the
   thumbnail column taking whatever width is left. Shrinking the cover made those
   thumbs wrap into a grid on top of the picture, so the column goes away entirely
   and the pictures are paged with two arrows (views/js/fit.js) instead.
   The sheet is a white square that always fits the screen. */
.modal-open #product-modal {
    padding-top: 0;
}
/* centre the sheet on screen: the modal layer itself does it, so the dialog needs
   no margin or min-height (those pushed the picture off the top of the screen) */
#product-modal.show,
#product-modal.in {
    display: flex !important;
    align-items: center;
    justify-content: center;
}
#product-modal .modal-dialog {
    /* the theme centres this dialog with its own translate(); with the flex centring
       above that would apply twice and throw the picture off the top of the screen */
    transform: none !important;
    top: auto;
    margin: 0 auto;
    min-height: 0;
    max-width: 96vw;
    width: auto;
}
#product-modal .modal-content {
    width: auto;
    border: 0;
    border-radius: 14px;
}
#product-modal .modal-body {
    display: block;
    margin: 0;
    padding: 0;
}
/* only the picture in the zoom — the description stays on the page */
#product-modal .image-caption,
#product-modal #thumbnails,
#product-modal .js-modal-arrows {
    display: none;
}
#product-modal figure {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 0;
    padding: 10px;
}
#product-modal .product-cover-modal {
    display: block;
    width: min(76vh, 70vw);
    height: min(76vh, 70vw);
    object-fit: contain;
    padding: 7.5%;
    box-sizing: border-box;
    background: #fff;
    border-radius: 10px;
}

/* paging arrows, one on each side of the picture */
.egfit-nav {
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    border: 1px solid #e2e2dc;
    border-radius: 50%;
    background: #fff;
    color: #1d1d1b;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.egfit-nav:hover {
    background: #f4f4f1;
}
.egfit-prev { order: -1; }

/* slightly darker backdrop behind the zoom */
.modal-backdrop.show,
.modal-backdrop.in {
    opacity: .75;
}


/* close button — on the white sheet, top right */
.egfit-close {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    color: #1d1d1b;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    z-index: 3;
}
.egfit-close:hover {
    background: #f4f4f1;
}
#product-modal figure {
    position: relative;
}

/* ── phones ──────────────────────────────────────────────────────────────
   Side-by-side arrows ate the width the picture needs (and pushed themselves off
   the screen on narrow phones). Here the sheet is full width with a FIXED picture
   height, so it never changes size from one picture to the next, and the strips of
   backdrop above and below it stay tappable for closing the zoom. */
@media (max-width: 767px) {
    #product-modal .modal-dialog,
    #product-modal .modal-content {
        width: 100vw;
        max-width: 100vw;
        margin: 0;
        border-radius: 0;
    }
    #product-modal figure {
        padding: 0;
        gap: 0;
    }
    #product-modal .product-cover-modal {
        width: 100%;
        height: 74vh;
        padding: 8px;
        border-radius: 0;
    }
    .egfit-nav {
        position: absolute;
        top: 50%;
        transform: translateY(-50%);
        width: 38px;
        height: 38px;
        font-size: 22px;
        background: rgba(255, 255, 255, .85);
        border-color: rgba(0, 0, 0, .12);
        box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    }
    .egfit-prev { left: 8px; }
    .egfit-next { right: 8px; }
    .egfit-close {
        top: 8px;
        right: 8px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, .18);
    }
}