/**
 * The consent interface.
 *
 * Two things here are load-bearing rather than decorative.
 *
 * 1. `.wpc-btn--choice` is ONE rule shared by "Accept all" and "Reject all".
 *    They cannot be given different sizes, weights or colours, because the
 *    styling of the two is the same declaration. Regulators have fined for
 *    exactly the asymmetry this forbids, and making it impossible in the
 *    stylesheet is more reliable than making it a rule somebody has to
 *    remember while theming.
 *
 * 2. Everything is scoped under #wpc-consent-root and every property is set
 *    explicitly. A theme's global `button {}` or `* { box-sizing }` should not
 *    be able to reshape a consent control, and `all: unset` on the buttons is
 *    too blunt — it takes the focus ring with it.
 *
 * 3. The three colour declarations on each button, and every link colour,
 *    carry `!important`. Specificity is enough against an ordinary theme, but
 *    it is not enough against `#content .button { background: #fff !important }`
 *    — which plenty of themes and every "button colour" plugin ship, because
 *    that is how they beat the theme they sit on top of. A customer who has
 *    chosen their brand colours in the dashboard and sees the theme's instead
 *    has no way to find out why, so on exactly these properties we do the same
 *    thing back. It is kept to the properties a customer picks: layout,
 *    spacing and typography still lose to the reset order above.
 *
 * The palette comes in as custom properties from the banner's colour set, so a
 * customer's brand changes a handful of values rather than a stylesheet — and
 * the four override properties (link, button, button text, button border)
 * default to `var()` fallbacks so an untouched banner renders exactly as it
 * always did.
 */

#wpc-consent-root {
	--wpc-surface: #ffffff;
	--wpc-text: #1f2933;
	--wpc-muted: #5b6b7c;
	--wpc-accent: #1d4ed8;
	--wpc-accent-text: #ffffff;
	--wpc-border: #d9e0e8;
	--wpc-radius: 10px;
	--wpc-shadow: 0 8px 30px rgba( 15, 23, 42, 0.18 );

	/*
	 * Derived, and the var() fallbacks are what makes them optional.
	 *
	 * The banner writes a custom property into its style attribute ONLY when
	 * the customer actually set that colour. So a website that has never
	 * opened the appearance controls renders exactly as it did before these
	 * existed — the links follow the accent, the two choice buttons follow the
	 * surface and the text — and one that has set them overrides only what it
	 * set. Writing concrete defaults here instead would have repainted every
	 * banner whose accent was already customised.
	 */
	--wpc-link: var( --wpc-accent );
	--wpc-button: var( --wpc-surface );
	--wpc-button-text: var( --wpc-text );
	--wpc-button-border: var( --wpc-text );

	/* How wide a corner box may grow. A full-width bar ignores it. */
	--wpc-width: 480px;

	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
	color: var( --wpc-text );
}

#wpc-consent-root *,
#wpc-consent-root *::before,
#wpc-consent-root *::after {
	box-sizing: border-box;
}

#wpc-consent-root [hidden] {
	display: none !important;
}

/*
 * Everything a theme imposes, taken back.
 *
 * This banner renders inside somebody else's stylesheet, and a WordPress theme
 * styles `button` and `a` globally: uppercase, letter-spaced, a minimum height,
 * a box shadow, a full-width block on a phone. On the first customer website
 * this module met, the theme uppercased "Reject all", gave the close cross a
 * bordered box the size of a button, and pushed "Save my choices" onto a line
 * of its own. None of that was in this file — it was the theme reaching in, and
 * every property below is here because a real website set it.
 *
 * The mechanism is a specificity split, and it is the whole trick. Every rule
 * in this file now carries `#wpc-consent-root`, so a theme's `#content .button`
 * can no longer outrank it. This reset carries the same id but selects
 * ELEMENTS, so it loses to every class rule here while still beating anything
 * the theme has — which means it owns exactly the properties we never mention,
 * and only those.
 *
 * `outline` is deliberately NOT reset. The focus ring is how somebody using a
 * keyboard knows where they are, and removing it to tidy the appearance is an
 * accessibility failure rather than a style choice.
 */

