/**
 * BAUHELFER Consent: banner, settings panel, settings link, YouTube placeholder.
 *
 * Colors come from the theme's presets (--wp--preset--color--*), which the bauhelfer theme also
 * switches for dark mode. The fallbacks are the same palette, for themes without these presets.
 */

.bh-consent,
.bh-consent-open,
.bh-embed {
	--bhc-base: var(--wp--preset--color--base, #fff);
	--bhc-surface: var(--wp--preset--color--surface, #f3f4f7);
	--bhc-line: var(--wp--preset--color--line, #e1e4e8);
	--bhc-ink: var(--wp--preset--color--ink, #1f2933);
	--bhc-text: var(--wp--preset--color--text, #3e4c59);
	--bhc-muted: var(--wp--preset--color--muted, #5f6b78);
	--bhc-accent: var(--wp--preset--color--accent, #e47b02);
	--bhc-on-accent: var(--wp--preset--color--on-accent, #1f2933);
	--bhc-accent-text: var(--wp--preset--color--accent-text, #a65800);
}

:root[data-theme="dark"] .bh-consent,
:root[data-theme="dark"] .bh-consent-open,
:root[data-theme="dark"] .bh-embed {
	--bhc-base: var(--wp--preset--color--base, #14181c);
	--bhc-surface: var(--wp--preset--color--surface, #1d232a);
	--bhc-line: var(--wp--preset--color--line, #2e363f);
	--bhc-ink: var(--wp--preset--color--ink, #f1f3f5);
	--bhc-text: var(--wp--preset--color--text, #cfd6dd);
	--bhc-muted: var(--wp--preset--color--muted, #9aa5b1);
	--bhc-accent: var(--wp--preset--color--accent, #f0901a);
	--bhc-on-accent: var(--wp--preset--color--on-accent, #1f2933);
	--bhc-accent-text: var(--wp--preset--color--accent-text, #f5a54a);
}

.bh-consent-sr {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

/* Banner ------------------------------------------------------------------------------ */

.bh-consent {
	position: fixed;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 99999;
	max-height: 85vh;
	max-height: 85dvh;
	overflow-y: auto;
	overscroll-behavior: contain;
	box-sizing: border-box;
	border-top: 1px solid var(--bhc-line);
	background: var(--bhc-surface);
	box-shadow: 0 -6px 24px rgb(0 0 0 / 0.14);
	color: var(--bhc-text);
	font-size: 16px;
	line-height: 1.5;
	text-align: left;
}

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

.bh-consent *,
.bh-consent *::before,
.bh-consent *::after {
	box-sizing: border-box;
}

.bh-consent__inner {
	max-width: 1200px;
	margin: 0 auto;
	padding: 16px 16px max(16px, env(safe-area-inset-bottom));
}

.bh-consent__layer {
	display: grid;
	gap: 4px 32px;
	grid-template-columns: minmax(0, 1fr);
}

.bh-consent__title {
	margin: 0 0 4px;
	color: var(--bhc-ink);
	font-family: inherit;
	font-size: 18px;
	font-weight: 700;
	line-height: 1.3;
	letter-spacing: normal;
	text-transform: none;
}

.bh-consent__title:focus {
	outline: none;
}

.bh-consent__title:focus-visible {
	outline: 3px solid var(--bhc-ink);
	outline-offset: 2px;
}

.bh-consent__text {
	margin: 0;
	max-width: 75ch;
}

.bh-consent__links {
	display: flex;
	flex-wrap: wrap;
	gap: 0 16px;
	margin: 0;
}

.bh-consent a {
	color: var(--bhc-accent-text);
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.bh-consent__links a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
}

.bh-consent a:hover {
	text-decoration-thickness: 2px;
}

.bh-consent a:focus-visible,
.bh-consent button:focus-visible,
.bh-consent summary:focus-visible,
.bh-consent input:focus-visible,
.bh-consent-open:focus-visible,
.bh-embed a:focus-visible,
.bh-embed button:focus-visible,
.bh-embed__frame:focus-visible {
	outline: 3px solid var(--bhc-ink);
	outline-offset: 2px;
}

/* The three decision buttons share one look and size (no "nudging"). */
.bh-consent__actions {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 8px;
	margin-top: 8px;
}

.bh-consent__button,
.bh-embed__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	min-height: 44px;
	margin: 0;
	padding: 10px 16px;
	border: 2px solid var(--bhc-accent);
	border-radius: 6px;
	background: var(--bhc-accent);
	color: var(--bhc-on-accent);
	font: inherit;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
}

.bh-consent__button:hover,
.bh-embed__button:hover {
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

@media (min-width: 960px) {
	.bh-consent__layer {
		grid-template-columns: minmax(0, 1fr) minmax(0, 480px);
	}

	.bh-consent__layer > .bh-consent__actions {
		grid-column: 2;
		grid-row: 1 / span 3;
		align-self: center;
		margin-top: 0;
	}
}

@media (max-width: 559px) {
	.bh-consent__actions {
		grid-template-columns: minmax(0, 1fr);
	}

	.bh-consent__inner {
		padding-top: 12px;
	}

	.bh-consent__text {
		font-size: 15px;
	}
}

/* Settings panel ---------------------------------------------------------------------- */

.bh-consent.is-prefs .bh-consent__inner {
	max-width: 760px;
}

.bh-consent__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.bh-consent__close {
	display: inline-flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--bhc-line);
	border-radius: 6px;
	background: transparent;
	color: var(--bhc-ink);
	cursor: pointer;
}

.bh-consent__cats {
	margin: 12px 0 0;
	padding: 0;
	list-style: none;
}

.bh-consent__cat {
	margin: 0 0 8px;
	padding: 4px 12px;
	border: 1px solid var(--bhc-line);
	border-radius: 6px;
	background: var(--bhc-base);
}

.bh-consent__cat-head {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 4px 12px;
	min-height: 44px;
}

.bh-consent__cat-head label {
	flex: 1 1 auto;
	padding: 10px 0;
	color: var(--bhc-ink);
	font-weight: 700;
	cursor: pointer;
}

.bh-consent__badge {
	color: var(--bhc-muted);
	font-size: 14px;
}

/* Switch: a styled checkbox (role="switch"), knob drawn with gradients so no pseudo-elements are needed. */
.bh-consent__switch {
	flex: none;
	width: 44px;
	height: 26px;
	margin: 9px 0;
	border: 2px solid var(--bhc-muted);
	border-radius: 13px;
	background: radial-gradient(circle at 11px 50%, var(--bhc-muted) 7px, transparent 8px) var(--bhc-base);
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.bh-consent__switch:checked {
	border-color: var(--bhc-accent);
	background: radial-gradient(circle at calc(100% - 11px) 50%, var(--bhc-on-accent) 7px, transparent 8px) var(--bhc-accent);
}

.bh-consent__switch:disabled {
	cursor: not-allowed;
	opacity: 0.7;
}

.bh-consent__details summary {
	display: flex;
	align-items: center;
	min-height: 44px;
	color: var(--bhc-accent-text);
	cursor: pointer;
}

.bh-consent__facts {
	display: grid;
	grid-template-columns: max-content minmax(0, 1fr);
	gap: 4px 16px;
	margin: 0 0 12px;
	font-size: 15px;
}

.bh-consent__facts dt {
	color: var(--bhc-ink);
	font-weight: 700;
}

.bh-consent__facts dd {
	margin: 0;
}

@media (max-width: 559px) {
	.bh-consent__facts {
		grid-template-columns: minmax(0, 1fr);
	}

	.bh-consent__facts dd {
		margin-bottom: 6px;
	}
}

/* Settings link (footer block, shortcode) ---------------------------------------------- */

.bh-consent-open {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	cursor: pointer;
}

/* YouTube placeholder ----------------------------------------------------------------- */

.bh-embed {
	position: relative;
	display: grid;
	aspect-ratio: 16 / 9;
	border-radius: 6px;
	background: #1d232a;
	color: #f1f3f5;
	font-size: 16px;
	line-height: 1.45;
}

.bh-embed__thumb {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border-radius: inherit;
	object-fit: cover;
}

.bh-embed__thumb--none {
	background: linear-gradient(135deg, #2e363f, #14181c);
}

.bh-embed__overlay {
	position: relative;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 16px;
	border-radius: inherit;
	background: rgb(20 24 28 / 0.8);
	text-align: center;
}

.bh-embed__title {
	margin: 0;
	color: #fff;
	font-size: 18px;
	font-weight: 700;
}

.bh-embed__notice {
	max-width: 60ch;
	margin: 0;
	font-size: 14px;
}

.bh-embed__notice a,
.bh-embed__link a {
	color: #fff;
	text-decoration: underline;
}

.bh-embed__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
}

.bh-embed__actions[hidden] {
	display: none;
}

.bh-embed__link {
	margin: 0;
	font-size: 14px;
}

.bh-embed__link a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
}

/* The placeholder is always dark, so its focus ring is always light. */
.bh-embed a:focus-visible,
.bh-embed button:focus-visible {
	outline-color: #fff;
}

.bh-embed.is-loaded {
	background: #000;
}

.bh-embed__frame {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	border-radius: inherit;
}

@media (prefers-reduced-motion: no-preference) {
	.bh-consent__switch {
		transition: background-position 0.15s ease;
	}
}

@media (forced-colors: active) {
	.bh-consent__switch {
		border-color: CanvasText;
	}

	.bh-consent__switch:checked {
		background: Highlight;
	}
}
