/**
 * Popup zgód „Prywatność” — panel na całą szerokość ekranu wysuwany od dołu.
 * Tło strony przykrywa pseudoelement ::before na cały ekran, a panel leży
 * nad nim (wyższy z-index w tym samym kontekście nakładania).
 * Kolory, zaokrąglenia i fonty z ustawień motywu (zmienne z header.php).
 *
 * „Akceptuj” i „Odrzuć” mają celowo ten sam wygląd: odmowa nie może być
 * trudniejsza ani mniej widoczna niż zgoda (wytyczne EROD 03/2022, UODO).
 */

.qd-consent,
.qd-embed,
.qd-consent-fab {
	/* Domyślnie z ustawień szablonu; własne kolory z panelu nadpisują je przez atrybut style. */
	--qd-primary: var(--primary-color, #1e5aa0);
	--qd-btn-text: #ffffff;
	--qd-bg: #ffffff;
	--qd-overlay: rgba(15, 23, 42, 0.6);
	--qd-primary-soft: color-mix(in srgb, var(--qd-primary) 10%, var(--qd-bg));
	--qd-primary-shadow: color-mix(in srgb, var(--qd-primary) 22%, transparent);
	--qd-ink: #1e293b;
	--qd-muted: #5b6474;
	--qd-paper: var(--bg-color, #fcfaf7);
	--qd-line: #e5e1d8;
	--qd-radius: var(--radius, 12px);
	--qd-btn-radius: var(--btn-radius, 50px);
	font-family: var(--font-body, Poppins, "Segoe UI", sans-serif);
	line-height: 1.5;
}

.qd-consent[hidden] {
	display: none !important;
}

/* Tło strony nie przewija się pod otwartym popupem. */
html.qd-consent-open {
	overflow: hidden;
}

/* ---------- Warstwa popupu ---------- */

/* Uwaga: .qd-consent nie może mieć transform/filter — zamieniłyby
   position: fixed pseudoelementu w pozycjonowanie względem kontenera. */
.qd-consent {
	position: fixed;
	inset: 0;
	z-index: 99990;
	display: flex;
	flex-direction: column;
	justify-content: flex-end;
	color: var(--qd-ink);
}

/* Nakładka na całą szerokość i wysokość ekranu, pod panelem. */
.qd-consent::before {
	content: "";
	position: fixed;
	inset: 0;
	z-index: 1;
	background: var(--qd-overlay);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	animation: qd-consent-fade 0.35s ease-out both;
}

.qd-consent--no-blur::before {
	-webkit-backdrop-filter: none;
	backdrop-filter: none;
}

/* Panel — nad nakładką. */
.qd-consent__panel {
	position: relative;
	z-index: 2;
	width: 100%;
	max-height: 92vh;
	max-height: 92dvh;
	overflow-y: auto;
	overscroll-behavior: contain;
	background: var(--qd-bg);
	border-top: 4px solid var(--qd-primary);
	box-shadow: 0 -18px 40px rgba(15, 23, 42, 0.25);
	animation: qd-consent-up 0.45s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Domyślny układ: treść, (ustawienia), przyciski pod treścią, stopka. */
.qd-consent__inner {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-areas:
		"head"
		"settings"
		"actions"
		"meta";
	gap: 18px;
	max-width: var(--container-width, 1200px);
	margin: 0 auto;
	padding: 26px 24px 18px;
}

/* Opcja „Obok treści”: przyciski po prawej, tylko na szerokich ekranach. */
@media (min-width: 1025px) {
	.qd-consent--inline .qd-consent__inner {
		grid-template-columns: minmax(0, 1fr) auto;
		grid-template-areas:
			"head     actions"
			"settings settings"
			"meta     meta";
		align-items: center;
		column-gap: 40px;
	}

	.qd-consent--inline .qd-consent__actions {
		justify-content: flex-end;
	}
}

.qd-consent__head {
	grid-area: head;
	min-width: 0;
}

.qd-consent__tab {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 8px;
	padding: 4px 12px;
	border-radius: 999px;
	background: var(--qd-primary-soft);
	color: var(--qd-primary);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
}

.qd-consent__title {
	margin: 0 0 6px;
	font-family: var(--font-heading, inherit);
	font-size: 1.3rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--qd-ink);
	outline: none;
}

.qd-consent__text {
	max-width: 760px;
	font-size: 0.9rem;
	color: var(--qd-muted);
}

.qd-consent__text p {
	margin: 0;
}

/* ---------- Przyciski ---------- */

.qd-consent__actions {
	grid-area: actions;
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-start;
	gap: 10px;
}

.qd-consent--align-center .qd-consent__actions {
	justify-content: center;
}

.qd-consent--align-right .qd-consent__actions {
	justify-content: flex-end;
}

.qd-consent--align-stretch .qd-consent__actions .qd-consent__btn {
	flex: 1 1 0;
}

.qd-consent__btn {
	appearance: none;
	min-height: 48px;
	padding: 12px 24px;
	border: 2px solid var(--qd-primary);
	border-radius: var(--qd-btn-radius);
	background: var(--qd-primary);
	color: var(--qd-btn-text);
	font: inherit;
	font-size: 0.92rem;
	font-weight: 700;
	line-height: 1.2;
	white-space: nowrap;
	cursor: pointer;
	transition: filter 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.qd-consent__btn:hover {
	filter: brightness(1.12);
}

.qd-consent__btn:active {
	transform: translateY(1px);
}

.qd-consent__btn--ghost {
	background: var(--qd-bg);
	color: var(--qd-primary);
}

.qd-consent__btn--ghost:hover {
	filter: none;
	background: var(--qd-primary-soft);
}

/* Po rozwinięciu ustawień „Zapisz mój wybór” dostaje wyróżnienie. */
.qd-consent.is-settings .qd-consent__btn--ghost {
	background: var(--qd-primary-soft);
}

/* ---------- Ustawienia (przełączniki kategorii) ---------- */

.qd-consent__settings {
	grid-area: settings;
	display: grid;
	grid-template-columns: repeat(4, minmax(0, 1fr));
	gap: 12px;
	padding: 16px;
	background: var(--qd-paper);
	border: 1px solid var(--qd-line);
	border-radius: var(--qd-radius);
}

.qd-consent__settings[hidden] {
	display: none;
}

.qd-consent-opt {
	display: flex;
	flex-direction: column;
	gap: 6px;
	padding: 14px;
	background: #fff;
	border: 1.5px solid var(--qd-line);
	border-radius: calc(var(--qd-radius) * 0.75);
	cursor: pointer;
	transition: border-color 0.15s ease;
}

.qd-consent-opt:hover,
.qd-consent-opt:has(:checked) {
	border-color: var(--qd-primary);
}

.qd-consent-opt.is-locked {
	cursor: default;
	border-style: dashed;
}

.qd-consent-opt__top {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 10px;
}

.qd-consent-opt__name {
	font-weight: 700;
	font-size: 0.92rem;
	line-height: 1.25;
}

.qd-consent-opt__name small {
	display: block;
	font-weight: 400;
	font-size: 0.72rem;
	color: var(--qd-muted);
}

.qd-consent-opt__always {
	font-size: 0.72rem;
	font-weight: 700;
	color: #15803d;
	text-transform: uppercase;
	letter-spacing: 0.05em;
}

.qd-consent-opt__desc {
	font-size: 0.8rem;
	color: var(--qd-muted);
}

/* Przełącznik na zwykłym checkboksie — czytniki ekranu widzą „przełącznik”. */
.qd-consent-switch {
	appearance: none;
	-webkit-appearance: none;
	flex: 0 0 auto;
	position: relative;
	width: 44px;
	height: 24px;
	margin: 0;
	border-radius: 24px;
	background: #cbd5e1;
	cursor: pointer;
	transition: background 0.15s ease;
}

.qd-consent-switch::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
	transition: transform 0.15s ease;
}

.qd-consent-switch:checked {
	background: var(--qd-primary);
}

.qd-consent-switch:checked::after {
	transform: translateX(20px);
}

/* ---------- Stopka popupu ---------- */

.qd-consent__meta {
	grid-area: meta;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 16px;
	margin: 0;
	padding-top: 12px;
	border-top: 1px solid var(--qd-line);
	font-size: 0.78rem;
	color: var(--qd-muted);
}

.qd-consent__meta:not(:has(> :not([hidden]))) {
	display: none;
}

.qd-consent__meta a {
	color: var(--qd-muted);
	text-decoration: underline;
}

.qd-consent__close {
	margin-left: auto;
	padding: 2px 0;
	border: 0;
	background: none;
	color: var(--qd-primary);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.qd-consent__btn:focus-visible,
.qd-consent-switch:focus-visible,
.qd-consent__close:focus-visible,
.qd-consent__meta a:focus-visible,
.qd-embed__always:focus-visible,
.qd-consent-fab:focus-visible {
	outline: 3px solid var(--qd-primary);
	outline-offset: 2px;
}

.qd-consent__title:focus-visible {
	outline: 2px dashed var(--qd-primary);
	outline-offset: 4px;
}

/* ---------- Link „Ustawienia cookies” w stopce ---------- */

.site-footer a[data-qd-consent-open] {
	color: inherit;
	text-decoration: underline;
}

/* ---------- Pływająca zakładka „Prywatność” ---------- */

.qd-consent-fab {
	position: fixed;
	left: 24px;
	bottom: 0;
	z-index: 99980;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	height: 32px;
	padding: 0 14px;
	border: 0;
	border-radius: 10px 10px 0 0;
	background: var(--qd-primary);
	color: var(--qd-btn-text);
	font-size: 0.72rem;
	font-weight: 700;
	letter-spacing: 0.08em;
	text-transform: uppercase;
	box-shadow: 0 -2px 10px rgba(15, 23, 42, 0.15);
	cursor: pointer;
	transition: height 0.15s ease;
}

.qd-consent-fab:hover {
	height: 36px;
}

html.qd-consent-open .qd-consent-fab {
	display: none;
}

/* ---------- Zaślepka osadzonej treści ---------- */

.qd-embed {
	position: relative;
	min-height: 260px;
}

.qd-embed iframe[data-qd-src] {
	visibility: hidden;
}

.qd-embed__ph {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	border-radius: inherit;
	background: #e9eef3;
}

/* Mapa: szkic planu ulic zamiast pustego pola. */
.qd-embed--map .qd-embed__ph {
	background-color: #e8eee3;
	background-image:
		linear-gradient(32deg, transparent 47%, #f6dfa4 47%, #f6dfa4 53%, transparent 53%),
		linear-gradient(-58deg, transparent 49%, #fff 49%, #fff 51.5%, transparent 51.5%),
		repeating-linear-gradient(0deg, transparent 0 46px, #fff 46px 52px),
		repeating-linear-gradient(90deg, transparent 0 70px, #fff 70px 76px);
}

.qd-embed--video .qd-embed__ph {
	background: linear-gradient(135deg, #1e293b, #0f172a);
}

.qd-embed__note {
	max-width: 340px;
	padding: 16px 18px;
	background: #fff;
	border: 2px solid var(--qd-primary);
	border-radius: var(--qd-radius);
	box-shadow: 6px 6px 0 var(--qd-primary-shadow);
	text-align: center;
	font-size: 0.84rem;
	color: var(--qd-muted);
}

.qd-embed__icon {
	display: block;
	margin: -36px auto 6px;
	padding: 6px;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: var(--qd-primary);
	color: #fff;
	box-shadow: 0 0 0 4px #fff;
}

.qd-embed__note p {
	margin: 0 0 12px;
}

.qd-embed__note strong {
	color: var(--qd-ink);
}

.qd-embed__note .qd-consent__btn {
	width: 100%;
}

.qd-embed__always {
	margin-top: 8px;
	padding: 4px;
	border: 0;
	background: none;
	color: var(--qd-primary);
	font: inherit;
	font-size: 0.8rem;
	font-weight: 600;
	text-decoration: underline;
	cursor: pointer;
}

/* ---------- Tablet ---------- */

@media (max-width: 1024px) {
	.qd-consent__settings {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

/* ---------- Telefon ---------- */

@media (max-width: 600px) {
	.qd-consent__inner {
		padding: 20px 16px 14px;
	}

	.qd-consent__title {
		font-size: 1.15rem;
	}

	.qd-consent__text {
		font-size: 0.85rem;
	}

	.qd-consent__actions {
		flex-direction: column-reverse;
	}

	.qd-consent__actions .qd-consent__btn {
		width: 100%;
		flex: none;
	}

	.qd-consent__settings {
		grid-template-columns: minmax(0, 1fr);
		padding: 10px;
	}
}

@keyframes qd-consent-up {
	from { transform: translateY(100%); }
	to   { transform: translateY(0); }
}

@keyframes qd-consent-fade {
	from { opacity: 0; }
	to   { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.qd-consent::before,
	.qd-consent__panel {
		animation: none;
	}
}