#wpc-consent-root button,
#wpc-consent-root a,
#wpc-consent-root h2,
#wpc-consent-root p,
#wpc-consent-root ul,
#wpc-consent-root li,
#wpc-consent-root label,
#wpc-consent-root span,
#wpc-consent-root div,
#wpc-consent-root input {
	margin: 0;
	text-transform: none;
	letter-spacing: normal;
	word-spacing: normal;
	text-indent: 0;
	text-shadow: none;
	min-width: 0;
	min-height: 0;
	max-width: none;
	max-height: none;
	width: auto;
	height: auto;
	box-shadow: none;
	background-image: none;
	float: none;
	clear: none;
	transform: none;
	filter: none;
	font-family: inherit;
	font-style: normal;
	font-size: inherit;
	font-weight: inherit;
	line-height: inherit;
	color: inherit;
	vertical-align: baseline;
	animation: none;
}

#wpc-consent-root button {
	-webkit-appearance: none;
	appearance: none;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: inherit;
	font-size: inherit;
	line-height: inherit;
	font-weight: inherit;
	text-decoration: none;
}

#wpc-consent-root ul,
#wpc-consent-root li {
	padding: 0;
	list-style: none;
}

#wpc-consent-root p,
#wpc-consent-root h2 {
	padding: 0;
	border: 0;
}

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

#wpc-consent-root .wpc-banner {
	position: fixed;
	z-index: 2147483000; /* above sticky headers, below nothing the visitor needs */
	left: 0;
	right: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 20px;
	padding: 20px 24px;
	background: var( --wpc-surface );
	color: var( --wpc-text );
	border-top: 1px solid var( --wpc-border );
	box-shadow: var( --wpc-shadow );
}

/* --- full-width bars ---------------------------------------------------- */

#wpc-consent-root.wpc-consent--bottom .wpc-banner {
	bottom: 0;
}

#wpc-consent-root.wpc-consent--top .wpc-banner {
	top: 0;
	border-top: 0;
	border-bottom: 1px solid var( --wpc-border );
}

/* --- corner boxes -------------------------------------------------------- *
 * The default. A box in a corner leaves most of the page readable while the
 * visitor decides, which a full-width bar across the bottom does not — and a
 * banner somebody cannot see past is a banner they dismiss without reading.
 */

#wpc-consent-root.wpc-consent--bottom-left .wpc-banner,
#wpc-consent-root.wpc-consent--bottom-right .wpc-banner,
#wpc-consent-root.wpc-consent--box .wpc-banner,
#wpc-consent-root.wpc-consent--centre .wpc-banner {
	max-width: var( --wpc-width );
	bottom: 24px;
	flex-direction: column;
	align-items: stretch;
	gap: 14px;
	border: 1px solid var( --wpc-border );
	border-radius: var( --wpc-radius );
}

/*
 * The text block's flex-basis is a WIDTH in a bar and a HEIGHT in a box,
 * because the box turns the flex direction to column. Left alone it made a
 * 320px-tall banner with a void between the words and the buttons.
 */
#wpc-consent-root.wpc-consent--bottom-left .wpc-banner__text,
#wpc-consent-root.wpc-consent--bottom-right .wpc-banner__text,
#wpc-consent-root.wpc-consent--box .wpc-banner__text,
#wpc-consent-root.wpc-consent--centre .wpc-banner__text {
	flex: 0 0 auto;
}

/* Three buttons sharing the row rather than wrapping one onto its own line. */
#wpc-consent-root.wpc-consent--bottom-left .wpc-banner__actions .wpc-btn,
#wpc-consent-root.wpc-consent--bottom-right .wpc-banner__actions .wpc-btn,
#wpc-consent-root.wpc-consent--box .wpc-banner__actions .wpc-btn,
#wpc-consent-root.wpc-consent--centre .wpc-banner__actions .wpc-btn {
	flex: 1 1 0;
	min-width: 0;
	padding-left: 10px;
	padding-right: 10px;
}

