/* ================================================================
PACKAGING SINGLE PAGE - Gallery Section
================================================================ */

/* ========== GALLERY SECTION (Desktop) ========== */
.packaging-gallery-section {
    position: relative;
    width: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--c-bg-gradient);
    padding-bottom: clamp(28px, 5vw, 56px);
}

/* Background gradient */
.packaging-gallery-bg {
    position: absolute;
    inset: 0;
    opacity: 0.77;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 0;
}

/* Decorative machine icon */
.packaging-gallery-machine-icon {
    position: absolute;
    top: 25px;
    right: 24px;
    width: 113.42px;
    height: 173.45px;
    opacity: 0.52;
    pointer-events: none;
    z-index: 1;
}

[dir="rtl"] .packaging-gallery-machine-icon {
    right: auto;
    left: 24px;
}

/* Wrapper for content */
.packaging-gallery-wrapper {
    position: relative;
    z-index: 2;
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px clamp(16px, 5vw, 76px) 48px;
    box-sizing: border-box;
}

/* x-gallery desktop: anchor for absolute filter control */
.global-gallery-wrapper {
    position: relative;
    z-index: 2;
}

/* Gallery Title */
.packaging-gallery-title {
    margin: 0;
    color: #fff;
    font-family: var(--font-arabic);
    font-weight: 900;
    font-size: 64px;
    line-height: 36px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Gold divider line */
.packaging-gallery-divider {
    display: block;
    width: 251.21px;
    height: 8px;
    background: #D4AF37;
    margin: 34px auto 80px;
    border-radius: 2px;
}

/* ==========  DESKTOP GALLERY GRID: 4 COLUMNS ========== */
.packaging-gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    /*  4 images per row */
    justify-items: stretch;
    gap: 46px 28px;
    /* column-gap, row-gap */
    padding: 0;
}

/* Gallery Item Container */
.packaging-gallery-item {
    position: relative;
    width: 100%;
    max-width: 260px;
    aspect-ratio: 214.83 / 284.18;
    margin: 0 auto;
}

/* Glass effect behind image */
.packaging-gallery-glass {
    position: absolute;
    left: 50%;
    top: 0;
    width: 93.35%;
    height: 69.25%;
    border-radius: 50px;
    border-top: 3px solid rgba(255, 255, 255, 0.05);
    border-right: 3px solid var(--c-white);
    border-bottom: none;
    border-left: 3px solid var(--c-white);
    border-image-slice: 1;
    opacity: 0.15;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1;
    background: radial-gradient(64.42% 64.42% at 50% 50%, rgba(255, 255, 255, 0.601) 60.1%, rgba(2, 17, 99, 0.999) 99.99%);
    transform: translateX(-50%) rotate(-47.58deg);
    box-sizing: border-box;
}

