/* =========================================================
   Cimo Product Gallery – gallery.css
   ========================================================= */

/* ── Wrapper ── */
.cpg-wrapper {
    display: flex;
    gap: 14px;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
    position: relative;
    align-items: flex-start;
    --cpg-accent: #36C0C8;
}

/* Desktop position (default tier, no media query) */
.cpg-wrapper[data-cpg-pos-desktop="left"]   { flex-direction: row; }
.cpg-wrapper[data-cpg-pos-desktop="right"]  { flex-direction: row-reverse; }
.cpg-wrapper[data-cpg-pos-desktop="bottom"] { flex-direction: column-reverse; align-items: stretch; }

.cpg-wrapper[data-cpg-pos-desktop="bottom"] .cpg-thumbs-wrap { width: 100%; }

/* ── Main panel ── */
.cpg-main {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.cpg-main-stage {
    position: relative;
    width: 100%;
    height: 540px;
    background: #f8f8f6;
    border-radius: 8px;
    overflow: hidden;
    user-select: none;
}

/* ── Slides ── */
.cpg-slide {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.35s cubic-bezier(.4,0,.2,1),
                transform 0.35s cubic-bezier(.4,0,.2,1);
    transform: scale(1.015);
    pointer-events: none;
}
.cpg-slide.is-active {
    opacity: 1;
    transform: scale(1);
    pointer-events: auto;
    z-index: 1;
}
.cpg-slide.slide-out {
    opacity: 0;
    transform: scale(0.985);
}
.cpg-main-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    border-radius: inherit;
    transition: transform 0.25s ease;
    will-change: transform;
}

/* ── Arrows ── */
.cpg-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.88);
    backdrop-filter: blur(6px);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1a1a1a;
    box-shadow: 0 2px 12px rgba(0,0,0,.12);
    opacity: 0;
    transition: opacity .2s, background .15s, transform .15s;
    padding: 0;
}
.cpg-arrow svg {
    width: 18px;
    height: 18px;
}
.cpg-main-stage:hover .cpg-arrow { opacity: 1; }
.cpg-arrow:hover {
    background: #fff;
    color: #1a1a1a;
    transform: translateY(-50%) scale(1.08);
}
.cpg-arrow:focus-visible {
    outline: 2px solid var(--cpg-accent);
    outline-offset: 2px;
}
.cpg-arrow:active,
.cpg-arrow:focus {
    background: #fff;
    color: #1a1a1a;
    outline: 2px solid var(--cpg-accent);
    outline-offset: 2px;
}
.cpg-prev { left: 12px; }
.cpg-next { right: 12px; }

/* ── Expand / lightbox trigger (the ONLY way to open the lightbox) ── */
.cpg-expand-btn {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
    width: 34px;
    height: 34px;
    background: rgba(255,255,255,0.82);
    backdrop-filter: blur(6px);
    border: none;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(0,0,0,.1);
    opacity: 0;
    transition: opacity .2s, background .15s;
    padding: 0;
}
.cpg-expand-btn svg { width: 16px; height: 16px; }
.cpg-main-stage:hover .cpg-expand-btn { opacity: 1; }
.cpg-expand-btn:hover { background: #fff; }

/* ── Counter badge ── */
.cpg-counter {
    position: absolute;
    bottom: 12px;
    left: 12px;
    z-index: 10;
}
.cpg-counter-inner {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: #36C0C8;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .04em;
    padding: 4px 10px;
    border-radius: 20px;
    line-height: 1;
}

/* ── Dot indicators (mobile) ── */
.cpg-dots {
    display: none;
    justify-content: center;
    gap: 6px;
}
.cpg-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #d0d0ce;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: background .2s, transform .2s;
    flex-shrink: 0;
}
.cpg-dot.is-active {
    background: #36C0C8;
    transform: scale(1.25);
}

/* =========================================================
   THUMBNAILS
   Orientation (vertical strip vs horizontal strip) is driven
   purely by the ancestor wrapper's position attribute, at
   each responsive tier — no separate PHP markup needed.
   ========================================================= */

.cpg-thumbs-wrap {
    position: relative;
    flex-shrink: 0;
}

