/* Classic WooCommerce product cards on catalog archives only.
 * Keep the existing grid, card widths, images, type, colors and button margins.
 * The grid must already stretch cards to equal row heights.
 * Official structure: templates/content-product.php opens the product link,
 * renders the image/title/price, closes the link, then renders the cart button.
 */
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product:not(.product-category) {
    display: flex;
    flex-direction: column;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product:not(.product-category) > a.woocommerce-LoopProduct-link {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    min-width: 0;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product:not(.product-category) > a.woocommerce-LoopProduct-link > img {
    flex-shrink: 0;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product:not(.product-category) > a.woocommerce-LoopProduct-link > .woocommerce-loop-product__title {
    margin-top: auto;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product:not(.product-category) > a.woocommerce-LoopProduct-link > .price {
    margin-top: .875rem;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product:not(.product-category) > .button {
    align-self: flex-start;
    flex-shrink: 0;
}
/* Extension to Shop Polish: classic product archives only.
 * The existing equal-height grid and flexible product links align prices.
 * This fixed-height purchase section then aligns quantity rows and buttons.
 * Controls remain visible after enhancement on touch and pointer devices.
 */
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product:not(.product-category) > form.cb-shop-purchase {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-width: 0;
    margin: 0;
    min-height: 9rem;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase > .cb-shop-quantity {
    display: flex;
    align-items: stretch;
    align-self: flex-start;
    flex-shrink: 0;
    box-sizing: border-box;
    width: 8.75rem;
    max-width: 100%;
    min-height: 2.75rem;
    /* Match the card's normal 18px inset; reduce it only on narrow cards. */
    margin: 0.75rem clamp(0px, calc(50% - 4.375rem), 1.125rem) 0;
    border: 1px solid var(--cb-shop-quantity-border, #dfe5ef);
    border-radius: 999px;
    background: var(--cb-shop-quantity-background, #fff);
    color: inherit;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase .cb-shop-quantity > .quantity {
    display: flex;
    flex: 1 1 auto;
    min-width: 0;
    float: none;
    margin: 0;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase .cb-shop-quantity__button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 2.75rem;
    box-sizing: border-box;
    width: 2.75rem;
    min-width: 2.75rem;
    min-height: 2.75rem;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

/* Author display styles must not override the no-JavaScript hidden state. */
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase .cb-shop-quantity__button[hidden] {
    display: none !important;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase .cb-shop-quantity__input {
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    min-height: 2.75rem;
    margin: 0;
    padding: 0 0.125rem;
    border: 0;
    background: transparent;
    color: inherit;
    box-shadow: none;
    font: inherit;
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
    text-align: center;
}

/* Keep native number steppers available until the custom controls are ready. */
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase.cb-quantity-enhanced .cb-shop-quantity__input {
    -moz-appearance: textfield;
    appearance: textfield;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase.cb-quantity-enhanced .cb-shop-quantity__input::-webkit-inner-spin-button,
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase.cb-quantity-enhanced .cb-shop-quantity__input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase .cb-shop-quantity__button:hover:not(:disabled) {
    background: var(--cb-shop-quantity-hover, #fdf7e9);
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase .cb-shop-quantity__button:focus-visible,
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase .cb-shop-quantity__input:focus-visible {
    outline: 2px solid var(--cb-gold, #d99b20);
    outline-offset: -3px;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase .cb-shop-quantity__button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase[aria-busy="true"] {
    cursor: progress;
}

body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase > .button.cb-shop-submit {
    align-self: flex-start;
    flex-shrink: 0;
    /* Preserve the theme's remaining button margins, size, type and colors. */
    margin-top: 0.75rem;
}

/* Confirmed cart quantities remain visible in the brand's dark navy. */
.cb-shop-purchase [hidden] { display: none !important; }
.cb-shop-purchase .cb-shop-cart-label,
.cb-shop-purchase .cb-shop-bonus,
.cb-shop-purchase .cb-shop-manage,
.cb-shop-purchase .cb-shop-feedback:not(.screen-reader-text) {
    margin: .55rem clamp(0px, calc(50% - 4.375rem), 1.125rem) 0;
    font-size: .85rem;
    line-height: 1.4;
}
.cb-shop-purchase .cb-shop-cart-label { font-weight: 700; }
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase.is-in-cart > .cb-shop-quantity {
    background: #111b2e;
    border-color: #111b2e;
    color: #fff;
}
.cb-shop-purchase.is-in-cart .cb-shop-quantity input,
.cb-shop-purchase.is-in-cart .cb-shop-quantity button { color: #fff; }
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products > li.product > form.cb-shop-purchase.is-in-cart .cb-shop-quantity button:hover:not(:disabled) { background: #28344a; }
.cb-shop-purchase .cb-shop-bonus { color: #225c46; font-weight: 700; }
.cb-shop-purchase .cb-shop-feedback:not(.screen-reader-text) { color: #8b2525; }


/* A distinct hummingbird turquoise separates prices from navy product names. */
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products li.product .price,
body:is(.post-type-archive-product, .tax-product_cat, .tax-product_tag) ul.products li.product .price .woocommerce-Price-amount {
    color: #087f8c !important;
    font-variant-numeric: tabular-nums;
}
.cb-shop-currency[hidden] { display: none !important; }
.cb-shop-currency {
    clear: both;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin: 0 0 1.25rem;
    padding: .85rem 1rem;
    border: 1px solid #d6e8eb;
    border-radius: 16px;
    background: #f5fafb;
}
.cb-shop-currency__options {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}
.cb-shop-currency__options legend {
    margin-bottom: .3rem;
    padding: 0;
    color: #111b2e;
    font-size: .8rem;
    font-weight: 700;
}
.cb-shop-currency__options button {
    min-width: 4rem;
    min-height: 2.75rem;
    padding: .5rem .85rem;
    border: 1px solid #c4d9dd;
    border-radius: 999px;
    background: #fff;
    color: #111b2e;
    font: inherit;
    font-size: .9rem;
    font-weight: 700;
    cursor: pointer;
}
.cb-shop-currency__options button[aria-pressed="true"] {
    background: #087f8c;
    border-color: #087f8c;
    color: #fff;
}
.cb-shop-currency__options button:focus-visible {
    outline: 2px solid #d99b20;
    outline-offset: 3px;
}
.cb-shop-currency__note { margin: 0; color: #46516a; font-size: .8rem; line-height: 1.5; }
@media (max-width: 650px) {
    .cb-shop-currency { align-items: flex-start; flex-direction: column; gap: .6rem; }
}
