/* =====================================================================
   Bahga Shop – Home (index.php) – Professional Responsive Layer
   Load this file AFTER style.css and responsive.css so it can refine
   and patch a few real cross-device issues without fighting the base
   theme rules. Written mobile-first patches live inside max-width
   media queries so desktop/tablet look is untouched unless noted.
   ===================================================================== */

/* ---------- 0. Global safety net ---------- */
html {
    overflow-x: hidden;
}
body {
    overflow-x: hidden;
}
img {
    max-width: 100%;
    height: auto;
}
* {
    -webkit-tap-highlight-color: transparent;
}

/* ---------- 1. Left scrolling side-ad ---------- */
/* Bug: the outer #left-side-ad box is toggled by inline JS
   (style.display) independent of screen size, while only its
   inner button/image carry d-none d-md-block. Below 768px this can
   leave an empty, clickable, fixed 15%-wide / 550px-tall box
   sitting over page content. We hard-hide it below the tablet
   breakpoint and give it sane, proportional sizing above it. */
@media (max-width: 767.98px) {
    #left-side-ad {
        display: none !important;
    }
}
@media (min-width: 768px) and (max-width: 991.98px) {
    #left-side-ad,
    #left-side-ad a {
        width: 150px !important;
        height: 340px !important;
        left: 8px !important;
    }
}
@media (min-width: 992px) and (max-width: 1279.98px) {
    #left-side-ad,
    #left-side-ad a {
        width: 190px !important;
        height: 430px !important;
    }
}

/* ---------- 2. Banner ad images (top / mid / bottom placements) ---------- */
/* Bug: these were hard-coded to height:500px + object-fit:fill,
   which stretches/distorts the image and is far too tall on phones.
   Replace with a fluid, capped height + object-fit:cover so the
   image always keeps its aspect ratio and scales gracefully. */
.banner-ad-img {
    display: block;
    width: 100%;
    height: clamp(140px, 32vw, 500px);
    object-fit: cover;
    border-radius: 16px;
}
@media (max-width: 575.98px) {
    .banner-ad-img {
        border-radius: 12px;
    }
}

/* ---------- 3. Hero title / slider zone ---------- */
/* Desktop/tablet defaults are preserved. Phone-specific behavior is
   defined in the final BAHGA SHOP — HERO PRODUCT SLIDER / PHONE 3D MODE
   patch at the end of this file. */

/* ---------- 4. Section headings (Up Coming Items / Top Paid / Discover) ---------- */
.heading-section {
    flex-wrap: wrap;
    row-gap: 10px;
}
.heading-section .tf-title {
    font-size: clamp(22px, 4.2vw, 32px);
    line-height: 1.3;
}
@media (max-width: 575.98px) {
    .heading-section {
        justify-content: flex-start;
        gap: 10px 16px;
    }
}

/* Featured "Up Coming Items" heading row uses a bare col-md-9 with
   no explicit column below md, so on phones it can render at an
   unpredictable width instead of the full row. Force full width
   until Bootstrap's md kicks in. */
.featured-item .col-md-9 {
    width: 100%;
    max-width: 100%;
    flex: 0 0 100%;
}
@media (min-width: 768px) {
    .featured-item .col-md-9 {
        width: 75%;
        max-width: 75%;
        flex: 0 0 75%;
    }
}

/* ---------- 5. Discover item filter bar ---------- */
@media (max-width: 575.98px) {
    .tf-soft {
        flex-wrap: wrap;
        row-gap: 12px;
    }
    .tf-soft .soft-left {
        width: 100%;
        display: flex;
        gap: 10px;
    }
    .tf-soft .soft-left .dropdown {
        width: 100% !important;
    }
}
@media (max-width: 420px) {
    .tf-soft .soft-left {
        flex-direction: column;
    }
}

/* ---------- 6. Discover item product grid ---------- */
/* Root cause of "one product per row" on mobile: .tf-card-box.style-1
   .card-media img has a hard-coded width:235px;height:244px in the
   base stylesheet, which forces the whole card to that fixed size
   regardless of its grid column. We override it to fill the column,
   and lay the cards out 2-per-row on phones (same proven pattern
   already used on the explore page's #explore-products-grid). */
