/*=========== File Details ===========
*** Mobile UI fixes 1-6 (08-10-2026)
*** Loaded last from header-html.php (?v=filemtime). Scoped overrides only.
====================================*/

/* 4. Homepage: keep the floating notices button above the shop-by-country tiles.
      .img-heading has z-index 99 in the root stacking context; isolate the section
      so its inner z-indexes stay inside it (button is fixed at z-index 98). */
.shop-by-country-wrapper {
    isolation: isolate;
}

@media only screen and (max-width: 850px) {
    /* 1. Mobile search: dark, readable text + placeholder */
    .mobile-search-window-container .mobile-search-input {
        background-color: #ffffff;
        color: #232323;
        -webkit-text-fill-color: #232323;
        caret-color: #232323;
    }

    .mobile-search-window-container .mobile-search-input::placeholder {
        color: #6b6b6b;
        -webkit-text-fill-color: #6b6b6b;
        opacity: 1;
    }

    /* 3. Mobile bottom nav icons: same size as the header cart bag
          (.mini-cart-button 1.2em x .mini-cart-button i 1.4em = 1.68em) */
    .mobile-footer-nav-item-container .mobile-nav-item,
    .mini-cart-button.mobile i.mobile-nav-item {
        font-size: 1.68rem;
        line-height: 1;
    }

    /* 5. Mobile homepage: side padding for shop-by-country */
    .shop-by-country-wrapper {
        padding-left: 1rem;
        padding-right: 1rem;
        box-sizing: border-box;
    }
}

@media (max-width: 768px) {
    /* 2. Product popup close X: the text "×" sits off-centre because of font metrics
          (differs per device font). Hide the text glyph and draw the X with two
          centred bars, so it is centred by construction in the fixed-size circle. */
    .product-popup .close-popup {
        font-size: 0;
        line-height: 0;
        padding: 0;
    }

    .product-popup .close-popup::before,
    .product-popup .close-popup::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 1.1rem;
        height: 2px;
        border-radius: 1px;
        background-color: currentColor;
        transform: translate(-50%, -50%) rotate(45deg);
    }

    .product-popup .close-popup::after {
        transform: translate(-50%, -50%) rotate(-45deg);
    }
}

@media only screen and (max-width: 850px) {
    /* 7. Mobile homepage: banner flush under the sticky icons row.
          functions.js (always fresh, ?v=time) adds a 40px --mk-header-gap to the page
          clearance; the cancelling margin lives in banner_slider/css/slider-styles.css,
          which has no ?v= and can be served stale. Repeat it here (versioned file). */
    #slider {
        margin-top: calc(-1 * var(--mk-header-gap, 0px));
    }
}

@media only screen and (max-width: 700px) {
    /* 6. Mobile homepage: vertical spacing between the stacked bottom blocks */
    .column-3-image-row .column-2-image-row-image:not(:last-child) {
        margin-bottom: 1rem;
    }

    .information-banner-wrapper {
        margin-bottom: 1rem;
    }
}

/* 8. Home category tabs (.cat-row-btn <button>): no color set, so iOS/Safari UA button colour (system blue)
      showed on unselected tabs. Low specificity on purpose: existing .cat-row-btn:hover and .cat-row-btn.selected
      (styles.css) still win, so hover/active states are unchanged. All widths. */
.cat-row-btn,
.cat-row-btn:not(.selected):not(:hover):focus,
.cat-row-btn:not(.selected):not(:hover):active {
    color: #000000;
    -webkit-text-fill-color: currentColor;
}

/* 9. Product page (mobile): price / qty / Add To Cart sit directly under the image + title
      (sidebar purchase box is pulled between the title and the categories/description).
      scroll-margin keeps the qty field clear of the sticky header when focused/scrolled to. */
@media only screen and (max-width: 768px) {
    .page-container .single-product-main-content-grid {
        display: flex !important;
        flex-direction: column;
        gap: 0.75rem;
    }

    .page-container .single-product-main-content-grid .single-product-rows,
    .page-container .single-product-main-content-grid .single-product-grid,
    .page-container .single-product-main-content-grid .single-product-grid > .product-text-content {
        display: contents !important;
    }

    .page-container .single-product-grid > .product-popup-media { order: 1; }

    .page-container .single-product-grid > .product-text-content > * {
        order: 2;
        margin: 0 !important;
        padding: 0.75rem;
        background-color: #ffffff;
        border-radius: 5px;
        box-sizing: border-box;
    }

    .page-container .single-product-grid > .product-text-content > .single-product-title ~ * { order: 4; }
    .page-container .single-product-sidebar-purchase { order: 3; }
    .page-container .single-product-rows > :not(.single-product-grid) { order: 5; }
    .page-container .single-product-sidebar-info { order: 6; }

    .page-container .single-product-sidebar-purchase,
    .page-container #order-qty,
    .page-container .mk-add-to-cart-btn {
        scroll-margin-top: calc(var(--mk-menu-bar-bottom, 5.5rem) + 1rem);
    }
}

/* 10. Store picker: card padding (Sandton address touched the edge); when a site NOTICE is showing,
       the picker opens below it and the notice stays above the dim overlay instead of being covered. */
#store-picker-modal .store-picker-item {
    padding: 1rem 1.25rem !important;
    box-sizing: border-box;
    overflow-wrap: anywhere;
}

body:has(#store-picker-modal:not(.hidden)) .site-notice-banner {
    z-index: 10055;
}

body:has(.site-notice-banner:not([hidden])) #store-picker-modal {
    align-items: flex-start;
    padding: calc(var(--mk-menu-bar-bottom, 5.5rem) + 4.5rem) 0 1rem;
    box-sizing: border-box;
}

body:has(.site-notice-banner:not([hidden])) #store-picker-modal .modal-content {
    max-height: 100%;
}

/* 11. Mobile menu: close X stays visible (sticky) while the menu panel scrolls.
       Negative margins keep it in the same spot as before without pushing the menu down. */
#mobile-menu .close-mobile-menu-button {
    position: -webkit-sticky;
    position: sticky;
    top: 1rem;
    right: auto;
    align-self: flex-end;
    flex: 0 0 auto;
    margin: -2.25rem -1rem -0.5rem auto;
}

/* 12. Home product rows (mobile): a section with a single product filled only the left half.
       Centre the lone card instead of leaving the right column empty. */
@media only screen and (max-width: 768px) {
    .home-product-grid > li:only-child {
        grid-column: 1 / -1;
        justify-self: center;
        width: min(100%, 15rem);
    }
}