.btmx-3d-stage {
    width: 100%;
}

/* --- Long description relocated under the gallery on desktop (>=768px).
   The host sits in the left (gallery) column; print_layout_script() moves
   #tab-description into it on desktop and back to its tab on mobile. --- */
.btmx-3d-desc-host { margin-top: 24px; }
.btmx-3d-desc-host:empty { display: none; }
.btmx-3d-desc-host .woocommerce-Tabs-panel--description { display: block !important; opacity: 1 !important; }
/* WooDmart caps the tab/accordion panel height and adds an inner scroll
   (.wd-scroll wrappers). In the gallery column there's plenty of room — let the
   relocated description flow at full height with no inner scrollbar. */
.btmx-3d-desc-host,
.btmx-3d-desc-host .woocommerce-Tabs-panel--description,
.btmx-3d-desc-host .wd-accordion-content,
.btmx-3d-desc-host .wd-scroll,
.btmx-3d-desc-host .wd-scroll-content,
.btmx-3d-desc-host .wc-tab-inner {
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}
.btmx-3d-desc-host .ps__rail-x,
.btmx-3d-desc-host .ps__rail-y { display: none !important; }

.btmx-3d-viewer {
    position: relative;
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    min-height: 400px;
    margin-bottom: 16px;
}

.btmx-3d-viewer canvas {
    display: block;
    width: 100% !important;
    height: 100% !important;
}

.btmx-3d-loader {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    background: rgba(0, 0, 0, 0.25);
    z-index: 5;
}

.btmx-3d-loader-msg {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
}

.btmx-3d-loader-bar {
    width: 240px;
    height: 4px;
    background: #333;
    border-radius: 2px;
    overflow: hidden;
}

.btmx-3d-loader-bar > div {
    height: 100%;
    background: #fff;
    width: 0%;
    transition: width 0.2s;
}

.btmx-3d-hint {
    position: absolute;
    bottom: 10px;
    right: 14px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.4);
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
}

.btmx-3d-views {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 4px;
    z-index: 6;
}

.btmx-3d-views button {
    background: rgba(0, 0, 0, 0.5);
    color: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 4px;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.btmx-3d-views button:hover {
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
}

/* ===== Fullscreen button — force reset, Woodmart paints all <button>s ===== */
.btmx-3d-viewer .btmx-3d-fs-btn,
.btmx-3d-viewer .btmx-3d-fs-btn:hover,
.btmx-3d-viewer .btmx-3d-fs-btn:focus,
.btmx-3d-viewer .btmx-3d-fs-btn:active {
    appearance: none !important;
    -webkit-appearance: none !important;
    position: absolute !important;
    top: 10px !important;
    left: 10px !important;
    z-index: 7 !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.6) !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    background-image: none !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: 1 !important;
    font: inherit !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    transition: background 0.15s, color 0.15s;
}

.btmx-3d-viewer .btmx-3d-fs-btn:hover {
    background: rgba(0, 0, 0, 0.85) !important;
    background-color: rgba(0, 0, 0, 0.85) !important;
}

.btmx-3d-viewer .btmx-3d-fs-btn svg {
    display: block !important;
    width: 20px !important;
    height: 20px !important;
}

/* ===== Zoom +/- (lower-left) — same force-reset as fs button ===== */
.btmx-3d-viewer .btmx-3d-zoom {
    position: absolute !important;
    bottom: 10px !important;
    left: 10px !important;
    z-index: 7 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
}

.btmx-3d-viewer .btmx-3d-zoom button,
.btmx-3d-viewer .btmx-3d-zoom button:hover,
.btmx-3d-viewer .btmx-3d-zoom button:focus,
.btmx-3d-viewer .btmx-3d-zoom button:active {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 36px !important;
    height: 36px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.6) !important;
    background-color: rgba(0, 0, 0, 0.6) !important;
    background-image: none !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: 1 !important;
    font: 600 18px/1 sans-serif !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
}

.btmx-3d-viewer .btmx-3d-zoom button:hover {
    background: rgba(0, 0, 0, 0.85) !important;
    background-color: rgba(0, 0, 0, 0.85) !important;
}

