/*
 * Baner zgód (inc/consent.php). Kolory z tokenów motywu; opcjonalne nadpisanie: --mppc-consent-bg / --mppc-consent-accent
 * (ustawiane w Ustawienia → Zgody cookies). Telefon: pełna szerokość u dołu (arkusz); tablet i desktop: karta w lewym dolnym rogu.
 */

.mppc-consent {
	--_bg: var(--mppc-consent-bg, var(--wp--preset--color--white));
	--_accent: var(--mppc-consent-accent, var(--wp--custom--color--accent));
	/* przyciski: ciemna czerwień (kontrast ≥ 4,5:1 z białym i z tłem karty); jasna czerwień akcentu tylko do linii */
	--_action: var(--mppc-consent-accent, var(--wp--preset--color--brand-primary-strong));
	position: fixed;
	z-index: 100000;
	inset: auto 0 0;
	box-sizing: border-box;
	max-height: 90dvh;
	overflow-y: auto;
	overscroll-behavior: contain;
	padding: var(--wp--preset--spacing--24);
	border-top: var(--wp--custom--border-width--accent) solid var(--_accent);
	background: var(--_bg);
	color: var(--wp--preset--color--neutral-900);
	box-shadow: 0 -8px 32px color-mix(in srgb, var(--wp--preset--color--neutral-900) 18%, transparent);
	font-size: var(--wp--preset--font-size--nav);
	line-height: var(--wp--custom--line-height--body);
	opacity: 0;
	transform: translateY(1.5rem);
	transition:
		opacity var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--easing),
		transform var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--easing);
}

.mppc-consent[hidden] {
	display: none;
}

.mppc-consent.is-visible {
	opacity: 1;
	transform: none;
}

.mppc-consent:focus {
	outline: none;
}

.mppc-consent__title {
	margin: 0 0 var(--wp--preset--spacing--8);
	font-size: var(--wp--preset--font-size--h-4);
	line-height: var(--wp--custom--line-height--h-4);
}

.mppc-consent__intro {
	margin: 0 0 var(--wp--preset--spacing--16);
}

.mppc-consent__intro a {
	color: inherit;
	text-decoration-color: var(--_accent);
	text-underline-offset: 0.2em;
}

/* Rozsuwanie: wiersz siatki 0fr → 1fr (animowalna wysokość „auto”), treść przenika; zwinięta część jest inert */
.mppc-consent__details {
	display: grid;
	grid-template-rows: 0fr;
	opacity: 0;
	transition:
		grid-template-rows var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--easing),
		opacity var(--wp--custom--motion--duration-base) var(--wp--custom--motion--easing);
}

.mppc-consent__details-inner {
	min-height: 0;
	overflow: hidden;
	padding-block-end: 0;
}

.mppc-consent.is-expanded .mppc-consent__details {
	grid-template-rows: 1fr;
	opacity: 1;
}

.mppc-consent.is-expanded .mppc-consent__details-inner {
	padding-block-end: var(--wp--preset--spacing--16);
}

.mppc-consent__cats {
	display: grid;
	gap: var(--wp--preset--spacing--8);
	margin: 0;
	padding: 0;
	list-style: none;
}

.mppc-consent__cat {
	padding: var(--wp--preset--spacing--12) var(--wp--preset--spacing--16);
	background: color-mix(in srgb, var(--wp--preset--color--neutral-900) 5%, transparent);
}

.mppc-consent__cat p {
	margin: var(--wp--preset--spacing--4) 0 0;
	font-size: var(--wp--preset--font-size--caption);
}

.mppc-consent__cat-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--wp--preset--spacing--16);
	font-weight: var(--wp--custom--font-weight--semibold);
}

/* Przełącznik (input[role=switch] z natywnym stanem, fokusem i klawiaturą) */
.mppc-consent__switch {
	appearance: none;
	position: relative;
	flex: none;
	width: 48px;
	height: 28px;
	margin: 0;
	border-radius: 14px;
	background: var(--wp--preset--color--neutral-800);
	cursor: pointer;
	transition: background-color var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing);
}

.mppc-consent__switch::after {
	content: "";
	position: absolute;
	inset: 3px auto 3px 3px;
	width: 22px;
	border-radius: 50%;
	background: var(--wp--preset--color--white);
	transition: transform var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing);
}

.mppc-consent__switch:checked {
	background: var(--_action);
}

.mppc-consent__switch:checked::after {
	transform: translateX(20px);
}

