/* ============================================================
   CWS Suite — Product Gallery
   ============================================================ */
.cws-gallery {
    --cws-gallery-bg: #ffffff;
    --cws-gallery-tint: #f4f1ec;
    --cws-gallery-fg: #1a1a1a;
    --cws-gallery-muted: rgba(20, 20, 20, 0.55);
    --cws-gallery-active: #1a1a1a;
    --cws-gallery-radius: 0px;
    --cws-gallery-gap: 16px;
    --cws-gallery-thumb-size: 92px;
    --cws-gallery-hero-aspect: 62.5%;
    --cws-gallery-lightbox-bg: #f4f1ec;
    --cws-gallery-lightbox-fg: #1a1a1a;
    --cws-gallery-mono-font: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
    --cws-gallery-body-font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;

    background: var(--cws-gallery-bg);
    color: var(--cws-gallery-fg);
    font-family: var(--cws-gallery-body-font);
    display: flex;
    flex-direction: column;
    gap: var(--cws-gallery-gap);
    position: relative;
    box-sizing: border-box;
    width: 100%;
}

.cws-gallery *,
.cws-gallery *::before,
.cws-gallery *::after {
    box-sizing: border-box;
}

.cws-gallery img {
    max-width: 100%;
    display: block;
}

.cws-gallery button {
    font-family: inherit;
    cursor: pointer;
}

/* ============================================================
   HEADER
   ============================================================ */
.cws-gallery__header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    column-gap: 16px;
    row-gap: 8px;
    align-items: baseline;
}

.cws-gallery__mono {
    font-family: var(--cws-gallery-mono-font);
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 11px;
    color: var(--cws-gallery-muted);
    line-height: 1.4;
}

.cws-gallery__mono--meta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.cws-gallery__title {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 0;
    font-size: clamp(22px, 2vw, 28px);
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--cws-gallery-fg);
    line-height: 1.2;
}

.cws-gallery__counter {
    justify-self: end;
    display: inline-flex;
    gap: 4px;
    align-items: baseline;
    color: var(--cws-gallery-fg);
    font-size: 11px;
}

