/* Shared card component: native Woo loops and the TTS products shortcode.
 * Change appearance here; collection columns/gaps live in layout stylesheets. */
:root {
    --tt-card-radius: 22px;
    --tt-card-image-ratio: 1 / 1.18;
    --tt-card-background: #fff;
    --tt-card-ink: #101828;
    --tt-card-cutout: #eaf7ef;
    --tt-card-separator: rgba(10, 20, 35, .18);
    --tt-card-shadow: 0 14px 34px rgba(9, 23, 42, .09);
    --tt-card-padding-x: 18px;
    --tt-card-padding-top: 16px;
    --tt-card-padding-bottom: 18px;
    --tt-card-title-size: 18px;
    --tt-card-title-line-height: 1.15;
    --tt-card-title-style: italic;
    --tt-card-title-weight: var(--tt-weight-bold, 700);
    --tt-card-title-spacing: -.02em;
    --tt-card-price-size: 16px;
    --tt-card-price-line-height: 1.2;
    --tt-card-price-weight: var(--tt-weight-bold, 700);
    --tt-card-price-spacing: -.01em;
}

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: var(--tt-card-radius);
    background: var(--tt-card-background);
    color: var(--tt-card-ink);
    box-shadow: var(--tt-card-shadow);
    text-align: center;
}

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;
}

html:root body .tts-theme-product-card__image-wrap {
    display: block;
    width: 100%;
    overflow: hidden;
    background: var(--tt-card-background);
}

html:root body :is(.tts-theme-product-card__image, ul.products > li.product a img) {
    box-sizing: border-box;
    display: block;
    flex: none;
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: var(--tt-card-image-ratio);
    object-fit: cover;
    object-position: center;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: var(--tt-card-background);
}

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: var(--tt-card-padding-top) var(--tt-card-padding-x) 8px;
    border-top: 2px dashed var(--tt-card-separator);
    color: var(--tt-card-ink);
    font-family: var(--tt-font-body, sans-serif) !important;
    font-size: var(--tt-card-title-size) !important;
    font-weight: var(--tt-card-title-weight) !important;
    font-style: var(--tt-card-title-style) !important;
    line-height: var(--tt-card-title-line-height) !important;
    letter-spacing: var(--tt-card-title-spacing) !important;
    text-align: center;
    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__title, .woocommerce-loop-product__title, .woocommerce-loop-category__title)::before,
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)::after {
    content: '';
    position: absolute;
    top: -10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--tt-card-cutout);
    pointer-events: none;
}

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)::before {
    left: -9px;
}

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)::after {
    right: -9px;
}

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: 0 var(--tt-card-padding-x) var(--tt-card-padding-bottom);
    color: var(--tt-card-ink);
    font-family: var(--tt-font-body, sans-serif) !important;
    font-size: var(--tt-card-price-size) !important;
    font-weight: var(--tt-card-price-weight) !important;
    font-style: normal !important;
    line-height: var(--tt-card-price-line-height) !important;
    letter-spacing: var(--tt-card-price-spacing) !important;
    text-align: center;
    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: var(--tt-card-cutout);
    color: var(--tt-card-ink);
}

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

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    html:root body :is(.tts-theme-product-card, ul.products > li.product) {
        transition: transform 180ms ease, box-shadow 180ms ease;
    }
    html:root body :is(.tts-theme-product-card, ul.products > li.product):hover {
        transform: translateY(-3px);
        box-shadow: 0 20px 44px rgba(9, 23, 42, .12);
    }
}

/* Woo's smallscreen stylesheet gives each li 48% width and a bottom margin.
 * These cards already sit in grid tracks (including the related-product rail),
 * so they must fill the track instead of applying a second percentage width.
 * Match Woo's attribute-selector specificity without changing desktop cards. */
@media (max-width: 768px) {
    html:root body .tts-theme-product-card,
    html:root body ul.products > li.product,
    html:root body ul.products[class*="columns-"] > li.product {
        width: 100%;
        max-width: none;
        margin: 0;
        justify-self: stretch;
    }

    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, .tts-theme-product-card__price, .price) {
        text-align: left;
    }

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

@media (max-width: 640px) {
    :root {
        --tt-card-radius: 20px;
        --tt-card-image-ratio: 1 / 1.28;
        --tt-card-padding-x: 10px;
        --tt-card-padding-top: 12px;
        --tt-card-padding-bottom: 14px;
        --tt-card-title-size: 15px;
        --tt-card-title-line-height: 1.08;
        --tt-card-title-spacing: -.025em;
        --tt-card-price-size: 15px;
        --tt-card-price-line-height: 1.12;
        --tt-card-price-spacing: -.02em;
    }
}

@media (max-width: 420px) {
    :root {
        --tt-card-radius: 18px;
        --tt-card-padding-x: 9px;
        --tt-card-padding-top: 11px;
        --tt-card-padding-bottom: 13px;
        --tt-card-title-size: 14px;
        --tt-card-price-size: 14px;
    }
}

@media (max-width: 360px) {
    :root {
        --tt-card-padding-x: 8px;
        --tt-card-padding-top: 10px;
        --tt-card-padding-bottom: 12px;
        --tt-card-title-size: 13px;
        --tt-card-price-size: 13px;
    }
}