.mppc-consent__switch:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.mppc-consent__list {
	margin-block-start: var(--wp--preset--spacing--12);
	font-size: var(--wp--preset--font-size--caption);
}

.mppc-consent__list summary {
	cursor: pointer;
	font-weight: var(--wp--custom--font-weight--semibold);
}

/* Płynne rozwijanie listy cookies (Chrome/Safari z interpolate-size; starsze przeglądarki otwierają bez animacji) */
@supports (interpolate-size: allow-keywords) {
	.mppc-consent__list {
		interpolate-size: allow-keywords;
	}

	.mppc-consent__list::details-content {
		block-size: 0;
		overflow: hidden;
		transition:
			block-size var(--wp--custom--motion--duration-base) var(--wp--custom--motion--easing),
			content-visibility var(--wp--custom--motion--duration-base) allow-discrete;
	}

	.mppc-consent__list[open]::details-content {
		block-size: auto;
	}
}

.mppc-consent__list table {
	width: 100%;
	margin-block-start: var(--wp--preset--spacing--8);
	border-collapse: collapse;
}

.mppc-consent__list th,
.mppc-consent__list td {
	padding: var(--wp--preset--spacing--4) var(--wp--preset--spacing--8) var(--wp--preset--spacing--4) 0;
	border-bottom: var(--wp--custom--border-width--hairline) solid var(--wp--custom--color--border);
	text-align: start;
	vertical-align: top;
}

.mppc-consent__actions {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--8);
}

.mppc-consent__btn {
	flex: 1 1 auto;
	padding: var(--wp--preset--spacing--12) var(--wp--preset--spacing--24);
	border: var(--wp--custom--border-width--hairline) solid var(--_action);
	border-radius: 0;
	background: transparent;
	color: var(--_action);
	font: inherit;
	font-weight: var(--wp--custom--font-weight--bold);
	text-align: center;
	cursor: pointer;
	transition: background-color var(--wp--custom--motion--duration-fast) var(--wp--custom--motion--easing);
}

/* „Zapisz wybór”: wsuwa się pod przyciskami (wiersz 0fr → 1fr), tak samo jak szczegóły */
.mppc-consent__save {
	display: grid;
	flex-basis: 100%;
	grid-template-rows: 0fr;
	margin-block-start: calc(-1 * var(--wp--preset--spacing--8)); /* kasuje odstęp flex, gdy zwinięty */
	opacity: 0;
	transition:
		grid-template-rows var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--easing),
		margin-block-start var(--wp--custom--motion--duration-slow) var(--wp--custom--motion--easing),
		opacity var(--wp--custom--motion--duration-base) var(--wp--custom--motion--easing);
}

.mppc-consent.is-expanded .mppc-consent__save {
	grid-template-rows: 1fr;
	margin-block-start: 0;
	opacity: 1;
}

.mppc-consent__save-inner {
	display: flex;
	min-height: 0;
	overflow: hidden;
}

.mppc-consent__save-inner > .mppc-consent__btn {
	flex: 1 1 auto;
}

.mppc-consent__btn:hover {
	background: color-mix(in srgb, var(--_action) 10%, transparent);
}

.mppc-consent__btn--primary,
.mppc-consent__btn--save {
	background: var(--_action);
	color: var(--wp--preset--color--white);
}

.mppc-consent__btn--primary:hover,
.mppc-consent__btn--save:hover {
	background: color-mix(in srgb, var(--_action) 85%, var(--wp--preset--color--neutral-900));
}

.mppc-consent__btn--link {
	flex-basis: 100%;
	border-color: transparent;
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.mppc-consent :is(button, summary, input, a):focus-visible {
	outline: var(--wp--custom--focus--width) solid var(--wp--custom--color--focus);
	outline-offset: var(--wp--custom--focus--offset);
}

@media (min-width: 782px) {
	.mppc-consent {
		inset: auto auto var(--wp--preset--spacing--24) var(--wp--preset--spacing--24);
		width: min(30rem, calc(100vw - 2 * var(--wp--preset--spacing--24)));
		border-top-width: var(--wp--custom--border-width--accent);
	}

	.mppc-consent__btn--link {
		flex-basis: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	.mppc-consent,
	.mppc-consent__details,
	.mppc-consent__save,
	.mppc-consent__list::details-content,
	.mppc-consent__switch,
	.mppc-consent__switch::after,
	.mppc-consent__btn {
		transition: none;
	}
}
