/**
 * ZG Product Feature Gallery frontend styles.
 *
 * Two layouts:
 *  - Default: one view at a time with a crossfade (no peek).
 *  - Peek (opt-in via data-peek="true"): a sliding card track where the next
 *    card peeks on the right so visitors can see the gallery is swipeable.
 */

.zg-feature-gallery {
    color: #202429;
    font-family: Inter, Arial, sans-serif;
    min-width: 0;
    width: 100%;
}

.zg-feature-gallery * {
    box-sizing: border-box;
}

/* ---------- Stage / slides (default crossfade) ---------- */

.zg-feature-gallery__stage {
    position: relative;
    width: 100%;
    margin-right: auto;
    margin-left: auto;
    overflow: hidden;
    border: 0;
    border-radius: 8px;
    background: #f3f4f4;
    aspect-ratio: var(--zg-active-aspect, 1);
    transition: height 0.28s ease;
}

.zg-feature-gallery__slide {
    position: absolute;
    inset: 0;
    margin: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
}

.zg-feature-gallery__slide.is-active {
    opacity: 1;
    pointer-events: auto;
}

/* Mixed-ratio single-card canvas. The stage and its media both adopt the
   active asset's ratio, so portrait video is not letterboxed inside a wide
   gallery frame and square media remains visibly square. */
.zg-feature-gallery[data-peek="false"] .zg-feature-gallery__slide {
    display: grid;
    place-items: center;
}

.zg-feature-gallery[data-peek="false"] .zg-feature-gallery__picture,
.zg-feature-gallery[data-peek="false"] .zg-feature-gallery__video {
    width: min(100%, var(--zg-media-width, 100%));
    height: var(--zg-media-height, 100%);
    margin: auto;
    overflow: hidden;
    border-radius: 8px;
}

.zg-feature-gallery[data-peek="false"] .zg-feature-gallery__slide[data-fit="contain"] img,
.zg-feature-gallery[data-peek="false"] .zg-feature-gallery__slide[data-fit="contain"] video {
    padding: 0;
}

.zg-feature-gallery__picture,
.zg-feature-gallery__picture img,
.zg-feature-gallery__video {
    display: block;
    width: 100%;
    height: 100%;
}

.zg-feature-gallery__picture img,
.zg-feature-gallery__video {
    background: #f7f8f8;
}

.zg-feature-gallery__slide[data-fit="cover"] img,
.zg-feature-gallery__slide[data-fit="cover"] video {
    object-fit: cover;
}

.zg-feature-gallery__slide[data-fit="contain"] img,
.zg-feature-gallery__slide[data-fit="contain"] video {
    object-fit: contain;
    padding: 34px;
}

/* Portrait feature videos keep their complete frame and burned-in captions. */
.zg-feature-gallery__slide[data-fit="contain"][data-media-type="video"] {
    background: #000;
}

.zg-feature-gallery__slide[data-fit="contain"][data-media-type="video"] video {
    padding: 0;
    background: #000;
}

.zg-feature-gallery__caption {
    position: absolute;
    left: 18px;
    bottom: 18px;
    display: grid;
    gap: 4px;
    max-width: min(420px, calc(100% - 36px));
    padding: 10px 12px;
    border: 1px solid rgba(255, 255, 255, 0.65);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.1);
}

.zg-feature-gallery__caption span {
    color: #c93219;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.zg-feature-gallery__caption strong {
    font-size: 15px;
    line-height: 1.25;
}

/* ---------- Controls (shared) ---------- */

.zg-feature-gallery .zg-feature-gallery__arrow {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    color: #1f2428 !important;
    cursor: pointer;
    font-size: 32px;
    line-height: 1;
    transform: translateY(-50%);
}

.zg-feature-gallery__arrow--prev {
    left: 16px;
}

.zg-feature-gallery__arrow--next {
    right: 16px;
}

.zg-feature-gallery[data-peek="false"] .zg-feature-gallery__arrow--prev {
    left: max(16px, calc((100% - var(--zg-media-width, 100%)) / 2 + 16px));
}

.zg-feature-gallery[data-peek="false"] .zg-feature-gallery__arrow--next,
.zg-feature-gallery[data-peek="false"] .zg-feature-gallery__pause {
    right: max(16px, calc((100% - var(--zg-media-width, 100%)) / 2 + 16px));
}

.zg-feature-gallery .zg-feature-gallery__gallery-toggle {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 5;
    display: none;
    width: 42px;
    height: 42px;
    place-items: center;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    color: #5b6066 !important;
    cursor: pointer;
    transition: right 0.2s ease, transform 0.2s ease;
}

.zg-feature-gallery[data-has-product-gallery="true"]:not([data-active-feature="product-gallery"]) .zg-feature-gallery__gallery-toggle {
    display: grid;
}

