/* Product archive: header, filters, grid and card. */

.igm-shop {
    display: grid;
    gap: 24px;
}

@media (min-width: 900px) {
    .igm-shop--sidebar {
        grid-template-columns: 260px minmax(0, 1fr);
        align-items: start;
    }
}

/* Filter toggle (mobile) ---------------------------------------------------
 * Below 900px the sidebar is collapsed behind this button instead of
 * stacking in-flow above the product grid — without it, a category with
 * several facet groups (molecule, manufacturer, form, strength) pushed
 * every product below a full screen of checkboxes before a shopper saw
 * anything to buy. Mirrors .igm-nav__toggle's own mobile/desktop split. */
.igm-shop__filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    margin-bottom: 4px;
    padding: 0 16px;
    border: 1px solid var(--gray-400);
    border-radius: var(--radius-md);
    background: var(--white);
    color: var(--navy-700);
    font: 600 14px/1 var(--font-body);
    cursor: pointer;
}

.igm-shop__filter-toggle::after {
    content: "\25BE";
    font-size: 11px;
}

.igm-shop__filter-toggle[aria-expanded="true"]::after {
    content: "\25B4";
}

@media (max-width: 899px) {
    .igm-shop__sidebar {
        display: none;
    }

    .igm-shop__sidebar.is-open {
        display: block;
    }
}

@media (min-width: 900px) {
    .igm-shop__filter-toggle {
        display: none;
    }
}

/* Toolbar ----------------------------------------------------------------- */

.igm-shop-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

.igm-shop-tools .woocommerce-result-count {
    margin: 0;
    font: 13px/1.4 var(--font-body);
    color: var(--gray-600);
}

.igm-shop-tools .woocommerce-ordering select {
    min-height: 44px;
    padding: 8px 12px;
    border: 1px solid var(--gray-400);
    border-radius: var(--radius-md);
    font: 13px/1 var(--font-body);
}

/* Filters ----------------------------------------------------------------- */

.igm-facets {
    display: grid;
    gap: 18px;
}

.igm-facet-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}

.igm-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    border: 1px solid var(--navy-700);
    border-radius: var(--radius-pill);
    background: var(--brand-tint-08);
    font: 600 12px/1 var(--font-body);
    color: var(--navy-700);
}

.igm-chip__remove {
    border: 0;
    background: none;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
}

/* Grid -------------------------------------------------------------------- */

.igm-products {
    display: grid;
    gap: 14px;
    margin: 0;
    padding: 0;
    list-style: none;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 640px) {
    .igm-products { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/*
 * Desktop is a fixed six-column rail (2 on mobile, 3 on tablet, 6 here) so a
 * product grid is the same shape everywhere it appears — homepage rails, the
 * shop, related products under an article or a product.
 *
 * The one exception is a grid sharing its row with the 260px filter sidebar:
 * six columns there produced 155px cards, narrower than their own Add-to-cart
 * button, with wrapped titles and clipped prices. That case keeps the
 * auto-fill behaviour with a floor, so cards stay legible instead of being
 * counted out into a space that cannot hold them.
 */
@media (min-width: 1024px) {
    .igm-products {
        grid-template-columns: repeat(6, minmax(0, 1fr));
    }

    .igm-shop--sidebar .igm-products {
        grid-template-columns: repeat(auto-fill, minmax(var(--igm-card-min, 230px), 1fr));
    }
}

/* Reflects loading state during an AJAX page/filter change. */
.igm-products[aria-busy="true"] {
    opacity: .5;
    pointer-events: none;
    transition: opacity .2s var(--ease-standard);
}

/* Product card ------------------------------------------------------------ */

.igm-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--white);
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: var(--transition-fast);
}

.igm-product-card:hover {
    border-color: var(--navy-700);
    box-shadow: var(--shadow-card);
}

.igm-product-card__media {
    position: relative;
    display: block;
    aspect-ratio: 3 / 4;
    background: var(--gradient-product-frame);
}

.igm-product-card__media img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    mix-blend-mode: multiply;
}

.igm-product-card__flags {
    position: absolute;
    inset-block-start: 8px;
    inset-inline-start: 8px;
    display: grid;
    gap: 4px;
    justify-items: start;
}

.igm-product-card__actions {
    position: absolute;
    inset-block-start: 8px;
    inset-inline-end: 8px;
    display: grid;
    gap: 6px;
    opacity: 0;
    transform: translateX(6px);
    transition: var(--transition-fast);
}

.igm-product-card:hover .igm-product-card__actions,
.igm-product-card:focus-within .igm-product-card__actions {
    opacity: 1;
    transform: none;
}

/* Touch devices have no hover; keep the actions visible instead of unreachable. */
@media (hover: none) {
    .igm-product-card__actions {
        opacity: 1;
        transform: none;
        gap: 8px;
    }
}

/* WCAG 2.5.5 wants a 44px target regardless of input modality — gating this on
   `hover: none` missed hybrid/touchscreen laptops, which report `hover: hover`
   and still get poked with a finger. The chip stays 34px visually; an invisible
   overlay carries the hit area out to 44px so the layout is unchanged. */
.igm-product-card__action {
    position: relative;
}

.igm-product-card__action::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 44px;
    height: 44px;
    transform: translate(-50%, -50%);
}

.igm-product-card__action {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-pill);
    background: var(--white);
    color: var(--gray-700);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}

.igm-product-card__action:hover,
.igm-product-card__action[aria-pressed="true"] {
    background: var(--navy-700);
    border-color: var(--navy-700);
    color: var(--white);
}

.igm-product-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 6px;
    padding: 12px 14px 14px;
}

.igm-product-card__title {
    margin: 0;
    font: 600 14px/1.35 var(--font-display);
}

