/* =============================================================================
   RW 2026 – galeria karty produktu.
   Desktop (≥992px): div.product staje się siatką 2 kolumn (zdjęcia 58% | opis 38%),
   zdjęcia: 2 duże w pierwszym rzędzie, dalej rzędy po 3 mniejsze + „Zobacz więcej zdjęć”, prawa kolumna position: sticky
   (w gridzie blok zawierający = obszar siatki, więc „odkleja się” razem z końcem galerii).
   Mobile (<992px): pasek przewijany palcem (scroll-snap) z licznikiem.
   Nadpisujemy WooCommerce (woocommerce-layout.css, woocommerce.css) i style.css motywu
   wyłącznie specyficznością – scope: body.rw-gallery-on. Żadnych zmian w starych plikach.
   ============================================================================ */

:root {
	--rw-gal-gap: 12px;
	--rw-gal-radius: 6px;
	--rw-gal-bg: #f6f3f1;
	--rw-ink: #312d2e;
	--rw-accent: #ddb9b1;
	--rw-sticky-top: 84px; /* header po przewinięciu = 64px + oddech; JS koryguje, gdy opis jest wyższy niż ekran */
}

/* --- układ dwóch kolumn (desktop) ------------------------------------------
   .rw-product-top obejmuje galerię i opis (otwierany/zamykany hookami w gallery.php).
   Sticky opisu kończy się razem z tym kontenerem, czyli z końcem galerii. */
.rw-product-top {
	position: relative; /* dla znaczka promocji .onsale (absolute) */
}

.rw-product-top::after {
	content: "";
	display: table;
	clear: both;
}

@media (min-width: 992px) {
	.rw-gallery-on .rw-product-top {
		display: grid;
		grid-template-columns: minmax(0, 58fr) minmax(0, 38fr);
		column-gap: 4%;
		align-items: start;
	}

	.woocommerce.rw-gallery-on div.product .rw-product-top > div.images.rw-gallery {
		grid-column: 1;
		grid-row: 1;
		float: none;
		width: auto;
		margin: 0 0 2em;
	}

	.woocommerce.rw-gallery-on div.product .rw-product-top > div.summary {
		grid-column: 2;
		grid-row: 1;
		float: none;
		width: auto;
		position: -webkit-sticky;
		position: sticky;
		top: var(--rw-sticky-top);
		align-self: start;
	}
}