.cpg-thumbs {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 88px;
    max-height: 540px;
    overflow-y: auto;
    overflow-x: hidden;
    /* native scrollbar hidden — replaced by the fade/shadow cue below */
    scrollbar-width: none;
    -ms-overflow-style: none;
    cursor: grab;
}
.cpg-thumbs::-webkit-scrollbar { display: none; width: 0; height: 0; }
.cpg-thumbs.is-dragging { cursor: grabbing; user-select: none; scroll-behavior: auto; }

.cpg-wrapper[data-cpg-pos-desktop="bottom"] .cpg-thumbs {
    flex-direction: row;
    width: 100%;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
}

/* ── Thumb-strip arrows: only shown for the horizontal (bottom) layout,
      same hover-reveal pattern as the main image arrows ── */
.cpg-thumb-arrow {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 30px;
    height: 30px;
    background: rgba(255,255,255,0.92);
    border: none;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #1a1a1a;
    box-shadow: 0 2px 10px rgba(0,0,0,.15);
    opacity: 0;
    transition: opacity .2s, background .15s;
    padding: 0;
}
.cpg-thumb-arrow svg { width: 14px; height: 14px; }
.cpg-thumb-arrow:hover { background: #fff; color: #1a1a1a; }
.cpg-thumb-arrow:focus-visible { outline: 2px solid var(--cpg-accent); outline-offset: 2px; }
.cpg-thumb-arrow:active,
.cpg-thumb-arrow:focus { background: #fff; color: #1a1a1a; outline: 2px solid var(--cpg-accent); outline-offset: 2px; }
.cpg-thumb-prev { left: 4px; }
.cpg-thumb-next { right: 4px; }

.cpg-wrapper[data-cpg-pos-desktop="bottom"] .cpg-thumb-arrow { display: flex; }
.cpg-wrapper[data-cpg-pos-desktop="bottom"] .cpg-thumbs-wrap:hover .cpg-thumb-arrow { opacity: 1; }

/* ── Scroll cue: soft edge shadow that only appears while there's
      more content to scroll to (toggled by JS based on scroll offset) ── */
.cpg-thumbs-wrap::before,
.cpg-thumbs-wrap::after {
    content: '';
    position: absolute;
    z-index: 2;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s ease;
}
/* vertical (left / right positions): shadow at top & bottom */
.cpg-thumbs-wrap::before {
    top: 0; left: 0; right: 0; height: 26px;
    background: linear-gradient(to bottom, rgba(0,0,0,.16), rgba(0,0,0,0));
    border-radius: 8px 8px 0 0;
}
.cpg-thumbs-wrap::after {
    bottom: 0; left: 0; right: 0; height: 26px;
    background: linear-gradient(to top, rgba(0,0,0,.16), rgba(0,0,0,0));
    border-radius: 0 0 8px 8px;
}
.cpg-thumbs-wrap.has-scroll-start::before { opacity: 1; }
.cpg-thumbs-wrap.has-scroll-end::after { opacity: 1; }

/* horizontal (bottom position): shadow at left & right instead */
.cpg-wrapper[data-cpg-pos-desktop="bottom"] .cpg-thumbs-wrap::before {
    top: 0; bottom: 0; left: 0; right: auto; width: 26px; height: auto;
    background: linear-gradient(to right, rgba(0,0,0,.16), rgba(0,0,0,0));
    border-radius: 8px 0 0 8px;
}
.cpg-wrapper[data-cpg-pos-desktop="bottom"] .cpg-thumbs-wrap::after {
    top: 0; bottom: 0; right: 0; left: auto; width: 26px; height: auto;
    background: linear-gradient(to left, rgba(0,0,0,.16), rgba(0,0,0,0));
    border-radius: 0 8px 8px 0;
}
.cpg-thumbs-wrap.has-scroll-start-x::before { opacity: 1; }
.cpg-thumbs-wrap.has-scroll-end-x::after { opacity: 1; }

.cpg-wrapper[data-cpg-pos-desktop="bottom"] .cpg-thumb {
    width: 72px;
    height: 72px;
}

/* ── Thumb button ── */
.cpg-thumb {
    width: 88px;
    height: 88px;
    flex-shrink: 0;
    border: 2px solid transparent;
    border-radius: 6px;
    background: #f8f8f6;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    transition: border-color .18s, opacity .18s, box-shadow .18s;
    outline: none;
}
.cpg-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .25s;
}
.cpg-thumb:hover img { transform: scale(1.06); }
.cpg-thumb.is-active {
    border-color: #36C0C8;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
}
.cpg-thumb:hover { border-color: #36C0C8; opacity: .9; }
.cpg-thumb:focus-visible { outline: 2px solid #36C0C8; outline-offset: 2px; }

/* ── Placeholder (editor) ── */
.cpg-placeholder {
    background: #f5f5f5;
    border: 2px dashed #ccc;
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    color: #888;
    font-size: 14px;
}

/* =========================================================
   LIGHTBOX
   ========================================================= */
.cpg-lb {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10,10,10,.94);
    backdrop-filter: blur(8px);
    animation: cpgLbIn .25s ease;
    padding: 20px;
    box-sizing: border-box;
}
@keyframes cpgLbIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}
.cpg-lb.is-closing {
    animation: cpgLbOut .2s ease forwards;
}
@keyframes cpgLbOut {
    to { opacity: 0; }
}

.cpg-lb-inner {
    position: relative;
    max-width: 1060px;
    max-height: 90vh;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}
.cpg-lb-img-wrap {
    position: relative;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
    min-height: 0;
}
.cpg-lb-img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 6px;
    display: block;
    animation: cpgImgIn .28s cubic-bezier(.4,0,.2,1);
    box-shadow: 0 20px 60px rgba(0,0,0,.5);
}
@keyframes cpgImgIn {
    from { opacity:0; transform: scale(.96); }
    to   { opacity:1; transform: scale(1);   }
}

