/**
 * Squee cookie consent.
 *
 * Deliberately plain CSS rather than Tailwind. This has to render correctly
 * before anything else on the page, must not depend on a Tailwind rebuild, and
 * must not be at the mercy of a purge pass. It is also why nothing in here
 * belongs in input.css.
 *
 * Design: a full width bar pinned to the bottom, same structure as the
 * Celebrating Disability build, but on Squee's dark palette.
 *
 * On the ground colour: the page itself is #0D0D0D, so a bar in the black
 * token would disappear into it. #232323 is the token the footer and the card
 * surfaces already use, which is why the bar reads as sitting on top of the
 * page rather than being part of it.
 */

.squee-consent {
	/* Surfaces */
	--squee-consent-ground: var(--color-dark, #232323);
	--squee-consent-ground-alt: var(--color-faqblack, #323232);
	--squee-consent-line: var(--color-stroke, #3E3E3E);

	/* Type */
	--squee-consent-heading: var(--color-heading, #FAFAFA);
	--squee-consent-body: var(--color-body, #E0E0E0);

	/*
	 * Pale pink, not the primary #BA126A. Primary pink on #232323 is only
	 * 2.5:1, which fails 1.4.11 for the button shape and is uncomfortable for
	 * link text. #FFCFE8 on #232323 is 11.5:1.
	 */
	--squee-consent-accent: var(--color-secondary, #FFCFE8);

	font-family: inherit;
	color: var(--squee-consent-body);

	/* The panel is dark, so native controls should be too. */
	color-scheme: dark;
}

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

/*
 * Side offsets are the theme's .container padding at each breakpoint PLUS an
 * inset, so the bar sits visibly within the hero panel rather than almost
 * lining up with it. The full ladder has to be mirrored — .container jumps
 * again at 1920 and 2560, and stopping at the 1536 step left the bar 32px
 * wider than the hero on a 1920 screen, which is what made it look wrong.
 */
.squee-consent__banner {
	position: fixed;
	z-index: 9998;

	--squee-consent-gutter: 1rem;
	--squee-consent-inset: 1.5rem;

	left: calc(var(--squee-consent-gutter) + var(--squee-consent-inset));
	right: calc(var(--squee-consent-gutter) + var(--squee-consent-inset));
	bottom: 0.75rem;

	background: var(--squee-consent-ground);
	border: 1px solid var(--squee-consent-line);
	border-radius: 1rem;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
	padding: 1.5rem 1.75rem;

	max-height: 85vh;
	overflow-y: auto;
}

@media (width >= 640px) {  /* sm */
	.squee-consent__banner {
		--squee-consent-gutter: 1.5rem;
		bottom: 1rem;
	}
}

@media (width >= 1024px) { /* lg */
	.squee-consent__banner {
		--squee-consent-gutter: 2rem;
	}
}

@media (width >= 1280px) { /* xl */
	.squee-consent__banner {
		--squee-consent-gutter: 2.5rem;
	}
}

@media (width >= 1536px) { /* 2xl */
	.squee-consent__banner {
		--squee-consent-gutter: 6rem;
	}
}

@media (width >= 1920px) { /* 3xl */
	.squee-consent__banner {
		--squee-consent-gutter: 8rem;
	}
}

@media (width >= 2560px) { /* 4xl */
	.squee-consent__banner {
		--squee-consent-gutter: 12rem;
	}
}

/*
 * Stacked rather than two columns. Side by side forces the paragraph into a
 * narrow ragged column while leaving the rest of the bar empty.
 */
.squee-consent__banner-inner {
	display: flex;
	flex-direction: column;
	gap: 1.25rem;
}

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

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

.squee-consent__title {
	margin: 0;
	font-size: 1.0625rem;
	font-weight: 700;
	line-height: 1.3;
	color: var(--squee-consent-heading);
}

.squee-consent__banner a,
.squee-consent__modal a {
	color: var(--squee-consent-accent);
	text-decoration: underline;
	text-underline-offset: 2px;
}

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

.squee-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. */
.squee-consent__actions .squee-consent__btn--link {
	margin-left: auto;
}

.squee-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(--squee-consent-accent);
	cursor: pointer;
	background: transparent;
	color: var(--squee-consent-accent);
	transition: background-color 0.15s ease, color 0.15s ease;
}

/*
 * Accept is filled, reject is outlined. They are deliberately kept the same
 * size, in the same place, one click apart, and at the same contrast (both
 * #FFCFE8 against #232323, 11.5:1) — the thing the ICO objects to is a reject
 * that is harder to find or harder to use, not one that is a different fill.
 * If that ever gets challenged, making reject --primary again is a one word
 * change in class-squee-consent.php.
 */
.squee-consent__btn--primary {
	background: var(--squee-consent-accent);
	color: var(--squee-consent-ground);
}

.squee-consent__btn--secondary {
	background: transparent;
	color: var(--squee-consent-accent);
}

.squee-consent__btn--link {
	border-color: transparent;
	background: transparent;
	color: var(--squee-consent-body);
	text-decoration: underline;
	text-underline-offset: 2px;
	padding-left: 0.5rem;
	padding-right: 0.5rem;
}

.squee-consent__btn--primary:hover {
	background: var(--squee-consent-heading);
	border-color: var(--squee-consent-heading);
}

.squee-consent__btn--secondary:hover,
.squee-consent__btn--link:hover {
	background: var(--squee-consent-ground-alt);
	color: var(--squee-consent-heading);
}

/* Light outline, because a dark focus ring on a dark bar is invisible. */
.squee-consent__btn:focus-visible,
.squee-consent__close:focus-visible,
.squee-consent__choice input:focus-visible,
.squee-consent a:focus-visible {
	outline: 3px solid var(--squee-consent-heading);
	outline-offset: 3px;
}

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

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

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

.squee-consent__overlay {
	position: fixed;
	inset: 0;
	z-index: 9999;
	background: rgba(0, 0, 0, 0.7);
	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.
 */
.squee-consent__modal {
	background: var(--squee-consent-ground);
	border: 1px solid var(--squee-consent-line);
	border-radius: 1rem;
	max-width: 40rem;
	width: 100%;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

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

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

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

.squee-consent__close:hover {
	background: var(--squee-consent-ground-alt);
	color: var(--squee-consent-heading);
}

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

.squee-consent__modal-body > p {
	margin-top: 0;
	margin-bottom: 1.5rem;
	line-height: 1.6;
}

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

.squee-consent__group-title {
	font-weight: 700;
	padding: 0 0.35rem;
	font-size: 1rem;
	color: var(--squee-consent-heading);
}

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

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

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

/*
 * Drawn by hand rather than left native. The theme sets its own styles on bare
 * inputs, and a native dark-scheme checkbox rendered as a filled dark square
 * with no visible border, which read as "on" when it was off.
 */
.squee-consent__choice input[type="checkbox"] {
	-webkit-appearance: none;
	appearance: none;
	position: relative;
	width: 1.4rem;
	height: 1.4rem;
	min-height: 0;
	margin: 0;
	padding: 0;
	flex: none;
	cursor: pointer;
	border: 2px solid var(--squee-consent-body);
	border-radius: 0.3rem;
	background: transparent;
	box-shadow: none;
}

.squee-consent__choice input[type="checkbox"]:checked {
	background: var(--squee-consent-accent);
	border-color: var(--squee-consent-accent);
}

/* The tick: two borders of a rotated box. */
.squee-consent__choice input[type="checkbox"]:checked::after {
	content: "";
	position: absolute;
	left: 0.38rem;
	top: 0.15rem;
	width: 0.32rem;
	height: 0.62rem;
	border: solid var(--squee-consent-ground);
	border-width: 0 3px 3px 0;
	transform: rotate(45deg);
}

@media (forced-colors: active) {
	.squee-consent__choice input[type="checkbox"] {
		border-color: ButtonText;
	}

	.squee-consent__choice input[type="checkbox"]:checked {
		background: Highlight;
		border-color: Highlight;
	}

	.squee-consent__choice input[type="checkbox"]:checked::after {
		border-color: HighlightText;
	}
}

.squee-consent__choice label {
	cursor: pointer;
	font-weight: 600;
	color: var(--squee-consent-heading);
}

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

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

/*
 * Visually hidden, but announced. Confirms the choice landed for anyone who
 * cannot see the bar disappear.
 */
.squee-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 bar covering the end of the page. */
html.squee-consent-active body {
	padding-bottom: 13rem;
}

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

@media (max-width: 40rem) {
	.squee-consent__banner {
		/* No room for the inset at this width; sit on the gutter alone. */
		--squee-consent-gutter: 0.75rem;
		--squee-consent-inset: 0rem;
		padding: 1.25rem;
		max-height: 80vh;
	}

	/* Full width stacked buttons, so Manage preferences is not stranded. */
	.squee-consent__actions .squee-consent__btn {
		flex: 1 1 100%;
		text-align: center;
	}

	.squee-consent__actions .squee-consent__btn--link {
		margin-left: 0;
	}

	.squee-consent__modal-foot .squee-consent__btn {
		flex: 1 1 100%;
	}

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

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