.zg-feature-gallery[data-active-media="video"] .zg-feature-gallery__gallery-toggle {
    right: 68px;
}

.zg-feature-gallery__gallery-toggle:hover,
.zg-feature-gallery__gallery-toggle:focus-visible {
    transform: translateY(-2px);
}

.zg-feature-gallery__gallery-toggle:focus-visible {
    outline: 2px solid #1f64ff;
    outline-offset: 2px;
}

.zg-feature-gallery__gallery-toggle svg {
    width: 19px;
    height: 19px;
    fill: currentColor;
}

.zg-feature-gallery__dots {
    position: absolute;
    left: 50%;
    bottom: 18px;
    z-index: 4;
    display: flex;
    gap: 8px;
    transform: translateX(-50%);
}

.zg-feature-gallery__dots button {
    width: 7px;
    height: 7px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: rgba(32, 36, 41, 0.25);
    cursor: pointer;
}

.zg-feature-gallery__dots button.is-active {
    width: 28px;
    background: rgba(32, 36, 41, 0.76);
}

.zg-feature-gallery__dots button.is-hidden {
    display: none;
}

.zg-feature-gallery .zg-feature-gallery__pause {
    position: absolute;
    right: 16px;
    bottom: 16px;
    z-index: 5;
    display: none;
    width: 42px;
    height: 42px;
    place-items: center;
    border: 0;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.88) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    cursor: pointer;
}

.zg-feature-gallery[data-active-media="video"] .zg-feature-gallery__pause {
    display: grid;
}

.zg-feature-gallery__pause-icon {
    position: relative;
    display: block;
    width: 16px;
    height: 18px;
}

.zg-feature-gallery__pause-icon::before,
.zg-feature-gallery__pause-icon::after {
    position: absolute;
    top: 0;
    display: block;
    width: 5px;
    height: 18px;
    border-radius: 999px;
    background: #5b6066;
    content: "";
}

.zg-feature-gallery__pause-icon::before {
    left: 2px;
}

.zg-feature-gallery__pause-icon::after {
    right: 2px;
}

.zg-feature-gallery[data-video-paused="true"] .zg-feature-gallery__pause-icon {
    width: 0;
    height: 0;
    border-top: 9px solid transparent;
    border-bottom: 9px solid transparent;
    border-left: 14px solid #5b6066;
}

.zg-feature-gallery[data-video-paused="true"] .zg-feature-gallery__pause-icon::before,
.zg-feature-gallery[data-video-paused="true"] .zg-feature-gallery__pause-icon::after {
    display: none;
}

