/* =============================================================================
   RW 2026 – swatche kolorów na karcie produktu (panel „Wybierz kolor”).
   Nadpisuje wtyczkę AovUp (frontend.css + style inline) i assets/styles/style.css
   wyłącznie wyższą specyficznością. Tamtych plików nie edytujemy.
   Wtyczka używa selektorów typu
   `.woocommerce div.product .cart.variations_form .tawcvs-swatches .swatch.selected:before` (do 0,7,2),
   dlatego nasze zaczynają się od tego samego prefiksu, dokładają .swatch-item-wrapper i [data-value] (0,8,x).
   ============================================================================ */

:root {
	--rw-swatch-size: 56px;
	--rw-swatch-gap: 10px;
	--rw-swatch-radius: 8px;
	--rw-swatch-scale: 1.18;
	--rw-ink: #312d2e;          /* kolor tekstu motywu */
	--rw-accent: #ddb9b1;       /* róż marki */
	--rw-line: rgba(49, 45, 46, 0.18);
}

@media (max-width: 575.98px) {
	:root {
		--rw-swatch-size: 52px;
		--rw-swatch-gap: 10px;
	}
}

/* --- siatka ---------------------------------------------------------------- */
.woocommerce div.product .variations_form .tawcvs-swatches {
	display: flex;
	flex-wrap: wrap;
	gap: var(--rw-swatch-gap);
	margin: 6px 0 0;
	padding: 6px 0 2px; /* miejsce na powiększenie i znacznik „wybrane” */
}

/* Wtyczka wstrzykuje marginesy wrappera z !important (style inline w <head>). */
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper {
	position: relative;
	margin: 0 !important;
	padding: 0 !important;
	line-height: 0;
}

/* --- pojedynczy swatch ------------------------------------------------------ */
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value] {
	position: relative;
	box-sizing: border-box;
	display: block;
	width: var(--rw-swatch-size);
	height: var(--rw-swatch-size);
	margin: 0;
	padding: 0;
	border: 1px solid var(--rw-line);
	border-radius: var(--rw-swatch-radius) !important; /* wtyczka: border-radius:50% !important */
	background-color: #f3efed;
	background-position: center;
	background-size: cover;
	box-shadow: inset 0 0 0 2px #fff;
	overflow: visible;
	cursor: pointer;
	transform: none;
	transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
	outline: none;
}

/* Typ „color” ma w środku <span class="text"> z nazwą – w kafelku jej nie pokazujemy. */
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value] > .text {
	display: none;
}

/* --- stan wybrany ----------------------------------------------------------- */
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value].selected {
	border-color: var(--rw-ink);
	box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--rw-ink);
}

/* Wtyczka rysuje własną okrągłą obwódkę (::before, 1px #ddd, -4px) i ::after.
   Chowamy je; ::after zostaje tylko dla stanu „wybrane” (nasz znacznik) i „niedostępne” (krzyżyk wtyczki). */
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value]::before,
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value]:not(.selected):not(.disabled)::after {
	display: none !important;
}

.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value].selected::after {
	content: "";
	position: absolute;
	top: -7px;
	right: -7px;
	width: 20px;
	height: 20px;
	box-sizing: border-box;
	border: 2px solid #fff;
	border-radius: 50%;
	background: var(--rw-ink) url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3.2' stroke-linecap='round' stroke-linejoin='round'><path d='M5 12.5l4.5 4.5L19 7.5'/></svg>") center / 11px 11px no-repeat;
	opacity: 1;
	transform: none;
	z-index: 2;
}

/* --- niedostępne ------------------------------------------------------------ */
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value].disabled {
	opacity: 0.35;
	filter: grayscale(0.5);
	cursor: not-allowed;
}

/* --- dymek z nazwą ---------------------------------------------------------- */
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value] .rw-swatch__name {
	position: absolute;
	left: 50%;
	bottom: calc(100% + 9px);
	transform: translate(-50%, 4px) scale(calc(1 / var(--rw-swatch-scale)));
	transform-origin: 50% 100%;
	padding: 6px 10px;
	border-radius: 4px;
	background: var(--rw-ink);
	color: #fff;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.2;
	letter-spacing: 0.01em;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s linear 0.15s;
	z-index: 10;
}

