/*
 * Matrix Detail Block
 *
 * Hero + spec table. Keep the markup recognizable: a matrix page is an
 * interactive version of a printed catalog page, so the table reads
 * like a catalog — rows of variants with their specs, ending in price
 * and an action column.
 */

.ims-matrix-detail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin: 0 0 3rem;
}

/* -----------------------------------------------------------------------
 * Archive layout collapse on a matrix-swapped category page
 * -----------------------------------------------------------------------
 *
 * The product archive template (templates/archive-product.html) lays
 * out a two-column grid: a filter sidebar on the left and the product
 * loop on the right. On a matrix-swapped category the filters block
 * bails (it doesn't apply — the matrix-detail block has its own per-
 * spec dropdowns) but the surrounding `ims-filter-sidebar-wrapper`
 * group still renders as an empty column. Body-class targeting lets
 * us collapse that wrapper and stretch the products column full
 * width without touching the template markup itself.
 */
body.ims-matrix-view .ims-filter-sidebar-wrapper {
    display: none;
}
body.ims-matrix-view .ims-product-listing-layout {
    display: block;
}
body.ims-matrix-view .ims-products-main {
    width: 100%;
    margin-block-start: 0;
}

/* Matrix-mode header. Title / short description live in the matrix
 * hero immediately under the breadcrumbs, so this header must not
 * occupy a band of empty space. Collapse it out of flow and pin the
 * view toggle to the top-right of the heading row.
 */
.ims-product-listing-header--matrix {
    position: relative;
    height: 0;
    margin: 0;
    padding: 0;
    overflow: visible;
    z-index: 2;
}
.ims-product-listing-header--matrix .ims-page-title-row {
    position: absolute;
    top: 0.35rem;
    right: 0;
    justify-content: flex-end;
    padding: 0;
    border-bottom: 0;
}

.ims-product-listing-header--matrix .ims-view-toggle-wrap {
    position: relative;
    display: inline-block;
}

/* Callout under the view toggle. Hidden until JS confirms the visitor
 * has not opted out (localStorage) or already dismissed this session. */
.ims-matrix-view-tip {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 20;
    width: 260px;
    padding: 0.85rem 0.95rem 0.8rem;
    background: #111827;
    color: #f9fafb;
    border-radius: 8px;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
    text-align: left;
}

.ims-matrix-view-tip::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 18px;
    width: 12px;
    height: 12px;
    background: #111827;
    transform: rotate(45deg);
}

