.du-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    list-style: none;
    padding: 0;
    margin: 12px 0;
}

.du-swatches li {
    position: relative;
    margin: 0;
    padding: 0;
    list-style: none;
    align-self: baseline;
}

.du-swatch {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    overflow: hidden;
    text-decoration: none;
    box-sizing: content-box;
    line-height: 1;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

.du-swatch > img,
.du-swatch > span {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.du-swatch--selected {
    padding: 4px;
    box-shadow: 0 0 0 1px #000;
    overflow: visible;
}

.du-swatch--selected > img,
.du-swatch--selected > span {
    width: 20px;
    height: 20px;
    /* Keep the light ring on the inner circle so a white selected swatch is
       still distinguishable from the gap inside the dark selection ring. */
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.2);
}

/* Out-of-stock: faded, not interactive, with a diagonal line across. */
.du-swatch--oos {
    position: relative;
    opacity: 0.5;
    cursor: not-allowed;
}

.du-swatch--oos::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.6);
    transform: rotate(-45deg);
    z-index: 2;
}

.du-swatch--text > span {
    background: #f5f5f5;
    color: #333;
    font-size: 9px;
    line-height: 20px;
    text-align: center;
    padding: 0 4px;
    white-space: nowrap;
    width: auto;
    min-width: 20px;
    border-radius: 10px;
}

.du-swatches--loop {
    margin: 6px 0;
    gap: 6px;
}

.du-swatch-image-preview {
    max-width: 60px;
    height: auto;
    display: block;
    margin: 8px 0;
    border: 1px solid #ddd;
}

/* Variation swatches on configurable products. The native <select> is kept in
   the DOM (hidden) so WooCommerce's variation script still works. */
.du-swatch-native-select {
    display: none;
}

.du-swatches--variations .du-swatch {
    cursor: pointer;
}

.du-swatches--variations .du-swatch--oos {
    cursor: not-allowed;
}

/* Tooltip — shown on hover/focus. Lives on the <li> because the swatch itself
   clips its overflow, which would hide a tooltip placed above it. */
.du-swatches li[data-du-tip]:hover::after,
.du-swatches li[data-du-tip]:focus-within::after {
    content: attr(data-du-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #042a74; /* theme --color-blue-2 */
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.4;
    white-space: nowrap;
    padding: 5px 9px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    pointer-events: none;
    z-index: 10;
}

.du-swatches li[data-du-tip]:hover::before,
.du-swatches li[data-du-tip]:focus-within::before {
    content: "";
    position: absolute;
    bottom: calc(100% + 3px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #042a74; /* theme --color-blue-2 */
    pointer-events: none;
    z-index: 10;
}
