/* WC Carousel Manager v1.4.0 — Public Styles
   All rules scoped under .wccm-carousel-wrap to prevent ANY leakage
   into WooCommerce shop loop or Page Builder layouts               */

/* ── Scoped reset ────────────────────────────────────────────────────────── */
.wccm-carousel-wrap,
.wccm-carousel-wrap * ,
.wccm-carousel-wrap *::before,
.wccm-carousel-wrap *::after {
    box-sizing: border-box;
}

/* ── Font ────────────────────────────────────────────────────────────────────
   The carousel font is controlled by its OWN variable, --wccm-carousel-font,
   independent from the site/filter/PDP font. Default is `inherit`, so the
   carousel follows the host theme automatically — important because this plugin
   is reused on other sites. Override per-carousel (admin: Font setting) or
   globally via  .wccm-carousel-wrap { --wccm-carousel-font: … }. */
.wccm-carousel-wrap { --wccm-carousel-font: inherit; }
.wccm-carousel-wrap,
.wccm-carousel-wrap * {
    font-family: var(--wccm-carousel-font);
}

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.wccm-carousel-wrap {
    position: relative;
    width: 100%;
    max-width: 100%;
    /* min-width:0 is critical when the carousel sits inside a flex item that
       has `flex:1` but no min-width (e.g. a WooCommerce theme's `.shop-content`).
       Without it the flex item defaults to min-width:auto and tries to fit the
       carousel's *intrinsic* width — which, combined with aspect-ratio cards,
       blows up to millions of px and makes autoHeight compute an absurd height
       that pushes the rest of the page off-screen. */
    min-width: 0;
    padding: 32px 0 16px;
    overflow: visible;          /* let arrows poke out */
    /* reset anything the page theme may inject */
    float: none;
    clear: both;
}

/* ── Swiper: strict containment — THE main bug fix ───────────────────────── */
.wccm-carousel-wrap .wccm-swiper {
    position: relative;         /* override any absolute from theme */
    width: 100%;
    max-width: 100%;
    min-width: 0;               /* see .wccm-carousel-wrap note — prevents runaway width in flex parents */
    height: auto !important;    /* kill Swiper's 100% height that causes black block */
    min-height: 0 !important;
    overflow: hidden;
    padding-bottom: 40px;       /* room for pagination */
    margin: 0;
    display: block;
}
.wccm-carousel-wrap .swiper-wrapper {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    width: 100% !important;
    min-height: 0;
    /* align-items:flex-start (not stretch) — every carousel here uses Swiper's
       autoHeight:true, which sets the wrapper's own height from the tallest
       slide's measured offsetHeight. With align-items:stretch, flex would
       instead stretch every slide DOWN to match the wrapper's current height —
       creating a circular 0px trap the first time the wrapper's height is 0
       (e.g. right after a hidden tab panel becomes visible): slides get
       stretched to 0, Swiper then measures those already-stretched slides as
       0, and the wrapper height never recovers. flex-start lets each slide
       keep its own natural content height so autoHeight has real numbers
       to read from. */
    align-items: flex-start;
    /* height is left to Swiper's autoHeight (set inline via JS) — do not force !important here,
       or the wrapper can't grow to fit tall slides (e.g. boxed cards, long titles) */
    /* DO NOT set position:relative here — Swiper needs to control it */
}
.wccm-carousel-wrap .swiper-slide {
    flex-shrink: 0;
    height: auto !important;
    min-height: 0 !important;
    /* width is set by Swiper JS — do not override */
}

/* Prevent Swiper from affecting elements OUTSIDE .wccm-carousel-wrap */
.wccm-carousel-wrap + * { clear: none; }

/* ── Header row ──────────────────────────────────────────────────────────── */
.wccm-carousel-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 20px;
    width: 100%;
}
.wccm-layout-modern .wccm-carousel-header { justify-content: space-between; }
.wccm-header-arrows { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Headings ────────────────────────────────────────────────────────────── */
.wccm-carousel-wrap .wccm-section-heading {
    font-size: clamp(18px, 5vw, 30px);
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    display: block;
    word-break: normal;
    overflow-wrap: break-word;
    max-width: 100%;
}
.wccm-layout-classic .wccm-section-heading { text-align: center; }
.wccm-layout-modern  .wccm-section-heading { text-align: left; }

.wccm-carousel-wrap .wccm-section-subheading {
    text-align: center;
    font-size: 15px;
    margin: 0 0 20px;
    line-height: 1.5;
    display: block;
}

/* ── Arrows: Classic layout (floating ± wrapper) ─────────────────────────── */
.wccm-layout-classic .wccm-nav,
.wccm-product-carousel .wccm-tab-panel > .wccm-nav,
.wccm-taxonomy-carousel .wccm-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 10;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0,0,0,.10);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #334155;
    transition: background .15s, color .15s, box-shadow .15s;
    padding: 0;
    line-height: 1;
}
.wccm-layout-classic .wccm-prev,
.wccm-product-carousel .wccm-tab-panel > .wccm-prev,
.wccm-taxonomy-carousel .wccm-prev { left: -22px; }

