/* =====================================================================
   SITE-WIDE MOBILE BASELINE (≤ 768px)
   Loaded by templates/layout/default.php on every page, after all the
   per-page stylesheets. Page-specific mobile files (e.g. mobile/home.css)
   load after this one and can refine it.

   Several templates carry their own inline <style> blocks, which come
   later in the document than this file. Layout-critical properties here
   therefore use !important so phones always get one consistent layout.

     1. No sideways scrolling
     2. Header bar + logo (same size on every page)
     3. Page titles + "N Results"
     4. Product listing grids (Surgical, Gloves, Gowns, Dental, …)
     5. Brochure pages
     6. Single product page
   ===================================================================== */

@media screen and (max-width: 768px) {
    :root {
        --site-header-h: 64px;
        --site-gutter: 20px;
        --site-title-top: 32px;
        --site-navy: #0b2545;
    }

    /* =================================================================
       1. NO SIDEWAYS SCROLLING
       `clip` (unlike `hidden`) doesn't create a scroll container, so
       fixed headers and smooth scrolling keep working.
       ================================================================= */
    html,
    body {
        max-width: 100%;
        overflow-x: clip;
    }

    .main,
    .main > .container {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        box-sizing: border-box;
    }

    .main img {
        max-width: 100%;
    }

    /* =================================================================
       2. HEADER BAR + LOGO
       ================================================================= */
    .fixed-banneritems,
    .fixed-banneritems1 {
        height: var(--site-header-h) !important;
        opacity: 0.97;
        box-shadow: 0 2px 12px rgba(11, 37, 69, 0.15);
        z-index: 50 !important;
    }

    .logo-link {
        position: fixed !important;
        top: 0 !important;
        left: 6px !important;
        z-index: 60 !important;
    }

    .logo-link img.logo-image,
    .logo-link .logo-image {
        position: static !important;
        width: auto !important;
        height: var(--site-header-h) !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        transform: none !important;
    }

    /* No hover zoom/pulse on touch devices */
    .logo-link img.logo-image:hover {
        transform: none !important;
        animation: none !important;
        filter: none !important;
    }

    .hamburger {
        top: 0 !important;
        right: 8px !important;
        width: 48px;
        height: var(--site-header-h);
        display: flex !important;
        align-items: center;
        justify-content: center;
        font-size: 30px !important;
        line-height: 1;
        color: var(--site-navy) !important;
        -webkit-tap-highlight-color: transparent;
    }

    /* Menu logo sits in the menu flow, not pinned like the header logo */
    .mobile-menu .logo-image {
        position: static !important;
        width: 200px !important;
        height: auto !important;
        max-height: none !important;
        margin: 0 auto 20px !important;
    }

    .mobile-menu {
        padding-top: calc(var(--site-header-h) + 16px);
        padding-bottom: 40px;
        height: 100dvh;
        box-sizing: border-box;
    }

    /* =================================================================
       3. PAGE TITLES + RESULT COUNT
       Every listing/brochure page: title flush with the 20px gutter,
       directly under the header, results count right below it.
       ================================================================= */
    /* `body .main` prefix outranks older per-page !important rules
       (e.g. mobilegowns.css pulls the Gowns title -70px left) */
    body .main .container > h1,
    body .main .view-background > h1,
    body .main .explore-view-background > h1,
    body .main h1.page-title,
    body .main h2.surgical-brochures-title,
    body .main h2.essential-brochures-title,
    body .main h2.sterilization-brochures-title {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        transform: none !important;
        width: auto !important;
        max-width: none !important;
        margin: calc(var(--site-header-h) + var(--site-title-top)) 0 0 !important;
        padding: 0 var(--site-gutter) !important;
        font-size: clamp(28px, 8.5vw, 36px) !important;
        line-height: 1.15 !important;
        letter-spacing: 0 !important;
        text-align: left !important;
        white-space: normal !important;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    /* Wrapper divs shouldn't add their own offsets on top of the title */
    .view-background,
    .explore-view-background,
    .all-products-page {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 0 48px !important;
        transform: none !important;
        box-sizing: border-box;
    }

    .main .total-items {
        position: static !important;
        margin: 8px 0 20px !important;
        padding: 0 var(--site-gutter) !important;
        font-size: 16px !important;
        text-align: left !important;
        transform: none !important;
    }

    /* =================================================================
       4. PRODUCT LISTING GRIDS
       One full-width card per row, 20px gutters, images fit the card.
       ================================================================= */
    /* `body .main .container` prefix outranks per-page !important rules
       (e.g. mobilegowns.css adds a 100px gap above the Gowns grid) */
    body .main .container .items-grid,
    body .main .container .explore-items-grid {
        display: grid !important;
        grid-template-columns: minmax(0, 1fr) !important;
        gap: 20px !important;
        position: static !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 var(--site-gutter) !important;
        transform: none !important;
        box-sizing: border-box;
    }

    /* explore.php nests one grid inside another */
    body .main .container .items-grid > .explore-items-grid {
        padding: 0 !important;
    }

    body .main .container .items-grid > .item-link {
        display: block;
        min-width: 0;
        text-decoration: none;
    }

    body .main .container .items-grid .item {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        height: auto !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 16px 16px 20px !important;
        transform: none !important;
        box-sizing: border-box;
        text-align: center;
        overflow: hidden;
    }

    /* Templates set style="width:400px" inline — only !important beats it */
    body .main .container .items-grid .item img {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        height: 240px !important;
        margin: 0 auto 14px !important;
        object-fit: contain;
        position: static !important;
        transform: none !important;
    }

    body .main .container .items-grid .item .name {
        position: static !important;
        margin: 0 0 8px !important;
        padding: 0 !important;
        font-size: 18px !important;
        line-height: 1.3 !important;
        text-align: center !important;
        transform: none !important;
    }

    body .main .container .items-grid .item .description,
    body .main .container .items-grid .item .description p {
        position: static !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 15px !important;
        line-height: 1.55 !important;
        text-align: center !important;
        transform: none !important;
    }

    /* =================================================================
       5. BROCHURE PAGES (Pages/display*.php)
       ================================================================= */
    .main .brochure-gallery {
        width: 100% !important;
        margin: 24px 0 0 !important;
        padding: 0 var(--site-gutter) 48px !important;
        align-items: stretch !important;
        gap: 24px;
        box-sizing: border-box;
    }

    .main .brochure-image {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        transform: none !important;
        border-radius: 8px;
        box-shadow: 0 6px 18px rgba(11, 37, 69, 0.12) !important;
    }

    /* =================================================================
       6. SINGLE PRODUCT PAGE (Products/view_item.php) — overflow guard
       Full phone layout lives in mobile/product.css.
       ================================================================= */
    .item-detail-page {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: clip;
        box-sizing: border-box;
    }

    .item-detail-page img {
        max-width: 100% !important;
        height: auto;
    }
}

/* Small phones (iPhone SE / mini) */
@media screen and (max-width: 380px) {
    :root {
        --site-gutter: 16px;
    }
}
