/*
 * Fallback styles for the consent banner and preferences dialog.
 *
 * Themes restyle it by setting the --sd-consent-* custom properties (or with
 * more specific selectors). Rules are scoped under .sd-consent.
 *
 * All three choice buttons share one style on purpose: rejecting must be as
 * prominent as accepting.
 */
.sd-consent {
	--_bg: var(--sd-consent-bg, #fff);
	--_fg: var(--sd-consent-fg, #14161a);
	--_muted: var(--sd-consent-muted, color-mix(in srgb, var(--_fg) 72%, var(--_bg)));
	--_border: var(--sd-consent-border, color-mix(in srgb, var(--_fg) 18%, var(--_bg)));
	--_button-bg: var(--sd-consent-button-bg, var(--_fg));
	--_button-fg: var(--sd-consent-button-fg, var(--_bg));
	--_focus: var(--sd-consent-focus, var(--_fg));
	--_radius: var(--sd-consent-radius, 4px);
	--_shadow: var(--sd-consent-shadow, 0 0.5rem 2rem rgb(0 0 0 / 0.18));
	--_gap: var(--sd-consent-gap, 1rem);

	font: inherit;
	font-family: var(--sd-consent-font, inherit);
	line-height: 1.5;
}

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

.sd-consent .sd-consent__banner,
.sd-consent .sd-consent__dialog {
	box-sizing: border-box;
	background: var(--_bg);
	color: var(--_fg);
	border: 1px solid var(--_border);
	border-radius: var(--_radius);
	box-shadow: var(--_shadow);
}

.sd-consent .sd-consent__banner {
	position: fixed;
	inset: auto var(--_gap) var(--_gap) var(--_gap);
	z-index: var(--sd-consent-z-index, 99999);
	max-width: var(--sd-consent-banner-width, 34rem);
	max-height: calc(100dvh - 2 * var(--_gap));
	overflow-y: auto;
	padding: 1.25rem;
}

.sd-consent .sd-consent__dialog {
	/* Themes often reset margin to 0, which un-centres a modal dialog. */
	margin: auto;
	width: min(36rem, calc(100% - 2 * var(--_gap)));
	max-height: min(42rem, calc(100dvh - 2 * var(--_gap)));
	padding: 0;
	overflow: hidden;
}

.sd-consent .sd-consent__dialog::backdrop {
	background: var(--sd-consent-backdrop, rgb(0 0 0 / 0.5));
}

.sd-consent .sd-consent__form {
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	max-height: inherit;
	box-sizing: border-box;
	padding: 1.25rem;
	overflow-y: auto;
}

.sd-consent .sd-consent__dialog-header {
	display: flex;
	align-items: start;
	justify-content: space-between;
	gap: 1rem;
}

.sd-consent .sd-consent__title {
	margin: 0 0 0.5rem;
	font: inherit;
	font-size: 1.125rem;
	font-weight: 650;
	line-height: 1.3;
	color: inherit;
}

.sd-consent .sd-consent__body,
.sd-consent .sd-consent__description {
	margin: 0;
	font-size: 0.9375rem;
}

.sd-consent .sd-consent__description {
	margin-top: 0.25rem;
	color: var(--_muted);
}

.sd-consent .sd-consent__link {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.sd-consent .sd-consent__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin-top: 1rem;
}

/* Keep the choices reachable while the category list scrolls. */
.sd-consent .sd-consent__form > .sd-consent__actions {
	position: sticky;
	bottom: -1.25rem;
	margin: 0 -1.25rem -1.25rem;
	padding: 1rem 1.25rem 1.25rem;
	background: var(--_bg);
	border-top: 1px solid var(--_border);
}

.sd-consent .sd-consent__button,
.sd-consent .sd-consent__reopen {
	flex: 1 1 auto;
	min-height: 2.75rem;
	padding: 0.5rem 1rem;
	border: 2px solid var(--_button-bg);
	border-radius: var(--_radius);
	background: var(--_button-bg);
	color: var(--_button-fg);
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
}

.sd-consent .sd-consent__button:hover {
	background: color-mix(in srgb, var(--_button-bg) 85%, var(--_button-fg));
}

.sd-consent .sd-consent__close {
	display: grid;
	place-items: center;
	flex: none;
	width: 2.75rem;
	height: 2.75rem;
	margin: -0.5rem -0.5rem 0 0;
	padding: 0;
	border: 0;
	border-radius: var(--_radius);
	background: transparent;
	color: inherit;
	font-size: 1.75rem;
	line-height: 1;
	cursor: pointer;
}

.sd-consent .sd-consent__categories {
	margin: 0;
	padding: 0;
	list-style: none;
	border-top: 1px solid var(--_border);
}

.sd-consent .sd-consent__category {
	padding: 0.875rem 0;
	border-bottom: 1px solid var(--_border);
}

.sd-consent .sd-consent__category-header {
	display: flex;
	align-items: center;
	gap: 0.75rem;
}

.sd-consent .sd-consent__label {
	flex: 1;
	font-weight: 600;
	cursor: pointer;
}

.sd-consent .sd-consent__always {
	font-size: 0.875rem;
	color: var(--_muted);
}

.sd-consent .sd-consent__switch {
	appearance: none;
	position: relative;
	flex: none;
	width: 2.75rem;
	height: 1.5rem;
	margin: 0;
	border: 2px solid var(--_fg);
	border-radius: 999px;
	background: var(--_bg);
	cursor: pointer;
}

.sd-consent .sd-consent__switch::before {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: calc(1.5rem - 8px);
	height: calc(1.5rem - 8px);
	border-radius: 50%;
	background: var(--_fg);
}

.sd-consent .sd-consent__switch:checked {
	background: var(--_fg);
}

.sd-consent .sd-consent__switch:checked::before {
	left: calc(100% - 1.5rem + 6px);
	background: var(--_bg);
}

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

.sd-consent .sd-consent__reopen {
	position: fixed;
	inset: auto auto var(--_gap) var(--_gap);
	z-index: var(--sd-consent-z-index, 99999);
	flex: none;
	min-height: 2.5rem;
	padding: 0.375rem 0.875rem;
	font-size: 0.875rem;
	box-shadow: var(--_shadow);
}

.sd-consent :focus-visible {
	outline: 3px solid var(--_focus);
	outline-offset: 2px;
}

@media (max-width: 30rem) {
	.sd-consent .sd-consent__banner {
		inset: auto 0 0 0;
		max-width: none;
		border-radius: var(--_radius) var(--_radius) 0 0;
	}

	.sd-consent .sd-consent__actions {
		flex-direction: column;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.sd-consent .sd-consent__banner:not([hidden]) {
		animation: sd-consent-in 240ms cubic-bezier(0.16, 1, 0.3, 1);
	}

	.sd-consent .sd-consent__switch::before {
		transition: left 160ms ease;
	}
}

@keyframes sd-consent-in {
	from {
		opacity: 0;
		transform: translateY(0.75rem);
	}
}

/* Windows High Contrast and similar: fall back to native controls. */
@media (forced-colors: active) {
	.sd-consent .sd-consent__switch {
		appearance: auto;
		width: auto;
		height: auto;
	}

	.sd-consent .sd-consent__switch::before {
		content: none;
	}

	.sd-consent .sd-consent__button,
	.sd-consent .sd-consent__reopen {
		border-color: ButtonText;
	}
}

/* Cookie declaration block. Lives outside .sd-consent, inside page content. */
.sd-consent-declaration__category + .sd-consent-declaration__category {
	margin-top: 2em;
}

.sd-consent-declaration__table-wrap {
	overflow-x: auto;
}

.sd-consent-declaration__table {
	width: 100%;
	border-collapse: collapse;
	font-size: 0.9375em;
}

.sd-consent-declaration__table th,
.sd-consent-declaration__table td {
	padding: 0.5em 0.75em;
	border-bottom: 1px solid color-mix(in srgb, currentColor 20%, transparent);
	text-align: start;
	vertical-align: top;
}

.sd-consent-declaration__table thead th {
	font-weight: 600;
}

.sd-consent-declaration__always {
	font-size: 0.75em;
	font-weight: normal;
}

.sd-consent .sd-consent__meta {
	margin: 0;
	font-size: 0.8125rem;
	color: var(--_muted);
	overflow-wrap: anywhere;
}

/* A quiet footnote: the signal is honoured either way, so it needn't compete with the choices. */
.sd-consent .sd-consent__gpc {
	margin: 0.75rem 0 0;
	color: var(--_muted);
	font-size: 0.8125rem;
	line-height: 1.45;
}

/* Click-to-load embeds. Inside WP's aspect-ratio wrappers the placeholder
   fills the reserved box; elsewhere it takes a sensible minimum height. */
.sd-consent-embed {
	position: relative;
}

.sd-consent-embed__placeholder {
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.75rem;
	min-height: 12rem;
	padding: 1.5rem;
	border: 1px solid color-mix(in srgb, currentColor 20%, transparent);
	background: color-mix(in srgb, currentColor 5%, transparent);
	text-align: center;
}

.wp-has-aspect-ratio .sd-consent-embed {
	position: absolute;
	inset: 0;
}

.wp-has-aspect-ratio .sd-consent-embed__placeholder {
	height: 100%;
	min-height: 0;
}

.sd-consent-embed__notice,
.sd-consent-embed__actions {
	margin: 0;
	max-width: 32rem;
}

.sd-consent-embed__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem;
}
