/*
 * LE Consent — front-end banner, preferences panel and revisit button.
 *
 * Every rule is anchored to the plugin's own container ID
 * (#le-consent, or #le-consent-preview in the admin), so theme and
 * page-builder styles for buttons, links and headings can't leak in.
 * Colours come from custom properties set in Consent → Banner.
 */

:is(#le-consent, #le-consent-preview) {
	--lec-bg: #ffffff;
	--lec-text: #1f2328;
	--lec-btn-bg: #1f2328;
	--lec-btn-text: #ffffff;
	--lec-link: #1f2328;
	--lec-muted: color-mix(in srgb, var(--lec-text) 72%, var(--lec-bg));
	--lec-line: color-mix(in srgb, var(--lec-text) 14%, var(--lec-bg));
	--lec-soft: color-mix(in srgb, var(--lec-text) 6%, var(--lec-bg));
	--lec-radius: 10px;
	--lec-z: 2147483000;
	font-size: 15px;
	line-height: 1.5;
	color: var(--lec-text);
	text-align: left;
	letter-spacing: normal;
	text-transform: none;
}

:is(#le-consent, #le-consent-preview).lec--system-font,
:is(#le-consent, #le-consent-preview).lec--system-font :is(button, p, span, a, li) {
	font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

:is(#le-consent, #le-consent-preview) *,
:is(#le-consent, #le-consent-preview) *::before,
:is(#le-consent, #le-consent-preview) *::after {
	box-sizing: border-box;
}

:is(#le-consent, #le-consent-preview) [hidden] {
	display: none !important;
}

/* ---------------------------------------------------------------- reset */

:is(#le-consent, #le-consent-preview) button,
:is(#le-consent, #le-consent-preview) button:hover,
:is(#le-consent, #le-consent-preview) button:focus,
:is(#le-consent, #le-consent-preview) button:active {
	-webkit-appearance: none;
	appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	width: auto;
	min-width: 0;
	height: auto;
	min-height: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	font-size: inherit;
	font-weight: inherit;
	line-height: 1.2;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: none;
	text-align: inherit;
	white-space: normal;
	cursor: pointer;
	transition: none;
}

:is(#le-consent, #le-consent-preview) p {
	margin: 0;
	padding: 0;
	font-size: inherit;
	line-height: inherit;
	color: inherit;
}

:is(#le-consent, #le-consent-preview) a,
:is(#le-consent, #le-consent-preview) a:visited {
	color: var(--lec-link);
	font: inherit;
	font-size: inherit;
	font-weight: 600;
	text-decoration: underline;
	text-underline-offset: 2px;
	box-shadow: none;
}

:is(#le-consent, #le-consent-preview) a:hover {
	color: var(--lec-link);
	opacity: 0.8;
}

:is(#le-consent, #le-consent-preview) ul,
:is(#le-consent, #le-consent-preview) li {
	margin: 0;
	padding: 0;
	list-style: none;
}

:is(#le-consent, #le-consent-preview) svg {
	display: block;
	flex: none;
	fill: none;
	width: auto;
	height: auto;
}

html.lec-lock,
html.lec-lock body {
	overflow: hidden;
}

/* -------------------------------------------------------------- overlay */

:is(#le-consent, #le-consent-preview) .lec-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 20, 25, 0.5);
	z-index: var(--lec-z);
}

/* --------------------------------------------------------------- banner */

:is(#le-consent, #le-consent-preview) .lec-banner {
	position: fixed;
	z-index: calc(var(--lec-z) + 1);
	background: var(--lec-bg);
	color: var(--lec-text);
	display: flex;
	gap: 20px;
	outline: none;
}

:is(#le-consent, #le-consent-preview) .lec-title {
	font-size: 17px;
	font-weight: 700;
	line-height: 1.3;
	margin: 0 0 6px;
}

:is(#le-consent, #le-consent-preview) .lec-desc {
	font-size: 14px;
	line-height: 1.55;
	max-width: 760px;
}

:is(#le-consent, #le-consent-preview) .lec-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	align-items: center;
}

/* Bottom bar / top strip */
:is(#le-consent, #le-consent-preview):is(.lec--bar, .lec--top) .lec-banner {
	left: 0;
	right: 0;
	align-items: center;
	justify-content: space-between;
	padding: 20px clamp(16px, 4vw, 56px);
}

:is(#le-consent, #le-consent-preview).lec--bar .lec-banner {
	bottom: 0;
	box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.1);
}

:is(#le-consent, #le-consent-preview).lec--top .lec-banner {
	top: 0;
	padding-top: 12px;
	padding-bottom: 12px;
	box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

:is(#le-consent, #le-consent-preview).lec--top .lec-title {
	display: none;
}

:is(#le-consent, #le-consent-preview):is(.lec--bar, .lec--top) .lec-actions {
	flex: none;
}

/* Floating box */
:is(#le-consent, #le-consent-preview).lec--box .lec-banner {
	bottom: 24px;
	width: min(400px, calc(100vw - 32px));
	flex-direction: column;
	gap: 14px;
	padding: 24px;
	border-radius: 16px;
	box-shadow: 0 18px 50px rgba(0, 0, 0, 0.22);
}

:is(#le-consent, #le-consent-preview).lec--box.lec--pos-left .lec-banner {
	left: 24px;
}

:is(#le-consent, #le-consent-preview).lec--box.lec--pos-right .lec-banner {
	right: 24px;
}

/* Centred modal */
:is(#le-consent, #le-consent-preview).lec--modal .lec-banner {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	width: min(520px, calc(100vw - 32px));
	max-height: calc(100vh - 32px);
	overflow: auto;
	flex-direction: column;
	gap: 16px;
	padding: 32px;
	border-radius: 18px;
	box-shadow: 0 30px 80px rgba(0, 0, 0, 0.3);
}

:is(#le-consent, #le-consent-preview).lec--modal .lec-title {
	font-size: 21px;
}

:is(#le-consent, #le-consent-preview).lec--modal .lec-desc {
	font-size: 15px;
}

:is(#le-consent, #le-consent-preview):is(.lec--box, .lec--modal) .lec-actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
}

:is(#le-consent, #le-consent-preview):is(.lec--box, .lec--modal) .lec-actions [data-lec-action="manage"] {
	grid-column: 1 / -1;
	order: 3;
}

/* -------------------------------------------------------------- buttons */

:is(#le-consent, #le-consent-preview) button.lec-btn {
	min-height: 46px;
	padding: 0 20px;
	border-radius: var(--lec-radius);
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	white-space: nowrap;
	transition: filter 0.15s, background-color 0.15s;
}

/* Accept and Reject share one style on purpose: equal prominence. */
:is(#le-consent, #le-consent-preview) button.lec-btn--solid,
:is(#le-consent, #le-consent-preview) button.lec-btn--solid:hover,
:is(#le-consent, #le-consent-preview) button.lec-btn--solid:focus {
	background: var(--lec-btn-bg);
	color: var(--lec-btn-text);
	border: 1.5px solid var(--lec-btn-bg);
}

:is(#le-consent, #le-consent-preview) button.lec-btn--outline,
:is(#le-consent, #le-consent-preview) button.lec-btn--outline:focus {
	background: transparent;
	color: var(--lec-text);
	border: 1.5px solid var(--lec-btn-bg);
}

:is(#le-consent, #le-consent-preview) button.lec-btn--solid:hover {
	filter: brightness(0.92);
}

:is(#le-consent, #le-consent-preview) button.lec-btn--outline:hover {
	background: var(--lec-soft);
	color: var(--lec-text);
	border: 1.5px solid var(--lec-btn-bg);
}

:is(#le-consent, #le-consent-preview) button.lec-btn--block {
	width: 100%;
}

:is(#le-consent, #le-consent-preview) button:focus-visible,
:is(#le-consent, #le-consent-preview) a:focus-visible {
	outline: 3px solid color-mix(in srgb, var(--lec-btn-bg) 60%, #2a7fff);
	outline-offset: 2px;
}

:is(#le-consent, #le-consent-preview) button.lec-icon-btn,
:is(#le-consent, #le-consent-preview) button.lec-icon-btn:hover {
	width: 44px;
	height: 44px;
	flex: none;
	border-radius: var(--lec-radius);
	background: var(--lec-soft);
	color: var(--lec-text);
}

/* ---------------------------------------------------- preferences panel */

:is(#le-consent, #le-consent-preview) .lec-prefs {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	z-index: calc(var(--lec-z) + 2);
	width: min(460px, 100vw);
	background: var(--lec-bg);
	color: var(--lec-text);
	box-shadow: -18px 0 50px rgba(0, 0, 0, 0.16);
	display: flex;
	flex-direction: column;
	outline: none;
}

:is(#le-consent, #le-consent-preview) .lec-prefs__head {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	gap: 12px;
	padding: 24px 24px 18px;
	border-bottom: 1px solid var(--lec-line);
}

:is(#le-consent, #le-consent-preview) .lec-prefs__title {
	font-size: 20px;
	font-weight: 700;
	line-height: 1.3;
	margin: 0 0 6px;
}

:is(#le-consent, #le-consent-preview) .lec-prefs__intro {
	font-size: 13px;
	color: var(--lec-muted);
}

:is(#le-consent, #le-consent-preview) .lec-prefs__body {
	flex: 1;
	overflow-y: auto;
	padding: 8px 24px;
}

:is(#le-consent, #le-consent-preview) .lec-cat {
	border-bottom: 1px solid var(--lec-line);
	padding: 10px 0;
}

:is(#le-consent, #le-consent-preview) .lec-cat:last-child {
	border-bottom: 0;
}

:is(#le-consent, #le-consent-preview) .lec-cat__head {
	display: flex;
	align-items: center;
	gap: 12px;
}

:is(#le-consent, #le-consent-preview) button.lec-cat__toggle,
:is(#le-consent, #le-consent-preview) button.lec-cat__toggle:hover {
	flex: 1;
	justify-content: flex-start;
	gap: 10px;
	min-height: 48px;
	padding: 4px 0;
	text-align: left;
	color: var(--lec-text);
	background: none;
	border: 0;
}

:is(#le-consent, #le-consent-preview) .lec-chev {
	transition: transform 0.15s;
}

:is(#le-consent, #le-consent-preview) .lec-cat__toggle[aria-expanded="true"] .lec-chev {
	transform: rotate(90deg);
}

:is(#le-consent, #le-consent-preview) .lec-cat__label {
	display: flex;
	flex-direction: column;
	gap: 1px;
}

:is(#le-consent, #le-consent-preview) .lec-cat__name {
	font-size: 15px;
	font-weight: 700;
	color: var(--lec-text);
}

:is(#le-consent, #le-consent-preview) .lec-cat__count {
	font-size: 12px;
	font-weight: 400;
	color: var(--lec-muted);
}

:is(#le-consent, #le-consent-preview) .lec-always {
	flex: none;
	font-size: 12px;
	font-weight: 700;
	color: var(--lec-muted);
}

:is(#le-consent, #le-consent-preview) .lec-cat__body {
	padding: 2px 0 10px 26px;
	font-size: 13px;
	line-height: 1.5;
	color: var(--lec-muted);
}

:is(#le-consent, #le-consent-preview) ul.lec-cookie-list {
	margin: 10px 0 0;
	padding: 10px 12px;
	border-radius: 8px;
	background: var(--lec-soft);
	color: var(--lec-text);
	display: flex;
	flex-direction: column;
	gap: 8px;
}

:is(#le-consent, #le-consent-preview) .lec-cookie-list li {
	display: flex;
	flex-direction: column;
}

:is(#le-consent, #le-consent-preview) .lec-cookie-list__name {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 12px;
	font-weight: 600;
}

:is(#le-consent, #le-consent-preview) .lec-cookie-list__meta,
:is(#le-consent, #le-consent-preview) .lec-cookie-list__desc {
	font-size: 12px;
	color: var(--lec-muted);
}

/* Toggle switch */
:is(#le-consent, #le-consent-preview) button.lec-switch,
:is(#le-consent, #le-consent-preview) button.lec-switch:hover,
:is(#le-consent, #le-consent-preview) button.lec-switch:focus {
	flex: none;
	justify-content: flex-start;
	width: 52px;
	height: 30px;
	min-height: 30px;
	padding: 3px;
	border: 0;
	border-radius: 999px;
	background: color-mix(in srgb, var(--lec-text) 28%, var(--lec-bg));
	transition: background-color 0.15s;
}

:is(#le-consent, #le-consent-preview) button.lec-switch[aria-checked="true"] {
	justify-content: flex-end;
	background: var(--lec-btn-bg);
}

:is(#le-consent, #le-consent-preview) .lec-switch__knob {
	display: block;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: #ffffff;
	box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

:is(#le-consent, #le-consent-preview) .lec-prefs__foot {
	padding: 16px 24px 20px;
	border-top: 1px solid var(--lec-line);
	display: flex;
	flex-direction: column;
	gap: 10px;
}

:is(#le-consent, #le-consent-preview) .lec-prefs__row {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

:is(#le-consent, #le-consent-preview) .lec-prefs__meta {
	font-size: 11px;
	line-height: 1.6;
	color: var(--lec-muted);
	text-align: center;
}

:is(#le-consent, #le-consent-preview) .lec-prefs__meta a {
	font-size: 11px;
}

/* ------------------------------------------------------- revisit button */

:is(#le-consent, #le-consent-preview) button.lec-revisit,
:is(#le-consent, #le-consent-preview) button.lec-revisit:hover,
:is(#le-consent, #le-consent-preview) button.lec-revisit:focus {
	position: fixed;
	bottom: 20px;
	z-index: calc(var(--lec-z) - 1);
	width: 52px;
	height: 52px;
	min-height: 52px;
	padding: 0;
	border-radius: 999px;
	border: 2px solid var(--lec-btn-text);
	background: var(--lec-btn-bg);
	color: var(--lec-btn-text);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
	transition: transform 0.15s;
}

:is(#le-consent, #le-consent-preview) button.lec-revisit:hover {
	transform: translateY(-2px);
}

:is(#le-consent, #le-consent-preview) button.lec-revisit svg {
	width: 24px;
	height: 24px;
}

/* Icon + label pill */
:is(#le-consent, #le-consent-preview) button.lec-revisit.lec-revisit--label,
:is(#le-consent, #le-consent-preview) button.lec-revisit.lec-revisit--label:hover {
	width: auto;
	height: 46px;
	min-height: 46px;
	padding: 0 18px 0 14px;
	gap: 8px;
	font-size: 14px;
	font-weight: 700;
	white-space: nowrap;
}

:is(#le-consent, #le-consent-preview) button.lec-revisit.lec-revisit--label svg {
	width: 20px;
	height: 20px;
}

:is(#le-consent, #le-consent-preview).lec--revisit-left button.lec-revisit {
	left: 20px;
	right: auto;
}

:is(#le-consent, #le-consent-preview).lec--revisit-right button.lec-revisit {
	right: 20px;
	left: auto;
}

/* --------------------------------------------------- blocked embed card */

div.le-consent-placeholder {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	width: 100%;
	min-height: 200px;
	margin: 0 0 1em;
	padding: 24px;
	border-radius: 12px;
	background: #f1f3f5;
	color: #1f2328;
	text-align: center;
	font-size: 14px;
	line-height: 1.5;
}

div.le-consent-placeholder p {
	margin: 0;
	max-width: 420px;
	color: #1f2328;
	font-size: 14px;
}

div.le-consent-placeholder button.le-consent-placeholder__btn,
div.le-consent-placeholder button.le-consent-placeholder__btn:hover,
div.le-consent-placeholder button.le-consent-placeholder__btn:focus {
	-webkit-appearance: none;
	appearance: none;
	min-height: 44px;
	padding: 0 18px;
	border-radius: 10px;
	border: 0;
	background: #1f2328;
	color: #ffffff;
	font: inherit;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.2;
	text-transform: none;
	cursor: pointer;
}

/* --------------------------------------------------------------- mobile */

@media (max-width: 640px) {
	#le-consent:is(.lec--bar, .lec--top, .lec--box) .lec-banner {
		top: auto;
		left: 0;
		right: 0;
		bottom: 0;
		width: 100%;
		flex-direction: column;
		align-items: stretch;
		gap: 14px;
		padding: 20px 16px calc(16px + env(safe-area-inset-bottom));
		border-radius: 16px 16px 0 0;
		max-height: 80vh;
		overflow: auto;
	}

	#le-consent.lec--top .lec-title {
		display: block;
	}

	#le-consent .lec-actions {
		display: grid;
		grid-template-columns: 1fr 1fr;
	}

	#le-consent .lec-actions [data-lec-action="manage"] {
		grid-column: 1 / -1;
		order: 3;
	}

	#le-consent.lec--modal .lec-banner {
		padding: 24px 20px;
	}

	#le-consent .lec-prefs {
		width: 100vw;
	}

	#le-consent button.lec-revisit.lec-revisit--label span {
		display: none;
	}

	#le-consent button.lec-revisit.lec-revisit--label {
		width: 52px;
		padding: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	:is(#le-consent, #le-consent-preview) *,
	:is(#le-consent, #le-consent-preview) *::before,
	:is(#le-consent, #le-consent-preview) *::after {
		transition: none !important;
	}
}

/* ------------------------------------------- admin live preview scope */

#le-consent-preview {
	position: absolute;
	inset: 0;
	--lec-z: 1;
	pointer-events: none;
}

#le-consent-preview .lec-banner,
#le-consent-preview .lec-overlay {
	position: absolute;
}

#le-consent-preview.lec--modal .lec-overlay,
#le-consent-preview.lec--dim .lec-overlay {
	display: block !important;
}

#le-consent-preview button.lec-revisit {
	position: absolute;
}