#wpc-consent-root.wpc-consent--bottom-right .wpc-banner,
#wpc-consent-root.wpc-consent--box .wpc-banner,
#wpc-consent-root.wpc-consent--centre .wpc-banner {
	left: auto;
	right: 24px;
}

/*
 * Left last, so it wins.
 *
 * The root carries the position AND the shape as classes, and `box` used to be
 * one of the positions — so a website set to bottom-left with a box shape had
 * `--bottom-left` and `--box` on the same element, equal specificity, and the
 * later rule decided. It rendered on the right. The shape class is now
 * `wpc-layout--*` so it cannot position anything, and this rule is last so an
 * old website still carrying `--box` alongside `--bottom-left` lands left.
 */
#wpc-consent-root.wpc-consent--bottom-left .wpc-banner {
	left: 24px;
	right: auto;
}

#wpc-consent-root .wpc-banner__text {
	flex: 1 1 320px;
	min-width: 0;
}

#wpc-consent-root .wpc-banner__title {
	margin: 0 0 4px;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.3;
	color: var( --wpc-text );
}

#wpc-consent-root .wpc-banner__body {
	margin: 0;
	font-size: 14px;
	color: var( --wpc-muted );
}

/*
 * With the heading switched off the body IS the first thing read, and a
 * banner whose only words are small grey secondary text reads as a footnote
 * somebody forgot to finish. It steps up to the primary colour and size.
 */
#wpc-consent-root .wpc-banner__body--lead {
	font-size: 15px;
	color: var( --wpc-text );
}

/*
 * A link the customer wrote into the body copy.
 *
 * The reset above hands every element `color: inherit`, which is right for
 * everything except this: an anchor that takes the paragraph's own grey is
 * not visibly a link at all, and the two links in this sentence are usually
 * the privacy policy and the terms — the pages the banner is asking about.
 * Underlined as well as coloured, because colour alone fails for a reader who
 * cannot distinguish these two.
 */
#wpc-consent-root .wpc-banner__body a {
	color: var( --wpc-link ) !important;
	font-weight: 600;
	text-decoration: underline;
}

#wpc-consent-root .wpc-banner__body a:hover {
	text-decoration: none;
}

#wpc-consent-root .wpc-banner__link {
	color: var( --wpc-link ) !important;
	text-decoration: underline;
}

#wpc-consent-root .wpc-banner__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 10px;
	flex: 0 0 auto;
}

/*
 * The policy links, under the buttons.
 *
 * Under rather than inside the body text on purpose: a link buried in a
 * paragraph is read by nobody, and these two are the pages that say what the
 * banner is actually asking about. In a corner box they sit on their own row;
 * in a full-width bar they tuck under the text column.
 */
#wpc-consent-root .wpc-banner__links {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px 16px;
	flex: 1 0 100%;
	order: 3;
	margin: 0;
	padding: 0;
	list-style: none;
}

#wpc-consent-root.wpc-consent--bottom .wpc-banner__links,
#wpc-consent-root.wpc-consent--top .wpc-banner__links {
	justify-content: flex-start;
}

#wpc-consent-root .wpc-banner__links a {
	font-size: 12.5px;
	color: var( --wpc-link ) !important;
	text-decoration: underline;
}

#wpc-consent-root .wpc-banner__links a:hover {
	opacity: 0.8;
}

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

#wpc-consent-root .wpc-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	font-family: inherit;
	font-size: 14px;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	border-radius: 8px;
	transition: opacity 0.15s ease;
}

#wpc-consent-root .wpc-btn:focus-visible {
	outline: 2px solid var( --wpc-accent );
	outline-offset: 2px;
}

#wpc-consent-root .wpc-btn:hover {
	opacity: 0.88;
}