/* Emulated fullscreen for iOS / non-Fullscreen-API browsers.
   - dvh/dvw is the "dynamic viewport" (excludes iOS Safari's collapsing
     address bar). 100vh on iPhone overshoots into the toolbar area, so the
     bottom of the viewer ends up off-screen. Plain vh/vw kept as fallback
     before dvh/dvw for browsers < iOS 15.4 / Chrome 108.
   - z-index = max signed-int 32-bit so we sit above Woodmart's sticky
     header (z-index 9999+) and any other late-loaded chrome.
   - JS additionally relocates the node to <body> on enter so any ancestor
     transform/filter/will-change can't trap position:fixed. */
.btmx-3d-viewer.btmx-3d-fs-emulated {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    width: 100dvw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border-radius: 0 !important;
    aspect-ratio: auto !important;
    z-index: 2147483647;
    background: #0a0a0a;
}

body.btmx-3d-fs-lock {
    overflow: hidden;
}

/* Shop-loop swatches: display-only (purely "this product comes in N
   colours"). Override Woodmart's pointer cursor so the swatches don't
   advertise themselves as clickable — the whole card is the link. */
.btmx-3d-loop-swatches .wd-swatch,
.btmx-3d-loop-swatches .wd-swatch:hover {
    cursor: default;
}

/* Native fullscreen: browser drops the viewer into a host that needs the same
   normalisation so canvas fills properly. */
.btmx-3d-viewer:fullscreen,
.btmx-3d-viewer:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    aspect-ratio: auto;
    border-radius: 0;
    background: #0a0a0a;
}

/* ===== Color swatches ===== */
.btmx-3d-swatches {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    width: 100%;
    margin-bottom: 24px;
}

/* Reset everything Woodmart / WC throw at <button> — they default-add white
   background, padding, borders, gradient shadow, etc. */
.btmx-3d-swatches .btmx-3d-swatch,
.btmx-3d-swatches .btmx-3d-swatch:hover,
.btmx-3d-swatches .btmx-3d-swatch:focus,
.btmx-3d-swatches .btmx-3d-swatch:active {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    height: 32px;
    width: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    outline: none;
    border-radius: 4px;
    background: var(--btmx-swatch-color, #333) !important;
    background-color: var(--btmx-swatch-color, #333) !important;
    background-image: none !important;
    box-shadow: none !important;
    color: inherit;
    cursor: pointer;
    overflow: visible;
    text-shadow: none;
    min-width: 0;
    min-height: 0;
    line-height: 1;
    font: inherit;
    transition: transform 0.1s;
}

.btmx-3d-swatches .btmx-3d-swatch:hover {
    /* No transform — caused 1px layout-shift in Firefox on hover. */
}

/* Active = white outline along the swatch perimeter, drawn INSIDE so it can't
   bleed the white into the surrounding dark layout. */
.btmx-3d-swatches .btmx-3d-swatch.is-active {
    outline: 2px solid #fff !important;
    outline-offset: -2px;
}

/* Inner span is now redundant — button itself shows the colour. Hide span if
   it exists so a leftover Woodmart rule on <span> backgrounds can't paint
   something visible. */
.btmx-3d-swatch-fill {
    display: none;
}

.btmx-3d-swatch-badge { display: none; }

/* ===== Stage shell (contains 3D layer + photo layer + nav arrows) ===== */
.btmx-3d-stage-shell {
    position: relative;
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 12px;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    min-height: 400px;
    margin-bottom: 16px;
}

.btmx-3d-layer {
    position: absolute;
    inset: 0;
}

.btmx-3d-stage-shell > .btmx-3d-viewer {
    /* viewer was a top-level box before — now an inner layer; drop its own
       border-radius/background/aspect-ratio. */
    position: absolute;
    inset: 0;
    border-radius: 0;
    background: transparent;
    aspect-ratio: auto;
    min-height: 0;
    margin-bottom: 0;
}

.btmx-3d-layer-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0a0a0a;
    z-index: 4; /* above 3D viewer (z-auto) but below stage arrows (z:7) */
}
/* Without this override, our `display: flex` wins specificity over the
   browser-default `[hidden] { display: none }` and the photo layer stays
   visible after setting .hidden = true. */
.btmx-3d-layer-photo[hidden] {
    display: none !important;
}
.btmx-3d-photo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}
.btmx-3d-photo-counter {
    position: absolute;
    bottom: 10px;
    right: 14px;
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(0, 0, 0, 0.45);
    padding: 4px 8px;
    border-radius: 4px;
    pointer-events: none;
    font-family: monospace;
}

