/* Shared product cards: native WooCommerce loops and the TTS shortcode. */
:root { --tt-card-padding-x: 12px; }

html:root body :is(.tts-theme-product-card, ul.products > li.product) {
    box-sizing: border-box;
    position: relative;
    display: flex;
    flex-direction: column;
    float: none;
    clear: none;
    width: auto;
    min-width: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: 0;
    background: #fff;
    color: #252527;
    box-shadow: none;
    text-align: left;
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) > :is(.tts-theme-product-card__link, .woocommerce-LoopProduct-link, .woocommerce-loop-product__link) {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0;
    color: inherit;
    text-decoration: none;
}

/* Flatten the shortcode's extra content wrapper to use the same title/price rules. */
html:root body .tts-theme-product-card__content {
    display: contents;
}

/* A 4:5 viewport with the source scaled to card width.
 * Only images taller than the viewport need a vertical crop. */
html:root body .tts-theme-product-card__image-wrap {
    position: relative;
    display: block;
    flex: none;
    width: 100%;
    aspect-ratio: 4 / 5;
    overflow: hidden;
    border-radius: 4px 4px 0 0;
    background: #fff;
}

html:root body :is(.tts-theme-product-card__image-wrap img, ul.products > li.product > a > img) {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: auto;
    margin: 0;
    padding: 0;
    border: 0;
    object-fit: cover;
    object-position: center;
}

html:root body .tts-theme-product-card__image-wrap img {
    position: absolute;
    top: 50%;
    left: 0;
    max-height: none;
    transform: translateY(-50%);
}

/* Native WooCommerce links have no thumbnail wrapper. Reserve the first
 * row for the image and cap its height only when it exceeds that row. */
html:root body ul.products > li.product {
    container-type: inline-size;
}

html:root body ul.products > li.product > :is(.woocommerce-LoopProduct-link, .woocommerce-loop-product__link),
html:root body ul.products > li.product-category > a {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 125cqw;
    align-content: start;
    border-radius: 4px 4px 0 0;
    overflow: hidden;
}

html:root body ul.products > li.product > a > img {
    grid-area: 1 / 1;
    align-self: center;
    min-height: 0;
    max-height: 125cqw;
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) :is(.tts-theme-product-card__title, .woocommerce-loop-product__title, .woocommerce-loop-category__title) {
    box-sizing: border-box;
    position: relative;
    display: block;
    width: 100%;
    margin: 0 !important;
    padding: 12px var(--tt-card-padding-x) 0;
    border-top: 0;
    color: #252527;
    font-family: var(--tt-font-headings) !important;
    font-size: 14px !important;
    font-weight: 400 !important;
    font-style: normal !important;
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    text-align: left;
    text-transform: none !important;
    white-space: normal;
    overflow: visible;
    overflow-wrap: anywhere;
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) :is(.tts-theme-product-card__price, .price) {
    box-sizing: border-box;
    display: block;
    width: 100%;
    margin: 0;
    padding: 14px var(--tt-card-padding-x) 12px;
    color: #252527;
    font-family: var(--tt-font-body) !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    font-style: normal !important;
    line-height: 1.4 !important;
    letter-spacing: normal !important;
    text-align: left;
    text-transform: none !important;
    white-space: normal;
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) :is(.tts-theme-product-card__price, .price) :where(span, bdi, ins, del) {
    font: inherit !important;
    letter-spacing: inherit !important;
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) :is(.tts-theme-product-card__price, .price) del {
    display: inline;
    opacity: .55;
    margin-right: 6px;
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) :is(.tts-theme-product-card__price, .price) ins {
    background: transparent;
    text-decoration: none;
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) .onsale {
    position: absolute;
    z-index: 2;
    top: 12px;
    left: 12px;
    right: auto;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 8px 12px;
    border-radius: 999px;
    background: #fff;
    color: #252527;
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) > a:focus-visible {
    outline: 2px solid #1769c2;
    outline-offset: -3px;
}

@media (hover: hover) {
    html:root body :is(.tts-theme-product-card__link, .woocommerce-LoopProduct-link):hover :is(.tts-theme-product-card__title, .woocommerce-loop-product__title) {
        text-decoration: underline;
        text-underline-offset: 3px;
    }
}

@media (max-width: 768px) {
    html:root body ul.products[class*="columns-"] > li.product {
        width: 100%;
        max-width: none;
        margin: 0;
    }
    :root { --tt-card-padding-x: 8px; }
}

html:root body :is(.tts-theme-product-card, ul.products > li.product) .woocommerce-Price-amount {
    white-space: nowrap;
}