@media (max-width: 767.98px) {
    .discover-item .row {
        margin-left: -6px;
        margin-right: -6px;
        row-gap: 14px;
    }
    .discover-item .row > [class*="col-"] {
        flex: 0 0 50%;
        max-width: 50%;
        padding-left: 6px;
        padding-right: 6px;
    }
    .discover-item .tf-card-box.style-1 {
        padding: 8px 8px 12px;
        border-radius: 12px;
        overflow: hidden;
    }
    .discover-item .tf-card-box.style-1 .card-media {
        aspect-ratio: 1 / 1;
        border-radius: 10px;
    }
    .discover-item .tf-card-box.style-1 .card-media img {
        width: 100% !important;
        height: 100% !important;
        object-fit: cover;
    }
    .discover-item .tf-card-box.style-1 .name {
        font-size: 13px;
        line-height: 1.4;
        margin: 8px 4px 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding: 0;
    }
    .discover-item .tf-card-box.style-1 .author {
        margin: 0 4px;
        font-size: 11px;
    }
    .discover-item .tf-card-box.style-1 .author .info span {
        font-size: 10px;
        opacity: .7;
    }
    .discover-item .tf-card-box.style-1 .author .info h6 {
        font-size: 12px;
    }
    .discover-item .tf-card-box.style-1 .divider {
        margin: 4px;
    }
    .discover-item .tf-card-box.style-1 .meta-info {
        margin: 0 4px 6px;
        padding: 0;
    }
    .discover-item .tf-card-box.style-1 .price {
        font-size: 13px;
    }
    .discover-item .tf-card-box.style-1 .price span[style*="line-through"] {
        font-size: 10px;
    }
    .discover-item .tf-card-box.style-1 .button-place-bid {
        flex-wrap: wrap;
        gap: 6px !important;
    }
    .discover-item .tf-card-box.style-1 .button-place-bid .tf-button {
        font-size: 11px;
        padding: 6px 10px;
        height: auto;
    }
}

/* Very narrow phones: drop back to 1 column so text/buttons don't
   get squeezed too tight. */
