/**
 * Cookie consent banner (T006).
 *
 * Bottom sheet: never covers the header, and while it is open the two fixed
 * right-hand controls are kept disjoint from it *and* from each other (see the
 * offsets at the end of this file: the back-to-top button is lifted by
 * --maven-consent-offset, the contact sidebar is anchored above the banner and
 * the button is moved to its left, because a tall settings banner otherwise
 * reaches the vertically centred sidebar and the lifted button lands inside it).
 * No entrance animation on purpose: the banner is revealed by JS and a fade
 * would read as a flicker on a cached page.
 */

.maven-cookie-banner {
	position: fixed;
	inset: auto 0 0 0;
	z-index: calc(var(--maven-z-modal, 300) + 1);
	background: #fff;
	border-top: 1px solid var(--maven-border, #d7e0e5);
	box-shadow: 0 -10px 34px rgba(6, 47, 89, 0.18);
	color: var(--maven-text, #29455d);
	font-family: var(--maven-font);
}

.maven-cookie-banner[hidden],
.maven-cookie-banner [hidden] {
	display: none !important;
}

.maven-cookie-banner__inner {
	display: grid;
	grid-template-columns: minmax(0, 1fr) minmax(20rem, 26rem);
	justify-content: space-between;
	align-items: start;
	gap: 1.25rem 2.5rem;
	width: min(100% - 2 * var(--maven-gutter, 1.5rem), var(--maven-wide, 92rem));
	margin: auto;
	padding: 1.35rem 0 1.4rem;
	max-height: calc(100vh - 1rem);
	/* dvh: on iOS Safari 100vh counts the toolbars that are actually on screen. */
	max-height: calc(100dvh - 1rem);
	overflow-y: auto;
}

.maven-cookie-banner__copy {
	min-width: 0;
	padding-right: 2.5rem;
}

.maven-cookie-banner__copy h2 {
	margin: 0 0 0.35rem;
	color: var(--maven-heading, #102a43);
	font-size: 1.05rem;
	line-height: 1.3;
	letter-spacing: 0;
}

.maven-cookie-banner__copy p {
	margin: 0;
	color: var(--maven-text, #29455d);
	font-size: 0.875rem;
	line-height: 1.55;
}

.maven-cookie-banner__copy a {
	color: var(--maven-blue, #005aa9);
	font-weight: 700;
	text-decoration-thickness: 1px;
	text-underline-offset: 0.18em;
}

/* Settings groups only exist in "settings" mode. */
.maven-cookie-banner__choices {
	grid-column: 1 / -1;
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 0.85rem 1.5rem;
	padding: 0.9rem 0 0.2rem;
	border-top: 1px solid var(--maven-border, #d7e0e5);
}

.maven-cookie-banner__group {
	min-width: 0;
}

.maven-cookie-banner__row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	min-height: 2rem;
	cursor: pointer;
}

.maven-cookie-banner__label {
	color: var(--maven-heading, #102a43);
	font-size: 0.875rem;
	font-weight: 700;
	line-height: 1.3;
}

.maven-cookie-banner__always {
	color: var(--maven-success, #247a3b);
	font-size: 0.75rem;
	font-weight: 700;
	white-space: nowrap;
}

.maven-cookie-banner__note {
	margin: 0.15rem 0 0;
	color: var(--maven-muted, #64788a);
	font-size: 0.78rem;
	line-height: 1.45;
}

/* Switch: 2.5rem track, keyboard reachable via the real checkbox. */
.maven-cookie-banner__switch {
	position: relative;
	display: inline-flex;
	flex: 0 0 auto;
	width: 2.5rem;
	height: 1.4rem;
}

.maven-cookie-banner__switch input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	margin: 0;
	opacity: 0;
	cursor: pointer;
}

.maven-cookie-banner__switch i {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	border: 1px solid #9fb0bd;
	border-radius: 999px;
	background: #e6edf2;
	transition: background-color 180ms ease, border-color 180ms ease;
	pointer-events: none;
}

.maven-cookie-banner__switch i::after {
	content: "";
	position: absolute;
	top: 0.17rem;
	left: 0.17rem;
	width: 0.96rem;
	height: 0.96rem;
	border-radius: 50%;
	background: #fff;
	box-shadow: 0 1px 3px rgba(6, 47, 89, 0.32);
	transition: transform 180ms ease;
}

.maven-cookie-banner__switch input:checked + i {
	border-color: var(--maven-blue, #005aa9);
	background: var(--maven-blue, #005aa9);
}

.maven-cookie-banner__switch input:checked + i::after {
	transform: translateX(1.1rem);
}

.maven-cookie-banner__switch input:focus-visible + i {
	box-shadow: var(--maven-focus, 0 0 0 3px rgba(57, 168, 69, 0.5));
}

.maven-cookie-banner__actions {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: 0.5rem;
	align-content: start;
}

/* Explicit placement: Accept (primary) sits left and Reject right on row 1
 * (user requested Accept left / Reject right, 2026-11-18). */
.maven-cookie-banner__button--reject {
	grid-area: 1 / 2 / 2 / 3;
}

.maven-cookie-banner__button--accept {
	grid-area: 1 / 1 / 2 / 2;
}

/* T018: the settings view (Save only) is the one state where the actions row
 * must be as wide as the panel content. The inner sheet is a two-column grid
 * (copy | actions) and the choices block above the actions spans both, so the
 * auto-placed actions row fell into column 1 only: at 1920 the blue Save button
 * stopped at x=1233 while the choices block ends at x=1689 (456px short, and
 * its width followed the copy column instead of the panel). Spanning both
 * columns while settings is open makes Save exactly as wide as the panel
 * content (217 → 1689), in all three languages. */
.maven-cookie-banner[data-mode="settings"] .maven-cookie-banner__actions {
	grid-column: 1 / -1;
}

.maven-cookie-banner__button--customise,
.maven-cookie-banner__button--save {
	grid-area: 2 / 1 / 3 / 3;
}

.maven-cookie-banner__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 2.9rem;
	padding: 0.5rem 1rem;
	border: 1px solid transparent;
	border-radius: 0;
	font-family: inherit;
	font-size: 0.9375rem;
	font-weight: 700;
	line-height: 1.2;
	text-align: center;
	cursor: pointer;
	transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}

/* A1: accept and reject are the same size, weight and fill weight; only the
 * hue differs, so neither is the "hidden" option. */
.maven-cookie-banner__button--accept {
	background: var(--maven-blue, #005aa9);
	border-color: var(--maven-blue, #005aa9);
	color: #fff;
}

.maven-cookie-banner__button--reject {
	background: #062f59;
	border-color: #062f59;
	color: #fff;
}

.maven-cookie-banner__button--accept:hover,
.maven-cookie-banner__button--accept:focus-visible {
	background: var(--maven-dark, #003b70);
	border-color: var(--maven-dark, #003b70);
}

.maven-cookie-banner__button--reject:hover,
.maven-cookie-banner__button--reject:focus-visible {
	background: #0b4478;
	border-color: #0b4478;
}

.maven-cookie-banner__button--customise {
	grid-column: 1 / -1;
	min-height: 2.4rem;
	background: #fff;
	border-color: var(--maven-border, #d7e0e5);
	color: var(--maven-blue, #005aa9);
}

.maven-cookie-banner__button--customise:hover,
.maven-cookie-banner__button--customise:focus-visible {
	background: var(--maven-surface, #f4f7f8);
	border-color: var(--maven-blue, #005aa9);
}

/* Save inherits the primary fill; its own hover must stay dark enough for white
 * text (sharing the customise hover rule made the label invisible, #f4f7f8 on
 * #fff). */
.maven-cookie-banner__button--save {
	background: var(--maven-blue, #005aa9);
	border-color: var(--maven-blue, #005aa9);
	color: #fff;
}

.maven-cookie-banner__button--save:hover,
.maven-cookie-banner__button--save:focus-visible {
	background: var(--maven-dark, #003b70);
	border-color: var(--maven-dark, #003b70);
	color: #fff;
}

.maven-cookie-banner__close {
	position: absolute;
	top: 0.6rem;
	right: 0.6rem;
	display: grid;
	place-items: center;
	width: 2.25rem;
	height: 2.25rem;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--maven-muted, #64788a);
	cursor: pointer;
}

.maven-cookie-banner__close svg {
	width: 1.1rem;
	height: 1.1rem;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
}

.maven-cookie-banner__close:hover,
.maven-cookie-banner__close:focus-visible {
	color: var(--maven-heading, #102a43);
}

.maven-cookie-banner__status:empty {
	display: none;
}

/* B3: keep the fixed controls usable and disjoint while the banner is open. */
body.maven-consent-visible .maven-back-to-top {
	bottom: calc(var(--maven-consent-offset, 7rem) + 0.75rem);
}

/* Mobile pins the contact sidebar 5rem above the bottom edge, which is exactly
 * where the banner sits; lift it above the banner instead of covering it. */
@media (max-width: 48rem) {
	body.maven-consent-visible .maven-contact-sidebar {
		bottom: calc(var(--maven-consent-offset, 12rem) + 1rem);
	}
}

/* Desktop: the sidebar is vertically centred, so a tall settings banner (413px
 * at 1024x768) reaches its bottom edge, and the back-to-top button lifted by
 * the banner height lands inside the same right-hand column. Anchor the sidebar
 * above the banner and move the button to its left, so banner / button / sidebar
 * are pairwise disjoint in both banner states. */
@media (min-width: 48.0625rem) {
	body.maven-consent-visible .maven-contact-sidebar {
		top: auto;
		bottom: calc(var(--maven-consent-offset, 12rem) + 1rem);
		transform: none;
	}

	body.maven-consent-visible .maven-back-to-top {
		/* clamp(1rem, 2vw, 2rem) (the sidebar's right inset) + sidebar width + gap */
		right: calc(clamp(1rem, 2vw, 2rem) + 4.5rem + 0.75rem);
	}
}

/* Very short desktop viewports: the lifted sidebar (234px) + sticky header (72px)
 * + banner cannot all fit, so the sidebar slides under the header and only a
 * sliver shows (844x390: y=-105, 72px hidden). There is no layout that fits all
 * three; while the banner is open it is the one thing the visitor must interact
 * with, so hide the sidebar until a decision is stored. Threshold 35.5rem
 * (568px): measured crossover is ~567px — at 600x the sidebar sits at y=105 and
 * clears the header, so 568-600 must keep it visible. */
@media (min-width: 48.0625rem) and (max-height: 35.5rem) {
	body.maven-consent-visible .maven-contact-sidebar {
		display: none;
	}
}

/* Very short desktop viewports (e.g. 1024x720): the settings banner (413px) is
 * taller than the gap between the sticky header and the lifted sidebar, so the
 * lifted sidebar would slide under the header and a right-hand gutter would cut
 * the sheet visibly short. Keep the full-width sheet and let it scroll inside
 * itself (its inner block is already a scroll container) so the sidebar can stay
 * above it and nothing overlaps.
 *
 * T013: the reservation below (5rem header + 14.625rem sidebar + 2rem gap =
 * 346px) only makes sense while the viewport can also pay for the sheet. Two
 * hard rules follow:
 * - `max()`, never a bare `calc()`: at 390px tall the subtraction went negative
 *   and collapsed the whole sheet to 44px, pushing every button below its own
 *   scroll area ("only a sliver of the popup visible").
 * - the block is gated on `min-height: 40rem` (640px), i.e. 100vh - 346px >=
 *   294px, so the compressed height can never be arithmetic nonsense. Below
 *   640px the base `calc(100dvh - 1rem)` governs, which is correct because the
 *   sheet's natural content (244px today, 265px with a 150-char longer copy)
 *   fits a short viewport anyway.
 * The 18rem floor is the last-resort guard: it is NOT a hardcoded content height
 * (that would rot with the copy), it is the smallest sheet that still shows the
 * copy plus the whole action stack including a 2-line save row. */
@media (min-width: 48.0625rem) and (max-height: 46.5rem) and (min-height: 40rem) {
	body.maven-consent-visible .maven-cookie-banner__inner {
		max-height: max(18rem, calc(100vh - 5rem - 14.625rem - 2rem));
		/* dvh: on iOS Safari 100vh includes the toolbars, so the vh form
		 * overstates the visible area; the dvh line wins where supported. */
		max-height: max(18rem, calc(100dvh - 5rem - 14.625rem - 2rem));
	}
}

/* Footer withdraw entry: same row as the legal links, all three languages. */
.maven-footer__consent {
	padding: 0;
	border: 0;
	background: none;
	color: #dce8ef;
	font: inherit;
	font-size: var(--maven-caption);
	text-align: left;
	text-decoration: none;
	cursor: pointer;
}

.maven-footer__consent:hover,
.maven-footer__consent:focus-visible {
	color: #fff;
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

@media (max-width: 64rem) {
	.maven-cookie-banner__inner {
		grid-template-columns: 1fr;
		gap: 0.9rem;
	}
	.maven-cookie-banner__copy {
		padding-right: 2rem;
	}
	.maven-cookie-banner__choices {
		grid-template-columns: 1fr;
		gap: 0.5rem;
	}
}

@media (max-width: 48rem) {
	.maven-cookie-banner__inner {
		width: calc(100% - 2rem);
		padding: 1rem 0 1.1rem;
		gap: 0.8rem;
	}
	.maven-cookie-banner__copy {
		padding-right: 1.75rem;
	}
	.maven-cookie-banner__copy h2 {
		font-size: 1rem;
	}
	.maven-cookie-banner__copy p {
		font-size: 0.8125rem;
		line-height: 1.5;
	}
	.maven-cookie-banner__note {
		display: none;
	}
	.maven-cookie-banner__actions {
		gap: 0.4rem;
	}
	.maven-cookie-banner__button {
		min-height: 2.75rem;
		font-size: 0.875rem;
		padding: 0.4rem 0.5rem;
	}
	.maven-cookie-banner__button--customise,
	.maven-cookie-banner__button--save {
		min-height: 2.4rem;
	}
	.maven-footer__consent {
		display: inline-block;
	}
}

@media (prefers-reduced-motion: reduce) {
	.maven-cookie-banner__switch i,
	.maven-cookie-banner__switch i::after,
	.maven-cookie-banner__button {
		transition: none;
	}
}