.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value] .rw-swatch__name::after {
	content: "";
	position: absolute;
	left: 50%;
	top: 100%;
	margin-left: -5px;
	border: 5px solid transparent;
	border-top-color: var(--rw-ink);
}

/* Hover tylko tam, gdzie jest kursor. Na telefonie nazwa pokazuje się w podpisie pod siatką. */
@media (hover: hover) and (pointer: fine) {
	.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value]:not(.disabled):hover,
	.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value]:not(.disabled):focus-visible {
		transform: scale(var(--rw-swatch-scale));
		border-color: var(--rw-ink);
		box-shadow: inset 0 0 0 2px #fff, 0 6px 16px rgba(0, 0, 0, 0.18);
		z-index: 5;
	}

	.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value].selected:not(.disabled):hover,
	.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value].selected:not(.disabled):focus-visible {
		box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px var(--rw-ink), 0 6px 16px rgba(0, 0, 0, 0.18);
	}

	.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value]:not(.disabled):hover .rw-swatch__name,
	.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value]:not(.disabled):focus-visible .rw-swatch__name {
		opacity: 1;
		visibility: visible;
		transform: translate(-50%, 0) scale(calc(1 / var(--rw-swatch-scale)));
		transition: opacity 0.15s ease, transform 0.15s ease, visibility 0s;
	}
}

/* Klawiatura: widoczny focus także bez hovera. */
.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value]:focus-visible {
	box-shadow: inset 0 0 0 2px #fff, 0 0 0 3px var(--rw-accent);
}

/* --- podpis „Wybrany kolor” + próbnik -------------------------------------- */
.woocommerce div.product .variations_form .rw-swatch-meta {
	margin: 12px 0 4px;
	font-size: 14px;
	line-height: 1.4;
	color: var(--rw-ink);
}

.woocommerce div.product .variations_form .rw-swatch-current {
	margin: 0;
}

.woocommerce div.product .variations_form .rw-swatch-current__label {
	color: #7a7375;
}

.woocommerce div.product .variations_form .rw-swatch-current__value {
	font-weight: 600;
}

.woocommerce div.product .variations_form .rw-swatch-current__value.is-empty {
	font-weight: 400;
	font-style: italic;
	color: #9a9395;
}

.woocommerce div.product .variations_form .rw-swatch-sampler {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin-top: 12px;
	padding: 9px 16px;
	border: 1px solid var(--rw-accent);
	border-radius: 999px;
	background: #fff;
	color: var(--rw-ink);
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.woocommerce div.product .variations_form .rw-swatch-sampler svg {
	width: 16px;
	height: 16px;
	flex: none;
}

.woocommerce div.product .variations_form .rw-swatch-sampler:hover,
.woocommerce div.product .variations_form .rw-swatch-sampler:focus-visible {
	background: var(--rw-accent);
	border-color: var(--rw-accent);
	color: #fff;
	text-decoration: none;
	outline: none;
}

/* --- duży podgląd próbki (desktop, po najechaniu; wstrzykiwany przez JS) --- */
.rw-swatch-preview {
	position: fixed;
	width: 200px;
	height: 200px;
	box-sizing: border-box;
	border: 4px solid #fff;
	border-radius: 12px;
	background: #fff center / cover no-repeat;
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.22);
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.18s ease, visibility 0s linear 0.18s;
	z-index: 1001; /* panel boczny motywu ma 1000 */
	overflow: hidden;
}

.rw-swatch-preview.is-visible {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.18s ease, visibility 0s;
}

.rw-swatch-preview__name {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 8px 10px;
	background: rgba(49, 45, 46, 0.85);
	color: #fff;
	font-size: 12px;
	font-weight: 500;
	line-height: 1.3;
	text-align: center;
}

@media (prefers-reduced-motion: reduce) {
	.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value],
	.woocommerce div.product .variations_form .tawcvs-swatches .swatch-item-wrapper .swatch.rw-swatch[data-value] .rw-swatch__name,
	.rw-swatch-preview {
		transition: none;
	}
}
