/*
 * Pop-up próbek na stronie głównej (template-parts/front-page/samples-popup.php,
 * assets/js/samples-popup.js). Wzorzec z Figmy: pop-up-probki.png, ramka
 * 910x576 (desktop, jednostka --u ramki 1728). Mobile nie ma projektu: okno
 * 328px (ramka 360), zdjęcie nad tekstem, te same kolory i typografia.
 */

.samples-popup {
	/* Jasnoszare tło z prawej krawędzi wzorca (224, 226, 232). */
	--samples-popup-bg: #e0e2e8;

	width: calc(328 * var(--u));
	max-width: calc(100vw - 32px);
	max-height: calc(100dvh - 32px);
	margin: auto;
	padding: 0;
	border: 0;
	border-radius: var(--radius-0);
	overflow: auto;
	background-color: var(--samples-popup-bg);
	color: var(--color-ink);
	overscroll-behavior: contain;
}

.samples-popup::backdrop {
	background-color: rgb(30 30 28 / 0.6);
}

/* Strona pod oknem nie przewija się, gdy pop-up jest otwarty. */
html.has-samples-popup {
	overflow: hidden;
}

.samples-popup__inner {
	position: relative;
}

.samples-popup__media {
	display: block;
	position: relative;
	aspect-ratio: 1040 / 840;
	overflow: hidden;
	background-color: var(--samples-popup-bg);
}

.samples-popup__media img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}

/* Mobile: dół zdjęcia przechodzi w tło okna, bez widocznej krawędzi. */
.samples-popup__media::after {
	content: "";
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	height: 22%;
	background-image: linear-gradient(to bottom, rgb(224 226 232 / 0) 0%, var(--samples-popup-bg) 100%);
	pointer-events: none;
}

.samples-popup__content {
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: calc(8 * var(--u)) calc(20 * var(--u)) calc(28 * var(--u));
	text-align: center;
}

.samples-popup__title {
	margin: 0;
	font-size: calc(22 * var(--u));
	font-weight: var(--font-weight-bold);
	line-height: calc(27 * var(--u));
	text-transform: uppercase;
	color: var(--color-brand-red);
}

.samples-popup__text {
	max-width: calc(230 * var(--u));
	margin: calc(12 * var(--u)) 0 0;
	font-size: calc(12 * var(--u));
	font-weight: var(--font-weight-bold);
	line-height: calc(18 * var(--u));
	text-transform: uppercase;
	color: var(--color-ink);
}

.samples-popup__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: calc(183 * var(--u));
	min-height: calc(44 * var(--u));
	margin-top: calc(24 * var(--u));
	padding: 0 calc(24 * var(--u));
	background-color: var(--color-brand-red);
	color: var(--color-white);
	font-size: calc(13 * var(--u));
	font-weight: var(--font-weight-medium);
	line-height: 1.2;
	text-transform: uppercase;
	text-decoration: none;
	transition: background-color 0.2s ease;
}

.samples-popup__button:hover,
.samples-popup__button:focus-visible {
	background-color: var(--color-ink);
	color: var(--color-white);
}

.samples-popup__button:focus-visible,
.samples-popup__close:focus-visible {
	outline: 2px solid var(--color-ink);
	outline-offset: 2px;
}

/* Sam X (bez okręgu), pole kliknięcia większe niż rysunek. */
.samples-popup__close {
	position: absolute;
	top: calc(6 * var(--u));
	right: calc(6 * var(--u));
	z-index: 1;
	width: calc(40 * var(--u));
	height: calc(40 * var(--u));
	padding: calc(10 * var(--u));
	border: 0;
	background: none;
	color: var(--color-ink);
	cursor: pointer;
}

.samples-popup__close-icon {
	display: block;
	width: 100%;
	height: 100%;
	overflow: visible;
}

/*
 * Desktop (wzorzec 910x576): render popup.webp (1560x1152) w skali 0.521
 * (811x599) od x 32, y -5, czyli pudełko 107-314 i fiolka obok niej jak we
 * wzorcu. Prawa część przechodzi w tło #e0e2e8 (od ~440 do ~800).
 * Kolumna tekstu wyśrodkowana na x 643: tytuł 27/33 od 190, opis 14.5/21,
 * przycisk 183x43 od 375. X 26x26 od (849, 35).
 *
 * --pu: jednostka --u z dolną granicą 0.7px, żeby przy 900-1280px okno
 * (min. 637px) i tekst nie robiły się zbyt małe; od 1000px = --u.
 */
@media (min-width: 900px) {
	.samples-popup {
		--pu: max(var(--u), 0.7px);

		width: calc(910 * var(--pu));
		overflow: hidden;
	}

	.samples-popup__inner {
		aspect-ratio: 910 / 576;
		overflow: hidden;
	}

	.samples-popup__media {
		position: absolute;
		inset: 0;
		aspect-ratio: auto;
	}

	.samples-popup__media img {
		inset: auto;
		top: calc(-5 / 576 * 100%);
		left: calc(32 / 910 * 100%);
		width: calc(811 / 910 * 100%);
		height: auto;
		object-fit: fill;
	}

	.samples-popup__media::after {
		top: 0;
		height: auto;
		background-image: linear-gradient(
			90deg,
			rgb(224 226 232 / 0) 48%,
			rgb(224 226 232 / 0.35) 55%,
			rgb(224 226 232 / 0.72) 68%,
			rgb(224 226 232 / 0.9) 77%,
			var(--samples-popup-bg) 88%
		);
	}

	.samples-popup__content {
		position: absolute;
		top: calc(190 * var(--pu));
		left: calc(480 * var(--pu));
		width: calc(326 * var(--pu));
		padding: 0;
	}

	.samples-popup__title {
		font-size: calc(27 * var(--pu));
		line-height: calc(33 * var(--pu));
	}

	/* Opis łamie się po "?" jak we wzorcu (wiersze 206 i 254px). */
	.samples-popup__text {
		max-width: calc(275 * var(--pu));
		margin-top: calc(23 * var(--pu));
		font-size: calc(14.5 * var(--pu));
		line-height: calc(21 * var(--pu));
	}

	.samples-popup__button {
		min-width: calc(183 * var(--pu));
		min-height: calc(43 * var(--pu));
		margin-top: calc(54 * var(--pu));
		padding: 0 calc(28 * var(--pu));
		font-size: calc(14 * var(--pu));
	}

	.samples-popup__close {
		top: calc(26 * var(--pu));
		right: calc(27 * var(--pu));
		width: calc(44 * var(--pu));
		height: calc(44 * var(--pu));
		padding: calc(9 * var(--pu));
	}
}

@media (prefers-reduced-motion: no-preference) {
	.samples-popup[open] {
		animation: samples-popup-in 0.2s ease-out;
	}
}

@keyframes samples-popup-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}

	to {
		opacity: 1;
		transform: none;
	}
}
