/* ============================================================
   carousel.css — Lightweight slider & product gallery
   Zero dependencies · ~3 KB · CWV-optimized · v1.3
   ============================================================ */

/* ── Slider: container when active ─────────────────────── */

.js-carousel.is-active {
    position: relative;
    overflow: hidden;
    display: block !important;
    grid-template-columns: none !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    /* Contain layout to this element — prevents ancestor reflows */
    contain: layout style;
}

/* ── Slider: track ─────────────────────────────────────── */

.carousel-track {
    display: flex;
    /* Use transform instead of left/margin — compositor-only, no reflow */
    will-change: transform;
    transition: transform 0.45s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translate3d(0, 0, 0);
    /* Prevent subpixel flickering during GPU compositing */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    -webkit-font-smoothing: antialiased;
}

.carousel-track.no-transition {
    transition: none !important;
}

.js-carousel.is-active > .carousel-track > * {
    flex: 0 0 auto;
    box-sizing: border-box;
    /* Contain each slide so internal changes don't reflow siblings */
    contain: layout style;
}

/* ── Slider: nav buttons ───────────────────────────────── */

.carousel-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .92);
    color: #1e293b;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    /* Transition only compositor-friendly properties */
    transition: background .2s, opacity .2s, box-shadow .2s;
    -webkit-tap-highlight-color: transparent;
    /* Promote to own layer to avoid triggering ancestor reflows */
    will-change: opacity;
}

.carousel-btn:hover {
    background: #fff;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
}

.carousel-btn:disabled {
    opacity: .35;
    cursor: not-allowed;
    /* NO pointer-events:none — disabled buttons must still block click-through */
}

.carousel-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.carousel-btn--prev { left: 8px; }
.carousel-btn--next { right: 8px; }

/* ── Slider: dots ──────────────────────────────────────── */

.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 14px 0 4px;
    list-style: none;
    margin: 0;
}

.carousel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: none;
    background: #cbd5e1;
    cursor: pointer;
    padding: 0;
    /* Only transition compositor-safe properties */
    transition: background .25s, transform .25s;
    will-change: transform;
}

.carousel-dot:hover { background: #94a3b8; }

.carousel-dot.is-current {
    background: #6366f1;
    transform: scale(1.25);
}

.carousel-dot:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* ── Slider: hide nav when inactive ────────────────────── */

.js-carousel:not(.is-active) > .carousel-btn,
.js-carousel:not(.is-active) > .carousel-dots {
    display: none;
}

/* ── Slider: responsive nav visibility ─────────────────── */

@media (max-width: 767px) {
    .js-carousel.hide-nav-mobile > .carousel-btn { display: none !important; }
}
@media (min-width: 768px) {
    .js-carousel.hide-nav-desktop > .carousel-btn { display: none !important; }
}
@media (max-width: 767px) {
    .js-carousel.hide-dots-mobile > .carousel-dots { display: none !important; }
}
@media (min-width: 768px) {
    .js-carousel.hide-dots-desktop > .carousel-dots { display: none !important; }
}

/* ============================================================
   Product Gallery  (.has-product-gallery)
   ============================================================ */

.js-carousel.is-gallery-active {
    display: block !important;
    grid-template-columns: none !important;
    flex-wrap: nowrap !important;
    gap: 0 !important;
    overflow: visible;
    /* Contain layout to prevent ancestor reflows */
    contain: layout style;
}

/* ── Gallery: main hero ────────────────────────────────── */

.pgallery__main {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 12px;
    background: #f8fafc;
    margin-bottom: 12px;
    /* Size is known — prevent CLS */
    contain: layout;
}

.pgallery__main-content {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 260px;
    padding: 20px;
    /* Transition opacity only — compositor-only, zero reflow cost */
    transition: opacity .2s ease;
    will-change: opacity;
}

.pgallery__main-content.is-fading {
    opacity: 0;
}

.pgallery__main-content img {
    max-width: 100%;
    max-height: 480px;
    object-fit: contain;
    display: block;
    border-radius: 6px;
}

.pgallery__main-clone {
    text-align: center;
    padding: 24px 16px;
    width: 100%;
}

/* ── Gallery: main nav ─────────────────────────────────── */

.pgallery__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .88);
    color: #1e293b;
    cursor: pointer;
    box-shadow: 0 1px 6px rgba(0, 0, 0, .12);
    transition: background .2s, box-shadow .2s;
    -webkit-tap-highlight-color: transparent;
    will-change: opacity;
}

.pgallery__nav:hover {
    background: #fff;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .18);
}

.pgallery__nav:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.pgallery__nav:disabled {
    opacity: .3;
    cursor: not-allowed;
    /* NO pointer-events:none — must block click-through */
}

.pgallery__nav--prev { left: 8px; }
.pgallery__nav--next { right: 8px; }

/* ── Gallery: thumbnail strip ──────────────────────────── */

.pgallery__thumbs {
    position: relative;
    overflow: hidden;
    contain: layout;
}

.pgallery__thumb-track {
    display: flex;
    gap: 8px;
    will-change: transform;
    transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.pgallery__thumb-track.no-transition {
    transition: none !important;
}

.js-carousel.is-gallery-active .pgallery__thumb {
    flex: 0 0 auto;
    box-sizing: border-box;
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid transparent;
    opacity: .55;
    /* Compositor-only transitions */
    transition: opacity .25s, border-color .25s;
    background: #f1f5f9;
    padding: 10px;
    will-change: opacity;
}

.js-carousel.is-gallery-active .pgallery__thumb:hover { opacity: .85; }

.js-carousel.is-gallery-active .pgallery__thumb.is-active-thumb {
    opacity: 1;
    border-color: #6366f1;
}

.js-carousel.is-gallery-active .pgallery__thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 4px;
}

/* ── Gallery: thumb strip nav ──────────────────────────── */

.pgallery__thumb-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, .9);
    color: #334155;
    cursor: pointer;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .12);
    transition: background .2s;
    -webkit-tap-highlight-color: transparent;
    font-size: 0;
}

.pgallery__thumb-nav:hover { background: #fff; }

.pgallery__thumb-nav:disabled {
    opacity: 0;
    pointer-events: none;
}

.pgallery__thumb-nav--prev { left: 0; }
.pgallery__thumb-nav--next { right: 0; }

/* ── Gallery: responsive nav visibility ─────────────────── */

@media (max-width: 767px) {
    .js-carousel.hide-nav-mobile > .pgallery__main > .pgallery__nav { display: none !important; }
    .js-carousel.hide-nav-mobile .pgallery__thumb-nav { display: none !important; }
}

@media (min-width: 768px) {
    .js-carousel.hide-nav-desktop > .pgallery__main > .pgallery__nav { display: none !important; }
    .js-carousel.hide-nav-desktop .pgallery__thumb-nav { display: none !important; }
}