/*
 * Accept and reject. One rule, on purpose — see the note at the top of this
 * file. Adding a `.wpc-btn--accept` here that changed anything visual would be
 * reintroducing the exact dark pattern the module refuses to ship.
 */
#wpc-consent-root .wpc-btn--choice {
	min-width: 132px;
	padding: 11px 20px;
	font-weight: 600;
	color: var( --wpc-button-text ) !important;
	background: var( --wpc-button ) !important;
	border: 1.5px solid var( --wpc-button-border ) !important;
}

#wpc-consent-root .wpc-btn--primary {
	min-width: 132px;
	padding: 11px 20px;
	font-weight: 600;
	color: var( --wpc-accent-text ) !important;
	background: var( --wpc-accent ) !important;
	border: 1.5px solid var( --wpc-accent ) !important;
}

#wpc-consent-root .wpc-btn--quiet {
	padding: 11px 12px;
	/* Two words on two lines beside two single-line buttons reads as a
	   mistake. It still wraps when the box genuinely is too narrow. */
	white-space: nowrap;
	font-weight: 500;
	color: var( --wpc-muted ) !important;
	background: transparent !important;
	border: 0 !important;
	text-decoration: underline;
}

/* --- preferences -------------------------------------------------------- */

#wpc-consent-root .wpc-prefs {
	position: fixed;
	inset: 0;
	z-index: 2147483001;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba( 15, 23, 42, 0.55 );
}

#wpc-consent-root .wpc-prefs__panel {
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: 560px;
	max-height: calc( 100vh - 40px );
	background: var( --wpc-surface );
	border-radius: var( --wpc-radius );
	box-shadow: var( --wpc-shadow );
	overflow: hidden;
}

#wpc-consent-root .wpc-prefs__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 18px 22px;
	border-bottom: 1px solid var( --wpc-border );
}

#wpc-consent-root .wpc-prefs__title {
	margin: 0;
	font-size: 17px;
	font-weight: 600;
}

#wpc-consent-root .wpc-prefs__close {
	padding: 0 6px;
	font-size: 26px;
	line-height: 1;
	color: var( --wpc-muted );
	background: transparent;
	border: 0;
	cursor: pointer;
}

#wpc-consent-root .wpc-prefs__body {
	padding: 6px 22px 14px;
	overflow-y: auto;
}

#wpc-consent-root .wpc-prefs__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: flex-end;
	gap: 10px;
	padding: 16px 22px;
	border-top: 1px solid var( --wpc-border );
}

/* --- one category ------------------------------------------------------- */

#wpc-consent-root .wpc-cat {
	padding: 16px 0;
	border-bottom: 1px solid var( --wpc-border );
}

#wpc-consent-root .wpc-cat:last-child {
	border-bottom: 0;
}

#wpc-consent-root .wpc-cat__head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	cursor: pointer;
}

#wpc-consent-root .wpc-cat__label {
	font-size: 15px;
	font-weight: 600;
}

#wpc-consent-root .wpc-cat__control {
	display: inline-flex;
	align-items: center;
	gap: 10px;
	flex: 0 0 auto;
}

#wpc-consent-root .wpc-cat__always {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var( --wpc-muted );
}

/*
 * The checkbox stays in the accessibility tree and keeps its keyboard
 * behaviour; only its painting is replaced. Hiding it with display:none — the
 * usual shortcut — takes it out of the tab order, which is how a preferences
 * panel ends up unusable without a mouse.
 */
#wpc-consent-root .wpc-cat__input {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	white-space: nowrap;
}

#wpc-consent-root .wpc-cat__switch {
	position: relative;
	display: inline-block;
	width: 44px;
	height: 24px;
	background: var( --wpc-border );
	border-radius: 999px;
	transition: background 0.15s ease;
}

#wpc-consent-root .wpc-cat__switch::after {
	content: "";
	position: absolute;
	top: 3px;
	left: 3px;
	width: 18px;
	height: 18px;
	background: var( --wpc-surface );
	border-radius: 50%;
	transition: transform 0.15s ease;
}