.cws-gallery__counter-label {
    color: var(--cws-gallery-muted);
    margin-left: 6px;
    max-width: 28ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cws-gallery__counter-current,
.cws-gallery__counter-total {
    font-variant-numeric: tabular-nums;
}

/* ============================================================
   STAGE LAYOUT
   ============================================================ */
.cws-gallery__stage {
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas:
        "hero"
        "thumbs"
        "dots"
        "caption";
    gap: var(--cws-gallery-gap);
}

.cws-gallery--thumbs-left .cws-gallery__stage {
    grid-template-columns: var(--cws-gallery-thumb-size) 1fr;
    grid-template-areas:
        "thumbs hero"
        "dots   dots"
        "caption caption";
}

.cws-gallery--thumbs-right .cws-gallery__stage {
    grid-template-columns: 1fr var(--cws-gallery-thumb-size);
    grid-template-areas:
        "hero thumbs"
        "dots dots"
        "caption caption";
}

.cws-gallery--thumbs-left .cws-gallery__thumbs-wrap,
.cws-gallery--thumbs-right .cws-gallery__thumbs-wrap {
    flex-direction: column;
}

.cws-gallery--thumbs-left .cws-gallery__thumb-strip,
.cws-gallery--thumbs-right .cws-gallery__thumb-strip {
    flex-direction: column;
    overflow-x: visible;
    overflow-y: auto;
    max-height: 100%;
}

/* ============================================================
   HERO
   ============================================================ */
.cws-gallery__hero {
    grid-area: hero;
    position: relative;
    overflow: hidden;
    background: var(--cws-gallery-tint);
    border: 1px solid rgba(20, 20, 20, 0.06);
    border-radius: var(--cws-gallery-radius);
    width: 100%;
    padding-top: var(--cws-gallery-hero-aspect);
    cursor: zoom-in;
}

.cws-gallery[data-enable-lightbox="0"] .cws-gallery__hero {
    cursor: default;
}

.cws-gallery__slide {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms ease;
}

.cws-gallery__slide.is-active {
    opacity: 1;
    visibility: visible;
    z-index: 2;
}

.cws-gallery .cws-gallery__hero-image {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    object-fit: contain;
    user-select: none;
    -webkit-user-drag: none;
}

.cws-gallery__icon-btn {
    width: 36px;
    height: 36px;
    padding: 0;
    background: rgba(255, 255, 255, 0.9);
    color: var(--cws-gallery-fg);
    border: 1px solid rgba(20, 20, 20, 0.08);
    border-radius: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    transition: background 120ms ease, color 120ms ease;
}

.cws-gallery__icon-btn:hover {
    background: rgba(255, 255, 255, 1);
}

.cws-gallery__icon-frame {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
}

.cws-gallery__icon-frame > svg {
    width: 100%;
    height: 100%;
    display: block;
}

.cws-gallery__mobile-counter {
    display: none;
    position: absolute;
    bottom: 16px;
    left: 16px;
    padding: 7px 12px;
    background: rgba(26, 26, 26, 0.85);
    color: #ffffff;
    font-size: 10px;
    letter-spacing: 0.15em;
    z-index: 4;
    gap: 4px;
}

/* ============================================================
   THUMB STRIP
   ============================================================ */
.cws-gallery__thumbs-wrap {
    grid-area: thumbs;
    display: flex;
    align-items: center;
    gap: 10px;
}

.cws-gallery__nav-btn {
    width: 40px;
    height: var(--cws-gallery-thumb-size);
    padding: 0;
    background: transparent;
    border: 1px solid rgba(20, 20, 20, 0.1);
    color: var(--cws-gallery-fg);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 120ms ease;
}

.cws-gallery__nav-btn:hover {
    background: rgba(20, 20, 20, 0.04);
}

.cws-gallery__thumb-strip {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scrollbar-width: thin;
    flex: 1;
    min-width: 0;
}

.cws-gallery__thumb-strip::-webkit-scrollbar {
    height: 4px;
}

.cws-gallery__thumb-strip::-webkit-scrollbar-thumb {
    background: rgba(20, 20, 20, 0.2);
}

.cws-gallery__thumb {
    flex: 0 0 var(--cws-gallery-thumb-size);
    width: var(--cws-gallery-thumb-size);
    height: var(--cws-gallery-thumb-size);
    padding: 0;
    background: var(--cws-gallery-tint);
    border: 1px solid rgba(20, 20, 20, 0.08);
    border-radius: var(--cws-gallery-radius);
    position: relative;
    scroll-snap-align: start;
    overflow: hidden;
    transition: outline-color 150ms ease;
    outline: 1px solid transparent;
    outline-offset: 3px;
}

.cws-gallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cws-gallery__thumb--active {
    outline-color: var(--cws-gallery-active);
}

/* ============================================================
   DOTS (mobile only by default)
   ============================================================ */
.cws-gallery__dots {
    grid-area: dots;
    display: none;
    justify-content: center;
    gap: 6px;
}

.cws-gallery__dot {
    width: 6px;
    height: 6px;
    border-radius: 3px;
    background: rgba(20, 20, 20, 0.18);
    transition: width 200ms ease, background 200ms ease;
    cursor: pointer;
}

.cws-gallery__dot.is-active {
    width: 18px;
    background: var(--cws-gallery-active);
}

/* ============================================================
   CAPTION
   ============================================================ */
.cws-gallery__caption {
    grid-area: caption;
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    font-size: 11px;
    letter-spacing: 0.15em;
}

.cws-gallery__caption-label {
    color: var(--cws-gallery-muted);
}

.cws-gallery__caption-sub {
    color: rgba(20, 20, 20, 0.4);
    text-align: right;
}

/* ============================================================
   LIGHTBOX
   ============================================================ */
.cws-gallery__lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: none;
    flex-direction: column;
    background: var(--cws-gallery-lightbox-bg);
    color: var(--cws-gallery-lightbox-fg);
    font-family: var(--cws-gallery-body-font);
}

.cws-gallery__lightbox--open {
    display: flex;
}

.cws-gallery__lightbox-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    padding: 20px 32px;
}

.cws-gallery__lightbox-meta {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
}

.cws-gallery__lightbox-sku {
    font-size: 10px;
    letter-spacing: 0.2em;
    color: rgba(20, 20, 20, 0.5);
}

.cws-gallery__lightbox-title {
    font-family: var(--cws-gallery-body-font);
    text-transform: none;
    letter-spacing: -0.01em;
    font-size: 16px;
    font-weight: 500;
    color: var(--cws-gallery-lightbox-fg);
}

