/* Etsy-style listing badges — shop grid + homepage featured cards */

.woocommerce ul.products li.product,
.woocommerce-page ul.products li.product {
    position: relative;
}

.woocommerce ul.products li.product > a:first-child,
.woocommerce-page ul.products li.product > a:first-child {
    position: relative;
    display: block;
}

.product-img,
.woocommerce ul.products li.product a:has(img) {
    position: relative;
}

.mocha-listing-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: calc(100% - 16px);
    font-family: var(--ms-font-body, 'Be Vietnam Pro', system-ui, sans-serif);
    font-size: 11px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0;
    text-transform: none;
    padding: 4px 8px;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
    white-space: nowrap;
    overflow: visible;
    cursor: default;
}

.mocha-listing-badge--bestseller {
    background: #fdebd0;
    color: #222;
}

.mocha-listing-badge--popular {
    background: #ffe8d9;
    color: #5c3111;
}

.mocha-listing-badge--pick {
    background: #e8f0f7;
    color: #1a3a52;
}

.mocha-listing-badge--new {
    background: #e6f4ea;
    color: #1e4d2b;
}

.mocha-listing-badge--default {
    background: rgba(255, 255, 255, 0.92);
    color: #222;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.mocha-listing-badge__icon {
    width: 12px;
    height: 12px;
    flex: 0 0 12px;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 16.8l-6.2 4.5 2.4-7.4L2 9.4h7.6z'/%3E%3C/svg%3E") center / contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23000' d='M12 2l2.4 7.4H22l-6.2 4.5 2.4 7.4L12 16.8l-6.2 4.5 2.4-7.4L2 9.4h7.6z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.mocha-listing-badge__tooltip {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    min-width: 220px;
    max-width: 280px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fff;
    color: #222;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    white-space: normal;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.14);
    border: 1px solid rgba(0, 0, 0, 0.08);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
    z-index: 5;
    pointer-events: none;
}

.mocha-listing-badge:hover .mocha-listing-badge__tooltip,
.mocha-listing-badge:focus .mocha-listing-badge__tooltip,
.mocha-listing-badge:focus-within .mocha-listing-badge__tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mocha-pdp-listing-badge {
    top: 12px;
    left: 12px;
}

.woocommerce-product-gallery.mocha-has-listing-badge,
.single-product .woocommerce-product-gallery {
    position: relative;
}

.single-product .woocommerce-product-gallery .mocha-pdp-listing-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 4;
}

/* Sale badge — top-right */
.woocommerce span.onsale,
.woocommerce ul.products li.product .onsale {
    top: var(--ms-space-4);
    right: var(--ms-space-4);
    left: auto;
    z-index: 3;
}

/* Loop star rating */
/* Hide duplicate WC star row when our compact rating is present */
.woocommerce ul.products li.product > a .star-rating {
    display: none !important;
}

.mocha-loop-rating {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 8px;
    min-height: 18px;
}

.mocha-loop-rating .star-rating {
    float: none;
    margin: 0;
    font-size: 14px;
    width: 5.2em;
}

.mocha-loop-rating__count {
    font-size: 12px;
    color: var(--ms-on-surface-variant, #6b7280);
}

/* Hover video on listing cards */
.mocha-listing-media {
    position: relative;
    display: block;
    overflow: hidden;
}

.mocha-listing-media img {
    display: block;
    width: 100%;
    transition: opacity 0.2s ease;
}

.mocha-listing-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    background: #f8f9fa;
}

.mocha-listing-media.is-video-active .mocha-listing-video {
    opacity: 1;
}

.mocha-listing-media.is-video-active > img {
    opacity: 0;
}

.product-card .mocha-listing-media {
    aspect-ratio: 1;
}

.product-card .mocha-listing-media img,
.product-card .mocha-listing-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* PDP gallery video thumb + stage */
.flex-control-nav.flex-control-thumbs .mocha-video-thumb {
    position: relative;
    cursor: pointer;
}

