/* =========================================================
   MODULAR PROMOTION: GRID LAYOUT & CARD UI (FINAL CLEAN)
   ========================================================= */

/* --- 1. BASE CARD UI --- */
.st-card-promo {
    background: transparent;
    border: none;
    position: relative;
    transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
    will-change: transform;
}

.st-card-promo-link {
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
}

.st-card-promo-thumb {
    position: relative;
    border-radius: var(--border-radius);
    /* Penting agar border-radius tidak 'pecah' saat img di-scale */
    overflow: hidden; 
    background: #f5f5f5;
    /* Optimasi rendering */
    isolation: isolate; 
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Memastikan gambar tetap di dalam container saat zoom */
    transform: translateZ(0); 
    
    /* Gunakan variabel dari PHP logic, default 1/1 */
    aspect-ratio: var(--card-aspect-ratio, 1/1); 
}

.st-card-promo-thumb img {
    width: 100%;
    height: 100%; /* Ubah ke 100% agar sinkron dengan aspect-ratio parent */
    object-fit: cover;
    object-position: center;
    display: block;
    will-change: transform;
    transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

/* --- HOVER EFFECTS (Modular via PHP Class) --- */

/* Effect 1: Zoom (Default) - Fix Selector */
.st-card-promo.hover-zoom:hover .st-card-promo-thumb img {
    transform: scale(1.1) translateZ(0);
}

/* Effect 2: Soft Lift & Shadow */
.st-card-promo.hover-lift {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.st-card-promo.hover-lift:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
}

/* Effect 3: Dark Overlay Reveal */
.st-card-promo.hover-overlay .product-card-overlay {
    opacity: 0;
    transition: opacity 0.3s ease;
}
.st-card-promo.hover-overlay:hover .product-card-overlay {
    opacity: 1;
}

/* --- 2. CARD CONTENT --- */
.st-card-promo-content {
    display: grid !important;
    grid-template-columns: 100%;
    row-gap: var(--p-content-gap, 8px) !important;
    padding: 15px 5px !important;
    text-align: center !important;
    justify-items: center;
    flex-grow: 1;
}

.st-card-promo-title {
    font-size: 0.95rem !important;
    font-weight: 600;
    margin: 0 !important;
    color: var(--primary-color, #333);
    line-height: 1.4;
    text-transform: capitalize;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.st-card-promo-price {
    display: flex !important;
    justify-content: center !important;
    align-items: baseline !important;
    gap: 8px;
    width: 100%;
    margin-top: 2px;
}

.st-card-promo-price .actual {
    color: var(--accent-color, #e67e22);
    font-weight: 700;
    font-size: 0.9rem !important;
}

.st-card-promo-price .old {
    color: var(--text-muted, #999);
    text-decoration: line-through;
    font-size: 0.75rem !important;
}

/* --- 3. LAYOUT: CAROUSEL SNAP --- */
.st-promo-container.st-layout-carousel-snap {
    display: flex !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-padding: 0 20px; 
    gap: 20px;
    padding: 10px 5px 30px 5px;
    scrollbar-width: none; 
    -ms-overflow-style: none;
}

.st-promo-container.st-layout-carousel-snap::-webkit-scrollbar {
    display: none;
}

.st-promo-container.st-layout-carousel-snap .st-card-promo {
    flex: 0 0 300px;
    min-width: 300px;
    scroll-snap-align: start;
    scroll-snap-stop: always;
}

/* --- 4. CAROUSEL NAVIGATION ARROWS --- */
.st-nav-arrow {
    display: none;
}

@media (min-width: 1024px) {
    .st-grid-promotion .st-container {
        position: relative;
    }

    .st-nav-arrow {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: calc(50% + 25px); 
        transform: translateY(-50%);
        width: 44px;
        height: 44px;
        background: #ffffff;
        border: 1px solid #eee;
        border-radius: 50%;
        color: #333;
        cursor: pointer;
        z-index: 50;
        transition: all 0.3s ease;
        box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    }

    .st-nav-arrow:hover {
        background: var(--primary-color, #e67e22);
        color: #fff;
        border-color: var(--primary-color, #e67e22);
        transform: translateY(-50%) scale(1.1);
    }

    .st-nav-arrow.prev { left: -22px; }
    .st-nav-arrow.next { right: -22px; }

    .st-grid-promotion .st-container {
        padding-left: 35px;
        padding-right: 35px;
    }
}

/* --- 5. LAYOUT: FEATURED (DESKTOP) --- */
@media (min-width: 769px) {
    .st-promo-container.st-layout-featured {
        display: grid !important;
        grid-template-columns: repeat(4, 1fr); 
        grid-template-rows: repeat(2, 1fr);
        column-gap: 25px; 
        row-gap: 12px; 
        height: 550px; /* Batas tinggi grid desktop */
    }

    .st-promo-container.st-layout-featured .st-card-promo:first-child {
        grid-column: span 2;
        grid-row: span 2;
    }

    .st-promo-container.st-layout-featured .st-card-promo:not(:first-child) .st-card-promo-thumb {
        height: 100%;
        aspect-ratio: auto !important;
        position: relative;
        overflow: hidden;
    }

    .st-promo-container.st-layout-featured .st-card-promo:not(:first-child) .st-card-promo-thumb img {
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        object-fit: cover !important;
    }
}

/* --- 6. LAYOUT: SCROLL SNAP (MOBILE) --- */
@media (max-width: 768px) {
    .st-promo-container.st-layout-featured {
        /* Kita timpa grid desktop menjadi flex agar bisa scroll samping */
        display: flex !important;
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
        -webkit-overflow-scrolling: touch;
        
        /* Layouting */
        gap: 15px; 
        padding: 10px 20px 30px 20px !important;
        margin-left: -20px;
        margin-right: -20px;
        height: auto; /* Matikan batas tinggi desktop */
        
        scrollbar-width: none;
    }

    .st-promo-container.st-layout-featured::-webkit-scrollbar {
        display: none;
    }

    /* Reset aturan 'first-child' desktop agar sama rata di mobile */
    .st-promo-container.st-layout-featured .st-card-promo {
        flex: 0 0 82%; 
        scroll-snap-align: center;
        grid-column: auto !important; /* Reset grid spans */
        grid-row: auto !important;
    }

    /* Pastikan gambar di semua card mobile tetap konsisten */
    .st-promo-container.st-layout-featured .st-card-promo .st-card-promo-thumb {
        position: relative;
        height: auto;
        aspect-ratio: 1 / 1; /* Di mobile buat kotak agar seragam */
    }

    .st-promo-container.st-layout-featured .st-card-promo .st-card-promo-thumb img {
        position: relative; /* Bukan absolute agar aspect-ratio bekerja */
        width: 100%;
        height: 100%;
        object-fit: cover !important;
    }
}