/* ===== Stage prev/next arrows — same style as fs/zoom/views buttons ===== */
.btmx-3d-stage-shell .btmx-3d-stage-arrow,
.btmx-3d-stage-shell .btmx-3d-stage-arrow:hover,
.btmx-3d-stage-shell .btmx-3d-stage-arrow:focus,
.btmx-3d-stage-shell .btmx-3d-stage-arrow:active {
    appearance: none !important;
    -webkit-appearance: none !important;
    position: absolute !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    z-index: 7 !important;
    width: 40px !important;
    height: 56px !important;
    min-width: 0 !important;
    max-width: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.5) !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    background-image: none !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: 1 !important;
    font: 600 22px/1 sans-serif !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.btmx-3d-stage-shell .btmx-3d-stage-arrow:hover {
    background: rgba(0, 0, 0, 0.85) !important;
}

.btmx-3d-stage-prev { left: 10px !important; }
.btmx-3d-stage-next { right: 10px !important; }

/* ===== Thumbnail strip carousel ===== */
.btmx-3d-thumbs {
    position: relative;
    margin-top: 16px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btmx-3d-thumbs-strip {
    flex: 1;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 2px 0;
}
.btmx-3d-thumbs-strip::-webkit-scrollbar { display: none; }

.btmx-3d-thumbs .btmx-3d-thumb,
.btmx-3d-thumbs .btmx-3d-thumb:hover,
.btmx-3d-thumbs .btmx-3d-thumb:focus,
.btmx-3d-thumbs .btmx-3d-thumb:active {
    appearance: none !important;
    -webkit-appearance: none !important;
    flex: 0 0 auto !important;
    width: 80px !important;
    height: 80px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 2px solid transparent !important;
    border-radius: 4px !important;
    background: rgba(255, 255, 255, 0.04) !important;
    background-color: rgba(255, 255, 255, 0.04) !important;
    background-image: none !important;
    cursor: pointer !important;
    overflow: hidden !important;
    scroll-snap-align: start !important;
    box-shadow: none !important;
    transition: border-color 0.15s;
    min-width: 0 !important;
}
.btmx-3d-thumbs .btmx-3d-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.btmx-3d-thumbs .btmx-3d-thumb.is-active {
    border-color: #fff !important;
}

/* Synthetic "3D" tile at the start of the strip — black square with white
   "3D" label, identical footprint to a photo thumb. */
.btmx-3d-thumbs .btmx-3d-thumb-3d {
    background: #0a0a0a !important;
    background-color: #0a0a0a !important;
    color: #fff !important;
    font: 600 14px/1 sans-serif !important;
    letter-spacing: 1px;
    text-align: center;
}

.btmx-3d-thumbs .btmx-3d-thumb-arrow,
.btmx-3d-thumbs .btmx-3d-thumb-arrow:hover,
.btmx-3d-thumbs .btmx-3d-thumb-arrow:focus,
.btmx-3d-thumbs .btmx-3d-thumb-arrow:active {
    appearance: none !important;
    -webkit-appearance: none !important;
    width: 28px !important;
    height: 80px !important;
    min-width: 0 !important;
    flex: 0 0 auto !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.5) !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    background-image: none !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.15) !important;
    border-radius: 4px !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    font: 600 18px/1 sans-serif !important;
    opacity: 1 !important;
    visibility: visible !important;
}
.btmx-3d-thumbs .btmx-3d-thumb-arrow:hover {
    background: rgba(0, 0, 0, 0.85) !important;
}

