/*
 * Components: consent (Borlabs Cookie 3.4), a Cocolino patch on top of the
 * engine's revsults/assets/css/components/consent.css. Loaded on every page.
 *
 * The engine sets every paragraph and heading in the dialog to "contrast",
 * but Borlabs draws its inner surfaces (group cards, service list, table
 * rows, tab bar, footer, checkboxes) from its own :root variables, which hold
 * the light colours of the stored dialog styles. In dark mode that left the
 * descriptions light on white (1.04:1). Here those variables point at the
 * presets, so the surfaces flip with dark mode; html:root outranks Borlabs'
 * :root. Links, the small outline buttons and the widget take "secondary",
 * the site's link colour (at least 4.5:1 in both modes); the engine's
 * "primary" reaches only 2.9:1 on white. The filled buttons keep Borlabs'
 * own fill; their border follows it (the engine draws it in "primary").
 * Not named consent.css: the engine's loader would take a child
 * file of that name instead of its own. Engine follow-up: move this into the
 * engine's consent.css, then delete this file and its registration in functions.php.
 */

html:root {
	--dialog-background-color: var(--wp--preset--color--base-2);
	--dialog-text-color: var(--wp--preset--color--contrast);
	--dialog-card-background-color: var(--wp--preset--color--base);
	--dialog-card-text-color: var(--wp--preset--color--contrast);
	--dialog-card-control-element-color: var(--wp--preset--color--secondary);
	--dialog-card-control-element-color-hover: var(--wp--preset--color--secondary-2);
	--dialog-control-element-color: var(--wp--preset--color--secondary);
	--dialog-control-element-color-hover: var(--wp--preset--color--secondary-2);
	--dialog-link-primary-color: var(--wp--preset--color--secondary);
	--dialog-link-primary-color-hover: var(--wp--preset--color--secondary-2);
	--dialog-link-secondary-color-hover: var(--wp--preset--color--secondary);
	--dialog-list-item-background-color-even: var(--wp--preset--color--base);
	--dialog-list-item-background-color-odd: var(--wp--preset--color--base);
	--dialog-list-item-text-color-even: var(--wp--preset--color--contrast);
	--dialog-list-item-text-color-odd: var(--wp--preset--color--contrast);
	--dialog-list-item-separator-color: var(--wp--preset--color--border);
	--dialog-list-item-control-element-color: var(--wp--preset--color--contrast);
	--dialog-list-item-control-element-color-hover: var(--wp--preset--color--secondary);
	--dialog-table-row-background-color-even: var(--wp--preset--color--base);
	--dialog-table-row-background-color-odd: var(--wp--preset--color--base-2);
	--dialog-table-row-text-color-even: var(--wp--preset--color--contrast);
	--dialog-table-row-text-color-odd: var(--wp--preset--color--contrast);
	--dialog-footer-background-color: var(--wp--preset--color--base);
	--dialog-footer-text-color: var(--wp--preset--color--contrast-2);
	--dialog-tab-bar-tab-background-color-inactive: var(--wp--preset--color--base);
	--dialog-tab-bar-tab-text-color-inactive: var(--wp--preset--color--contrast-2);
	--dialog-tab-bar-tab-border-color-top-inactive: var(--wp--preset--color--border);
	--dialog-tab-bar-tab-border-color-right-inactive: var(--wp--preset--color--border);
	--dialog-tab-bar-tab-border-color-bottom-inactive: var(--wp--preset--color--border);
	--dialog-tab-bar-tab-border-color-left-inactive: var(--wp--preset--color--border);
	--dialog-checkbox-background-color-inactive: var(--wp--preset--color--base);
	--dialog-checkbox-background-color-disabled: var(--wp--preset--color--border-strong);
	--dialog-checkbox-check-mark-color-disabled: var(--wp--preset--color--contrast-2);
	--dialog-switch-button-background-color-inactive: var(--wp--preset--color--border-strong);
	--widget-background-color: var(--wp--preset--color--base-2);
	--widget-color: var(--wp--preset--color--secondary);
}

/* Links and the transparent buttons ("Einstellungen anpassen", "Alle auswählen", back). */
html:root body #BorlabsCookieBox .brlbs-cmpnt-dialog :is(a:not(.brlbs-cmpnt-btn), .brlbs-cmpnt-link, .brlbs-cmpnt-inline-link),
html:root body #BorlabsCookieBox .brlbs-cmpnt-dialog-footer a,
html:root body #BorlabsCookieBox .brlbs-cmpnt-btn:is(.brlbs-cmpnt-btn-preferences, .brlbs-cmpnt-btn-selection, .brlbs-cmpnt-btn-sm, .brlbs-cmpnt-back-button) {
	border-color: var(--wp--preset--color--secondary);
	color: var(--wp--preset--color--secondary);
}

