/**
 * Cookie consent banner and preferences panel.
 *
 * The banner is a bar pinned to the bottom, on the footer's navy so it reads
 * as part of the site rather than as a third-party overlay. Deliberately not a
 * modal: the site asks for one optional thing, and blocking the page to ask it
 * would be out of proportion and would edge towards a cookie wall.
 *
 * The panel IS modal, because by then the visitor has chosen to go and set
 * something and should not lose it behind the page.
 *
 * THE THREE BUTTONS MUST STAY SYMMETRICAL. Same padding, font size, weight and
 * minimum width, all solid fills. The ICO requires rejecting to be as easy as
 * accepting, and the usual way that slips is Accept becoming a button while
 * Reject quietly becomes a link. See template-parts/consent-banner.php.
 */

/* ---------------------------------------------------------------- banner - */

.fx-consent {
	position: fixed;
	z-index: 1000;
	right: 0;
	bottom: 0;
	left: 0;
	background-color: var(--fx-color-bg-darker);
	border-top: 1px solid var(--fx-color-border-on-dark);
	box-shadow: 0 -10px 34px -18px rgba(15, 33, 64, 0.55);
	color: var(--fx-color-text-on-dark);
}

/* [hidden] needs the explicit rule because display:flex below would win. */
.fx-consent[hidden],
.fx-consent-panel[hidden] {
	display: none;
}

.fx-consent__inner {
	display: flex;
	align-items: center;
	gap: var(--fx-space-md);
	max-width: var(--fx-container-max);
	margin: 0 auto;
	padding: var(--fx-space-sm) var(--fx-space-md);
}

.fx-consent__copy {
	flex: 1 1 auto;
	min-width: 0;
}

.fx-consent__title {
	margin: 0 0 0.15rem;
	font-family: var(--fx-font-display);
	font-size: var(--fx-font-size-base);
	font-weight: 600;
	letter-spacing: var(--fx-tracking-heading);
	color: #fff;
}

.fx-consent__body {
	margin: 0;
	font-size: var(--fx-font-size-small);
	line-height: 1.5;
	color: var(--fx-color-text-on-dark-soft);
}

.fx-consent__body a {
	color: var(--fx-color-brand-aqua);
	text-decoration: underline;
	text-underline-offset: 2px;
}

.fx-consent__body a:hover {
	color: #fff;
}

.fx-consent__actions {
	display: flex;
	flex: 0 0 auto;
	gap: var(--fx-space-xs);
}

/* --------------------------------------------------------------- buttons - */

.fx-consent__btn {
	min-width: 9.5rem;
	padding: 0.7rem 1.15rem;
	border: 1px solid transparent;
	border-radius: var(--fx-radius-md);
	font-family: inherit;
	font-size: var(--fx-font-size-small);
	font-weight: 600;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	transition: background-color var(--fx-transition-fast), color var(--fx-transition-fast);
}

.fx-consent__btn--accept {
	background-color: var(--fx-color-brand-cyan);
	color: var(--fx-color-brand-navy);
}

.fx-consent__btn--accept:hover {
	background-color: var(--fx-color-brand-aqua);
}

/*
 * White rather than an outline. An outlined Reject beside a filled Accept is
 * the classic way of making refusal feel like the lesser option; a solid fill
 * with the same footprint keeps them level.
 */
.fx-consent__btn--reject,
.fx-consent__btn--customise {
	background-color: #fff;
	color: var(--fx-color-brand-navy);
}

.fx-consent__btn--reject:hover,
.fx-consent__btn--customise:hover {
	background-color: var(--fx-color-text-on-dark);
}

.fx-consent__btn:focus-visible {
	outline: 3px solid var(--fx-color-brand-aqua);
	outline-offset: 2px;
}

/* ----------------------------------------------------------------- panel - */

.fx-consent-panel {
	position: fixed;
	z-index: 1001;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--fx-space-sm);
	background-color: rgba(15, 33, 64, 0.6);
	overflow-y: auto;
}

