/**
 * Cirrusly Weather Theme - Variation Swatches
 *
 * @package Cirrusly_Theme
 */

/* ==========================================================================
   Swatch Container
   ========================================================================== */

.cirrusly-swatches {
	margin-bottom: 1.5rem;
}

.cirrusly-swatches label {
	display: block;
	font-size: var(--wp--preset--font-size--small);
	font-weight: 600;
	color: var(--wp--preset--color--primary-dark);
	margin-bottom: 0.75rem;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.cirrusly-swatches__options {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

/* ==========================================================================
   Color Swatches
   ========================================================================== */

.cirrusly-swatch {
	position: relative;
	width: 40px;
	height: 40px;
	border: 2px solid transparent;
	border-radius: 50%;
	cursor: pointer;
	transition: all 0.2s ease;
	padding: 0;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
	overflow: visible;
}

.cirrusly-swatch:hover:not(.disabled) {
	transform: scale(1.1);
	box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.cirrusly-swatch.selected {
	border-color: var(--wp--preset--color--primary-dark);
	box-shadow: 0 0 0 3px rgba(9, 69, 200, 0.2);
}

/* Checkmark for colorblind accessibility */
.cirrusly-swatch.selected::before {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 12px;
	height: 6px;
	border: 2px solid var(--wp--preset--color--white);
	border-top: none;
	border-right: none;
	transform: translate(-50%, -60%) rotate(-45deg);
	filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

/* Focus styles for keyboard navigation */
.cirrusly-swatch:focus {
	outline: none;
	box-shadow: 0 0 0 3px var(--wp--preset--color--primary), 0 0 0 5px rgba(9, 69, 200, 0.3);
}

.cirrusly-swatch:focus:not(:focus-visible) {
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cirrusly-swatch:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px var(--wp--preset--color--primary), 0 0 0 5px rgba(9, 69, 200, 0.3);
}

.cirrusly-swatch.selected:focus,
.cirrusly-swatch.selected:focus-visible {
	box-shadow: 0 0 0 3px var(--wp--preset--color--primary-dark), 0 0 0 5px rgba(9, 69, 200, 0.4);
}

.cirrusly-swatch.disabled {
	opacity: 0.3;
	cursor: not-allowed;
	position: relative;
}

.cirrusly-swatch.disabled::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 2px;
	height: 130%;
	background: #e74c3c;
	transform: translate(-50%, -50%) rotate(45deg);
}

/* Special styling for white/light colors */
.cirrusly-swatch[style*="ffffff"],
.cirrusly-swatch[style*="FFFFFF"],
.cirrusly-swatch[style*="white"] {
	border-color: var(--wp--preset--color--gray-300);
}

/* ==========================================================================
   Tooltip
   ========================================================================== */

.cirrusly-swatch__tooltip {
	position: absolute;
	bottom: 100%;
	left: 50%;
	transform: translateX(-50%) translateY(-8px);
	padding: 0.375rem 0.75rem;
	background: var(--wp--preset--color--primary-dark);
	color: var(--wp--preset--color--white);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 500;
	white-space: nowrap;
	border-radius: var(--wp--custom--border-radius--small);
	opacity: 0;
	visibility: hidden;
	transition: all 0.2s ease;
	pointer-events: none;
	z-index: 10;
}

.cirrusly-swatch__tooltip::after {
	content: '';
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	width: 0;
	height: 0;
	border-left: 5px solid transparent;
	border-right: 5px solid transparent;
	border-top: 5px solid var(--wp--preset--color--primary-dark);
}

.cirrusly-swatch:hover:not(.disabled) .cirrusly-swatch__tooltip {
	opacity: 1;
	visibility: visible;
	transform: translateX(-50%) translateY(-12px);
}

/* ==========================================================================
   Hidden Input
   ========================================================================== */

.cirrusly-swatches input[type="hidden"] {
	display: none;
}

/* ==========================================================================
   Reset Button Alignment
   ========================================================================== */

.variations .reset_variations {
	margin-top: 1rem;
	display: inline-block;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--primary);
	text-decoration: underline;
	background: none;
	border: none;
	padding: 0;
	cursor: pointer;
	transition: color 0.2s ease;
}

.variations .reset_variations:hover {
	color: var(--wp--preset--color--primary-dark);
}

/* ==========================================================================
   Integration with WooCommerce
   ========================================================================== */

.single_variation_wrap {
	margin-top: 1.5rem;
}

.woocommerce-variation-price {
	margin-bottom: 1rem;
}

.woocommerce-variation-availability {
	margin-bottom: 1rem;
	font-size: var(--wp--preset--font-size--small);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 600px) {
	.cirrusly-swatch {
		width: 36px;
		height: 36px;
	}

	.cirrusly-swatches__options {
		gap: 0.5rem;
	}
}