.cws-gallery__zoom-controls {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cws-gallery__zoom-level {
    min-width: 60px;
    text-align: center;
    padding: 0 8px;
    color: rgba(20, 20, 20, 0.65);
}

.cws-gallery__lightbox-actions {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.cws-gallery__lightbox-close {
    width: auto;
    padding: 0 12px;
    gap: 8px;
}

.cws-gallery__esc {
    font-size: 10px;
    letter-spacing: 0.18em;
}

.cws-gallery__lightbox-stage {
    flex: 1;
    display: grid;
    grid-template-columns: 56px 1fr 56px;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    min-height: 0;
}

.cws-gallery__lightbox-prev,
.cws-gallery__lightbox-next {
    width: 48px;
    height: 48px;
    justify-self: center;
}

.cws-gallery__lightbox-prev {
    grid-column: 1;
}

.cws-gallery__lightbox-next {
    grid-column: 3;
}

.cws-gallery__lightbox-imgwrap {
    grid-column: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    height: 100%;
}

.cws-gallery__lightbox-img {
    max-width: min(560px, 90vw);
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    background: #ffffff;
    border: 1px solid rgba(20, 20, 20, 0.06);
    transform-origin: center center;
    transition: transform 200ms ease;
    touch-action: pan-x pan-y;
    user-select: none;
}

.cws-gallery__lightbox-bottom {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 24px;
    padding: 20px 32px 24px;
    align-items: center;
}

.cws-gallery__lightbox-counter {
    min-width: 90px;
    display: inline-flex;
    gap: 4px;
}

.cws-gallery__lightbox-thumbs {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    justify-content: center;
    flex: 1;
    min-width: 0;
    padding: 2px;
}

.cws-gallery__lightbox-thumb {
    width: 56px;
    height: 56px;
    padding: 0;
    background: var(--cws-gallery-tint);
    border: 1px solid rgba(20, 20, 20, 0.08);
    overflow: hidden;
    flex-shrink: 0;
    outline: 1px solid transparent;
    transition: outline-color 150ms ease;
}

.cws-gallery__lightbox-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cws-gallery__lightbox-thumb.is-active {
    outline-color: var(--cws-gallery-lightbox-fg);
}

.cws-gallery__lightbox-caption {
    min-width: 90px;
    text-align: right;
    color: rgba(20, 20, 20, 0.55);
    font-size: 11px;
}

/* Editor stub */
.cws-gallery-editor-stub {
    padding: 24px;
    background: #f4f1ec;
    color: #1a1a1a;
    text-align: center;
    font-family: var(--cws-gallery-mono-font, ui-monospace, monospace);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    border: 1px dashed rgba(20, 20, 20, 0.2);
}

/* ============================================================
   MOBILE — <= 768px
   ============================================================ */
@media (max-width: 768px) {
    .cws-gallery__stage,
    .cws-gallery--thumbs-left .cws-gallery__stage,
    .cws-gallery--thumbs-right .cws-gallery__stage {
        grid-template-columns: 1fr;
        grid-template-areas:
            "hero"
            "dots"
            "thumbs"
            "caption";
    }

    .cws-gallery__hero {
        padding-top: 100%;
        cursor: pointer;
    }

    .cws-gallery__magnifier {
        display: none;
    }

    .cws-gallery__mobile-counter {
        display: inline-flex;
    }

    .cws-gallery__counter {
        display: none;
    }

    .cws-gallery__dots {
        display: flex;
    }

    .cws-gallery__nav-btn {
        display: none;
    }

    .cws-gallery__thumbs-wrap {
        gap: 0;
    }

    .cws-gallery__thumb-strip,
    .cws-gallery--thumbs-left .cws-gallery__thumb-strip,
    .cws-gallery--thumbs-right .cws-gallery__thumb-strip {
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
        padding-bottom: 4px;
        max-height: none;
    }

    .cws-gallery__thumb {
        --cws-gallery-thumb-size: 60px;
        width: 60px;
        height: 60px;
        flex: 0 0 60px;
    }

    .cws-gallery__title {
        font-size: clamp(18px, 4vw, 22px);
    }

    /* Lightbox mobile */
    .cws-gallery__lightbox-topbar {
        padding: 12px 16px;
        gap: 12px;
    }

    .cws-gallery__lightbox-meta {
        display: none;
    }

    .cws-gallery__zoom-controls {
        display: none;
    }

    .cws-gallery__lightbox-actions {
        margin-left: auto;
    }

    .cws-gallery__lightbox-stage {
        grid-template-columns: 1fr;
        padding: 0 16px;
    }

    .cws-gallery__lightbox-prev,
    .cws-gallery__lightbox-next {
        display: none;
    }

    .cws-gallery__lightbox-img {
        max-width: 100%;
        max-height: 60vh;
        width: 100%;
        height: auto;
    }

    .cws-gallery__lightbox-bottom {
        grid-template-columns: 1fr;
        padding: 12px 16px 20px;
        gap: 12px;
    }

    .cws-gallery__lightbox-counter,
    .cws-gallery__lightbox-caption {
        justify-self: center;
        text-align: center;
        min-width: 0;
    }
}

/* ============================================================
   SINGLE-SLIDE — hide all navigation chrome
   ============================================================ */
.cws-gallery[data-slide-count="1"] .cws-gallery__nav-btn,
.cws-gallery[data-slide-count="1"] .cws-gallery__thumbs-wrap,
.cws-gallery[data-slide-count="1"] .cws-gallery__thumb-strip,
.cws-gallery[data-slide-count="1"] .cws-gallery__dots,
.cws-gallery[data-slide-count="1"] .cws-gallery__counter,
.cws-gallery[data-slide-count="1"] .cws-gallery__mobile-counter,
.cws-gallery[data-slide-count="1"] .cws-gallery__lightbox-prev,
.cws-gallery[data-slide-count="1"] .cws-gallery__lightbox-next {
    display: none;
}

.cws-gallery[data-slide-count="1"] .cws-gallery__lightbox-thumb {
    pointer-events: none;
}

/* ============================================================
   LIGHTBOX WISHLIST TOGGLE
   Visual styling comes from .cws-wishlist-loop-toggle in the shared
   wishlist CSS. Only the absolute positioning needs to be undone
   so the button sits inline inside the lightbox topbar.
   ============================================================ */
.cws-gallery__lightbox-wishlist.cws-wishlist-loop-toggle {
    position: static;
    top: auto;
    right: auto;
}