/* ===== Addons (cable + branding) ===== */
.btmx-3d-addons {
    margin: 20px 0;
    padding: 16px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btmx-3d-addon {
    margin-bottom: 22px;
}

.btmx-3d-addon:last-child {
    margin-bottom: 0;
}

.btmx-3d-addon h4 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 10px;
}

.btmx-3d-radio {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.25);
    cursor: pointer;
    margin-bottom: 6px;
    transition: border-color 0.15s;
}

.btmx-3d-radio:hover {
    border-color: rgba(255, 255, 255, 0.3);
}

.btmx-3d-radio input {
    margin: 0;
    flex-shrink: 0;
}

.btmx-3d-radio span {
    flex: 1;
    font-size: 14px;
}

.btmx-3d-radio em {
    font-style: normal;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
}

/* ===== Branding upload ===== */
.btmx-3d-brand-spec {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.55);
    margin: 0 0 10px;
    line-height: 1.4;
}

.btmx-3d-brand-upload {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.btmx-3d-brand-btn {
    padding: 10px 16px;
    background: #fff;
    color: #000;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.15s;
}

.btmx-3d-brand-btn:hover {
    opacity: 0.85;
}

.btmx-3d-brand-status {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

.btmx-3d-brand-invert {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
}

.btmx-3d-brand-invert input {
    margin: 0;
    flex-shrink: 0;
}

.btmx-3d-brand-preview {
    margin-top: 12px;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.btmx-3d-brand-preview-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
}

.btmx-3d-brand-canvas {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    border-radius: 4px;
    background: #000;
    margin-bottom: 10px;
}

.btmx-3d-brand-remove {
    background: transparent;
    color: rgba(255, 100, 100, 0.85);
    border: 1px solid rgba(255, 100, 100, 0.4);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 12px;
    cursor: pointer;
}

.btmx-3d-brand-remove:hover {
    background: rgba(255, 100, 100, 0.1);
}

.btmx-3d-brand-price-line {
    margin: 12px 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.75);
}

@media (max-width: 768px) {
    .btmx-3d-swatches {
        grid-template-columns: repeat(5, 1fr);
    }
    .btmx-3d-stage-shell {
        aspect-ratio: 1 / 1;
        min-height: 320px;
    }
}

/* ===== Photo lightbox — fullscreen floating viewer with pinch-zoom (mobile) /
   wheel + double-click zoom (desktop). Opened from the photo stage; lives on
   <body> and never touches the 3D viewer or stage navigation. ===== */
/* In photo mode, hide the 3D-only overlays so they don't sit on top of the
   photo. The fullscreen button (top-left) stays visible — it switches to
   opening the photo lightbox (__btmxOpenLightbox). Prev/next + counter stay. */
.btmx-3d-stage-shell.btmx-photo-mode .btmx-3d-views,
.btmx-3d-stage-shell.btmx-photo-mode .btmx-3d-zoom,
.btmx-3d-stage-shell.btmx-photo-mode .btmx-3d-hint,
.btmx-3d-stage-shell.btmx-photo-mode .btmx-3d-loader {
    display: none !important;
}

.btmx-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
    overscroll-behavior: contain;
}
.btmx-lightbox[hidden] { display: none; }
.btmx-lightbox-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    will-change: transform;
    user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}
.btmx-lightbox-close,
.btmx-lightbox-close:hover,
.btmx-lightbox-close:focus,
.btmx-lightbox-close:active {
    appearance: none !important;
    -webkit-appearance: none !important;
    position: fixed !important;
    top: 12px !important;
    right: 16px !important;
    z-index: 1 !important;
    width: 44px !important;
    height: 44px !important;
    min-width: 0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    background: rgba(0, 0, 0, 0.55) !important;
    background-image: none !important;
    color: #fff !important;
    border: 1px solid rgba(255, 255, 255, 0.25) !important;
    border-radius: 50% !important;
    cursor: pointer !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    font: 400 30px/1 sans-serif !important;
    opacity: 1 !important;
    visibility: visible !important;
}
html.btmx-lightbox-open { overflow: hidden; }