.zg-feature-gallery__features {
    display: grid;
    grid-auto-columns: minmax(146px, 1fr);
    grid-auto-flow: column;
    gap: 12px;
    overflow-x: auto;
    padding: 12px 0 2px;
    scroll-padding: 16px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.zg-feature-gallery__features::-webkit-scrollbar {
    display: none;
}

.zg-feature-gallery .zg-feature-gallery__feature {
    display: grid;
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    min-height: 66px;
    padding: 8px;
    border: 1px solid #e4e7ea;
    border-radius: 8px;
    background: #f2f3f3 !important;
    color: #202429 !important;
    cursor: pointer;
    text-align: left;
}

.zg-feature-gallery .zg-feature-gallery__feature.is-active {
    border-color: #1f64ff !important;
    background: #fff !important;
    box-shadow: 0 0 0 1px #1f64ff inset !important;
}

.zg-feature-gallery .zg-feature-gallery__feature:focus-visible {
    outline: 2px solid #1f64ff;
    outline-offset: 2px;
}

.zg-feature-gallery__feature img,
.zg-feature-gallery__feature-video {
    width: 58px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    background: #fff;
}

.zg-feature-gallery .zg-feature-gallery__feature span {
    color: inherit !important;
    font-size: 13px;
    font-weight: 900;
    line-height: 1.12;
}

/* ---------- Placeholder / wireframe media ---------- */

.zg-feature-gallery__ph {
    display: grid;
    place-items: center;
    gap: 6px;
    background: repeating-linear-gradient(45deg, #e9ebee, #e9ebee 12px, #e1e4e8 12px, #e1e4e8 24px);
    color: #8a9099;
}

.zg-feature-gallery__media-ph {
    width: 100%;
    height: 100%;
}

.zg-feature-gallery__media-ph .zg-feature-gallery__ph-icon {
    font-size: 40px;
    line-height: 1;
}

.zg-feature-gallery__media-ph .zg-feature-gallery__ph-label {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.zg-feature-gallery__feature-ph {
    width: 58px;
    height: 52px;
    border-radius: 6px;
    color: #9aa0a8;
    font-size: 18px;
    background: repeating-linear-gradient(45deg, #e9ebee, #e9ebee 6px, #e1e4e8 6px, #e1e4e8 12px);
}

/* ============================================================
   Peek layout (opt-in) — only active when data-peek="true"
   ============================================================ */

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__stage {
    border: 0;
    background: #eef0f2;
    --zg-peek: 13%;
    --zg-gap: 16px;
    aspect-ratio: calc(var(--zg-active-aspect, 1) / 0.87);
}

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__track {
    display: flex;
    height: 100%;
    gap: var(--zg-gap);
    transform: translateX(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform;
}

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__slide {
    position: relative;
    inset: auto;
    flex: 0 0 calc(100% - var(--zg-peek));
    height: 100%;
    opacity: 1;
    pointer-events: auto;
    transition: none;
    overflow: hidden;
    border: 1px solid #e4e7ea;
    border-radius: 10px;
    background: #f3f4f4;
    /* Soft elevation so each card edge reads against any photo/video content,
       keeping the peeking card distinct even when its frame is light or dark. */
    box-shadow: 0 2px 14px rgba(0, 0, 0, 0.16);
}

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__slide:not(.is-active) {
    cursor: pointer;
}

/* Video cards run full-bleed in peek mode: no frame, no letterbox bars. */
.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__slide[data-media-type="video"] {
    border: 0;
    background: #000;
}

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__slide[data-media-type="video"] .zg-feature-gallery__video {
    object-fit: cover;
    padding: 0;
    background: #000;
}

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__slide[data-media-type="video"][data-fit="contain"] .zg-feature-gallery__video {
    object-fit: contain;
}

/* Keep the incoming mixed-ratio card visible in the peek instead of showing
   only its contain-mode letterbox area. The active card remains centred. */
.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__slide:not(.is-active)[data-fit="contain"] img,
.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__slide:not(.is-active)[data-fit="contain"] video {
    object-position: left center;
}

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__caption {
    left: 14px;
    bottom: 14px;
    gap: 2px;
    max-width: min(280px, 52%);
    padding: 6px 9px;
    border-radius: 7px;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__caption span {
    font-size: 9.5px;
    letter-spacing: 0.07em;
}

.zg-feature-gallery[data-peek="true"] .zg-feature-gallery__caption strong {
    font-size: 12.5px;
    line-height: 1.18;
}

@media (prefers-reduced-motion: reduce) {
    .zg-feature-gallery__stage,
    .zg-feature-gallery[data-peek="true"] .zg-feature-gallery__track {
        transition: none;
    }
}

/* ---------- Mobile ---------- */

@media (max-width: 980px) {
    .zg-feature-gallery__stage {
        height: auto;
        min-height: 0;
        max-height: none;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
        aspect-ratio: var(--zg-active-aspect, 1);
    }

    .zg-feature-gallery__slide[data-fit="contain"] img,
    .zg-feature-gallery__slide[data-fit="contain"] video {
        padding: 12px;
    }

    .zg-feature-gallery__caption {
        left: 14px;
        bottom: 42px;
        max-width: calc(100% - 28px);
    }

    .zg-feature-gallery__arrow {
        width: 38px;
        height: 38px;
        font-size: 29px;
    }

    .zg-feature-gallery__arrow--prev {
        left: 12px;
    }

    .zg-feature-gallery__arrow--next {
        right: 12px;
    }

    .zg-feature-gallery__features {
        grid-auto-columns: 164px;
        padding: 10px 16px;
    }

    /* Peek tuning on mobile: a larger peek + caption parked at the bottom. */
    .zg-feature-gallery[data-peek="true"] .zg-feature-gallery__stage {
        --zg-peek: 24%;
        --zg-gap: 16px;
        aspect-ratio: calc(var(--zg-active-aspect, 1) / 0.76);
    }

    .zg-feature-gallery[data-peek="true"] .zg-feature-gallery__arrow--next {
        right: calc(var(--zg-peek) + 8px);
    }

    .zg-feature-gallery[data-peek="true"] .zg-feature-gallery__caption {
        left: 12px;
        bottom: 14px;
        max-width: min(240px, 54%);
    }
}

@media (max-width: 430px) {
    .zg-feature-gallery__features {
        grid-auto-columns: 158px;
    }

    /* Keep the floating offer tab from covering the media controls. */
    .zg-feature-gallery[data-active-media="video"] .zg-feature-gallery__pause {
        right: 62px;
    }

    .zg-feature-gallery[data-active-media="video"] .zg-feature-gallery__gallery-toggle {
        right: 114px;
    }

    .zg-feature-gallery[data-active-media="image"] .zg-feature-gallery__gallery-toggle {
        right: 62px;
    }
}
