/* Swatches in WooCommerce's chips and checkbox list blocks (spec 10.3, 10.4). */

.wcsw-block-swatches {
    --wcsw-block-radius: 0;
}

.wcsw-block-swatches.swatch-shape-rounded {
    --wcsw-block-radius: 6px;
}

.wcsw-block-swatches.swatch-shape-round {
    --wcsw-block-radius: 999px;
}

.wcsw-block-swatches.is-style-swatch .wc-block-product-filter-chips__item {
    border-radius: var(--wcsw-block-radius);
}

.wcsw-block-swatches.is-style-swatch .wc-block-product-filter-chips__swatch {
    width: var(--wcsw-block-width, 2.3em);
    height: var(--wcsw-block-height, 2.3em);
    border-radius: max(0px, calc(var(--wcsw-block-radius) - 2px));
}

/* A chosen filter swatch carries a tick, so the shopper sees which filters are on. */
.wcsw-block-swatches.is-style-swatch .wc-block-product-filter-chips__swatch {
    position: relative;
}

.wcsw-block-swatches.is-style-swatch .wc-block-product-filter-chips__item[aria-checked="true"] .wc-block-product-filter-chips__swatch::after {
    content: "";
    position: absolute;
    inset: 0;
    background: url("data:image/svg+xml,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20viewBox%3D%220%200%2024%2024%22%20fill%3D%22none%22%20stroke-linecap%3D%22round%22%20stroke-linejoin%3D%22round%22%3E%3Cpath%20d%3D%22M6%2012.5l4%204%208-9%22%20stroke%3D%22rgba(0%2C0%2C0%2C.45)%22%20stroke-width%3D%224.5%22%2F%3E%3Cpath%20d%3D%22M6%2012.5l4%204%208-9%22%20stroke%3D%22%23fff%22%20stroke-width%3D%222.5%22%2F%3E%3C%2Fsvg%3E") center / 70% no-repeat;
}

/* A term without a swatch shows its name. */
.wcsw-block-swatches.is-style-swatch .wc-block-product-filter-chips__swatch--no-color {
    display: none;
}

.wcsw-block-swatches.is-style-swatch .wc-block-product-filter-chips__item:has(.wc-block-product-filter-chips__swatch--no-color) {
    min-height: calc(var(--wcsw-block-height, 2.3em) + 6px);
    padding: 2px 0.75em;
    border-color: color-mix(in srgb, currentColor 40%, transparent);
}

.wcsw-block-swatches.is-style-swatch .wc-block-product-filter-chips__item:has(.wc-block-product-filter-chips__swatch--no-color) .wc-block-product-filter-chips__text {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
    clip-path: none;
    white-space: nowrap;
}

.wcsw-block-swatches .wc-block-product-filter-checkbox-list__color-swatch {
    border-radius: var(--wcsw-block-radius);
}

/* Filter Products by Attribute widget (spec 10.4). */

.wcsw-filter-term {
    display: inline-flex;
    align-items: center;
    gap: 0.5em;
}

.wcsw-filter-swatch {
    display: inline-block;
    flex-shrink: 0;
    box-sizing: border-box;
    width: 1.5em;
    height: 1.5em;
    overflow: hidden;
    border: 1px solid color-mix(in srgb, currentColor 30%, transparent);
    background-position: 50%;
    background-size: cover;
}

.wcsw-filter-swatch.swatch-shape-rounded {
    border-radius: 4px;
}

.wcsw-filter-swatch.swatch-shape-round {
    border-radius: 50%;
}

.wcsw-filter-swatch img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wcsw-filter-term--button {
    padding: 0.1em 0.6em;
    border: 1px solid color-mix(in srgb, currentColor 40%, transparent);
}

.chosen > .wcsw-filter-term .wcsw-filter-swatch,
.chosen > .wcsw-filter-term--button {
    outline: 2px solid currentColor;
    outline-offset: 1px;
}