.flex-control-nav.flex-control-thumbs .mocha-video-thumb img {
    display: block;
    width: 100%;
    height: auto;
}

.mocha-video-thumb__play {
    position: absolute;
    inset: 0;
    margin: auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

.mocha-video-thumb__play::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 54%;
    transform: translate(-50%, -50%);
    border-style: solid;
    border-width: 6px 0 6px 10px;
    border-color: transparent transparent transparent #222;
}

.woocommerce-product-gallery.is-video-mode .flex-viewport .woocommerce-product-gallery__image {
    visibility: hidden;
}

.mocha-gallery-video-stage {
    position: absolute;
    inset: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #111;
}

.mocha-gallery-video-stage[hidden] {
    display: none !important;
}

.mocha-gallery-video-el {
    width: 100%;
    height: 100%;
    max-height: 100%;
    object-fit: contain;
    background: #111;
}

/* Lightbox video */
.mc-lb__video {
    width: 100%;
    height: 100%;
    max-height: var(--mc-lb-h, 80vh);
    object-fit: contain;
    background: #111;
}

.mc-lb__thumb.is-video::after {
    content: '';
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.mc-lb__thumb.is-video::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 53%;
    transform: translate(-50%, -50%);
    z-index: 1;
    border-style: solid;
    border-width: 5px 0 5px 8px;
    border-color: transparent transparent transparent #222;
}

/* === Shop listing — mobile tidy === */
@media (max-width: 768px) {
    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 10px !important;
    }

    .woocommerce ul.products li.product,
    .woocommerce-page ul.products li.product {
        padding: 8px !important;
        border-radius: 10px;
    }

    .woocommerce ul.products li.product:hover,
    .woocommerce-page ul.products li.product:hover {
        transform: none;
        box-shadow: none;
    }

    .woocommerce ul.products li.product a img,
    .woocommerce-page ul.products li.product a img,
    .woocommerce ul.products li.product .mocha-listing-media,
    .woocommerce-page ul.products li.product .mocha-listing-media {
        width: 100%;
        height: auto !important;
        aspect-ratio: 1;
        margin: 0 0 8px !important;
        border-radius: 8px;
        overflow: hidden;
    }

    .woocommerce ul.products li.product .mocha-listing-media img,
    .woocommerce-page ul.products li.product .mocha-listing-media img {
        width: 100%;
        height: 100% !important;
        object-fit: cover;
        margin: 0 !important;
    }

    .mocha-listing-badge {
        top: 6px;
        left: 6px;
        max-width: calc(100% - 40px);
        font-size: 9px;
        padding: 3px 6px;
        pointer-events: none;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mocha-listing-badge__icon {
        display: none;
    }

    .mocha-listing-badge__tooltip {
        display: none !important;
    }

    .woocommerce span.onsale,
    .woocommerce ul.products li.product .onsale {
        top: 6px !important;
        right: 6px !important;
        left: auto !important;
        padding: 2px 7px !important;
        font-size: 9px !important;
        letter-spacing: 0.03em;
    }

    .woocommerce ul.products li.product .woocommerce-loop-product__title,
    .woocommerce-page ul.products li.product .woocommerce-loop-product__title {
        font-size: 13px !important;
        line-height: 1.35 !important;
        margin: 0 0 4px !important;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    .woocommerce ul.products li.product .price,
    .woocommerce-page ul.products li.product .price {
        font-size: 14px !important;
        margin: 0 0 6px !important;
    }

    .mocha-loop-rating {
        margin: 0 0 4px;
        min-height: 14px;
        gap: 4px;
    }

    .mocha-loop-rating .star-rating {
        font-size: 11px !important;
        width: 4.4em !important;
    }

    .mocha-loop-rating__count {
        font-size: 10px;
    }

    .woocommerce ul.products li.product .button,
    .woocommerce-page ul.products li.product .button {
        padding: 8px 10px !important;
        font-size: 12px !important;
        min-height: 0;
    }
}

@media (max-width: 480px) {
    .woocommerce ul.products,
    .woocommerce-page ul.products {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}
