/* =====================================================================
   PRODUCT LISTING PAGES — Surgical Gloves, Canisters, Gowns, Dental,
   Kits, All Products, …
   Loaded site-wide from templates/layout/default.php; only affects
   `.items-grid` listings.

     • Desktop (≥ 769px): grid + title placement (first block below)
     • All sizes: the card look itself (second block)
     • Phones: column count (last blocks); gutters/titles are in
       mobile/site.css

   Every listing uses the Surgical Gloves card as the standard:
     • square image area, product centred on white (never cropped,
       never stretched, never overlapping the text)
     • bold dark title, light grey description, centred
     • 3 equal columns (2 on narrow screens), title + results count
       aligned with the grid's left edge

   Older per-page/per-item rules (negative margins, fixed widths, inline
   style="width:400px") are overridden with !important on purpose.
   ===================================================================== */

@media screen and (min-width: 769px) {
    body .main {
        --ls-col: 316px;
        --ls-gap: 18px;
        --ls-width: calc(var(--ls-col) * 3 + var(--ls-gap) * 2);
    }

    /* ---- Title + "N Results": aligned with the grid ---- */
    body .main .container > h1:has(~ .items-grid),
    body .main .view-background > h1,
    body .main .explore-view-background > h1,
    body .main h1.page-title {
        position: relative !important;
        top: auto !important;
        right: auto !important;
        left: auto !important;
        transform: none !important;
        width: auto !important;
        max-width: var(--ls-width) !important;
        margin: 96px auto 0 !important;
        padding: 0 !important;
        text-align: left !important;
    }

    body .main .total-items {
        position: static !important;
        max-width: var(--ls-width) !important;
        margin: 6px auto 20px !important;
        padding: 0 !important;
        text-align: left !important;
        transform: none !important;
    }

    /* Wrapper divs: no offsets of their own */
    body .main .view-background,
    body .main .explore-view-background {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        transform: none !important;
        margin: 0 !important;
        padding: 0 0 72px !important;
        width: 100% !important;
    }

    /* ---- Grid ---- */
    body .main .container .items-grid,
    body .main .container .explore-items-grid {
        display: grid !important;
        grid-template-columns: repeat(3, var(--ls-col)) !important;
        gap: var(--ls-gap) !important;
        justify-content: center !important;
        align-items: stretch !important;
        position: static !important;
        top: auto !important;
        left: auto !important;
        width: auto !important;
        max-width: none !important;
        margin: 0 auto !important;
        padding: 0 !important;
        transform: none !important;
        box-sizing: border-box;
    }

    /* explore.php nests a grid inside a grid: outer one is just a wrapper */
    body .main .container .items-grid:has(> .explore-items-grid) {
        display: block !important;
    }

    /* dental (drape_Items.php) wraps each card in a link */
    body .main .container .items-grid > .item-link {
        display: block !important;
        min-width: 0;
        text-decoration: none !important;
        color: inherit;
    }

}

/* =====================================================================
   CARD LOOK — ALL SCREEN SIZES (desktop + phones)
   ===================================================================== */
