/**
 * Celebrating Disability cookie consent.
 *
 * Deliberately plain CSS rather than Tailwind. This has to render correctly
 * before anything else on the page and must not depend on a Tailwind rebuild
 * or survive a purge pass.
 *
 * Theme tokens are used where they exist, with hex fallbacks so the banner
 * still looks right if the stylesheet load order ever changes.
 */

.cd-consent {
	--cd-consent-purple: var(--color-primary, #5b1f86);
	--cd-consent-ink: var(--color-dark, #1a1a1a);
	--cd-consent-paper: var(--color-light, #fdfdfd);
	--cd-consent-line: var(--color-grey, #e5e2e4);
	--cd-consent-tint: var(--color-pale-purple, #f8f2fb);

	font-family: inherit;
	color: var(--cd-consent-ink);
}

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

/*
 * A floating card rather than a full width bar, so it reads as part of the
 * site rather than something bolted on. Matches the rounded card treatment
 * used by the header and the stat panels.
 */
.cd-consent__banner {
	position: fixed;
	z-index: 9998;

	/*
	 * Side offsets track the theme's .container padding at each breakpoint so
	 * the card lines up with the header and the footer rather than floating on
	 * its own grid.
	 */
	left: var(--container-padding, 0.5rem);
	right: var(--container-padding, 0.5rem);
	bottom: 0.75rem;

	background: var(--cd-consent-paper);
	border: 1px solid var(--cd-consent-line);
	border-radius: 1rem;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.16);
	padding: 1.5rem 1.75rem;
}

@media (min-width: 40rem) {
	.cd-consent__banner {
		left: var(--container-padding-sm, 1.5rem);
		right: var(--container-padding-sm, 1.5rem);
		bottom: 1rem;
	}
}

@media (min-width: 64rem) {
	.cd-consent__banner {
		left: var(--container-padding-lg, 2rem);
		right: var(--container-padding-lg, 2rem);
	}
}

@media (min-width: 80rem) {
	.cd-consent__banner {
		left: var(--container-padding-xl, 3rem);
		right: var(--container-padding-xl, 3rem);
	}
}

@media (min-width: 96rem) {
	.cd-consent__banner {
		left: var(--container-padding-2xl, 5rem);
		right: var(--container-padding-2xl, 5rem);
	}
}

/*
 * Stacked rather than two columns. Side by side forced the paragraph into a
 * narrow ragged column while leaving the rest of the card empty, so the text
 * now runs the full width and the buttons sit underneath it.
 */
.cd-consent__banner-inner {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

.cd-consent__banner-text {
	min-width: 0;
	max-width: 88ch;
}

.cd-consent__banner-text p {
	margin: 0.4rem 0 0;
	font-size: 0.9375rem;
	line-height: 1.65;
}

.cd-consent__title {
	margin: 0;
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.3;
}

.cd-consent__banner a,
.cd-consent__modal a {
	color: var(--cd-consent-purple);
	text-decoration: underline;
}

/* --------------------------------------------------------------- Actions */

.cd-consent__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	align-items: center;
	justify-content: flex-start;
}

/* Pushed to the far end of the row, away from the accept/reject pair. */
.cd-consent__actions .cd-consent__btn--link {
	margin-left: auto;
}

.cd-consent__btn {
	font: inherit;
	font-size: 0.9375rem;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;

	/* 44px minimum target, per WCAG 2.5.5. */
	min-height: 44px;
	padding: 0.75rem 1.5rem;

	/* Pill, to match the site's own buttons. */
	border-radius: 999px;
	border: 2px solid var(--cd-consent-purple);
	cursor: pointer;
	background: transparent;
	color: var(--cd-consent-purple);
}

/*
 * Accept and reject are given identical weight on purpose. Making reject
 * quieter than accept is the pattern the ICO has repeatedly called out.
 */
.cd-consent__btn--primary {
	background: var(--cd-consent-purple);
	color: var(--cd-consent-paper);
}

.cd-consent__btn--secondary {
	background: transparent;
	color: var(--cd-consent-purple);
}

.cd-consent__btn--link {
	border-color: transparent;
	background: transparent;
	color: var(--cd-consent-ink);
	text-decoration: underline;
	padding-left: 0.5rem;
	padding-right: 0.5rem;
}

.cd-consent__btn:hover {
	opacity: 0.9;
}

.cd-consent__btn:focus-visible,
.cd-consent__close:focus-visible,
.cd-consent__choice input:focus-visible,
.cd-consent a:focus-visible {
	outline: 3px solid var(--cd-consent-purple);
	outline-offset: 3px;
}

/* Windows High Contrast Mode: borders and outlines must survive. */
@media (forced-colors: active) {
	.cd-consent__btn {
		border: 2px solid ButtonText;
	}

	.cd-consent__btn:focus-visible {
		outline: 3px solid Highlight;
	}
}

/* ----------------------------------------------------------- Preferences */

.cd-consent__overlay {
	position: fixed;
	inset: 0;
	z-index: 9999;
	background: rgba(0, 0, 0, 0.55);
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1rem;
	overflow-y: auto;
}

/*
 * A column layout with only the body scrolling. The buttons must stay in view,
 * otherwise someone who opens the panel to change one toggle has to scroll to
 * find Save, and may reasonably assume the toggle alone was enough.
 */
.cd-consent__modal {
	background: var(--cd-consent-paper);
	border-radius: 0.5rem;
	max-width: 40rem;
	width: 100%;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
}

.cd-consent__modal:focus {
	outline: none;
}

.cd-consent__modal-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	padding: 1.25rem 1.5rem;
	border-bottom: 1px solid var(--cd-consent-line);
	flex: none;
}

.cd-consent__close {
	font: inherit;
	font-size: 1.5rem;
	line-height: 1;
	min-width: 44px;
	min-height: 44px;
	border: 2px solid transparent;
	border-radius: 0.375rem;
	background: transparent;
	color: var(--cd-consent-ink);
	cursor: pointer;
}

.cd-consent__modal-body {
	padding: 1.25rem 1.5rem;
	overflow-y: auto;
	flex: 1 1 auto;
}

.cd-consent__modal-body > p {
	margin-top: 0;
	line-height: 1.6;
}

.cd-consent__group {
	border: 1px solid var(--cd-consent-line);
	border-radius: 0.375rem;
	padding: 1rem 1.25rem 1.25rem;
	margin: 0 0 1rem;
}

.cd-consent__group-title {
	font-weight: 700;
	padding: 0 0.35rem;
	font-size: 1rem;
}

.cd-consent__group-desc {
	margin: 0.35rem 0 0.85rem;
	line-height: 1.6;
	font-size: 0.9375rem;
}

.cd-consent__always {
	margin: 0;
	font-weight: 600;
	color: var(--cd-consent-purple);
	font-size: 0.9375rem;
}

.cd-consent__choice {
	display: flex;
	align-items: center;
	gap: 0.65rem;
	min-height: 44px;
}

.cd-consent__choice input {
	width: 1.35rem;
	height: 1.35rem;
	accent-color: var(--cd-consent-purple);
	flex: none;
	cursor: pointer;
}

.cd-consent__choice label {
	cursor: pointer;
	font-weight: 600;
}

.cd-consent__modal-foot {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
	padding: 1.25rem 1.5rem;
	border-top: 1px solid var(--cd-consent-line);
	background: var(--cd-consent-tint);
	border-radius: 0 0 0.5rem 0.5rem;
	flex: none;
}

/* ------------------------------------------------------- Status / footer */

/*
 * Visually hidden, but announced. Confirms the choice landed for anyone who
 * cannot see the banner disappear.
 */
.cd-consent__status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* Stop the fixed banner covering the end of the page. */
html.cd-consent-active body {
	padding-bottom: 13rem;
}

html.cd-consent-modal-open,
html.cd-consent-modal-open body {
	overflow: hidden;
}

@media (max-width: 40rem) {
	/* Full width stacked buttons, so Manage preferences is not stranded. */
	.cd-consent__actions .cd-consent__btn--link {
		margin-left: 0;
	}

	.cd-consent__banner {
		padding: 1.25rem;
		max-height: 80vh;
		overflow-y: auto;
	}

	.cd-consent__actions .cd-consent__btn {
		flex: 1 1 100%;
		text-align: center;
	}

	html.cd-consent-active body {
		padding-bottom: 24rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cd-consent *,
	.cd-consent *::before,
	.cd-consent *::after {
		transition: none !important;
		animation: none !important;
	}
}