@media (max-width: 380px) {
    .discover-item .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

/* ---------- 7. Promo / action banner (3-column auto slider) ---------- */
@media (max-width: 991.98px) {
    .tf-section.action .action__body {
        padding: 40px 24px;
        text-align: center;
    }
    .tf-section.action .action__body h2 {
        max-width: 100%;
        font-size: clamp(22px, 5vw, 30px);
        line-height: 1.4;
        margin-left: auto;
        margin-right: auto;
    }
    .tf-section.action .flat-button {
        justify-content: center;
    }
}
@media (max-width: 575.98px) {
    .tf-section.action .action__body {
        padding: 32px 16px;
        border-radius: 20px;
    }
}

/* ---------- 8. General touch / spacing polish ---------- */
@media (max-width: 575.98px) {
    .tf-card-box .wishlist-button,
    .tf-card-box .tf-button {
        min-height: 40px;
    }
    .button-place-bid {
        flex-wrap: wrap;
        row-gap: 8px;
    }
    .themesflat-container {
        padding-left: 16px;
        padding-right: 16px;
    }
}
@media (max-width: 360px) {
    .action__body h2,
    .heading-section .tf-title {
        font-size: 20px;
    }
}

/* ================================================================
   BAHGA SHOP — HERO PRODUCT SLIDER / PHONE 3D MODE
   ---------------------------------------------------------------
   Purpose:
   - Keep the existing desktop 3D slider unchanged.
   - On phones, show one dominant center card with partial
     neighboring cards, instead of a full-width single card.
   - Prevent horizontal page overflow.
   - Keep the card/image proportions stable across common phones.
   ================================================================ */

@media (max-width: 767.98px) {

    /* The 3D slider needs room for the neighboring cards to peek in. */
    .home-1 .flat-pages-title .relative {
        width: 100%;
        max-width: 100%;
        overflow: visible;
    }

    .home-1 .flat-pages-title .swiper-3d-7 {
        width: 100% !important;
        max-width: none !important;
        overflow: visible !important;
        padding: 0 !important;
    }

    .home-1 .flat-pages-title .swiper-3d-7 .swiper-wrapper {
        align-items: center;
    }

    /*
     * IMPORTANT:
     * Do NOT force 100% width here.
     * The desktop 3D slider relies on auto-sized slides.
     * These dimensions create the professional "center card +
     * neighboring cards" composition on phones.
     */
    .home-1 .flat-pages-title .swiper-3d-7 .swiper-slide {
        width: clamp(235px, 72vw, 285px) !important;
        max-width: 285px !important;
        flex-shrink: 0;
        box-sizing: border-box;
    }

    .home-1 .flat-pages-title .swiper-3d-7 .tf-card-box {
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
        margin: 0 auto;
        border-radius: 14px;
    }

    /* Stable square product image on phones. */
    .home-1 .flat-pages-title .swiper-3d-7 .card-media {
        width: 100%;
        aspect-ratio: 1 / 1;
        height: auto !important;
        overflow: hidden;
        border-radius: 12px;
    }

    .home-1 .flat-pages-title .swiper-3d-7 .card-media img {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;
        object-fit: cover !important;
        display: block;
    }

    /* Product title / price remain readable without making the card huge. */
    .home-1 .flat-pages-title .swiper-3d-7 .meta-info {
        padding: 8px 8px 12px;
        min-width: 0;
    }

    .home-1 .flat-pages-title .swiper-3d-7 .meta-info .name {
        margin: 0 0 5px;
        font-size: clamp(13px, 3.7vw, 16px);
        line-height: 1.35;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .home-1 .flat-pages-title .swiper-3d-7 .meta-info .price {
        margin: 0;
        font-size: clamp(12px, 3.5vw, 15px);
        line-height: 1.3;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    /* Keep the wishlist button comfortably inside the image. */
    .home-1 .flat-pages-title .swiper-3d-7 .wishlist-button {
        width: 34px;
        height: 34px;
        min-width: 34px;
        display: flex;
        align-items: center;
        justify-content: center;
        z-index: 20;
    }

    /*
     * On touch screens there is no real hover state. Keep the slider
     * clean and let users tap the card to open the product.
     */
    .home-1 .flat-pages-title .swiper-3d-7 .button-place-bid {
        display: none !important;
    }

    /* Smaller sale badge. */
    .home-1 .flat-pages-title .swiper-3d-7 .featured-countdown {
        font-size: 11px !important;
        line-height: 1;
        padding: 7px 10px !important;
        border-radius: 20px;
    }

    /*
     * Navigation arrows are unnecessary on narrow touch screens.
     * Swiping remains available.
     */
    .home-1 .flat-pages-title .next-3d,
    .home-1 .flat-pages-title .prev-3d {
        display: none !important;
    }

    /* Keep pagination below the cards and away from the edges. */
    .home-1 .flat-pages-title .swiper-pagination.pagination-number {
        position: relative;
        left: auto !important;
        right: auto !important;
        bottom: auto !important;
        margin: 18px auto 0;
        width: 100%;
    }
}

/* Very small phones: slightly narrower card so both neighbors remain visible. */
@media (max-width: 380px) {

    .home-1 .flat-pages-title .swiper-3d-7 .swiper-slide {
        width: 225px !important;
        max-width: 225px !important;
    }

    .home-1 .flat-pages-title .swiper-3d-7 .meta-info {
        padding-left: 7px;
        padding-right: 7px;
    }
}

/* Larger phones / small tablets in portrait. */
@media (min-width: 576px) and (max-width: 767.98px) {

    .home-1 .flat-pages-title .swiper-3d-7 .swiper-slide {
        width: 270px !important;
        max-width: 270px !important;
    }
}

