/**
 * Mobile layout fixes — Booktopia storefront (narrow viewports)
 */

/*
 * Product cards (shop grid, homepage, AJAX partials): main.css uses object-fit:contain on .book-thumb img
 * and a shrink-wrapped <a> — uneven cover sizes. Fill the thumb with a flex column + cover (same as x-booktopia.product-card).
 * Narrower rules in mobile-nav.css (e.g. .shop-default-wrapper) override height when more specific.
 */
.shop-box-items .book-thumb {
    position: relative;
    overflow: hidden;
    display: flex !important;
    flex-direction: column;
    flex-shrink: 0;
    height: 280px !important;
}

.shop-box-items .book-thumb > a {
    flex: 1 1 auto;
    min-height: 0;
    align-self: stretch;
    display: block;
    width: 100%;
}

.shop-box-items .book-thumb img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center;
}

/*
 * Homepage "Top Books" (book-shop-wrapper): markup puts .shop-button as a sibling AFTER .shop-content,
 * not inside .shop-content (unlike x-booktopia.product-card). Full-width button was flush to the grid cell edge.
 */
.book-shop-wrapper .shop-box-items.style-2 > .shop-content {
    padding-left: 14px !important;
    padding-right: 14px !important;
    padding-top: 10px !important;
}

.book-shop-wrapper .shop-box-items.style-2 > .shop-button {
    padding-left: 14px !important;
    padding-right: 14px !important;
    padding-bottom: 14px !important;
    margin-top: 8px !important;
    box-sizing: border-box;
}

.book-shop-wrapper .shop-box-items.style-2 > .shop-button .theme-btn {
    border-radius: 10px !important;
}

/* Floating back-to-top: sit above product CTAs / gesture bar */
@media (max-width: 767px) {
    .back-to-top {
        right: 12px !important;
        bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
        font-size: 16px !important;
        z-index: 40 !important;
    }
}

/*
 * Product card price row: main.css uses justify-content: space-between.
 * On 2-col grids (576px–991px) each card is still narrow — strikethrough price clips.
 * Stack sale + original vertically until large desktop; full-width lis.
 */
@media (max-width: 991px) {
    .shop-box-items .shop-content {
        padding-left: 10px !important;
        padding-right: 10px !important;
        min-width: 0;
    }

    .shop-box-items .shop-content .price-list.product-price-row {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        gap: 4px !important;
        width: 100% !important;
        min-width: 0 !important;
        margin-top: 8px !important;
    }

    .shop-box-items .shop-content .price-list.product-price-row li {
        width: 100% !important;
        max-width: 100% !important;
        flex: none !important;
        text-align: left !important;
        overflow: visible !important;
    }

    .shop-box-items .shop-content .price-list.product-price-row li del {
        color: #5c6f7e !important;
    }
}

/* Discount badges: clearer separation */
@media (max-width: 575px) {
    .shop-box-items .book-thumb .post-box {
        left: 10px;
        top: 10px;
        gap: 8px;
    }

    .shop-box-items .book-thumb .post-box li {
        padding: 6px 10px;
        font-size: 11px;
    }
}

/* Extra bottom space so last product row clears FAB */
@media (max-width: 767px) {
    .book-section,
    .shop-section,
    .shop-default-wrapper {
        padding-bottom: 4rem;
    }
}

/* Product detail page: price + old price + badge wrap on narrow screens */
.shop-details-content .price-list-main {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 12px;
}

.shop-details-content .price-list-main h3[style*="line-through"] {
    margin-left: 0 !important;
}

/* =============================================================================
   Mobile slide-out menu: why “so many colors”?
   - Lavender = --bg on .offcanvas__info (main.css)
   - Navy blue = MeanMenu defaults (#070337 in meanmenu.css) on .mean-nav
   - Dark gray = .offcanvas__overlay dimming the page (#151515)
   Unify panel + nav to Booktopia maroon + white; remove navy + extra top gap.
   ============================================================================= */
.offcanvas__info {
    background: #ffffff !important;
    border-left: 1px solid rgba(139, 21, 56, 0.12) !important;
}

.offcanvas__wrapper {
    padding-top: 16px !important;
}

.offcanvas__content .offcanvas__top {
    margin-bottom: 1rem !important;
}

/* MeanMenu: kill hidden “reveal” bar gap (meanmenu.css margin-top: 44px) */
.offcanvas__info .mean-container .mean-bar {
    background: transparent !important;
    min-height: 0 !important;
    padding: 0 !important;
}

.offcanvas__info .mean-container .mean-nav {
    background: #8b1538 !important;
    margin-top: 0 !important;
    float: none !important;
    width: 100% !important;
    border-radius: 10px;
    overflow: hidden;
}

.offcanvas__info .mean-container a.meanmenu-reveal {
    display: none !important;
}

.offcanvas__info .mean-container .mean-nav ul li a {
    border-top-color: rgba(255, 255, 255, 0.18) !important;
    color: #ffffff !important;
}

.offcanvas__info .mean-container .mean-nav ul li a.mean-expand {
    color: #ffffff !important;
    /* Default meanmenu uses top:0 — icon sits high vs padded label; center in row */
    top: 50% !important;
    margin-top: 0 !important;
    transform: translateY(-50%) !important;
    height: auto !important;
    min-height: 44px;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 48px !important;
    padding: 0 !important;
}

.offcanvas__info .mean-container .mean-nav ul li a.mean-expand i {
    line-height: 1 !important;
}

.offcanvas__info .mobile-menu {
    margin-bottom: 0.5rem !important;
}
