/* ============================================
   Configurable Swatches - Base Styles
   Used by Mage_ConfigurableSwatches module
   ============================================ */

/* Clearfix */
.configurable-swatch-list:after,
.product-view .product-options .swatch-attr:after {
    content: '';
    display: table;
    clear: both;
}

/* Swatch link & label base */
.swatch-link,
.swatch-label {
    display: block;
    border-radius: 3px;
    font-size: 0.875rem;
    text-align: center;
    text-decoration: none;
    box-sizing: content-box;
}

.swatch-link {
    border: 1px solid #ccc;
}

.swatch-link:hover {
    cursor: pointer;
    text-decoration: none;
    border-color: #333;
}

.swatch-link .x {
    display: none;
    text-indent: -999em;
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    z-index: 10;
}

.swatch-label {
    border: 1px solid transparent;
    margin: 0;
    white-space: nowrap;
}

/* Swatch list layout */
.configurable-swatch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    list-style: none;
    margin: 6px 0;
    padding: 0;
}

.products-grid .configurable-swatch-list {
    justify-content: center;
}

.configurable-swatch-list li {
    overflow: hidden;
    white-space: nowrap;
    margin: 0;
}

/* Out of stock */
.configurable-swatch-list .not-available .x {
    display: block;
}

.configurable-swatch-list .not-available .swatch-link {
    border-color: #ededed;
    position: relative;
}

.configurable-swatch-list .not-available .swatch-link.has-image img {
    opacity: 0.4;
}

.configurable-swatch-list .not-available .swatch-label {
    color: #aaa;
    background: #fff;
}

/* Wide text swatches */
.configurable-swatch-list .wide-swatch .swatch-label {
    padding: 0 6px;
}

.configurable-swatch-list .not-available a:focus {
    outline: 0;
}

/* Selected / hover state */
.configurable-swatch-list .selected .swatch-link,
.swatch-link:hover {
    border-color: #333;
    transform: scale(1.1);
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.swatch-link {
    transition: transform 0.15s ease, border-color 0.15s ease;
    cursor: pointer;
}

/* Image swatches — editorial circle, uniforme su list + product view + extra.
   Selettori con specificity alta per battere le regole in styles.css. */
.configurable-swatch-list li .swatch-link.has-image,
.product-options .swatch-link.has-image {
    padding: 0;
    border: 0 !important;
    border-radius: 50%;
    background: transparent;
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.08),
        0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 0;
}

.configurable-swatch-list li .swatch-link.has-image .swatch-label,
.product-options .swatch-link.has-image .swatch-label {
    border-radius: 50%;
    overflow: hidden;
    border: 0;
    background: transparent;
    margin: 0;
    position: relative;
}

.configurable-swatch-list li .swatch-link.has-image img,
.product-options .swatch-link.has-image img {
    display: block;
    border-radius: 50%;
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    top: 0;
    left: 0;
}

.configurable-swatch-list li .swatch-link.has-image:hover,
.product-options .swatch-link.has-image:hover {
    transform: scale(1.08);
    border: 0 !important;
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.08),
        0 2px 8px rgba(0, 0, 0, 0.14);
}

/* Selected image swatch: double-ring blu Apple */
.configurable-swatch-list li.selected .swatch-link.has-image,
.configurable-swatch-list li.filter-match .swatch-link.has-image,
.product-options li.selected .swatch-link.has-image {
    transform: scale(1.05);
    border: 0 !important;
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.08),
        0 0 0 2px #fff,
        0 0 0 4px var(--sys-blue);
}

/* Focus keyboard */
.swatch-link.has-image:focus-visible {
    outline: none;
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.08),
        0 0 0 2px #fff,
        0 0 0 4px var(--sys-blue);
}

/* Product detail page */
.product-view .configurable-swatch-list {
    justify-content: flex-start;
}

/* Layered nav */
#narrow-by-list .configurable-swatch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 8px 0 0;
    padding: 0;
}

#narrow-by-list dd .swatch-link.has-image {
    border: none;
    padding: 0;
}

#narrow-by-list dd .configurable-swatch-list li {
    margin: 0;
}

/* Currently selected in layered nav */
.currently .swatch-current .swatch-link {
    border-radius: 50%;
}

.currently .swatch-current .swatch-link .swatch-label {
    border-radius: 50%;
}

/* ============================================
   Editorial color swatches (product list)
   Stile coordinato con il filtro layered-nav — swatch puro a cerchio
   con inset+outer shadow, hover scale, active double-ring blu.
   Applicato solo agli `.swatch-link.has-color` (option color senza
   swatch image) — le varianti `.has-image` mantengono il render
   immagine storico.
   ============================================ */
.swatch-link.has-color {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 0 !important;
    border-radius: 50%;
    background: var(--swatch-bg, #eee);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.06),
        0 1px 3px rgba(0, 0, 0, 0.08);
    transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;
    overflow: visible;
}

/* Bianco: bordo sottile per staccarlo dal bg della card */
.swatch-link.has-color[title*="ianco" i],
.swatch-link.has-color[title*="hite" i] {
    box-shadow:
        inset 0 0 0 1px rgba(0, 0, 0, 0.08),
        inset 0 -2px 4px rgba(0, 0, 0, 0.04),
        0 1px 3px rgba(0, 0, 0, 0.08);
}

.swatch-link.has-color:hover {
    transform: scale(1.08);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.06),
        0 2px 8px rgba(0, 0, 0, 0.14);
    border: 0 !important;
}

/* Selected state: double-ring bianco + blu */
.configurable-swatch-list li.selected .swatch-link.has-color,
.configurable-swatch-list li.filter-match .swatch-link.has-color {
    transform: scale(1.05);
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.06),
        0 0 0 2px #fff,
        0 0 0 4px var(--sys-blue);
}

.swatch-link.has-color .swatch-label {
    /* label è visually-hidden via span interno, serve solo placeholder
       per il markup — azzera ogni styling residuo */
    width: 100%;
    height: 100%;
    background: transparent;
    border: 0;
    padding: 0;
    margin: 0;
    line-height: 0;
}

/* visually-hidden helper (screen reader only) */
.swatch-link.has-color .visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Out-of-stock: overlay semi-trasparente con X */
.configurable-swatch-list .not-available .swatch-link.has-color {
    opacity: 0.4;
}
.configurable-swatch-list .not-available .swatch-link.has-color::after {
    content: '';
    position: absolute;
    inset: 50% 0 auto 0;
    height: 1px;
    background: rgba(0, 0, 0, 0.5);
    transform: rotate(-45deg);
    transform-origin: center;
    pointer-events: none;
}

/* Focus state (keyboard nav) */
.swatch-link.has-color:focus-visible {
    outline: none;
    box-shadow:
        inset 0 1px 2px rgba(255, 255, 255, 0.4),
        inset 0 -2px 4px rgba(0, 0, 0, 0.06),
        0 0 0 2px #fff,
        0 0 0 4px var(--sys-blue);
}

/* Layout del list nella product card: centrato + gap compatto */
.products-grid .configurable-swatch-list {
    gap: 8px;
    padding: 4px 0;
}
.products-grid .configurable-swatch-list li {
    overflow: visible;    /* permette il ring scale fuori dal box */
}

/* Loading overlay on product image */
.products-grid .product-image:before,
.products-grid .product-image:after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none;
}

.products-grid .product-image:before {
    background-color: white;
    opacity: 0.8;
    z-index: 2;
}

.products-grid .product-image.loading {
    position: relative;
}

.products-grid .product-image.loading:before,
.products-grid .product-image.loading:after {
    display: block;
}