/* Lightbox buttons */
.cpg-lb-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 48px;
    height: 48px;
    background: rgba(255,255,255,.12);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, transform .15s;
    padding: 0;
}
.cpg-lb-btn svg { width: 22px; height: 22px; }
.cpg-lb-btn:hover { background: #36C0C8; transform: translateY(-50%) scale(1.08); }
.cpg-lb-prev { left: -56px; }
.cpg-lb-next { right: -56px; }

.cpg-lb-close {
    position: absolute;
    top: -16px;
    right: 0;
    transform: none;
    width: 38px;
    height: 38px;
    background: rgba(255,255,255,.14);
    border-radius: 8px;
    z-index: 3;
}
.cpg-lb-close:hover {
    background: #36C0C8;
    transform: scale(1.08);
}

/* Lightbox thumbnail strip */
.cpg-lb-thumbs {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
    padding: 2px 4px;
    max-width: 100%;
}
.cpg-lb-thumbs::-webkit-scrollbar { display: none; }
.cpg-lb-thumb {
    width: 56px;
    height: 56px;
    flex-shrink: 0;
    border: 2px solid rgba(255,255,255,.2);
    border-radius: 5px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color .15s, transform .15s;
    background: #111;
    padding: 0;
}
.cpg-lb-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: .65;
    transition: opacity .15s;
}
.cpg-lb-thumb.is-active {
    border-color: #fff;
    transform: scale(1.06);
}
.cpg-lb-thumb.is-active img,
.cpg-lb-thumb:hover img {
    opacity: 1;
}
.cpg-lb-thumb:hover { border-color: rgba(255,255,255,.7); }