.wccm-layout-classic .wccm-next,
.wccm-product-carousel .wccm-tab-panel > .wccm-next,
.wccm-taxonomy-carousel .wccm-next { right: -22px; }

.wccm-layout-classic .wccm-nav:hover,
.wccm-product-carousel .wccm-tab-panel > .wccm-nav:hover,
.wccm-taxonomy-carousel .wccm-nav:hover {
    background: #1a1a2e;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,.15);
}
/* Classic: hide when at boundary */
.wccm-layout-classic .wccm-nav.is-hidden,
.wccm-product-carousel .wccm-tab-panel > .wccm-nav.is-hidden,
.wccm-taxonomy-carousel .wccm-nav.is-hidden { display: none !important; }

/* ── Arrows: Modern layout (inline top-right) ────────────────────────────── */
.wccm-layout-modern .wccm-header-arrows .wccm-nav {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #fff;
    border: 1.5px solid #e2e8f0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #334155;
    transition: background .15s, color .15s, opacity .15s;
    padding: 0;
}
.wccm-layout-modern .wccm-header-arrows .wccm-nav:hover:not(:disabled) {
    background: #1a1a2e;
    color: #fff;
}
.wccm-layout-modern .wccm-header-arrows .wccm-nav.is-disabled,
.wccm-layout-modern .wccm-header-arrows .wccm-nav:disabled {
    opacity: .3;
    cursor: default;
    pointer-events: none;
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.wccm-carousel-wrap .wccm-pagination {
    position: absolute !important;
    bottom: 10px !important;
    left: 0 !important;
    width: 100% !important;
    text-align: center;
    z-index: 5;
}
.wccm-carousel-wrap .wccm-pagination .swiper-pagination-bullet {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: #cbd5e1;
    opacity: 1;
    border-radius: 50%;
    margin: 0 3px !important;
    transition: background .2s, transform .2s;
    cursor: pointer;
}
.wccm-carousel-wrap .wccm-pagination .swiper-pagination-bullet-active {
    transform: scale(1.35);
    /* background via inline <style> per-instance */
}

/* ── Category card ───────────────────────────────────────────────────────── */
.wccm-carousel-wrap .wccm-cat-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}
.wccm-carousel-wrap .wccm-cat-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: #f1f5f9; /* placeholder fallback only — cleared once a real image loads */
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.wccm-carousel-wrap .wccm-cat-img-wrap.has-image {
    background: transparent;
    border-color: transparent;
}
.wccm-carousel-wrap .wccm-cat-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}
.wccm-carousel-wrap .wccm-cat-card:hover .wccm-cat-img-wrap img,
.wccm-carousel-wrap .wccm-cat-card.is-active .wccm-cat-img-wrap img { transform: scale(1.04); }