@media screen {
    /* ---- Card ---- */
    body .main .container .items-grid .item {
        display: flex !important;
        flex-direction: column !important;
        position: relative !important;
        top: auto !important;
        right: auto !important;
        bottom: auto !important;
        left: auto !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        height: 100% !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 0 20px !important;
        background: linear-gradient(180deg, #f8fbff 0%, #edf6ff 100%) !important;
        border: 1px solid rgba(84, 172, 240, 0.6) !important;
        border-radius: 14px !important;
        box-shadow: none !important;
        overflow: hidden !important;
        text-align: center !important;
        transform: none !important;
        box-sizing: border-box !important;
        z-index: auto !important;
    }

    /* Image link fills the image area */
    body .main .container .items-grid .item > a {
        display: block !important;
        position: static !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
    }

    /* ---- Image: square, contained, on white (the Gloves look) ---- */
    body .main .container .items-grid .item img {
        display: block !important;
        position: static !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: none !important;
        aspect-ratio: 1 / 1;
        margin: 0 !important;
        padding: 0 !important;
        object-fit: contain !important;
        object-position: center !important;
        background: #ffffff !important;
        border: 0 !important;
        border-radius: 10px 10px 0 0 !important;
        box-shadow: none !important;
        transform: none !important;
        transition: transform 0.25s ease;
        /* Dental's old rules set z-index: -1, which hides the image behind
           the card now that cards are flex containers */
        z-index: auto !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* ---- Text ---- */
    body .main .container .items-grid .item .name {
        position: static !important;
        top: auto !important;
        left: auto !important;
        margin: 14px 16px 6px !important;
        padding: 0 !important;
        font-size: 18px !important;
        font-weight: 700 !important;
        line-height: 1.4 !important;
        color: #333333 !important;
        text-align: center !important;
        transform: none !important;
        -webkit-text-fill-color: currentColor;
        background: none !important;
    }

    /* Descriptions: templates nest <p> inside <p class="description">, which
       browsers split into sibling paragraphs — style every non-title <p> */
    body .main .container .items-grid .item > p:not(.name),
    body .main .container .items-grid .item .description,
    body .main .container .items-grid .item .description p {
        position: static !important;
        top: auto !important;
        left: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        font-size: 14px !important;
        font-weight: 300 !important;
        line-height: 1.5 !important;
        color: #666666 !important;
        text-align: center !important;
        transform: none !important;
    }

    body .main .container .items-grid .item > p:not(.name),
    body .main .container .items-grid .item .description {
        margin: 0 16px !important;
    }

    body .main .container .items-grid .item > p:not(.name):empty {
        display: none !important;
    }

    body .main .container .items-grid .item > p:not(.name) + p:not(.name):not(:empty) {
        margin-top: 6px !important;
    }

    body .main .container .items-grid .item .description strong {
        font-weight: 600;
        color: #444444;
    }
}

/* Narrow laptops / tablets: two columns */
@media screen and (min-width: 769px) and (max-width: 1060px) {
    body .main {
        --ls-width: calc(var(--ls-col) * 2 + var(--ls-gap));
    }

    body .main .container .items-grid,
    body .main .container .explore-items-grid {
        grid-template-columns: repeat(2, var(--ls-col)) !important;
    }
}

/* =====================================================================
   PHONES — the one-column grid and gutters come from mobile/site.css;
   large phones / small tablets get two columns so the square image
   area doesn't get oversized.
   ===================================================================== */
@media screen and (min-width: 481px) and (max-width: 768px) {
    body .main .container .items-grid,
    body .main .container .explore-items-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 16px !important;
    }

    body .main .container .items-grid:has(> .explore-items-grid) {
        display: block !important;
    }
}

@media screen and (max-width: 768px) {
    body .main .container .items-grid .item .name {
        margin: 14px 16px 6px !important;
    }
}


/* =====================================================================
   WHOLE CARD IS CLICKABLE (all listing pages, all screen sizes)
   Each card's image link is stretched invisibly over the entire card,
   so clicking the name, description or anywhere on the card opens the
   product — not just the image. (Dental already wraps the whole card in
   a link and is unaffected.)
   ===================================================================== */
body .main .container .items-grid .item {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease !important;
}

body .main .container .items-grid .item > a::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 2;
}

/* hover / focus feedback so it's obvious the card is a link */
body .main .container .items-grid .item:hover,
body .main .container .items-grid .item:focus-within,
body .main .container .items-grid > .item-link:hover .item {
    transform: translateY(-3px) !important;
    border-color: #0084ff !important;
    box-shadow: 0 10px 24px rgba(0, 92, 190, 0.16) !important;
}

body .main .container .items-grid .item > a:focus-visible {
    outline: none;
}

body .main .container .items-grid .item:focus-within {
    outline: 2px solid #0084ff;
    outline-offset: 2px;
}
