/* VP-032 (Memarket): the listing's photo gallery (templates/single/mm-gallery.php, js/mm-gallery.js).
   The photos sit in a native horizontal scroller with scroll snapping: sideways swipes change the
   photo, up and down ones scroll the page, pinching zooms the page (touch-action keeps panning in
   both directions and pinch-zoom; it only drops the double-tap zoom so a tap opens the viewer at once). */
.mm-gallery {
    position: relative;
}
.mm-gallery__stage {
    position: relative;
    isolation: isolate;
    width: 100%;
    aspect-ratio: var(--mm-gallery-ratio, 1.3333);
    max-height: 85vh;    /* a phone held sideways: the whole photo fits the screen (shown letterboxed) */
    max-height: 85svh;
    overflow: hidden;
    background: #f4f4f4;
}
.mm-gallery__track {
    display: flex;
    width: 100%;
    height: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    overscroll-behavior-x: contain;
    touch-action: pan-x pan-y pinch-zoom;
    scrollbar-width: none;
    outline: 0;
}
.mm-gallery__track::-webkit-scrollbar {
    display: none;
}
/* at the first / last photo (js/mm-gallery.js): no pan towards the end, so Chrome on touch screens does
   not take that swipe as Back / Forward; up and down and pinch stay */
@supports (touch-action: pan-left) {
    .mm-gallery__track.mm-pan-r {
        touch-action: pan-right pan-y pinch-zoom;
    }
    .mm-gallery__track.mm-pan-l {
        touch-action: pan-left pan-y pinch-zoom;
    }
    .mm-gallery__track.mm-pan-v {
        touch-action: pan-y pinch-zoom;
    }
}
@supports not (aspect-ratio: 1 / 1) {   /* older browsers: the same box from its padding */
    .mm-gallery__stage {
        height: 0;
        padding-top: calc(100% / var(--mm-gallery-ratio, 1.3333));
    }
    .mm-gallery__track {
        position: absolute;
        top: 0;
        left: 0;
    }
}
.mm-gallery__slide {
    flex: 0 0 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}
.mm-gallery__slide img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
    -webkit-user-select: none;
    user-select: none;
}
.mm-gallery__slide:focus {
    outline: 0;
}
.mm-gallery__slide:focus-visible {
    outline: 3px solid #337ab7;
    outline-offset: -3px;
}

/* the magnifier (decoration: the whole photo is the control) */
.mm-gallery__hint {
    position: absolute;
    top: 8px;
    inset-inline-end: 8px;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .88);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .25);
    pointer-events: none;
}
.mm-gallery__hint svg {
    fill: none;
    stroke: #222;
    stroke-width: 2;
    stroke-linecap: round;
}

/* previous / next */
.mm-gallery__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
    color: #222;
    cursor: pointer;
    transition: opacity .2s, background-color .2s;
    -webkit-tap-highlight-color: transparent;
}
.mm-gallery__nav[hidden] {
    display: none;
}
.mm-gallery__nav--prev {
    inset-inline-start: 8px;
}
.mm-gallery__nav--next {
    inset-inline-end: 8px;
}
.mm-gallery__nav svg {
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}
[dir="rtl"] .mm-gallery__nav svg {
    transform: scaleX(-1);
}
.mm-gallery__nav:hover {
    background: #fff;
}
.mm-gallery__nav:focus {
    outline: 0;
}
.mm-gallery__nav:focus-visible {
    outline: 3px solid #337ab7;
    outline-offset: 2px;
}
.mm-gallery__nav[aria-disabled="true"] {
    opacity: .35;
    cursor: default;
}

/* "2 / 4" */
.mm-gallery__count {
    position: absolute;
    bottom: 8px;
    inset-inline-end: 8px;
    z-index: 1;
    padding: 3px 9px;
    border-radius: 12px;
    background: rgba(0, 0, 0, .6);
    color: #fff;
    font-size: 13px;
    line-height: 18px;
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}
.mm-gallery__count[hidden] {
    display: none;
}

/* thumbnails */
.mm-gallery__thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}
.mm-gallery__thumb {
    display: block;
    width: 72px;
    border: 2px solid #eee;
    background: #fff;
    -webkit-tap-highlight-color: transparent;
}
.mm-gallery__thumb img {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 6 / 5;
    object-fit: cover;
}
.mm-gallery__thumb:hover {
    border-color: #999;
}
.mm-gallery__thumb[aria-current="true"] {
    border-color: #333;
}
.mm-gallery__thumb:focus {
    outline: 0;
}
.mm-gallery__thumb:focus-visible {
    outline: 3px solid #337ab7;
    outline-offset: 1px;
}

/* touch screens: a swipe that started on an arrow would not move the strip; the photo is swiped, the
   counter and the thumbnails show where it is */
@media (hover: none) and (pointer: coarse) {
    .mm-gallery__nav,
    .mm-gallery__nav[hidden] {
        display: none;
    }
}
@media (max-width: 480px) {
    .mm-gallery__nav {
        width: 40px;
        height: 40px;
        margin-top: -20px;
    }
    .mm-gallery__thumb {
        width: 64px;
    }
}
@media (prefers-reduced-motion: reduce) {
    .mm-gallery__nav {
        transition: none;
    }
}