.wccm-carousel-wrap .wccm-cat-card.is-active .wccm-cat-img-wrap {
    outline: 3px solid;
    outline-offset: 2px;
    /* color via inline CSS */
}
.wccm-carousel-wrap .wccm-active-badge {
    position: absolute;
    top: 8px; right: 8px;
    width: 24px; height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    color: #fff;
    /* background via inline CSS */
}
.wccm-carousel-wrap .wccm-cat-img-placeholder {
    width: 100%;
    height: 100%;
    background: repeating-conic-gradient(#e2e8f0 0% 25%, #f8fafc 0% 50%) 0 0 / 20px 20px;
}

/* Card text — fixed-height so count always aligns at bottom */
.wccm-carousel-wrap .wccm-cat-text {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding-top: 10px;
}
.wccm-carousel-wrap .wccm-cat-name {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 4px;
    color: #1e293b;
    text-align: center;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(2 * 1.4em + 0.25em); /* two lines + descender room */
    line-height: 1.4;
    padding-bottom: 2px;
}
.wccm-carousel-wrap .wccm-cat-count {
    font-size: 13px;
    color: #64748b;
    margin: auto 0 0;
    text-align: center;
    display: block;
}

/* ── Boxed card style — dark portrait card, image inset near top ────────── */
.wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed {
    background: #1a1a2e; /* overridden inline per-instance */
    border-radius: 18px;
    padding: 20px 16px 24px;
    aspect-ratio: 3 / 4.6;
    justify-content: flex-start;
}
.wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-img-wrap {
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    background: #fff; /* placeholder fallback only — cleared once a real image loads */
    border: none;
    flex: 1 1 auto;
    min-height: 0;
}
.wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-img-wrap.has-image {
    background: transparent;
}
.wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-img-wrap img {
    object-fit: contain;
    padding: 12px;
}
.wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-text {
    flex: 0 0 auto;
    padding-top: 16px;
}
.wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-name {
    color: #fff; /* overridden inline per-instance */
    font-size: 16px;
    /* Reserve exactly two lines (2 × line-height) plus a little room for
       descenders — g/y/p and Thai tails sit below the baseline and were being
       clipped by `overflow:hidden` when this was smaller than the real height. */
    min-height: calc(2 * 1.4em + 0.25em);
    -webkit-line-clamp: 2;
    -webkit-box-pack: start; /* pin text to top of the reserved box, whether 1 or 2 lines */
    justify-content: flex-start;
    padding-bottom: 2px; /* keeps descenders inside the clipping box */
}
.wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-count {
    color: #fff; /* overridden inline per-instance */
    opacity: .7;
    margin-top: 4px;
}
.wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed.is-active .wccm-cat-img-wrap {
    outline-offset: -2px;
}

/* ── Product carousel tabs ───────────────────────────────────────────────── */
.wccm-carousel-wrap .wccm-tab-nav {
    display: flex;
    flex-wrap: nowrap;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 24px;
    /* Centre the row when it fits, but fall back to flush-left the moment it
       overflows. `justify-content:center` on an overflowing scroll container
       spills content past BOTH edges and the left overflow can't be scrolled
       back to — the first tab ends up permanently clipped. `safe center` keeps
       centring only while it's safe to do so; the is-scrollable class below is
       the JS-driven belt-and-braces for browsers without `safe` support. */
    justify-content: safe center;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}
/* When tabs don't fit their row, left-align instead of center so the
   scrollable content starts flush at the left edge (centering a row
   that's wider than its container makes the start position ambiguous
   and looks like everything drifted off to one side). */
.wccm-carousel-wrap .wccm-tab-nav.is-scrollable { justify-content: flex-start; }
.wccm-carousel-wrap .wccm-tab-nav::-webkit-scrollbar { height: 4px; }
.wccm-carousel-wrap .wccm-tab-nav::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
.wccm-carousel-wrap .wccm-tab-btn {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: color .15s, border-color .15s;
    white-space: nowrap;
    line-height: 1.4;
    flex-shrink: 0;
}
.wccm-carousel-wrap .wccm-tab-btn:hover { color: #1e293b; }
/* .active color via inline CSS per-instance */

.wccm-carousel-wrap .wccm-tab-panels { position: relative; }
.wccm-carousel-wrap .wccm-tab-panel { display: none; position: relative; }
.wccm-carousel-wrap .wccm-tab-panel.active { display: block; }
.wccm-carousel-wrap .wccm-no-products {
    text-align: center; color: #94a3b8; margin: 0;
    display: flex; align-items: center; justify-content: center;
    min-height: 160px; font-size: 15px;
}

/* ── Product card (custom) ───────────────────────────────────────────────── */
.wccm-carousel-wrap .wccm-product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow .2s;
}
.wccm-carousel-wrap .wccm-product-card:hover { box-shadow: 0 6px 24px rgba(0,0,0,.09); }

.wccm-carousel-wrap .wccm-product-img-wrap {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f8fafc;
    flex-shrink: 0;
    text-decoration: none;
}
.wccm-carousel-wrap .wccm-product-img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}
.wccm-carousel-wrap .wccm-product-card:hover .wccm-product-img-wrap img { transform: scale(1.04); }

