/* "Images | 3D" media switcher on the storefront product pages (includes/product_media_markup.php,
   assets/js/product-media-switcher.js). Loaded after each page's own viewer styles. */
.product-media {
    --pm-pad: 15px;
    --pm-gold: #b8860b;
    --pm-ink: #212529;
    position: relative;
}

.product-media-panel[hidden] {
    display: none !important;
}

/* The photo panel is framed like the 3D viewer card so switching tabs does not move the picture. */
.product-media-card {
    background: #f8f9fa;
    border-radius: 12px;
    padding: var(--pm-pad);
}

/* ── Pill toggle, floating over the top centre of the viewport ─────────── */
.product-media-toggle {
    position: absolute;
    z-index: 6;
    top: calc(var(--pm-pad) + 10px);
    left: 50%;
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 4px;
    border-radius: 999px;
    background: rgba(255, 255, 255, .96);
    border: 1px solid rgba(15, 23, 42, .12);
    box-shadow: 0 4px 14px rgba(15, 23, 42, .14);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
}

.product-media-toggle-thumb {
    position: absolute;
    top: 4px;
    bottom: 4px;
    left: 4px;
    width: calc(50% - 4px);
    border-radius: 999px;
    background: var(--pm-ink);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
}

.product-media-toggle[data-active="3d"] .product-media-toggle-thumb {
    transform: translateX(100%);
}

.product-media-tab {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .4rem;
    min-width: 92px;
    min-height: 40px;
    padding: 0 1rem;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #495057;            /* 7.9:1 on white */
    font-size: .9rem;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: color .2s ease;
}

.product-media-tab:hover:not(.is-active) {
    color: var(--pm-ink);
}

.product-media-tab.is-active {
    color: #fff;               /* white on #212529: 15:1 */
}

.product-media-tab:focus-visible {
    outline: 3px solid rgba(184, 134, 11, .55);
    outline-offset: 2px;
}

@media (pointer: coarse) {
    .product-media-tab {
        min-height: 44px;
    }
}

/* ── Carousel ──────────────────────────────────────────────────────────── */
.product-media-carousel:focus-visible {
    outline: 3px solid rgba(184, 134, 11, .45);
    outline-offset: 3px;
    border-radius: 12px;
}

.product-media-stage {
    position: relative;
}

.product-media-track {
    display: flex;
    align-self: stretch;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

.product-media-track::-webkit-scrollbar {
    display: none;
}

.product-media-slide {
    flex: 0 0 100%;
    height: 100%;
    scroll-snap-align: center;
    scroll-snap-stop: always;
}

.product-media-zoom {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: #fff;
    overflow: hidden;
    cursor: zoom-in;
}

.product-media-zoom:focus-visible {
    outline: 3px solid rgba(184, 134, 11, .55);
    outline-offset: -3px;
}

.product-media-zoom img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
    transition: transform .15s ease-out;
    will-change: transform;
}

/* Hover zoom follows the cursor (set by the controller); pointer devices only. */
@media (hover: hover) and (pointer: fine) {
    .product-media-zoom.is-zooming img {
        transform: scale(2);
    }
}

.product-media-arrow {
    position: absolute;
    top: 50%;
    z-index: 3;
    width: 40px;
    height: 40px;
    margin-top: -20px;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: var(--pm-ink);
    box-shadow: 0 2px 8px rgba(15, 23, 42, .16);
    cursor: pointer;
    transition: opacity .2s ease, background-color .2s ease;
}

.product-media-arrow.is-prev { left: 8px; }
.product-media-arrow.is-next { right: 8px; }

.product-media-arrow:hover:not(:disabled) {
    background: #fff;
}

.product-media-arrow:focus-visible {
    outline: 3px solid rgba(184, 134, 11, .55);
    outline-offset: 2px;
}

.product-media-arrow:disabled {
    opacity: .35;
    cursor: default;
}

.product-media-counter {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 3;
    padding: .2rem .6rem;
    border-radius: 999px;
    background: rgba(33, 37, 41, .78);
    color: #fff;
    font-size: .75rem;
    font-weight: 600;
    pointer-events: none;
}

/* ── Thumbnails ────────────────────────────────────────────────────────── */
.product-media-thumbs {
    display: flex;
    justify-content: center;
    gap: .5rem;
    margin-top: .75rem;
    overflow-x: auto;
    padding: 2px;
    scrollbar-width: thin;
}

.product-media-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 0;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 10px;
    background: #fff;
    opacity: .7;
    cursor: pointer;
    transition: border-color .2s ease, opacity .2s ease;
}

.product-media-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.product-media-thumb:hover {
    opacity: 1;
}

.product-media-thumb.is-active {
    border-color: var(--pm-gold);
    opacity: 1;
}

.product-media-thumb:focus-visible {
    outline: 3px solid rgba(184, 134, 11, .55);
    outline-offset: 2px;
}

/* ── 3D panel: uniform white background ────────────────────────────────── */
.product-media .model-viewer-wrap,
.product-media .obj-viewer-stage {
    background: #fff;
}

/* ── Small screens ─────────────────────────────────────────────────────── */
@media (max-width: 576px) {
    .product-media {
        --pm-pad: 12px;
    }

    .product-media-tab {
        min-width: 80px;
        padding: 0 .8rem;
        font-size: .85rem;
    }

    .product-media-thumb {
        width: 56px;
        height: 56px;
    }

    .product-media-arrow {
        width: 36px;
        height: 36px;
        margin-top: -18px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .product-media-toggle-thumb,
    .product-media-tab,
    .product-media-zoom img,
    .product-media-thumb,
    .product-media-arrow {
        transition: none;
    }

    .product-media-track {
        scroll-behavior: auto;
    }
}
