/* ============================================================
   SAHA — saha-fixes.css
   FIX 1 : Product card image gallery (hover break)
   FIX 2 : Scroll-row sections (More from Brand / You May Also Like)
   Add this file to /wp-content/themes/saha-marketplace/assets/
   Then enqueue it AFTER saha-wp.css in functions.php
   ============================================================ */

/* ── FIX 1a: Kill the OLD scale-on-hover that fights the new slider ── */
/* The old rule transforms ALL imgs inside .product-card__media on hover.
   The new multi-image track uses opacity + absolute positioning instead.
   These two systems clash → images jump/break. We disable the old rule
   only for multi-image cards and let the new track system take over.     */

.product-card__img-track--multi ~ * ,
.product-card:has(.product-card__img-track--multi) .product-card__media img,
.product-card:has(.product-card__img-track--multi):hover .product-card__img,
.product-card:has(.product-card__img-track--multi):hover .product-card__media img {
    transform: none !important;
}

/* ── FIX 1b: Media container must clip everything strictly ── */
.product-card__media {
    position: relative;
    overflow: hidden !important;
    /* fixed aspect ratio so the container never collapses/jumps */
    aspect-ratio: 3 / 4;
    border-radius: 12px 12px 0 0;
    background: #f5f5f5;
}

/* ── FIX 1c: The image track fills the media container completely ── */
.product-card__img-track {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    line-height: 0;
}

/* ── FIX 1d: Multi-track — all slides are stacked, same fixed size ── */
.product-card__img-track--multi {
    position: absolute;   /* fill the .product-card__media box */
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Every slide: absolute, fills the track, invisible by default */
.product-card__img-track--multi .product-card__img {
    display: block;
    position: absolute !important;  /* override any :first-child relative */
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transform: scale(1.04);
    transition:
        opacity   0.38s cubic-bezier(.4, 0, .2, 1),
        transform 0.38s cubic-bezier(.4, 0, .2, 1);
    pointer-events: none;
    user-select: none;
    will-change: opacity, transform;
}

/* Active slide — fully visible, no transform offset */
.product-card__img-track--multi .product-card__img.is-active {
    opacity: 1 !important;
    transform: scale(1) !important;
    pointer-events: auto;
    position: absolute !important; /* keep in flow of the track, NOT page */
    z-index: 1;
}

/* Subtle zoom on the ACTIVE image when hovering the card (not all imgs) */
.product-card:hover .product-card__img-track--multi .product-card__img.is-active {
    transform: scale(1.03) !important;
}

/* Single-image track: still fills the container */
.product-card__img-track:not(.product-card__img-track--multi) {
    position: absolute;
    inset: 0;
}
.product-card__img-track:not(.product-card__img-track--multi) .product-card__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .5s ease;
}
.product-card:hover .product-card__img-track:not(.product-card__img-track--multi) .product-card__img {
    transform: scale(1.05);
}

/* ── FIX 1e: Arrows stay properly centered vertically ── */
.pc-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 20;            /* above images */
    /* rest of styling stays from saha-wp.css */
}
.pc-arrow:hover  { transform: translateY(-50%) scale(1.1); }
.pc-arrow:active { transform: translateY(-50%) scale(0.96); }

/* ── FIX 1f: Dots stay above images ── */
.pc-dots {
    z-index: 20;
}

/* ── FIX 1g: Wishlist button stays above images ── */
.product-card__media .wishlist-btn {
    z-index: 20;
    position: absolute;
    top: 10px;
    right: 10px;
}

/* ── FIX 1h: Sold-out / sale badges above images ── */
.product-card__media .corner-sold-out,
.product-card__media .corner-sale-badge {
    position: absolute;
    z-index: 20;
}

/* ── FIX 2: Horizontal scroll rows (More from Brand / You May Also Like) ── */
.saha-scroll-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0;
}

.saha-scroll-track {
    display: flex;
    gap: 16px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    padding: 4px 2px 12px;   /* room for card shadow */
    flex: 1;
    min-width: 0;
}
.saha-scroll-track::-webkit-scrollbar { display: none; }
.saha-scroll-track { scrollbar-width: none; }

/* Cards inside scroll track: fixed width, never shrink */
.saha-scroll-track .product-card {
    flex: 0 0 220px;
    scroll-snap-align: start;
    min-width: 0;
}
@media (max-width: 640px) {
    .saha-scroll-track .product-card { flex: 0 0 160px; }
}

/* Scroll nav buttons */
.saha-scroll-btn {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 1.5px solid var(--c-border, #e8e8e4);
    background: var(--c-surface, #fff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--c-primary, #0a1628);
    transition: background .2s, border-color .2s, transform .15s;
    box-shadow: 0 2px 8px rgba(0,0,0,.07);
    z-index: 5;
}
.saha-scroll-btn:hover {
    background: var(--c-primary, #0a1628);
    border-color: var(--c-primary, #0a1628);
    color: #fff;
    transform: scale(1.06);
}
.saha-scroll-btn--prev { margin-right: 8px; }
.saha-scroll-btn--next { margin-left:  8px; }