.wccm-carousel-wrap .wccm-product-info {
    padding: 12px 14px 4px;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.wccm-carousel-wrap .wccm-product-name {
    font-size: 14px;
    font-weight: 600;
    color: #1e293b;
    text-decoration: none;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(2 * 1.4em + 0.25em); /* two lines + descender room */
    padding-bottom: 2px;
    margin: 0;
}
.wccm-carousel-wrap .wccm-product-name:hover { color: #2271b1; }

.wccm-carousel-wrap .wccm-product-footer {
    padding: 8px 14px 14px;
}
/* WC add_to_cart — native classes preserved, only wrapped style */
.wccm-carousel-wrap .wccm-product-footer .button,
.wccm-carousel-wrap .wccm-product-footer a.button,
.wccm-carousel-wrap .wccm-product-footer .add_to_cart_button {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
    text-align: center;
    border-radius: 6px;
    padding: 10px 12px !important;
    font-size: 13px !important;
    font-weight: 600;
    background: #1a1a2e !important;
    color: #fff !important;
    border: none !important;
    text-decoration: none;
    transition: background .15s;
    box-sizing: border-box;
    gap: 6px;
    line-height: 1.4;
}
.wccm-carousel-wrap .wccm-product-footer .button:hover,
.wccm-carousel-wrap .wccm-product-footer a.button:hover { background: #2271b1 !important; }

/* WC default design slide */
/* Each WooCommerce slide carries its own `.woocommerce > ul.products` wrapper so
   the shop-card rules in fe-filter.css (all scoped under that ancestry) apply
   here too. Strip the list's own grid/margins — the slide is already the cell. */
.wccm-wc-slide > ul.products {
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    list-style: none !important;
    gap: 0 !important;
    grid-template-columns: none !important;
    height: 100%;
}
/* Swiper sizes slides to the tallest one only when told to stretch; without
   this a slide is as tall as its own card, so the quote button sits at a
   different height on every card as you page through. */
.wccm-carousel-wrap .swiper-wrapper { align-items: stretch; }
.wccm-carousel-wrap .swiper-slide.wccm-wc-slide { height: auto; }
.wccm-wc-slide > ul.products > li.product {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}
.wccm-wc-slide > ul.products::before,
.wccm-wc-slide > ul.products::after { content: none !important; }

.wccm-wc-slide .product,
.wccm-wc-slide li.product {
    margin: 0 !important;
    width: 100% !important;
    float: none !important;
    padding: 0 !important;
}

/* ── Taxonomy carousel label (brand name) ────────────────────────────────── */
.wccm-carousel-wrap .wccm-term-label {
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    color: #1e293b;
    margin: 8px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: calc(2 * 1.3em + 0.25em); /* two lines + descender room */
    line-height: 1.3;
    padding-bottom: 2px;
}
.wccm-carousel-wrap .wccm-term-img-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 10px;
    overflow: hidden;
    background: #f1f5f9; /* placeholder fallback only — cleared once a real image loads */
    border: 1px solid #e2e8f0;
}
.wccm-carousel-wrap .wccm-term-img-wrap.has-image {
    background: transparent;
    border-color: transparent;
}
.wccm-carousel-wrap .wccm-term-img-wrap img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .3s ease;
}
.wccm-carousel-wrap .wccm-term-card:hover .wccm-term-img-wrap img { transform: scale(1.04); }
.wccm-carousel-wrap .wccm-term-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: inherit;
    height: 100%;
}

