/* Product page full-screen image viewer (assets/js/product_lightbox.js).
   Theme tokens from theme.css; no inline styles (the script only sets the
   photo's zoom transform and the scrollbar-width variable). */

/* The main photo opens it. */
.pdp-lb-trigger {
    cursor: zoom-in;
}

.pdp-lb-trigger:focus-visible {
    outline: none;
    box-shadow: var(--cts-focus-ring);
}

/* Page behind: no scrolling, and no jump when the scrollbar goes away. */
html.pdp-lb-open,
html.pdp-lb-open body {
    overflow: hidden;
}

html.pdp-lb-open body {
    padding-right: var(--pdp-lb-gap, 0);
}

.pdp-lb {
    position: fixed;
    inset: 0;
    z-index: 1100; /* above the chat (1080) and staff toasts (1090); the page loader (2000) only shows while a page loads */
    display: flex;
    flex-direction: column;
    background-color: rgba(10, 15, 29, 0.97); /* --color-dark, nearly solid */
    color: var(--color-white);
    opacity: 0;
    transition: opacity 0.18s ease;
    overscroll-behavior: contain;
}

.pdp-lb[hidden] {
    display: none;
}

.pdp-lb.is-open {
    opacity: 1;
}

/* ---------- Top bar: counter, zoom, close ---------- */
.pdp-lb-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 1rem;
    flex: 0 0 auto;
}

.pdp-lb-counter {
    font-family: var(--font-family-heading);
    font-weight: 600;
    font-size: 0.95rem;
    letter-spacing: 0.02em;
    color: rgba(255, 255, 255, 0.85);
    min-width: 3rem;
}

.pdp-lb-actions {
    display: flex;
    gap: 0.5rem;
}

.pdp-lb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 0;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.12);
    color: var(--color-white);
    font-size: 1.15rem;
    cursor: pointer;
    transition: background-color 0.15s ease, transform 0.15s ease;
}

.pdp-lb-btn:hover {
    background-color: var(--color-primary);
}

.pdp-lb-btn:focus-visible {
    outline: 3px solid var(--color-white);
    outline-offset: 2px;
    background-color: var(--color-primary);
}

.pdp-lb-close {
    background-color: var(--color-primary);
}

/* Zoom button: the + icon, or the - icon while zoomed. */
.pdp-lb-zoom-out,
.pdp-lb-zoom[aria-pressed="true"] .pdp-lb-zoom-in {
    display: none;
}

.pdp-lb-zoom[aria-pressed="true"] .pdp-lb-zoom-out {
    display: inline;
}

.pdp-lb-close:hover {
    background-color: var(--cts-red-hover);
}

/* ---------- The photo ---------- */
.pdp-lb-stage {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    touch-action: none; /* swipe, pinch and pan are handled by the script */
    user-select: none;
    -webkit-user-select: none;
}

.pdp-lb-frame {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem 6rem;
}

/* A comfortable, contained size (like Jumia's viewer): at most 560px tall and
   720px wide, smaller on small windows, always with dark space around it.
   object-fit keeps the photo's proportions inside the white card. */
.pdp-lb-img {
    height: min(100%, 560px);
    width: auto;
    max-width: min(100%, 720px);
    max-height: 100%;
    object-fit: contain;
    background-color: var(--color-white); /* product photos are made for a white page */
    border-radius: 12px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    cursor: zoom-in;
    transition: transform 0.2s ease, opacity 0.25s ease;
    will-change: transform;
}

.pdp-lb.is-zoomed .pdp-lb-img {
    cursor: grab;
    transition: none;
    border-radius: 0;
}

.pdp-lb.is-zoomed .pdp-lb-img:active {
    cursor: grabbing;
}

/* ---------- Loading: grey CTS logo (as on the page loader) in a red ring ----------
   The photo stays hidden until it has loaded, then fades in; a photo that
   fails to load leaves just the logo (no broken-image icon). */
.pdp-lb.is-loading .pdp-lb-img,
.pdp-lb.is-broken .pdp-lb-img {
    opacity: 0;
    transition: none;
}

.pdp-lb-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 92px;
    height: 92px;
    margin: -46px 0 0 -46px;
    display: none;
    pointer-events: none;
}

.pdp-lb.is-loading .pdp-lb-loader,
.pdp-lb.is-broken .pdp-lb-loader {
    display: block;
}

.pdp-lb-loader::before {
    content: "";
    position: absolute;
    inset: 18px;
    background: url("../img/icons/android-chrome-192x192.png") center / contain no-repeat;
    filter: grayscale(1);
    animation: cts-loader-pulse 1.4s ease-in-out infinite; /* theme.css */
}

.pdp-lb-loader::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.14);
    border-top-color: var(--color-primary);
    animation: pdp-lb-spin 0.8s linear infinite;
}

.pdp-lb.is-broken .pdp-lb-loader::after {
    display: none;
}

@keyframes pdp-lb-spin {
    to { transform: rotate(360deg); }
}

.pdp-lb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    font-size: 1.25rem;
}

.pdp-lb-prev {
    left: 1rem;
}

.pdp-lb-next {
    right: 1rem;
}

.pdp-lb.is-zoomed .pdp-lb-nav {
    opacity: 0;
    pointer-events: none;
}

/* ---------- Thumbnails ---------- */
.pdp-lb-thumbs {
    flex: 0 0 auto;
    display: flex;
    justify-content: safe center; /* "safe": when there are too many to fit, the first ones stay reachable */
    gap: 0.6rem;
    padding: 0.85rem 1rem 1rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.pdp-lb-thumb {
    flex: 0 0 auto;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 8px;
    background-color: var(--color-white);
    overflow: hidden;
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.15s ease, border-color 0.15s ease;
}

.pdp-lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}

.pdp-lb-thumb:hover {
    opacity: 1;
}

.pdp-lb-thumb.is-active {
    opacity: 1;
    border-color: var(--color-primary);
}

.pdp-lb-thumb:focus-visible {
    outline: 3px solid var(--color-white);
    outline-offset: 2px;
    opacity: 1;
}

/* ---------- Phones ---------- */
@media (max-width: 767.98px) {
    .pdp-lb {
        background-color: var(--color-dark);
    }

    .pdp-lb-top {
        padding: 0.5rem 0.75rem;
    }

    .pdp-lb-frame {
        padding: 1rem 0.75rem;
    }

    /* The screen's width, with a little margin; never taller than about 60% of it. */
    .pdp-lb-img {
        width: 100%;
        height: auto;
        max-width: 100%;
        max-height: min(100%, 62vh);
        border-radius: 10px;
    }

    /* Swipe does it on a phone; the arrows stay small and out of the way. */
    .pdp-lb-nav {
        width: 40px;
        height: 40px;
        font-size: 1rem;
        background-color: rgba(10, 15, 29, 0.55);
    }

    .pdp-lb-prev {
        left: 0.4rem;
    }

    .pdp-lb-next {
        right: 0.4rem;
    }

    .pdp-lb-thumbs {
        justify-content: flex-start;
        padding: 0.6rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom));
    }

    .pdp-lb-thumb {
        width: 52px;
        height: 52px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .pdp-lb,
    .pdp-lb-img,
    .pdp-lb-btn,
    .pdp-lb-thumb {
        transition: none;
    }

    .pdp-lb-loader::before,
    .pdp-lb-loader::after {
        animation: none;
    }
}
