/* Smart Link by Custom Meta Field — product group swatches */

.slcmf-group-swatches {
    margin: 2rem 0;
    width: 100%;
}

.slcmf-group-title {
    font-size: 0.95rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 1rem;
    color: #333;
}

.slcmf-swatches-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: flex-start;
}

/* ── Individual swatch ─────────────────────────────────────── */

.slcmf-swatch {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 80px;
    text-decoration: none;
    color: inherit;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 6px;
    padding: 4px;
    transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
    position: relative;
}

.slcmf-swatch:hover {
    border-color: #999;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
    transform: translateY(-2px);
}

/* Active (current product) — not a link */
.slcmf-swatch--active {
    border-color: #2271b1;
    cursor: default;
}

.slcmf-swatch--active:hover {
    transform: none;
    box-shadow: none;
}

/* ── Thumbnail ─────────────────────────────────────────────── */

.slcmf-swatch__img {
    display: block;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border-radius: 4px;
    background: #f5f5f5;
}

.slcmf-swatch__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: opacity 0.15s ease;
}

.slcmf-swatch:hover .slcmf-swatch__img img {
    opacity: 0.88;
}

/* ── Label ─────────────────────────────────────────────────── */

.slcmf-swatch__label {
    font-size: 0.72rem;
    line-height: 1.3;
    text-align: center;
    color: #444;
    word-break: break-word;
    max-width: 100%;
}

.slcmf-swatch--active .slcmf-swatch__label {
    color: #2271b1;
    font-weight: 600;
}

/* ── Label hidden: tooltip on hover ───────────────────────── */

.slcmf-group-swatches--no-labels .slcmf-swatch {
    position: relative;
}

.slcmf-group-swatches--no-labels .slcmf-swatch__label {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    background: #111;
    color: #fff;
    font-size: 0.68rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

/* small caret */
.slcmf-group-swatches--no-labels .slcmf-swatch__label::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #111;
}

.slcmf-group-swatches--no-labels .slcmf-swatch:hover .slcmf-swatch__label {
    opacity: 1;
}

/* ── Out of stock overlay ──────────────────────────────────── */

.slcmf-swatch--out-of-stock .slcmf-swatch__img {
    position: relative;
}

.slcmf-swatch--out-of-stock .slcmf-swatch__img::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.55);
    border-radius: 4px;
}

.slcmf-swatch__oos {
    display: block;
    font-size: 0.65rem;
    color: #999;
    text-align: center;
    margin-top: -2px;
}

/* ── Responsive ────────────────────────────────────────────── */

@media ( max-width: 480px ) {
    .slcmf-swatch {
        width: 64px;
    }

    .slcmf-swatch__img {
        width: 56px;
        height: 56px;
    }
}

/* ── Shop / archive loop overlay ───────────────────────────── */

ul.products li.product {
    position: relative;
}

.slcmf-loop-swatches {
    position: absolute;
    bottom: 8px;
    left: 8px;
    z-index: 9;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: calc(100% - 16px);
}

.slcmf-loop-swatch {
    display: block;
    width: 36px;
    height: 36px;
    border-radius: 5px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.85);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
    flex-shrink: 0;
    transition: border-color 0.15s, transform 0.15s;
}

.slcmf-loop-swatch img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    /* Reset any theme hover transforms applied to loop product images */
    transform: none !important;
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
}

.slcmf-loop-swatch:hover {
    border-color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
}