/* ── Boxed card style — square (1:1) brand card, image inset near top ───── */
.wccm-carousel-wrap .wccm-term-card.wccm-card-boxed {
    background: #1a1a2e; /* overridden inline per-instance */
    border-radius: 18px;
    padding: 16px 16px 16px;
    aspect-ratio: 1 / 1;   /* square brand card */
    justify-content: flex-start;
}
.wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-img-wrap {
    aspect-ratio: 1 / 1;
    border-radius: 12px;
    background: #fff; /* placeholder fallback only — cleared once a real image loads */
    border: none;
    flex: 1 1 auto;
    min-height: 0;
}
.wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-img-wrap.has-image {
    background: transparent;
}
.wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-img-wrap img {
    object-fit: contain;
    padding: 12px;
}
.wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-label {
    color: #fff; /* overridden inline per-instance */
    font-size: 15px;
    /* Single-line reserve keeps the square card compact, but 1.4em is exactly
       one line-height — descenders (g/y/p, Thai tails) fell outside it and got
       clipped by `overflow:hidden`. Add room for them. */
    min-height: calc(1.4em + 0.3em);
    padding-top: 10px;
    padding-bottom: 2px;
    margin-top: 0;
    -webkit-box-pack: start; /* pin text to top of the reserved box */
    justify-content: flex-start;
}
/* Product count under the brand name (mirrors .wccm-cat-count exactly) */
.wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-count {
    color: #fff; /* overridden inline per-instance to match the label color */
    opacity: .7;
    font-size: 13px;
    margin-top: 4px;   /* match .wccm-cat-count */
    text-align: center; /* was defaulting to start (left) unlike category */
    flex: 0 0 auto;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 767px) {
    /* Keep arrows inside the wrapper's own box on mobile — some page-builder
       "full width" containers (e.g. the classic .alignfull negative-margin
       trick) add overflow-x:hidden on mobile, which clips anything poking
       outside the wrapper's bounds regardless of our own overflow:visible. */
    .wccm-layout-classic .wccm-prev,
    .wccm-product-carousel .wccm-tab-panel > .wccm-prev,
    .wccm-taxonomy-carousel .wccm-prev { left: 4px; }

    .wccm-layout-classic .wccm-next,
    .wccm-product-carousel .wccm-tab-panel > .wccm-next,
    .wccm-taxonomy-carousel .wccm-next { right: 4px; }

    .wccm-carousel-wrap .wccm-tab-btn { padding: 8px 12px; font-size: 13px; }
    .wccm-carousel-wrap .wccm-cat-name { font-size: 13px; }
    .wccm-carousel-wrap .wccm-carousel-header { padding: 0 20px; }

    .wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed,
    .wccm-carousel-wrap .wccm-term-card.wccm-card-boxed {
        padding: 12px 10px 16px;
        border-radius: 14px;
    }
    .wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-img-wrap,
    .wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-img-wrap {
        border-radius: 8px;
    }
    .wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-name,
    .wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-label {
        font-size: 13px;
        min-height: calc(2 * 1.4em + 0.25em); /* two lines + descender room */
        padding-top: 10px;
    }

    /* The boxed card is locked to a fixed aspect-ratio, so its height cannot
       grow to fit the text. At mobile widths a two-line name plus a wrapped
       count consumed the whole box and squeezed the image — which is
       `flex:1 1 auto; min-height:0` — down to zero height, so it vanished.
       Give the image a floor and keep the count on one line. */
    .wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed,
    .wccm-carousel-wrap .wccm-term-card.wccm-card-boxed {
        aspect-ratio: auto;   /* let the card size to its content instead */
    }
    .wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-img-wrap,
    .wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-img-wrap {
        flex: 0 0 auto;       /* never shrink the image away */
        width: 100%;
        aspect-ratio: 1 / 1;
    }
    .wccm-carousel-wrap .wccm-cat-card.wccm-card-boxed .wccm-cat-count,
    .wccm-carousel-wrap .wccm-term-card.wccm-card-boxed .wccm-term-count {
        font-size: 12px;
        white-space: nowrap;  /* "มีสินค้า 42 รายการ" must not wrap out of the card */
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* ── Banner mode ─────────────────────────────────────────────────────────── */
.wccm-banner-wrap {
    padding: 0;
    overflow: hidden;
}
.wccm-banner {
    position: relative;
    width: 100%;
    min-height: 320px;
    background-color: #0f1b3d;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    border-radius: 14px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}
/* Subtle dark scrim so an overlaid brand name stays readable; kept light so the
   uploaded banner artwork (logo + hero image) shows through. */
.wccm-banner.has-bg .wccm-banner-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(0,0,0,.15) 0%, rgba(0,0,0,.05) 45%, rgba(0,0,0,.35) 100%);
}
/* When no image is set, fall back to a solid brand-navy panel. */
.wccm-banner:not(.has-bg) .wccm-banner-overlay { background: transparent; }
.wccm-banner-content {
    position: relative;
    z-index: 2;
    text-align: center;
    padding: 40px 24px;
    width: 100%;
}
.wccm-banner-name {
    font-size: clamp(26px, 4vw, 44px);
    font-weight: 700;
    margin: 0;
    line-height: 1.15;
    text-shadow: 0 2px 12px rgba(0,0,0,.35);
}

@media (max-width: 767px) {
    .wccm-banner { min-height: 200px; }
    .wccm-banner-name { font-size: clamp(20px, 6vw, 30px); }
}

/* ── Shop-archive flexbox min-width guard ───────────────────────────────────
   When the carousel is auto-placed inside a theme's shop content column that
   is a flex item (very common: `.shop-content{flex:1}` with no min-width),
   that item defaults to min-width:auto and inflates to the carousel's broken
   intrinsic width — making autoHeight explode to millions of px. Force any
   direct flex/grid ancestor that CONTAINS our carousel to allow shrinking. */
:where(.shop-content, .site-main, #primary, .woocommerce-products-header + *, main):has(.wccm-carousel-wrap) {
    min-width: 0;
}
