/* Product listing image viewer (assets/js/shared/product-image-viewer.js). */

/* Bootstrap's max-width:100% lets the auto-width listing table squeeze the
   thumbnail to 0px on narrow screens, leaving nothing to tap. */
img.openModal {
    cursor: zoom-in;
    max-width: none;
}

/* The theme's cookie bar sits at z-index 2147483647; the viewer is moved to the
   end of <body> when it opens so the same z-index puts it on top. */
.piv {
    display: none;
    position: fixed;
    top: 0; right: 0; bottom: 0; left: 0;
    z-index: 2147483647;
    background: rgba(0, 0, 0, 0.92);
    color: #fff;
    font-family: Arial, Helvetica, sans-serif;
    -webkit-user-select: none;
    user-select: none;
}
.piv.is-open {
    display: block;
}
html.piv-lock,
html.piv-lock body {
    overflow: hidden !important;
}

.piv-stage {
    position: absolute;
    top: 0; right: 0; bottom: 0; left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none;
}
.piv.is-zoomed .piv-stage {
    cursor: grab;
}
.piv.is-dragging .piv-stage {
    cursor: grabbing;
}

.piv-image {
    display: block;
    flex: none;
    margin: auto;
    max-width: calc(100vw - 160px);
    max-height: calc(100vh - 160px);
    max-height: calc(100dvh - 160px);
    width: auto;
    height: auto;
    transform-origin: 50% 50%;
    transition: transform 0.2s ease, opacity 0.2s ease;
    will-change: transform;
    background: #fff;
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.6);
    cursor: zoom-in;
}
.piv.is-zoomed .piv-image {
    cursor: inherit;
}
.piv.is-dragging .piv-image,
.piv.no-anim .piv-image {
    transition: none;
}
.piv.is-loading .piv-image {
    opacity: 0;
}

.piv-spinner {
    display: none;
    position: absolute;
    font-size: 36px;
    color: rgba(255, 255, 255, 0.8);
}
.piv.is-loading .piv-spinner {
    display: block;
}

.piv-toolbar {
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    background: rgba(30, 30, 30, 0.85);
    border-radius: 30px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
    white-space: nowrap;
}
.piv button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    color: #fff;
    line-height: 1;
    cursor: pointer;
    text-shadow: none;
    opacity: 1;
    box-shadow: none;
}
.piv-toolbar button {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 17px;
}
.piv-toolbar button:hover,
.piv-toolbar button:focus-visible,
.piv-nav:hover,
.piv-nav:focus-visible {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    outline: none;
}
.piv-toolbar button:disabled {
    opacity: 0.35;
    cursor: default;
    background: transparent;
}
.piv-toolbar .piv-close {
    margin-left: 6px;
    background: rgba(255, 255, 255, 0.12);
}
.piv-toolbar .piv-close:hover {
    background: #c0392b;
}
.piv-level,
.piv-counter {
    min-width: 50px;
    text-align: center;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}
.piv-counter {
    padding-right: 6px;
    margin-right: 2px;
    border-right: 1px solid rgba(255, 255, 255, 0.25);
}

.piv-nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    width: 52px;
    height: 52px;
    margin-top: -26px;
    border-radius: 50%;
    background: rgba(30, 30, 30, 0.75) !important;
    font-size: 20px;
}
.piv-nav:hover {
    background: rgba(255, 255, 255, 0.25) !important;
}
.piv-prev { left: 20px; }
.piv-next { right: 20px; }

.piv-caption {
    position: absolute;
    left: 50%;
    bottom: 56px;
    transform: translateX(-50%);
    z-index: 2;
    max-width: 90%;
    padding: 6px 14px;
    border-radius: 4px;
    background: rgba(30, 30, 30, 0.8);
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    pointer-events: none;
}

.piv-hint {
    position: absolute;
    left: 50%;
    bottom: 18px;
    transform: translateX(-50%);
    z-index: 2;
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(30, 30, 30, 0.75);
    font-size: 12px;
    white-space: nowrap;
    pointer-events: none;
    transition: opacity 0.4s ease;
}
.piv.hint-hidden .piv-hint {
    opacity: 0;
}

@media (max-width: 600px) {
    .piv-toolbar {
        top: 10px;
        gap: 0;
        padding: 4px;
        max-width: calc(100vw - 16px);
    }
    .piv-toolbar button {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    .piv-level,
    .piv-counter {
        min-width: 38px;
        font-size: 11px;
    }
    .piv-toolbar [data-action="rotate-left"],
    .piv-toolbar [data-action="fullscreen"] {
        display: none !important;
    }
    .piv-image {
        max-width: 96vw;
        max-height: calc(100vh - 150px);
        max-height: calc(100dvh - 150px);
    }
    .piv-nav {
        top: auto;
        bottom: 90px;
        margin-top: 0;
        width: 44px;
        height: 44px;
    }
    .piv-prev { left: 12px; }
    .piv-next { right: 12px; }
    .piv-hint {
        display: none;
    }
    .piv-caption {
        bottom: 20px;
        font-size: 12px;
    }
}
