/**
 * Complianz cookie banner: Charis brand layer.
 *
 * Complianz prints its own sheet (uploads/complianz/css/banner-*.css) after the
 * theme, and its admin "Custom CSS" field ships !important rules. Every rule
 * here is scoped under the #cmplz-cookiebanner-container id so it wins on
 * specificity whatever the load order, and uses !important only where the
 * plugin or that admin CSS already does.
 *
 * Values come from theme.json presets only. Layout: a floating white card,
 * bottom right, on desktop; a bottom sheet on phones. Accept is the primary
 * button, Reject the secondary one at the same size and position (UK ICO:
 * rejecting must be as easy as accepting); "Manage cookies" is a text link.
 */

#cmplz-cookiebanner-container .cmplz-cookiebanner {
	--cb-ink: var(--wp--preset--color--text-main, #040405);
	--cb-muted: var(--wp--preset--color--text-placeholder, #4a5a69);
	--cb-surface: var(--wp--preset--color--bg-white, #fff);
	--cb-row: var(--wp--preset--color--bg-grey-light, #f8f9fb);
	--cb-line: var(--wp--preset--color--ui-border, #e3e9ee);
	--cb-red: var(--wp--preset--color--brand-red, #d92315);
	--cb-red-hover: var(--wp--preset--color--brand-red-hover, #c31f13);
	--cb-indigo: var(--wp--preset--color--brand-indigo, #251a5d);
	--cb-indigo-hover: var(--wp--preset--color--brand-indigo-hover, #1d1448);
	--cb-purple: var(--wp--preset--color--brand-purple, #4e3f9d);
	--cb-focus: var(--wp--preset--color--ui-focus, #2f83e4);
	--cb-off: var(--wp--preset--color--ui-checkbox-border, #8f979e);

	/* Feed Complianz's own variables so its untouched rules follow suit. */
	--cmplz_banner_background_color: var(--cb-surface);
	--cmplz_banner_border_color: var(--cb-line);
	--cmplz_text_color: var(--cb-ink);
	--cmplz_hyperlink_color: var(--cb-purple);
	--cmplz_text_font_size: 16px;
	--cmplz_link_font_size: 14px;
	--cmplz_title_font_size: 20px;
	--cmplz_category_body_font_size: 14px;
	--cmplz_category_header_title_font_size: 16px;
	--cmplz_category_header_active_font_size: 14px;
	--cmplz_slider_active_color: var(--cb-red);
	--cmplz_slider_inactive_color: var(--cb-off);
	--cmplz_slider_bullet_color: var(--cb-surface);

	position: fixed;
	inset: auto 24px 24px auto !important;
	transform: none !important;
	display: grid;
	grid-template-columns: minmax(0, 1fr) !important;
	gap: 16px;
	box-sizing: border-box;
	width: min(440px, calc(100vw - 48px)) !important;
	max-width: none !important;
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	margin: 0 !important;
	padding: 24px !important;
	overflow-y: auto;
	overscroll-behavior: contain;
	border: 1px solid var(--cb-line);
	border-radius: 24px !important;
	background: var(--cb-surface);
	color: var(--cb-ink);
	box-shadow: 0 12px 40px rgba(4, 4, 5, 0.18), 0 2px 8px rgba(4, 4, 5, 0.08) !important;
	font-family: var(--wp--preset--font-family--charis-display);
	font-weight: 300;
	letter-spacing: 0.8px;
	text-align: left;
}

/* The display above outranks the plugin's own hide rule, so restate it:
   without this the banner stays on screen after Accept/Deny/Save. */
#cmplz-cookiebanner-container .cmplz-cookiebanner.cmplz-dismissed {
	display: none !important;
}

/* Complianz's generated sheet sets font-family on every descendant
   (".cmplz-cookiebanner *"), so the site face has to be inherited explicitly. */
#cmplz-cookiebanner-container .cmplz-cookiebanner * {
	font-family: inherit;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner ::selection {
	background: var(--wp--preset--color--bg-lightblue, #e5e9ff);
	color: var(--cb-ink);
}

/* Every block spans the single column; the plugin places them on a 3-col grid. */
#cmplz-cookiebanner-container .cmplz-cookiebanner > *,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message,
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-description {
	grid-column: 1 / -1 !important;
	grid-row: auto !important;
	width: auto !important;
	min-width: 0 !important;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-divider {
	display: none;
}

/* Header: the title stays visible at every width (Complianz hides it <=425px). */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-header {
	display: block;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-header .cmplz-title {
	display: block !important;
	margin: 0;
	color: var(--cb-ink);
	font-size: 20px;
	font-weight: 600;
	line-height: 1.2;
	letter-spacing: 0.4px;
	text-wrap: balance;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-body {
	display: flex !important;
	flex-direction: column !important;
	max-height: none;
	overflow: visible;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message {
	margin: 0;
	color: var(--cb-ink);
	font-size: 16px;
	font-weight: 300;
	line-height: 22px;
	letter-spacing: 0.8px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message p {
	margin: 0 0 8px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message p:last-child {
	margin-bottom: 0;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner a {
	color: var(--cb-purple);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner a:hover {
	color: var(--cb-indigo);
}

/* Preferences: one quiet row per category. */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories {
	margin-top: 16px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category {
	overflow: hidden;
	border-radius: 12px;
	background: var(--cb-row) !important;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category:not(:last-child) {
	margin-bottom: 8px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-category-header {
	grid-template-columns: minmax(0, 1fr) auto 24px !important;
	gap: 12px;
	min-height: 48px;
	padding: 8px 12px 8px 16px;
	box-sizing: border-box;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-category-header .cmplz-category-title {
	color: var(--cb-ink);
	font-size: 16px;
	font-weight: 600;
	letter-spacing: 0.64px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-always-active {
	color: var(--cb-muted) !important;
	font-size: 14px;
	font-weight: 400;
	letter-spacing: 0.56px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-category-toggle {
	width: 24px;
	height: 24px;
	color: var(--cb-ink);
	border-radius: 6px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-icon.cmplz-open {
	width: 14px;
	height: 14px;
	transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-icon svg {
	width: 14px;
	height: 14px;
	color: var(--cb-ink);
	fill: currentColor;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-icon svg path {
	fill: currentColor;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-categories .cmplz-category .cmplz-description {
	padding: 0 16px 14px;
	color: var(--cb-muted);
	font-size: 14px;
	line-height: 20px;
	letter-spacing: 0.56px;
}

/* Switch: 36x20 track, brand red when on. */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-banner-checkbox .cmplz-label::before {
	width: 36px !important;
	height: 20px !important;
	border-radius: 999px !important;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-banner-checkbox .cmplz-label::after {
	/* The track sits at top:-7px (plugin); centre the knob inside it. */
	width: 14px !important;
	height: 14px !important;
	top: -4px !important;
	bottom: auto !important;
	left: 3px !important;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-banner-checkbox input.cmplz-consent-checkbox:checked + .cmplz-label::after {
	left: 19px !important;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-banner-checkbox input.cmplz-consent-checkbox:focus-visible + .cmplz-label::before {
	box-shadow: 0 0 0 2px var(--cb-surface), 0 0 0 4px var(--cb-focus);
}

/* Buttons: Accept all + Reject all side by side, same size and weight. */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons {
	display: flex;
	flex-flow: row wrap !important;
	align-items: stretch !important;
	align-self: stretch;
	gap: 8px 12px;
	margin: 0;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn {
	flex: 1 1 0 !important;
	min-width: 0;
	width: auto !important;
	min-height: 48px;
	height: auto !important;
	margin: 0;
	padding: 12px 16px !important;
	border: 1px solid transparent;
	border-radius: 8px;
	font-family: var(--wp--preset--font-family--charis-display);
	font-size: 16px !important;
	font-weight: 600;
	line-height: 1.25 !important;
	letter-spacing: 0.64px;
	white-space: normal;
	transition: background-color 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-accept {
	border-color: var(--cb-red);
	background: var(--cb-red);
	color: #fff;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-accept:hover {
	border-color: var(--cb-red-hover);
	background: var(--cb-red-hover);
}

/* Deny is the site's secondary button: indigo outline, same size as Accept. */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-deny {
	border-color: var(--cb-indigo);
	background: var(--cb-surface);
	color: var(--cb-indigo);
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-deny:hover {
	border-color: var(--cb-indigo);
	background: var(--wp--preset--color--bg-lightblue, #e5e9ff);
}

/* "Manage cookies": a link-weight action on its own line. */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-view-preferences {
	flex: 1 0 100% !important;
	order: 3;
	min-height: 44px;
	padding: 8px !important;
	border-color: transparent;
	background: transparent;
	color: var(--cb-purple);
	text-decoration: underline;
	text-decoration-thickness: 1px;
	text-underline-offset: 3px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-view-preferences:hover {
	color: var(--cb-indigo);
}

/* Preferences open: "Save choices" is a full-width outline button. */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-save-preferences {
	flex: 1 0 100% !important;
	order: 3;
	border-color: var(--cb-indigo);
	background: var(--cb-surface);
	color: var(--cb-indigo);
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn.cmplz-save-preferences:hover {
	background: var(--wp--preset--color--bg-lightblue, #e5e9ff);
}

#cmplz-cookiebanner-container .cmplz-cookiebanner.cmplz-categories-visible .cmplz-buttons {
	flex-direction: row !important;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner.cmplz-categories-visible .cmplz-buttons .cmplz-btn.cmplz-accept,
#cmplz-cookiebanner-container .cmplz-cookiebanner.cmplz-categories-visible .cmplz-buttons .cmplz-btn.cmplz-deny {
	flex: 1 1 0 !important;
	width: auto !important;
}

/* Policy links under the buttons (shown once enabled in Complianz). */
#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-links.cmplz-documents ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px 16px;
	margin: 0;
	padding: 0;
	list-style: none;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-links .cmplz-link {
	font-size: 14px;
	letter-spacing: 0.56px;
}

/* Keyboard focus: the site's focus blue, offset from the control. */
#cmplz-cookiebanner-container .cmplz-cookiebanner :focus-visible {
	outline: 2px solid var(--cb-focus);
	outline-offset: 2px;
}

#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-btn:focus:not(:focus-visible) {
	outline: none;
}

/* Phones: bottom sheet, buttons stay paired. */
@media (max-width: 600px) {
	#cmplz-cookiebanner-container .cmplz-cookiebanner {
		inset: auto 0 0 0 !important;
		gap: 12px;
		width: 100% !important;
		max-height: 85vh;
		max-height: 85dvh;
		padding: 20px 16px calc(12px + env(safe-area-inset-bottom, 0px)) !important;
		border-width: 1px 0 0;
		border-radius: 24px 24px 0 0 !important;
		box-shadow: 0 -8px 32px rgba(4, 4, 5, 0.18) !important;
	}

	#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-header .cmplz-title {
		font-size: 18px;
	}

	#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-message {
		font-size: 15px;
		line-height: 20px;
		letter-spacing: 0.75px;
	}

	#cmplz-cookiebanner-container .cmplz-cookiebanner .cmplz-buttons .cmplz-btn {
		padding: 12px !important;
	}
}

/*
 * No floating "Manage consent" tab: the footer legal menu carries a
 * "Cookie settings." button instead (improving_lives_footer_cookie_settings()).
 * Complianz binds its click to any button.cmplz-manage-consent, so the
 * footer button reopens the banner through the plugin's own handler.
 */
#cmplz-manage-consent {
	display: none !important;
}

.charis-footer__legal .charis-cookie-settings {
	display: inline-flex;
	align-items: flex-start;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--wp--preset--color--brand-periwinkle);
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 18px;
	letter-spacing: var(--wp--custom--charis--ls-control);
	text-align: left;
	text-decoration: underline;
	text-decoration-color: transparent;
	text-underline-offset: 4px;
	cursor: pointer;
	transition: text-decoration-color var(--charis-hover-duration) var(--charis-hover-easing);
}

.charis-footer__legal .charis-cookie-settings:hover {
	color: var(--wp--preset--color--brand-lavender);
	text-decoration-color: currentcolor;
}

@media (prefers-reduced-motion: reduce) {
	#cmplz-cookiebanner-container .cmplz-cookiebanner,
	#cmplz-cookiebanner-container .cmplz-cookiebanner * {
		animation: none !important;
		transition: none !important;
	}
}