#wpc-consent-root .wpc-cat__input:checked + .wpc-cat__switch {
	background: var( --wpc-accent );
}

#wpc-consent-root .wpc-cat__input:checked + .wpc-cat__switch::after {
	transform: translateX( 20px );
}

#wpc-consent-root .wpc-cat__input:disabled + .wpc-cat__switch {
	opacity: 0.5;
	cursor: not-allowed;
}

#wpc-consent-root .wpc-cat__input:focus-visible + .wpc-cat__switch {
	outline: 2px solid var( --wpc-accent );
	outline-offset: 2px;
}

#wpc-consent-root .wpc-cat__desc {
	margin: 8px 0 0;
	font-size: 13.5px;
	color: var( --wpc-muted );
}

/* --- the way back in ---------------------------------------------------- */

/*
 * The way back in.
 *
 * Bottom left, which is also where the default banner sits — so consent-ui.js
 * keeps this hidden while the banner is up. They are never both needed: the
 * banner IS the way in until it has been answered, and two overlapping
 * controls in one corner is how a visitor ends up pressing the wrong one.
 */
#wpc-consent-root .wpc-reopen {
	position: fixed;
	left: 16px;
	bottom: 16px;
	z-index: 2147482999;
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 8px 13px;
	font-family: inherit;
	font-size: 13px;
	color: var( --wpc-muted );
	background: var( --wpc-surface );
	border: 1px solid var( --wpc-border );
	border-radius: 999px;
	box-shadow: 0 2px 10px rgba( 15, 23, 42, 0.12 );
	cursor: pointer;
}

#wpc-consent-root .wpc-reopen:hover {
	color: var( --wpc-text );
}

#wpc-consent-root .wpc-reopen__icon {
	font-size: 14px;
	line-height: 1;
}

/* --- placeholder for a blocked embed ------------------------------------ */

#wpc-consent-root .wpc-placeholder {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 12px;
	min-height: 180px;
	padding: 24px;
	text-align: center;
	background: rgba( 15, 23, 42, 0.04 );
	border: 1px dashed var( --wpc-border );
	border-radius: var( --wpc-radius );
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#wpc-consent-root .wpc-placeholder__text {
	margin: 0;
	max-width: 42ch;
	font-size: 14px;
	color: var( --wpc-muted );
}

#wpc-consent-root .wpc-placeholder__btn {
	font-size: 13.5px;
}

/* A held iframe keeps its box so the layout does not move when it is
   released,
   but must not paint an empty white rectangle over the notice. */
iframe[ data-wpc-src ] {
	display: none !important;
}

/* --- small screens ------------------------------------------------------ */

@media ( max-width: 640px ) {
	#wpc-consent-root .wpc-banner {
		flex-direction: column;
		align-items: stretch;
		gap: 14px;
		padding: 18px;
		max-height: 85vh;
		overflow-y: auto;
	}

	#wpc-consent-root.wpc-consent--bottom-left .wpc-banner,
	#wpc-consent-root.wpc-consent--bottom-right .wpc-banner,
	#wpc-consent-root.wpc-consent--box .wpc-banner,
	#wpc-consent-root.wpc-consent--centre .wpc-banner {
		left: 12px;
		right: 12px;
		bottom: 12px;
		max-width: none;
	}

	#wpc-consent-root .wpc-banner__actions {
		flex-direction: column;
		align-items: stretch;
	}

	/* Still one rule for both, on the screen where the temptation to make
	   "Accept" full width and "Reject" a text link is strongest. */
	#wpc-consent-root .wpc-btn--choice,
	#wpc-consent-root .wpc-btn--primary {
		width: 100%;
	}

	#wpc-consent-root .wpc-prefs__actions {
		flex-direction: column-reverse;
		align-items: stretch;
	}
}

/* --- reduced motion ----------------------------------------------------- */

@media ( prefers-reduced-motion: reduce ) {
	#wpc-consent-root * {
		transition: none !important;
	}
}
