/* Keep the archive's native anchors readable when the WooCommerce theme styles are also present. */
:is(#catalog-products, #mis-related-list) .cat-card a.cat-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    line-height: 1.22;
    text-align: center;
    white-space: normal;
    overflow-wrap: normal;
}
:is(#catalog-products, #mis-related-list) .cat-price bdi { color: inherit; font: inherit; }
:is(#catalog-products, #mis-related-list) .cat-card [hidden] { display: none !important; }
:is(#catalog-products, #mis-related-list) .cat-quantity { width: 100%; }
:is(#catalog-products, #mis-related-list) [aria-disabled="true"].cat-add { cursor: progress; }

/* Extend the product link over the card while keeping the photo and purchase controls clickable. */
:is(#catalog-products, #mis-related-list) .cat-card { position: relative; isolation: isolate; }
:is(#catalog-products, #mis-related-list) .cat-card-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
}
:is(#catalog-products, #mis-related-list) .cat-card :is(.cat-image-link, .cat-add, .cat-quantity) {
    position: relative;
    z-index: 2;
}

:is(#catalog-products, #mis-related-list) .cat-card .cat-price { margin-block-start: auto; }
:is(#catalog-products, #mis-related-list) .cat-card .cat-detail { margin-block-start: 3px; }
:is(#catalog-products, #mis-related-list) .cat-quantity button { font-size: 19px; }
:is(#catalog-products, #mis-related-list) .cat-card a.cat-add:hover { color: #515151; }

.mis-pdp :is(.single_add_to_cart_button, [data-sticky-submit])[aria-busy="true"] {
    position: relative;
    cursor: progress;
}

/* Preserve the control's size while WooCommerce confirms the cart update. */
:is(.cat-add, .home-main [data-home-add], .mis-pdp .single_add_to_cart_button, .mis-pdp [data-sticky-submit])[aria-busy="true"] > .cat-add-label,
.cat-quantity[aria-busy="true"] > output { opacity: 0; }
:is(.cat-add, .home-main [data-home-add], .mis-pdp .single_add_to_cart_button, .mis-pdp [data-sticky-submit])[aria-busy="true"]::before,
.cat-quantity[aria-busy="true"]::after {
    content: "";
    position: absolute;
    inset: 0;
    width: 14px;
    height: 14px;
    margin: auto;
    box-sizing: border-box;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: mis-card-quantity-spin .7s linear infinite;
    pointer-events: none;
}
@keyframes mis-card-quantity-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    :is(.cat-add, .home-main [data-home-add], .mis-pdp .single_add_to_cart_button, .mis-pdp [data-sticky-submit])[aria-busy="true"]::before,
    .cat-quantity[aria-busy="true"]::after { animation: none; }
}

/* Only the horizontal shelf layout differs from the archive grid. */
.mis-related #mis-related-list {
    width: 100%;
    margin: 0;
    list-style: none;
}
#mis-related-list > .cat-item {
    min-width: 0;
    flex: 0 0 calc((100% - 56px) / 5);
    scroll-snap-align: start;
}
@media (max-width: 1130px) {
    #mis-related-list > .cat-item { flex-basis: calc((100% - 42px) / 4); }
}
@media (max-width: 900px) {
    #mis-related-list > .cat-item { flex-basis: calc((100% - 28px) / 3); }
}
@media (max-width: 760px) {
    #mis-related-list > .cat-item { flex-basis: calc((100% - 10px) / 2); }
}

/* The shared confirmation already links to the cart. Keep a single control in the card. */
:is(#catalog-products, #mis-related-list) .cat-card [data-cat-buy] ~ a.added_to_cart.wc-forward {
    display: none;
}