/* Actual Image */
.packaging-gallery-img {
    position: absolute;
    left: 50%;
    top: 9.5%;
    width: 100%;
    height: 50.23%;
    object-fit: cover;
    border-radius: 25px;
    border: 1px solid var(--c-white);
    border-image-slice: 1;
    opacity: 1;
    z-index: 2;
    transform: translateX(-50%) rotate(0.62deg);
    box-sizing: border-box;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.packaging-gallery-item:hover .packaging-gallery-img {
    transform: translateX(-50%) rotate(0.62deg) scale(1.03);
    opacity: 1;
}

/* Filter button (bottom start — inset so it does not hug the curved frame on desktop) */
.packaging-gallery-filter-btn,
.global-gallery-filter-btn {
    position: absolute;
    inset-inline-start: clamp(20px, 2.5vw, 44px);
    inset-block-end: clamp(18px, 2.2vw, 36px);
    width: 26.44px;
    height: 45.36px;
    border: 0;
    padding: 0;
    background: transparent;
    pointer-events: auto;
    z-index: 4;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

@media (max-width: 767.98px) {

    .packaging-gallery-filter-btn,
    .global-gallery-filter-btn {
        inset-inline-start: clamp(14px, 4vw, 24px);
        inset-block-end: clamp(12px, 3vw, 22px);
    }
}

.packaging-gallery-filter-btn img,
.global-gallery-filter-btn img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}
.packaging-gallery-section-mobile{
    display: none;
}

/* ========== MOBILE GALLERY: Infinite Loop Slider - FIXED ========== */
@media (max-width: 767.98px) {
    
    .packaging-gallery-section { display: none; }

    .packaging-gallery-section-mobile {
        display: block;
        position: relative;
        width: 100%;
        min-height: 320px;
        /* margin-top: 40px; */
        background: transparent;
        /* padding-bottom: 30px; */
    }

    .packaging-gallery-wrapper-mobile {
        background: var(--c-bg-gradient);
        position: relative;
        z-index: 2;
        width: 100%;
        padding: 20px 15px 40px;
        box-sizing: border-box;
        text-align: center;
    }

    .packaging-gallery-title-mobile {
        margin: 0;
        color: #fff;
        font-family: var(--font-arabic);
        font-weight: 900;
        font-size: 28px;
        line-height: 24px;
        text-align: center;
    }

    .packaging-gallery-divider-mobile {
        display: block;
        width: 140px;
        height: 6px;
        background: #D4AF37;
        margin: 18px auto 30px;
        border-radius: 2px;
    }

    /* Slider container */
    .packaging-gallery-slider {
        display: flex;
        overflow-x: auto;
        overflow-y: hidden;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        /* gap: 20px; */
        padding: 30px 15px;
        padding-left: calc(50vw - 70px);
        padding-right: calc(50vw - 70px);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        position: relative;
        box-sizing: border-box;
        width: 100%;
    }
    .packaging-gallery-slider::-webkit-scrollbar { display: none; }

    /* ==========  SLIDE CONTAINER ========== */
    .packaging-gallery-slide {
        position: relative;
        flex: 0 0 auto;
        width: 140px;
        height: 180px;
        scroll-snap-align: center;
        display: flex;
        align-items: center;      /*  Vertical center for children */
        justify-content: center;  /*  Horizontal center for children */
        opacity: 0.7;
        z-index: 1;
        transition: opacity 0.4s ease, z-index 0s 0.4s;
        cursor: grab;
        user-select: none;
        will-change: opacity;
    }
    .packaging-gallery-slide:active { cursor: grabbing; }

    .packaging-gallery-slide.is-active {
        opacity: 1;
        z-index: 10;
        transition: opacity 0.4s ease, z-index 0s 0s;
    }

    .packaging-gallery-slide.is-cloned { 
        pointer-events: none; 
    }
    .packaging-gallery-slide.is-cloned .packaging-gallery-img-mobile,
    .packaging-gallery-slide.is-cloned .packaging-gallery-glass-mobile {
        pointer-events: none;
    }

    /* ==========  GLASS EFFECT - BEHIND IMAGE, VERTICALLY CENTERED ========== */
    .packaging-gallery-glass-mobile {
        position: absolute;
        
        /*  CENTER BOTH HORIZONTALLY AND VERTICALLY */
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) rotate(-42.67deg);
        
        /*  SIDE SIZES */
        width: 38.56px;
        height: 46.39px;
        
        border-radius: 10px;
        border-top: 3px solid rgba(255,255,255,0.05);
        border-right: 3px solid var(--c-white);
        border-bottom: none;
        border-left: 3px solid var(--c-white);
        border-image-slice: 1;
        opacity: 0.15;
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        z-index: 1; /*  BEHIND image (z-index: 2) */
        background: radial-gradient(64.42% 64.42% at 50% 50%, rgba(255,255,255,0.601) 60.1%, rgba(2,17,99,0.999) 99.99%);
        box-sizing: border-box;
        transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease;
        will-change: width, height;
    }

    /*  ACTIVE (center) glass - bigger */
    .packaging-gallery-slide.is-active .packaging-gallery-glass-mobile {
        width: 96.4px;
        height: 115.97px;
        opacity: 0.15;
        transform: translate(-50%, -50%) rotate(-42.67deg);
    }

    /* ==========  IMAGE - VERTICALLY CENTERED ========== */
    .packaging-gallery-img-mobile {
        position: absolute;
        
        /*  CENTER BOTH HORIZONTALLY AND VERTICALLY */
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%) rotate(0.62deg);
        
        /*  SIDE SIZES */
        width: 49.44px;
        height: 32.85px;
        
        object-fit: cover;
        border-radius: 10px;
        border: 1px solid var(--c-white);
        border-image-slice: 1;
        opacity: 0.8;
        z-index: 2; /*  IN FRONT of glass (z-index: 1) */
        box-sizing: border-box;
        transition: width 0.4s ease, height 0.4s ease, opacity 0.4s ease, box-shadow 0.4s ease;
        will-change: width, height;
    }

    /*  ACTIVE (center) image - bigger */
    .packaging-gallery-slide.is-active .packaging-gallery-img-mobile {
        width: 123.59px;
        height: 82.12px;
        opacity: 1;
        transform: translate(-50%, -50%) rotate(0.62deg);
        box-shadow: 0 8px 25px rgba(0,0,0,0.3);
    }

    /* Hover effect for active slide */
    .packaging-gallery-slide.is-active:hover .packaging-gallery-img-mobile {
        transform: translate(-50%, -50%) rotate(0.62deg) scale(1.03);
    }

    /* Dots */
    .packaging-gallery-dots {
        display: flex;
        justify-content: center;
        gap: 8px;
        margin-top: 15px;
    }
    .packaging-gallery-dot {
        width: 8px;
        height: 8px;
        border-radius: 50%;
        background: rgba(255,255,255,0.3);
        transition: background 0.3s ease, transform 0.3s ease;
        cursor: pointer;
    }
    .packaging-gallery-dot.is-active {
        background: #D4AF37;
        transform: scale(1.3);
    }
}

/* Small Mobile (≤319px) */
@media (max-width: 319.98px) {
    .packaging-gallery-slider {
        padding: 25px 10px 45px;
    }
    .packaging-gallery-slide {
        width: 120px;
        height: 160px;
    }
    .packaging-gallery-glass-mobile {
        width: 32px;
        height: 38px;
    }
    .packaging-gallery-slide.is-active .packaging-gallery-glass-mobile {
        width: 80px;
        height: 95px;
    }
    .packaging-gallery-img-mobile {
        width: 40px;
        height: 28px;
    }
    .packaging-gallery-slide.is-active .packaging-gallery-img-mobile {
        width: 100px;
        height: 68px;
    }
}