html:root body #BorlabsCookieBox .brlbs-cmpnt-btn:is(.brlbs-cmpnt-btn-preferences, .brlbs-cmpnt-btn-selection, .brlbs-cmpnt-btn-sm, .brlbs-cmpnt-back-button):is(:hover, :focus-visible) {
	border-color: var(--wp--preset--color--secondary-2);
	background: var(--wp--preset--color--secondary-2);
	color: var(--wp--preset--color--base);
}

html:root body .brlbs-cmpnt-widget {
	color: var(--wp--preset--color--secondary);
}

/*
 * Phones and tablets: the floating widget (72 px, bottom left) sat on the
 * fixed bars at the bottom and hid what was under it: the left end of the
 * sticky bar's "Anrufen" and, on /buchen/, the booking bar's total
 * ("Gesamt ab €245"). It now waits just above the bar that is showing and
 * drops back into the corner when the booking bar slides away over the
 * summary or the menu is open. The sticky bar is hidden on the booking page
 * (booking.css), the booking bar shows only below 782 px (booking.css).
 */
html:root body .brlbs-cmpnt-widget {
	transition: bottom var(--wp--custom--transition--base, 0.2s ease);
}

@media (max-width: 999px) {
	html:root:has(.revsults-sticky-cta):not(:has(.cocolino-booking__form)):not(.has-modal-open) body .brlbs-cmpnt-widget {
		bottom: var(--revsults-sticky-cta-space, 72px);
	}
}

@media (max-width: 781px) {
	html:root:has(.cb-bar:not(.is-hidden)):not(.has-modal-open) body .brlbs-cmpnt-widget {
		bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
	}
}

@media (prefers-reduced-motion: reduce) {
	html:root body .brlbs-cmpnt-widget {
		transition: none;
	}
}

/*
 * The filled buttons ("Alle akzeptieren", "Auswahl speichern", "Nur essenzielle
 * akzeptieren"): Borlabs fills them from its stored styles, the engine gives
 * every dialog button a "primary" (coral) border and, on keyboard focus, a
 * "primary-2" fill. Border and focus follow Borlabs' own fill and hover colours.
 */
html:root body #BorlabsCookieBox .brlbs-cmpnt-btn.brlbs-btn-accept-all {
	border-color: var(--dialog-button-accept-all-color);
}

html:root body #BorlabsCookieBox .brlbs-cmpnt-btn.brlbs-btn-accept-all:is(:hover, :focus-visible) {
	border-color: var(--dialog-button-accept-all-color-hover);
	background-color: var(--dialog-button-accept-all-color-hover);
	color: var(--dialog-button-accept-all-text-color-hover);
}

html:root body #BorlabsCookieBox .brlbs-cmpnt-btn.brlbs-btn-save {
	border-color: var(--dialog-button-save-consent-color);
}

html:root body #BorlabsCookieBox .brlbs-cmpnt-btn.brlbs-btn-save:is(:hover, :focus-visible) {
	border-color: var(--dialog-button-save-consent-color-hover);
	background-color: var(--dialog-button-save-consent-color-hover);
	color: var(--dialog-button-save-consent-text-color-hover);
}

html:root body #BorlabsCookieBox .brlbs-cmpnt-btn.brlbs-btn-accept-only-essential {
	border-color: var(--dialog-button-accept-only-essential-color);
}

html:root body #BorlabsCookieBox .brlbs-cmpnt-btn.brlbs-btn-accept-only-essential:is(:hover, :focus-visible) {
	border-color: var(--dialog-button-accept-only-essential-color-hover);
	background-color: var(--dialog-button-accept-only-essential-color-hover);
	color: var(--dialog-button-accept-only-essential-text-color-hover);
}

/*
 * Phones: the four tabs of the settings layer do not fit in one row
 * ("Einwilligungsverlauf" was cut off at 375 px), so two rows of two, each
 * tab a framed box. Hyphenation only for very narrow screens (320 px).
 */
@media (max-width: 480px) {
	html:root body #BorlabsCookieBox .brlbs-cmpnt-tab-bar {
		display: grid;
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 0.25rem;
	}

	html:root body #BorlabsCookieBox .brlbs-cmpnt-tab-bar > .brlbs-cmpnt-tab {
		min-height: 44px;
		border-width: 0;
		border-radius: var(--wp--custom--radius--small, 0.5rem);
		-webkit-hyphens: auto;
		hyphens: auto;
	}

	html:root body #BorlabsCookieBox .brlbs-cmpnt-tab-bar > .brlbs-cmpnt-tab-inactive {
		box-shadow: inset 0 0 0 var(--wp--custom--border--width, 1px) var(--wp--preset--color--border-strong);
	}
}

/* The service list on /datenschutz/ (shortcode) prints each service's key ("google-tag-manager") after its name. */
html:root body [data-borlabs-cookie-service-list] .brlbs-items-center > span.brlbs-font-bold + span.brlbs-text-sm {
	display: none;
}

/* Borlabs puts the inline legal sentences next to each other without a space ("Browser.Mehr dazu"). */
html:root body #BorlabsCookieBox .brlbs-inline + .brlbs-inline::before {
	content: " ";
}