.ims-matrix-view-tip__title {
    margin: 0 0 0.35rem;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.ims-matrix-view-tip__body {
    margin: 0 0 0.7rem;
    font-size: 0.75rem;
    line-height: 1.45;
    color: #e5e7eb;
}

.ims-matrix-view-tip__actions {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
}

.ims-matrix-view-tip__dismiss,
.ims-matrix-view-tip__never {
    appearance: none;
    border: 0;
    cursor: pointer;
    padding: 0;
    background: none;
    font: inherit;
}

.ims-matrix-view-tip__dismiss {
    border-radius: 6px;
    padding: 0.35rem 0.65rem;
    background: var(--color-cta, #FAB000);
    color: #111827;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}

.ims-matrix-view-tip__dismiss:hover {
    filter: brightness(0.96);
}

.ims-matrix-view-tip__never {
    color: #d1d5db;
    font-size: 0.7rem;
    font-weight: 500;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ims-matrix-view-tip__never:hover {
    color: #f9fafb;
}

.ims-matrix-view-tip__dismiss:focus-visible,
.ims-matrix-view-tip__never:focus-visible {
    outline: 2px solid var(--color-gold-light, #FDE17F);
    outline-offset: 2px;
}

/* -----------------------------------------------------------------------
 * Hero
 * ----------------------------------------------------------------------- */

/* Root class is `ims-mx-hero` (not `ims-matrix-hero`) on purpose.
 * v2.49.3 CSS applied `display:grid; grid-template-columns: 220px 1fr`
 * to `.ims-matrix-hero`. After the heading moved out into its own
 * child, that stale rule jammed the title into the 220px column and
 * blew the image up on the right — and it kept winning until a hard
 * refresh fetched the new stylesheet. A new class name means a cached
 * old stylesheet cannot match this element. */
.ims-mx-hero {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 0.35rem 0 0.75rem;
    border-bottom: 1px solid #e5e7eb;
}

/* SKU + title + short description sit full-width under the breadcrumbs
 * so they fill the space the listing header used to occupy. Leave room
 * on the right for the floated view toggle. */
.ims-matrix-hero-heading {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding-right: 7.5rem;
}

.ims-matrix-hero-title-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* Image + long description share a row under the heading.
 * Media column is 360px so the hero drawing sits closer to the
 * spec list without crowding it. */
.ims-matrix-hero-main {
    --ims-matrix-hero-media: 360px;
    display: grid;
    grid-template-columns: minmax(0, var(--ims-matrix-hero-media)) 1fr;
    gap: 2rem;
    align-items: start;
}

/* No image set on the term — long description takes the full row. */
.ims-mx-hero--no-media .ims-matrix-hero-main {
    grid-template-columns: 1fr;
}

.ims-matrix-hero-media {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 0.75rem;
}

/* Clickable hero — opens the full-image lightbox.
 * Fixed square frame: gallery images have different natural aspect
 * ratios, so without a locked height the box would grow/shrink on
 * every thumbnail click and bounce the thumbnail strip below it. */
.ims-matrix-hero-zoom {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    cursor: zoom-in;
    border-radius: 8px;
    line-height: 0;
}

.ims-matrix-hero-zoom:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

.ims-matrix-hero-zoom-hint {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e5e7eb;
    color: #111827;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.ims-matrix-hero-zoom:hover .ims-matrix-hero-zoom-hint,
.ims-matrix-hero-zoom:focus-visible .ims-matrix-hero-zoom-hint {
    opacity: 1;
}

/* Fill the square frame and letterbox the image inside it, centered
 * both ways — swapping to a taller/wider image never resizes the box. */
.ims-matrix-hero-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    border-radius: 8px;
    background: #fff;
    border: 1px solid #e5e7eb;
    padding: 12px;
    display: block;
}

/* Thumbnail strip under the hero image. Always a single horizontal
 * row; arrows appear only when the track actually overflows. */
.ims-matrix-gallery {
    display: flex;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 100%;
    max-width: 100%;
}

.ims-matrix-gallery-track {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    gap: 6px;
    min-width: 0;
    flex: 1 1 auto;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.ims-matrix-gallery-track::-webkit-scrollbar {
    display: none;
}

.ims-matrix-gallery-thumb {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    padding: 3px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    scroll-snap-align: start;
    transition: border-color 0.15s ease;
}

.ims-matrix-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.ims-matrix-gallery-thumb:hover {
    border-color: #9ca3af;
}

.ims-matrix-gallery-thumb.is-active {
    border-color: #111827;
}

.ims-matrix-gallery-nav {
    flex: 0 0 auto;
    width: 22px;
    height: 48px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: #fff;
    color: #111827;
    cursor: pointer;
}

.ims-matrix-gallery-nav:hover:not(:disabled) {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.ims-matrix-gallery-nav:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 1px;
}

.ims-matrix-gallery-nav:disabled {
    opacity: 0.35;
    cursor: default;
}

.ims-matrix-gallery-nav[hidden] {
    display: none;
}

.ims-matrix-hero-title {
    display: flex;
    align-items: center;
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.15;
    color: #111111;
    text-transform: uppercase;
}

.ims-mx-hero[style*="--ims-cat-accent"] .ims-matrix-hero-title {
    padding-left: 0.75rem;
    border-left: 4px solid var(--ims-cat-accent);
}

.ims-matrix-hero-count {
    margin: 0;
    font-size: 12.5px;
    font-weight: 400;
    color: var(--ims-text-secondary, #6b7280);
}

.ims-matrix-hero-blurb {
    font-size: 1rem;
    color: #4b5563;
    line-height: 1.5;
    margin: 0;
}

/* -----------------------------------------------------------------------
 * Long description
 * ----------------------------------------------------------------------- */

.ims-matrix-long-desc {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
    min-width: 0;
}

.ims-matrix-long-desc p:first-child,
.ims-matrix-long-desc ul:first-child,
.ims-matrix-long-desc ol:first-child { margin-top: 0; }
.ims-matrix-long-desc p:last-child,
.ims-matrix-long-desc ul:last-child,
.ims-matrix-long-desc ol:last-child  { margin-bottom: 0; }

.ims-matrix-long-desc ul,
.ims-matrix-long-desc ol {
    margin: 0;
    padding-left: 1.2em;
}

/* -----------------------------------------------------------------------
 * Filter meta bar
 *
 * Slim strip above the table holding the result count and Clear button.
 * Dropdowns live IN the table thead (below), aligned per column.
 * ----------------------------------------------------------------------- */

.ims-matrix-filter-meta {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 0.75rem;
    padding: 0 0.25rem 0.25rem;
}

.ims-matrix-filter-count {
    font-size: 0.8rem;
    color: #6b7280;
    padding: 0.15rem 0.4rem;
    margin-left: -0.4rem;
    border-radius: 4px;
}

/* Soft amber pulse behind the count each time the result number
 * changes (class re-applied from frontend.js after a reflow so the
 * animation restarts even on rapid keystrokes). */
@keyframes ims-matrix-count-pulse {
    0% { background-color: rgba(251, 191, 36, 0); }
    30% { background-color: rgba(251, 191, 36, 0.5); }
    100% { background-color: rgba(251, 191, 36, 0); }
}

.ims-matrix-filter-count.is-pulsing {
    animation: ims-matrix-count-pulse 0.8s ease-out;
}

@media (prefers-reduced-motion: reduce) {
    .ims-matrix-filter-count.is-pulsing {
        animation: none;
    }
}

.ims-matrix-filter-clear {
    font-size: 0.72rem;
    font-weight: 600;
    color: #4f46e5;
    background: transparent;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ims-matrix-filter-clear:hover {
    background: #eef2ff;
    border-color: #a5b4fc;
}

/* -----------------------------------------------------------------------
 * Thead filter row (dropdowns aligned per column)
 * ----------------------------------------------------------------------- */

.ims-matrix-filter-row {
    background: #f3f4f6;
}

.ims-matrix-filter-cell {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid #e5e7eb;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
}

.ims-matrix-filter-cell--empty {
    padding: 0.5rem;
}

.ims-matrix-filter-select {
    width: 100%;
    min-width: 5rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 0.85rem;
    color: #111827;
    line-height: 1.2;
}

.ims-matrix-filter-select:focus {
    outline: 2px solid #6366f1;
    outline-offset: 1px;
    border-color: #6366f1;
}

.ims-matrix-filter-select option[disabled] {
    color: #d1d5db;
}

.ims-matrix-sku-filter {
    width: 100%;
    min-width: 4.5rem;
    max-width: 7.5rem;
    padding: 0.4rem 0.55rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #fff;
    font-size: 0.85rem;
    color: #111827;
    line-height: 1.2;
}

.ims-matrix-sku-filter:focus {
    outline: 2px solid #6366f1;
    outline-offset: 1px;
    border-color: #6366f1;
}

/* Flashed briefly when a keystroke is rejected because no part number
   in the table starts with the resulting digits. */
.ims-matrix-sku-filter.is-rejected {
    border-color: #dc2626;
    outline: 2px solid #dc2626;
    outline-offset: 1px;
}

.ims-matrix-filter-static-value {
    display: inline-block;
    font-size: 0.8rem;
    color: #6b7280;
    font-style: italic;
}

/* Rows hidden by the filter. Using display:none instead of visibility
 * so their height collapses — the table reflows as if the rows were
 * removed. */
.ims-matrix-row.is-filtered-out {
    display: none;
}

/* -----------------------------------------------------------------------
 * Table
 * ----------------------------------------------------------------------- */

.ims-matrix-table-wrap {
    width: 100%;
    overflow-x: auto;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.ims-matrix-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.ims-matrix-table thead {
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.ims-matrix-th {
    text-align: left;
    font-weight: 600;
    color: #374151;
    padding: 0.55rem 0.75rem;
    white-space: nowrap;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid #e5e7eb;
}

.ims-matrix-unit {
    font-weight: 400;
    color: #9ca3af;
    margin-left: 0.25rem;
    text-transform: none;
    letter-spacing: 0;
}

/* Sortable column header.
 *
 * The <button> is transparent and inherits typography from the <th> so it
 * reads as a plain column label. It's inline-flex so the label + indicator
 * stay on one line; the th's `text-align` controls which side of the cell
 * the whole button sits on (right-aligned for O.D., etc.). */
.ims-matrix-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0;
    margin: 0;
    background: transparent;
    border: 0;
    font: inherit;
    color: inherit;
    text-transform: inherit;
    letter-spacing: inherit;
    cursor: pointer;
    line-height: 1.1;
}

.ims-matrix-sort-btn:hover .ims-matrix-sort-label {
    color: #111827;
}

.ims-matrix-sort-btn:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
    border-radius: 3px;
}

.ims-matrix-sort-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    opacity: 0.45;
    transition: opacity 120ms ease;
}

.ims-matrix-sort-btn:hover .ims-matrix-sort-indicator {
    opacity: 0.8;
}

.ims-matrix-sort-icon {
    display: block;
}

/* Default both arrows dimmed; active direction gets darkened via state
 * classes below. `currentColor` + per-path opacity lets us keep one SVG. */
.ims-matrix-sort-icon-up,
.ims-matrix-sort-icon-down {
    opacity: 0.45;
}

.ims-matrix-th--sortable.is-sorted-asc .ims-matrix-sort-indicator,
.ims-matrix-th--sortable.is-sorted-desc .ims-matrix-sort-indicator {
    opacity: 1;
}

.ims-matrix-th--sortable.is-sorted-asc .ims-matrix-sort-icon-up {
    opacity: 1;
    color: #4f46e5;
}

.ims-matrix-th--sortable.is-sorted-desc .ims-matrix-sort-icon-down {
    opacity: 1;
    color: #4f46e5;
}

.ims-matrix-td {
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid #f3f4f6;
    color: #111827;
    vertical-align: middle;
    white-space: nowrap;
    font-size: 0.85rem;
    line-height: 1.3;
}

.ims-matrix-row:last-child .ims-matrix-td {
    border-bottom: 0;
}

.ims-matrix-row:hover {
    background: #fafafa;
}

/* Highlight the row currently shown in the quick-info modal. Mirrors
 * the card highlight in product-listing-grid/style.css so the user sees
 * which row they're previewing as they arrow-key through the table. */
.ims-matrix-row.qv-active,
.ims-matrix-row.qv-active:hover {
    background: var(--color-gold-light, #fff4d6);
    box-shadow: inset 3px 0 0 var(--color-cta, #FAB000);
}

.ims-matrix-align-left   { text-align: left; }
.ims-matrix-align-right  { text-align: right; }
.ims-matrix-align-center { text-align: center; }

.ims-matrix-td--sku {
    font-size: 0.85rem;
    color: #374151;
}

/* Site-wide part-number badge, compacted for the table context. Keeps
 * the gold pill + shield icon + "Item #" label so it reads as the same
 * component used in cart/quote drawers and checkout — just sized down
 * to fit the tighter row height. */
/* Matrix table sku link inherits sizing from the canonical
   .ims-part-number-badge (mini cart size) — only link-specific styles here. */
.ims-matrix-sku-link.ims-part-number-badge {
    text-decoration: none;
    transition: filter 120ms ease;
}

.ims-matrix-sku-link.ims-part-number-badge:hover {
    filter: brightness(0.96);
}

.ims-matrix-td--price {
    font-weight: 600;
    color: #111827;
}

/* Quote-only rows: a compact "i" stands in for the long RFQ label so the
 * price column can stay as narrow as a dollar amount. The popover itself
 * is portaled to <body> (see frontend.js) because .ims-matrix-table-wrap
 * clips overflow. */
.ims-matrix-rfq {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
}

.ims-matrix-rfq-btn {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #111;
    color: #fff;
    font-family: Georgia, "Times New Roman", serif;
    font-size: 11px;
    font-style: italic;
    font-weight: 700;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    vertical-align: middle;
    transition: background-color 0.15s;
}

.ims-matrix-rfq-btn:hover,
.ims-matrix-rfq-btn[aria-expanded="true"] {
    background: #374151;
}

.ims-matrix-rfq-btn:focus-visible {
    outline: 2px solid var(--color-cta, #FAB000);
    outline-offset: 2px;
}

.ims-matrix-rfq-tip {
    position: fixed;
    top: 0;
    left: -9999px;
    z-index: 10020;
    max-width: min(240px, calc(100vw - 24px));
    padding: 8px 12px;
    background: #fff;
    color: #111;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    border: 1px solid var(--color-border, #E8EAED);
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(17, 17, 17, 0.12);
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.12s ease;
}

.ims-matrix-rfq-tip.is-visible {
    opacity: 1;
    visibility: visible;
}

.ims-matrix-rfq-tip::before,
.ims-matrix-rfq-tip::after {
    content: "";
    position: absolute;
    left: var(--caret-left, 50%);
    width: 0;
    height: 0;
    border-style: solid;
    transform: translateX(-50%);
}

.ims-matrix-rfq-tip:not(.is-below)::before,
.ims-matrix-rfq-tip:not(.is-below)::after {
    top: 100%;
}

.ims-matrix-rfq-tip:not(.is-below)::before {
    border-width: 7px 7px 0 7px;
    border-color: var(--color-border, #E8EAED) transparent transparent transparent;
}

.ims-matrix-rfq-tip:not(.is-below)::after {
    margin-top: -1px;
    border-width: 6px 6px 0 6px;
    border-color: #fff transparent transparent transparent;
}

.ims-matrix-rfq-tip.is-below::before,
.ims-matrix-rfq-tip.is-below::after {
    bottom: 100%;
}

.ims-matrix-rfq-tip.is-below::before {
    border-width: 0 7px 7px 7px;
    border-color: transparent transparent var(--color-border, #E8EAED) transparent;
}

.ims-matrix-rfq-tip.is-below::after {
    margin-bottom: -1px;
    border-width: 0 6px 6px 6px;
    border-color: transparent transparent #fff transparent;
}

.ims-matrix-empty-val {
    color: #cbd5e1;
}

/* Actions cell — single-line compact control strip. Buttons reuse the
 * site-wide .ims-add-to-cart / .ims-add-to-quote classes so the global
 * click handlers bind without extra wiring; the overrides below scope
 * ONLY to the matrix context via `.ims-matrix-atc`. */

.ims-matrix-td--actions {
    white-space: nowrap;
    padding: 0.3rem 0.6rem;
    text-align: right;
}

.ims-matrix-atc {
    display: inline-flex;
    gap: 0.35rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: nowrap;
    margin: 0;
}

/* Compact quantity selector — reuses .ims-quantity-wrapper visuals
 * (rounded 1px border, dividers between cells) from product-listing.css
 * but shrinks the touch targets. */
.ims-matrix-atc .ims-quantity-wrapper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--color-border, #d1d5db);
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    height: 1.75rem;
}

.ims-matrix-atc .ims-quantity-btn {
    width: 1.5rem;
    height: 1.75rem;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: 0;
    cursor: pointer;
    color: #111827;
    line-height: 1;
}
.ims-matrix-atc .ims-quantity-btn:hover { background: #e5e7eb; }
.ims-matrix-atc .ims-quantity-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.ims-matrix-atc .ims-quantity-input {
    width: 2rem;
    height: 1.75rem;
    padding: 0;
    border: 0;
    border-left: 1px solid var(--color-border, #d1d5db);
    border-right: 1px solid var(--color-border, #d1d5db);
    border-radius: 0;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: #111827;
    background: #fff;
    -moz-appearance: textfield;
}
.ims-matrix-atc .ims-quantity-input::-webkit-outer-spin-button,
.ims-matrix-atc .ims-quantity-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Cart + Quote buttons — override the 180px-wide, 0.625rem/1.5rem padding
 * default from product-listing.css. Keep the same colours/border so they
 * read as the same buttons, just compact. */

.ims-matrix-atc .ims-add-to-cart,
.ims-matrix-atc .ims-add-to-quote {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-width: 0;
    width: auto;
    padding: 0 0.6rem;
    height: 1.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.ims-matrix-btn-icon {
    display: block;
    flex: 0 0 auto;
}

.ims-matrix-btn-label {
    display: inline-block;
}

/* -----------------------------------------------------------------------
 * Empty / preview
 * ----------------------------------------------------------------------- */

.ims-matrix-empty {
    padding: 2rem;
    text-align: center;
    color: #6b7280;
    border: 1px dashed #e5e7eb;
    border-radius: 10px;
    background: #fafafa;
}

.ims-matrix-preview-note {
    margin: 0;
    font-size: 0.8rem;
    color: #6b7280;
    font-style: italic;
}

.ims-matrix-detail--preview {
    outline: 1px dashed #c7d2fe;
    outline-offset: 4px;
}

/* -----------------------------------------------------------------------
 * Responsive
 *
 * Below the breakpoint, the hero stacks and the table keeps its
 * horizontal scroll (.ims-matrix-table-wrap handles overflow). On very
 * narrow screens the action column's ATC row reflows under the qty
 * controls so buttons don't get clipped.
 * ----------------------------------------------------------------------- */

@media (max-width: 768px) {
    .ims-matrix-hero-heading {
        padding-right: 6.5rem;
    }

    .ims-matrix-hero-main {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .ims-matrix-hero-media {
        justify-content: flex-start;
    }

    .ims-matrix-hero-zoom,
    .ims-matrix-hero-img {
        max-width: 280px;
    }

    .ims-matrix-hero-title {
        font-size: 20px;
    }

    .ims-matrix-th,
    .ims-matrix-td {
        padding: 0.7rem 0.75rem;
    }
}

@media (max-width: 520px) {
    /* Hide the button text on tiny screens; the icon + aria-label still
     * convey the action. */
    .ims-matrix-btn-label {
        display: none;
    }

    .ims-matrix-atc .ims-add-to-cart,
    .ims-matrix-atc .ims-add-to-quote {
        padding: 0 0.45rem;
    }

    .ims-matrix-filter-select,
    .ims-matrix-sku-filter {
        font-size: 0.8rem;
        padding: 0.35rem 0.5rem;
    }
}

/* =============================================================
 * Per-product NetSuite Minimum Order Quantity inline note.
 * Sits in the same actions cell as the matrix row's qty stepper,
 * directly below .ims-matrix-atc (which is inline-flex / nowrap
 * and would clip the note if nested inside it). Each row resolves
 * the message off its own product id so siblings render
 * independently — empty cells contribute no extra height.
 * ============================================================= */
.ims-matrix-td--actions .ims-matrix-min-note {
    display: block;
    margin-top: 4px;
    font-size: 0.7rem;
    line-height: 1.3;
    color: #6b7280;
    text-align: right;
}

/* -----------------------------------------------------------------------
 * Full-image lightbox
 *
 * Injected once into <body> by frontend.js. Opens from the hero image
 * (or any thumbnail) so the visitor can inspect the original attachment.
 * ----------------------------------------------------------------------- */

body.ims-matrix-lightbox-open {
    overflow: hidden;
}

.ims-matrix-lightbox {
    position: fixed;
    inset: 0;
    z-index: 10020;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.ims-matrix-lightbox.is-open {
    display: flex;
}

.ims-matrix-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
}

.ims-matrix-lightbox-dialog {
    position: relative;
    z-index: 1;
    max-width: min(1100px, 100%);
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ims-matrix-lightbox-img {
    display: block;
    max-width: min(1100px, calc(100vw - 48px));
    max-height: 90vh;
    width: auto;
    height: auto;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
}

.ims-matrix-lightbox-close,
.ims-matrix-lightbox-nav {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(0, 0, 0, 0.15);
    background: #fff;
    color: #111827;
    cursor: pointer;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.28);
}

.ims-matrix-lightbox-close {
    top: -12px;
    right: -12px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 22px;
    line-height: 1;
    z-index: 2;
}

.ims-matrix-lightbox-nav {
    top: 50%;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    transform: translateY(-50%);
}

.ims-matrix-lightbox-nav--prev {
    left: -56px;
}

.ims-matrix-lightbox-nav--next {
    right: -56px;
}

.ims-matrix-lightbox-close:hover,
.ims-matrix-lightbox-nav:hover {
    background: var(--color-gold-light, #FDE17F);
    border-color: var(--color-cta, #FAB000);
}

.ims-matrix-lightbox-close:focus-visible,
.ims-matrix-lightbox-nav:focus-visible {
    outline: 2px solid var(--color-cta, #FAB000);
    outline-offset: 3px;
}

.ims-matrix-lightbox-nav[hidden] {
    display: none;
}

@media (max-width: 768px) {
    .ims-matrix-lightbox-nav--prev {
        left: 8px;
    }

    .ims-matrix-lightbox-nav--next {
        right: 8px;
    }

    .ims-matrix-lightbox-close {
        top: 8px;
        right: 8px;
    }
}
