/**
 * BedCastle Shop Archive variations styling
 */

.bedcastle-archive-variations-wrapper {
    margin-top: 15px;
    width: 100%;
    display: block;
}

.bedcastle-archive-variations-wrapper form.cart {
    margin: 0 !important;
    display: block;
    width: 100%;
}

.bedcastle-archive-variations-wrapper table.variations {
    width: 100%;
    margin-bottom: 8px !important;
    border-collapse: collapse;
    display: table;
    border: none !important;
}

.bedcastle-archive-variations-wrapper table.variations td,
.bedcastle-archive-variations-wrapper table.variations th {
    padding: 2px 0 !important;
    border: none !important;
    background: transparent !important;
    vertical-align: middle;
}

.bedcastle-archive-variations-wrapper table.variations th.label {
    display: none !important; /* Hide labels (e.g. Color, Size) to keep cards clean */
}

.bedcastle-archive-variations-wrapper table.variations td.value {
    width: 100% !important;
    display: block !important;
}

/* Tiny Swatches Overrides */
.bedcastle-archive-variations-wrapper .variable-items-wrapper {
    gap: 4px !important;
}

.bedcastle-archive-variations-wrapper .variable-items-wrapper .variable-item:not(.radio-variable-item) {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    margin: 2px !important;
    padding: 0 !important;
    border-radius: 50% !important; /* Circle style */
    overflow: hidden !important;
}

/* Ensure inner elements and images are also clipped to circle shape */
.bedcastle-archive-variations-wrapper .variable-items-wrapper .variable-item:not(.radio-variable-item) .variable-item-contents,
.bedcastle-archive-variations-wrapper .variable-items-wrapper .variable-item:not(.radio-variable-item) .variable-item-span,
.bedcastle-archive-variations-wrapper .variable-items-wrapper .variable-item:not(.radio-variable-item) .variable-item-span-color,
.bedcastle-archive-variations-wrapper .variable-items-wrapper .variable-item:not(.radio-variable-item) img {
    border-radius: 50% !important;
    overflow: hidden !important;
    width: 100% !important;
    height: 100% !important;
}

/* For label/button swatches */
.bedcastle-archive-variations-wrapper .variable-items-wrapper .variable-item:not(.radio-variable-item).button-variable-item {
    font-size: 9px !important;
    line-height: 16px !important;
    width: auto !important;
    min-width: 24px !important;
    padding: 0 4px !important;
    border-radius: 4px !important;
}

/* Selected swatch visual confirmation checkmark size */
.bedcastle-archive-variations-wrapper .variable-items-wrapper .variable-item:not(.radio-variable-item).color-variable-item.selected:not(.no-stock) .variable-item-contents:before,
.bedcastle-archive-variations-wrapper .variable-items-wrapper .variable-item:not(.radio-variable-item).image-variable-item.selected:not(.no-stock) .variable-item-contents:before {
    background-size: 50% !important;
}

/* Hide Quantity selection on Shop archives */
.bedcastle-archive-variations-wrapper .quantity {
    display: none !important;
}

/* Hide reset/clear link on archive page */
.bedcastle-archive-variations-wrapper a.reset_variations {
    display: none !important;
}

/* Make Add to Cart full width and modern */
.bedcastle-archive-variations-wrapper .single_add_to_cart_button {
    width: 100% !important;
    float: none !important;
    margin: 8px 0 0 0 !important;
    padding: 8px 12px !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    border-radius: 6px !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: background-color 0.25s, transform 0.20s, box-shadow 0.25s !important;
}

/* Hide theme's default duplicate add-to-cart button or container only for variable products */
.product-type-variable > a.button,
.product-type-variable .ct-add-to-cart,
.product-type-variable .blocksy-add-to-cart,
.product-type-variable .add_to_cart_button:not(.single_add_to_cart_button) {
    display: none !important;
}

/* Loading state for card */
.bedcastle-adding-to-cart {
    opacity: 0.65;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

/* Spinner inside button */
.bedcastle-btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: bedcastle-spin 0.7s linear infinite;
}

@keyframes bedcastle-spin {
    to { transform: rotate(360deg); }
}

/* Glow ring pulse animation on successful AJAX add-to-cart */
.product.bedcastle-added-to-cart,
li.product.bedcastle-added-to-cart,
.product-grid-item.bedcastle-added-to-cart {
    animation: bedcastle-card-success-glow 2s cubic-bezier(0.25, 0.8, 0.25, 1);
}

@keyframes bedcastle-card-success-glow {
    0% {
        box-shadow: 0 0 0 0px rgba(37, 211, 102, 0.6);
        transform: scale(1.01);
    }
    15% {
        box-shadow: 0 0 0 6px rgba(37, 211, 102, 0.3);
    }
    30% {
        box-shadow: 0 0 0 12px rgba(37, 211, 102, 0);
        transform: scale(1);
    }
    100% {
        box-shadow: 0 0 0 0px rgba(37, 211, 102, 0);
    }
}