.fx-consent-panel__box {
	width: 100%;
	max-width: 36rem;
	max-height: 90vh;
	overflow-y: auto;
	padding: var(--fx-space-md);
	border-radius: var(--fx-radius-lg);
	background-color: var(--fx-color-bg);
	box-shadow: var(--fx-shadow-md);
	color: var(--fx-color-text);
}

.fx-consent-panel__title {
	margin: 0 0 var(--fx-space-xs);
	font-family: var(--fx-font-display);
	font-size: 1.2rem;
	font-weight: 600;
	letter-spacing: var(--fx-tracking-heading);
	color: var(--fx-color-heading);
}

.fx-consent-panel__intro {
	margin: 0 0 var(--fx-space-md);
	font-size: var(--fx-font-size-small);
	color: var(--fx-color-text-muted);
}

.fx-consent-panel__list {
	margin: 0 0 var(--fx-space-md);
	padding: 0;
	list-style: none;
}

.fx-consent-row {
	padding: var(--fx-space-sm) 0;
	border-top: 1px solid var(--fx-color-border);
}

.fx-consent-row__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: var(--fx-space-sm);
}

.fx-consent-row__label {
	font-weight: 600;
	color: var(--fx-color-heading);
}

/*
 * A plain label, not a ticked disabled checkbox. A disabled tick reads as a
 * choice the visitor has already made, and this one was never theirs.
 */
.fx-consent-row__locked {
	font-family: var(--fx-font-mono);
	font-size: var(--fx-font-size-tiny);
	letter-spacing: var(--fx-tracking-label);
	text-transform: uppercase;
	color: var(--fx-color-text-faint);
}

.fx-consent-row__description {
	margin: 0.4rem 0 0;
	font-size: var(--fx-font-size-small);
	line-height: 1.55;
	color: var(--fx-color-text-muted);
}

/* ---------------------------------------------------------------- toggle - */

.fx-consent-toggle {
	position: relative;
	flex: 0 0 auto;
}

.fx-consent-toggle__input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: 0;
	opacity: 0;
}

.fx-consent-toggle__label {
	display: block;
	width: 3rem;
	height: 1.65rem;
	border-radius: var(--fx-radius-pill);
	background-color: var(--fx-color-border-strong);
	cursor: pointer;
	transition: background-color var(--fx-transition-fast);
}

.fx-consent-toggle__label::after {
	content: "";
	position: absolute;
	top: 0.2rem;
	left: 0.2rem;
	width: 1.25rem;
	height: 1.25rem;
	border-radius: 50%;
	background-color: #fff;
	box-shadow: var(--fx-shadow-sm);
	transition: transform var(--fx-transition-fast);
}

.fx-consent-toggle__input:checked + .fx-consent-toggle__label {
	background-color: var(--fx-color-brand-cyan-deep);
}

.fx-consent-toggle__input:checked + .fx-consent-toggle__label::after {
	transform: translateX(1.35rem);
}

.fx-consent-toggle__input:focus-visible + .fx-consent-toggle__label {
	outline: 3px solid var(--fx-color-focus-ring);
	outline-offset: 2px;
}

.fx-consent-panel__actions {
	display: flex;
	gap: var(--fx-space-xs);
}

.fx-consent-panel__link {
	margin: var(--fx-space-sm) 0 0;
	font-size: var(--fx-font-size-small);
}

/* ------------------------------------------------------- footer control - */

/*
 * A button, because it performs an action, styled to sit in the footer's link
 * list without announcing itself as something different.
 */
.fx-consent-reopen {
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: inherit;
	text-align: left;
	cursor: pointer;
}

.fx-consent-reopen:hover {
	text-decoration: underline;
}

/* ------------------------------------------------------------ responsive - */

@media (max-width: 900px) {
	.fx-consent__inner {
		flex-direction: column;
		align-items: stretch;
		gap: var(--fx-space-sm);
	}

	.fx-consent__actions,
	.fx-consent-panel__actions {
		flex-direction: column;
	}

	.fx-consent__btn {
		min-width: 0;
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.fx-consent__btn,
	.fx-consent-toggle__label,
	.fx-consent-toggle__label::after {
		transition: none;
	}
}