/* --- kontener galerii -------------------------------------------------------- */
.woocommerce.rw-gallery-on div.product div.images.rw-gallery {
	position: relative;
	padding: 0;
	opacity: 1; /* WC ustawia opacity w JS; nie czekamy na niego */
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .woocommerce-product-gallery__trigger {
	display: none; /* lupa WC – mamy własny przycisk „Pełny ekran” */
}

.rw-gallery__frame {
	position: relative;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__grid {
	display: grid;
	grid-template-columns: repeat(6, minmax(0, 1fr));
	gap: var(--rw-gal-gap);
	margin: 0;
	padding: 0;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery[data-rw-tiles="1"] .rw-gallery__grid {
	grid-template-columns: minmax(0, 1fr);
	max-width: 72%;
	margin: 0 auto;
}

/* Układ (życzenie klienta 2026-11-12): dwa pierwsze kafelki duże (po pół szerokości),
   kolejne mniejsze – po trzy w rzędzie. Siatka ma 6 kolumn: duży = 3, mały = 2.
   Wyjątki, żeby nie zostawały dziury: 4 kafelki = 2×2 duże, 3 kafelki = trzeci wyśrodkowany. */
@media (min-width: 992px) {
	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__item {
		grid-column: span 2;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__item:nth-child(-n + 2),
	.woocommerce.rw-gallery-on div.product div.images.rw-gallery[data-rw-tiles="4"] .rw-gallery__item {
		grid-column: span 3;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery[data-rw-tiles="3"] .rw-gallery__item:nth-child(3) {
		grid-column: 3 / span 2;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery[data-rw-tiles="1"] .rw-gallery__item {
		grid-column: auto;
	}
}

/* --- kafelek ---------------------------------------------------------------- */
.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__item {
	position: relative;
	display: block;
	width: auto;
	margin: 0;
	max-height: none;
	max-width: none;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border-radius: var(--rw-gal-radius);
	background: var(--rw-gal-bg);
	-webkit-user-select: none;
	user-select: none;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__link {
	display: block;
	width: 100%;
	height: 100%;
	cursor: zoom-in;
	outline-offset: -3px;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	object-position: center;
	transition: transform 0.45s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__item--contain {
	background: #fff;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__item--contain .rw-gallery__img {
	object-fit: contain;
}

@media (hover: hover) and (pointer: fine) {
	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__link:hover .rw-gallery__img {
		transform: scale(1.035);
	}
}

/* Kolejność: zdjęcia (3, albo 2 przy dwóch filmach), film(y), reszta zdjęć.
   DOM zostaje: zdjęcia, potem filmy – wymaga tego lightbox WC (indeks po rodzeństwie). */
.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__item--video {
	order: 1;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery.rw-gallery--has-video .rw-gallery__item:nth-child(n + 4):not(.rw-gallery__item--video) {
	order: 2;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery.rw-gallery--has-2-videos .rw-gallery__item:nth-child(n + 3):not(.rw-gallery__item--video) {
	order: 2;
}

/* Film MP4: <video> wstawiany po kliknięciu, wypełnia kafelek */
.rw-gallery__item--mp4 video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	background: #000;
	object-fit: contain;
}

.rw-gallery__item--mp4 .rw-gallery__video-btn {
	background: #f6f3f1;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__item--mp4 .rw-gallery__poster {
	opacity: 1;
	object-fit: cover;
}

/* Zwinięte: dodatkowe zdjęcia poza DOM-em renderowania (display:none = brak pobierania przy loading=lazy). */
@media (min-width: 992px) {
	.woocommerce.rw-gallery-on div.product div.images.rw-gallery.rw-gallery--collapsed .rw-gallery__item--extra {
		display: none;
	}
}

/* --- wideo ------------------------------------------------------------------ */
.rw-gallery__video-btn {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	background: #1d1a1b;
	cursor: pointer;
	position: relative;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__poster {
	opacity: 0.92;
}

.rw-gallery__play {
	position: absolute;
	left: 50%;
	top: 50%;
	width: 64px;
	height: 64px;
	margin: -32px 0 0 -32px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.92);
	color: var(--rw-ink);
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
	transition: transform 0.2s ease, background-color 0.2s ease;
}

.rw-gallery__play svg {
	width: 30px;
	height: 30px;
	margin-left: 3px;
}

.rw-gallery__video-btn:hover .rw-gallery__play,
.rw-gallery__video-btn:focus-visible .rw-gallery__play {
	transform: scale(1.08);
	background: #fff;
}

.rw-gallery__video-label {
	position: absolute;
	left: 14px;
	bottom: 12px;
	padding: 6px 10px;
	border-radius: 4px;
	background: rgba(49, 45, 46, 0.78);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.rw-gallery__item--video.is-playing .rw-gallery__video-btn {
	display: none;
}

.rw-gallery__item--video iframe {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* --- licznik (mobile) ------------------------------------------------------- */
.rw-gallery__counter {
	display: none;
	position: absolute;
	right: 12px;
	bottom: 12px;
	padding: 5px 10px;
	border-radius: 999px;
	background: rgba(49, 45, 46, 0.72);
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.04em;
	pointer-events: none;
	z-index: 2;
}

/* --- przyciski pod galerią -------------------------------------------------- */
.rw-gallery__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	justify-content: center;
	align-items: center;
	margin: 18px 0 0;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__more,
.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__fullscreen {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 12px 22px;
	border-radius: 999px;
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	line-height: 1;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__more {
	border: 1px solid var(--rw-ink);
	background: var(--rw-ink);
	color: #fff;
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__more:hover,
.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__more:focus-visible {
	background: #000;
	border-color: #000;
	color: #fff;
}

.rw-gallery__more-icon {
	width: 16px;
	height: 16px;
	transition: transform 0.2s ease;
}

.rw-gallery__more[aria-expanded="true"] .rw-gallery__more-icon {
	transform: rotate(180deg);
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__fullscreen {
	border: 1px solid #d9d3d1;
	background: #fff;
	color: var(--rw-ink);
}

.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__fullscreen:hover,
.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__fullscreen:focus-visible {
	border-color: var(--rw-ink);
	background: #fff;
	color: var(--rw-ink);
}

.rw-gallery__fullscreen svg {
	width: 16px;
	height: 16px;
}

/* --- wymiary ---------------------------------------------------------------- */
.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__specs {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 10px 36px;
	list-style: none;
	margin: 22px 0 0;
	padding: 18px 0 0;
	border-top: 1px solid #ece7e4;
}

.rw-gallery__spec {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	min-width: 64px;
	text-align: center;
	color: var(--rw-ink);
}

.rw-gallery__spec .icon {
	font-size: 32px;
	color: var(--rw-accent);
	line-height: 1;
}

.rw-gallery__spec-label {
	font-size: 11px;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #8a8385;
}

.rw-gallery__spec-value {
	font-size: 13px;
	font-weight: 600;
}

/* =============================================================================
   Mobile / tablet: pasek przewijany
   ============================================================================ */
@media (max-width: 991.98px) {
	.woocommerce.rw-gallery-on div.product div.images.rw-gallery {
		width: 100%;
		float: none;
		margin: 0 0 24px;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__grid,
	.woocommerce.rw-gallery-on div.product div.images.rw-gallery[data-rw-tiles="1"] .rw-gallery__grid {
		display: flex;
		max-width: none;
		gap: 8px;
		margin: 0 -15px;
		padding: 0 15px;
		overflow-x: auto;
		overflow-y: hidden;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
		overscroll-behavior-x: contain;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__grid::-webkit-scrollbar {
		display: none;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__item {
		flex: 0 0 100%;
		scroll-snap-align: center;
		scroll-snap-stop: always;
		border-radius: 4px;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__link {
		cursor: default;
	}

	.rw-gallery__counter {
		display: block;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__more {
		display: none; /* wszystkie zdjęcia są w pasku */
	}

	.rw-gallery__actions {
		margin-top: 12px;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__specs {
		gap: 8px 22px;
		margin-top: 16px;
		padding-top: 14px;
	}

	.rw-gallery__spec .icon {
		font-size: 28px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__img,
	.rw-gallery__play,
	.rw-gallery__more-icon {
		transition: none;
	}

	.woocommerce.rw-gallery-on div.product div.images.rw-gallery .rw-gallery__grid {
		scroll-behavior: auto;
	}
}