/* Lightbox caption / counter */
.cpg-lb-info {
    color: rgba(255,255,255,.5);
    font-size: 12px;
    letter-spacing: .08em;
    text-align: center;
    font-family: inherit;
}
.cpg-lb-info strong { color: #fff; font-weight: 600; }

/* =========================================================
   RESPONSIVE — tablet & mobile position overrides
   ========================================================= */
@media (max-width: 1024px) {
    .cpg-wrapper[data-cpg-pos-tablet="left"]   { flex-direction: row; align-items: flex-start; }
    .cpg-wrapper[data-cpg-pos-tablet="right"]  { flex-direction: row-reverse; align-items: flex-start; }
    .cpg-wrapper[data-cpg-pos-tablet="bottom"] { flex-direction: column-reverse; align-items: stretch; }

    .cpg-wrapper[data-cpg-pos-tablet="bottom"] .cpg-thumbs-wrap { width: 100%; }
    .cpg-wrapper[data-cpg-pos-tablet="left"] .cpg-thumbs-wrap,
    .cpg-wrapper[data-cpg-pos-tablet="right"] .cpg-thumbs-wrap { width: auto; }

    .cpg-wrapper[data-cpg-pos-tablet="bottom"] .cpg-thumbs {
        flex-direction: row;
        width: 100%;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
    }
    .cpg-wrapper[data-cpg-pos-tablet="left"] .cpg-thumbs,
    .cpg-wrapper[data-cpg-pos-tablet="right"] .cpg-thumbs {
        flex-direction: column;
        width: 88px;
        max-height: 540px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .cpg-wrapper[data-cpg-pos-tablet="bottom"] .cpg-thumbs-wrap::before {
        top: 0; bottom: 0; left: 0; right: auto; width: 26px; height: auto;
        background: linear-gradient(to right, rgba(0,0,0,.16), rgba(0,0,0,0));
    }
    .cpg-wrapper[data-cpg-pos-tablet="bottom"] .cpg-thumbs-wrap::after {
        top: 0; bottom: 0; right: 0; left: auto; width: 26px; height: auto;
        background: linear-gradient(to left, rgba(0,0,0,.16), rgba(0,0,0,0));
    }

    .cpg-wrapper[data-cpg-pos-tablet="bottom"] .cpg-thumb-arrow { display: flex; }
    .cpg-wrapper[data-cpg-pos-tablet="bottom"] .cpg-thumbs-wrap:hover .cpg-thumb-arrow { opacity: 1; }
    .cpg-wrapper[data-cpg-pos-tablet="left"] .cpg-thumb-arrow,
    .cpg-wrapper[data-cpg-pos-tablet="right"] .cpg-thumb-arrow { display: none; }
}

@media (max-width: 767px) {
    .cpg-wrapper[data-cpg-pos-mobile="left"]   { flex-direction: row; align-items: flex-start; }
    .cpg-wrapper[data-cpg-pos-mobile="right"]  { flex-direction: row-reverse; align-items: flex-start; }
    .cpg-wrapper[data-cpg-pos-mobile="bottom"] { flex-direction: column-reverse; align-items: stretch; }

    .cpg-wrapper[data-cpg-pos-mobile="bottom"] .cpg-thumbs-wrap { width: 100%; }
    .cpg-wrapper[data-cpg-pos-mobile="left"] .cpg-thumbs-wrap,
    .cpg-wrapper[data-cpg-pos-mobile="right"] .cpg-thumbs-wrap { width: auto; }

    .cpg-wrapper[data-cpg-pos-mobile="bottom"] .cpg-thumbs {
        flex-direction: row;
        width: 100%;
        max-height: none;
        overflow-x: auto;
        overflow-y: hidden;
        height: 64px;
    }
    .cpg-wrapper[data-cpg-pos-mobile="left"] .cpg-thumbs,
    .cpg-wrapper[data-cpg-pos-mobile="right"] .cpg-thumbs {
        flex-direction: column;
        width: 64px;
        max-height: 320px;
        overflow-y: auto;
        overflow-x: hidden;
    }
    .cpg-wrapper[data-cpg-pos-mobile="left"] .cpg-thumb,
    .cpg-wrapper[data-cpg-pos-mobile="right"] .cpg-thumb,
    .cpg-wrapper[data-cpg-pos-mobile="bottom"] .cpg-thumb {
        width: 64px;
        height: 64px;
    }

    .cpg-wrapper[data-cpg-pos-mobile="bottom"] .cpg-thumbs-wrap::before {
        top: 0; bottom: 0; left: 0; right: auto; width: 22px; height: auto;
        background: linear-gradient(to right, rgba(0,0,0,.16), rgba(0,0,0,0));
    }
    .cpg-wrapper[data-cpg-pos-mobile="bottom"] .cpg-thumbs-wrap::after {
        top: 0; bottom: 0; right: 0; left: auto; width: 22px; height: auto;
        background: linear-gradient(to left, rgba(0,0,0,.16), rgba(0,0,0,0));
    }

    .cpg-thumb-arrow { display: none !important; }

    .cpg-main-stage { height: 320px !important; }
    .cpg-dots { display: flex; }
    .cpg-lb-prev { left: -10px; }
    .cpg-lb-next { right: -10px; }
    .cpg-lb-btn { width: 38px; height: 38px; }
    .cpg-lb-btn svg { width: 18px; height: 18px; }
}