.igm-product-card__title a {
    color: var(--navy-700);
}

.igm-product-card__meta {
    font: 12px/1.5 var(--font-body);
    color: var(--gray-600);
}

.igm-product-card__price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px 6px;
    margin-top: auto;
    padding-top: 6px;
    font: 700 17px/1.2 var(--font-display);
    color: var(--navy-700);
}

.igm-product-card__price del {
    font: 400 12px/1 var(--font-body);
    color: var(--gray-500);
    opacity: 1;
}

.igm-product-card__price ins {
    background: none;
    text-decoration: none;
    /* Red is reserved for an actual discount, not every price on the card. */
    color: var(--color-secondary);
}

.igm-product-card__cta {
    margin-top: 10px;
}

/* Pagination -------------------------------------------------------------- */

.igm-pagination-wrap {
    margin-top: 26px;
}

.igm-loadmore {
    display: none;
    width: 100%;
    padding: 14px;
    border: 1px solid var(--gray-400);
    border-radius: var(--radius-md);
    background: var(--white);
    font: 600 14px/1 var(--font-body);
    color: var(--navy-700);
    text-align: center;
    cursor: pointer;
}

.igm-loadmore:hover {
    background: var(--gray-100);
}

.igm-loadmore[aria-busy="true"] {
    opacity: .6;
    pointer-events: none;
}

/* Mobile (mockup 2b): "Load N more" button, no numbered pager.
   Desktop (mockup 3b): numbered pager, no load-more button. */
@media (max-width: 899px) {
    .igm-pagination-wrap .igm-pagination {
        display: none;
    }

    .igm-pagination-wrap .igm-loadmore {
        display: block;
    }
}

.igm-no-products {
    padding: 40px 20px;
    border: 1px dashed var(--gray-400);
    border-radius: var(--radius-lg);
    text-align: center;
    color: var(--gray-600);
}

.igm-shop__main {
    min-width: 0;
}

.igm-shop__sidebar {
    min-width: 0;
}

@media (min-width: 900px) {
    .igm-shop__sidebar {
        position: sticky;
        top: calc(var(--igm-header-h, 0px) + 20px);
    }
}

/* Filter panel ------------------------------------------------------------ */

.igm-facets {
    margin-bottom: 24px;
}

.igm-facets__title {
    margin: 0 0 16px;
    font: 700 18px/1.3 var(--font-display);
    color: var(--navy-700);
}

.igm-facet {
    margin: 0 0 20px;
    padding: 16px 0 0;
    border: 0;
    border-top: 1px solid var(--gray-200);
}

.igm-facet__legend {
    display: block;
    margin-bottom: 12px;
    padding: 0;
    font: 500 12px/1.2 var(--font-meta);
    letter-spacing: var(--ls-eyebrow);
    text-transform: uppercase;
    color: var(--gray-600);
}

.igm-facet__list {
    margin: 0;
    padding: 0;
    list-style: none;
    /* Long facets scroll rather than pushing the grid down the page. */
    max-height: 272px;
    overflow-y: auto;
}

.igm-facet__label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 0;
    font-size: 14px;
    color: var(--text-body);
    cursor: pointer;
}

.igm-facet__label:hover .igm-facet__name {
    color: var(--navy-700);
}

.igm-facet__name {
    flex: 1 1 auto;
    /* A long molecule name wraps instead of pushing the count out of view. */
    overflow-wrap: anywhere;
}

.igm-facet__count {
    flex: 0 0 auto;
    font: 400 12px/1 var(--font-meta);
    color: var(--gray-500);
    font-variant-numeric: tabular-nums;
}

.igm-facet__search {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    font: 400 14px/1.4 var(--font-body);
    color: var(--text-body);
}

.igm-facet__search:focus-visible {
    outline: var(--focus-outline);
    outline-offset: 1px;
}

.igm-facets__actions {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--gray-200);
}

.igm-facets__clear {
    font-size: 14px;
    color: var(--gray-600);
    text-decoration: underline;
}

.igm-facets__clear:hover {
    color: var(--red-500);
}

/* The archive grid shares its row with a 260px filter sidebar, so the 6-up
   layout only fits once the wide container has room for it. Below that the
   cards would fall to ~130px — narrower than their own Add-to-cart button.
   Full-width grids (homepage rails, search) are unaffected. */
/* Beside the filter sidebar the cards need a slightly higher floor: the
   remaining track is ~1000px, and anything under ~230px starts wrapping the
   button label again. */
@media (min-width: 1024px) {
    .igm-shop--sidebar .igm-products { --igm-card-min: 230px; }
}

/* Shop sidebar widgets ------------------------------------------------------
 *
 * The widget area sits under the filter rail, so a widget title styled as a
 * page heading competed with "Filter" above it. Widget titles now match the
 * facet legends, and the area is separated by a rule rather than by nothing.
 */

.igm-shop__sidebar .igm-widget,
.widget-area .igm-widget {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--gray-300);
}

.igm-shop__sidebar .igm-widget__title,
.widget-area .igm-widget__title {
    display: block;
    margin: 0 0 12px;
    font: 500 12px/1.2 var(--font-meta);
    letter-spacing: var(--ls-eyebrow);
    text-transform: uppercase;
    color: var(--gray-600);
}

.igm-widget ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.igm-widget li {
    margin-bottom: 4px;
}

.igm-widget li a {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    font: 400 14px/1.4 var(--font-body);
    color: var(--gray-700);
    text-decoration: none;
}

.igm-widget li a:hover {
    color: var(--navy-700);
    text-decoration: underline;
}

.igm-widget .count {
    margin-left: 6px;
    font-size: 12px;
    color: var(--gray-500);
}
