/**
 * Front-page promo popup (includes/promo.php, assets/js/promo.js).
 *
 * The box size is fixed by CSS, never by the upload: the photo is cropped into its
 * half of the card. Desktop is a two-column card, with the image side set per promo
 * (--img-left / --img-right), or a single narrower text panel when there is no photo
 * (--no-image). At 40rem and below it becomes a bottom sheet: a short
 * photo strip over the text, capped at 60vh so it never fills a phone screen.
 * Loaded only on the front page, and only when a promo exists.
 */

/* --- Shell ------------------------------------------------------------------ */

.bauuc-promo {
	width: min( 92vw, 56rem );
	max-width: none;
	max-height: 85vh;
	margin: auto; /* centres in the top layer */
	padding: 0;
	overflow: hidden auto; /* a tall card scrolls as a whole, never clips */
	color: inherit;
	background: transparent;
	border: 0;
	border-radius: 16px;
	box-shadow: 0 24px 64px rgba( 0, 0, 0, 0.45 );
}

.bauuc-promo::backdrop {
	background: rgba( 9, 13, 24, 0.72 );
}

/* Background page stops scrolling while it's open. */
html:has( .bauuc-promo[open] ) {
	overflow: hidden;
}

.bauuc-promo__card {
	position: relative;
	display: grid;
	/* minmax(0, …): equal halves. Plain 1fr lets the photo's min-content win. */
	grid-template-columns: minmax( 0, 1fr ) minmax( 0, 1fr );
}

/* Text-only (no featured image): one narrower panel, the panel colour fills the card. */
.bauuc-promo--no-image {
	width: min( 92vw, 32rem );
}

.bauuc-promo--no-image .bauuc-promo__card {
	grid-template-columns: minmax( 0, 1fr );
}

/* --- Photo ------------------------------------------------------------------ */

.bauuc-promo__media {
	/* No aspect-ratio on desktop: in a stretched grid row it feeds back into the
	   column widths. A floor height instead; the row grows with the text and the
	   absolutely positioned photo covers whatever height results. */
	position: relative;
	min-height: 24rem;
	background: var( --wp--preset--color--header-footer );
}

.bauuc-promo--img-right .bauuc-promo__media {
	order: 2;
}

.bauuc-promo__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover; /* object-position comes inline from the focus field */
}

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

.bauuc-promo__body {
	display: flex;
	flex-direction: column;
	justify-content: center;
	gap: var( --wp--preset--spacing--30 );
	padding: var( --wp--preset--spacing--50 );
	padding-top: calc( var( --wp--preset--spacing--50 ) + 1.5rem ); /* clear the × */
}

.bauuc-promo__body > * {
	margin: 0;
}

.bauuc-promo__title {
	font-size: var( --wp--preset--font-size--xx-large );
	font-weight: 800;
	line-height: 1.15;
	color: inherit;
	text-wrap: balance;
}

.bauuc-promo__lead {
	font-size: var( --wp--preset--font-size--large );
	font-weight: 600;
	line-height: 1.35;
}

.bauuc-promo__text {
	font-size: var( --wp--preset--font-size--medium );
	line-height: 1.55;
}

.bauuc-promo__text > * {
	margin: 0;
}

.bauuc-promo__text > * + * {
	margin-top: 0.6em;
}

.bauuc-promo__text ul,
.bauuc-promo__text ol {
	padding-left: 1.25em;
}

.bauuc-promo__text a {
	color: inherit;
	text-decoration: underline;
}

.bauuc-promo__button {
	margin-top: var( --wp--preset--spacing--20 );
}

/* Panel colours: palette slugs from bauuc_promo_panels(). */
.bauuc-promo--panel-card .bauuc-promo__body {
	color: var( --wp--preset--color--white );
	background: var( --wp--preset--color--card );
}

.bauuc-promo--panel-accent-3 .bauuc-promo__body {
	color: var( --wp--preset--color--white );
	background: var( --wp--preset--color--accent-3 );
}

.bauuc-promo--panel-primary .bauuc-promo__body {
	color: var( --wp--preset--color--header-footer );
	background: var( --wp--preset--color--primary );
}

/* Button colours are set here, not inherited. The theme's is-style-fill colours are
   per-rendered-block CSS (is-style-fill--N) that hand-built markup never receives.
   Selectors out-rank the theme's .is-style-fill .wp-block-button__link:hover (style.css §7). */
.bauuc-promo .bauuc-promo__button .bauuc-promo__cta {
	color: var( --wp--preset--color--header-footer );
	background: var( --wp--preset--color--primary );
	text-decoration: none;
}

.bauuc-promo .bauuc-promo__button .bauuc-promo__cta:hover,
.bauuc-promo .bauuc-promo__button .bauuc-promo__cta:focus-visible {
	color: var( --wp--preset--color--header-footer );
	background: var( --wp--preset--color--white );
}

.bauuc-promo .bauuc-promo__cta:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

/* On the light-blue panel a primary button would vanish: flip it to navy. */
.bauuc-promo--panel-primary .bauuc-promo__button .bauuc-promo__cta {
	color: var( --wp--preset--color--white );
	background: var( --wp--preset--color--header-footer );
}

/* --- Close ------------------------------------------------------------------ */

.bauuc-promo__close {
	position: absolute;
	top: 12px;
	right: 12px;
	z-index: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	color: var( --wp--preset--color--white );
	background: rgba( 9, 13, 24, 0.6 );
	border: 1px solid rgba( 255, 255, 255, 0.25 );
	border-radius: 50%;
	transition: background-color 0.15s ease;
}

.bauuc-promo__close:hover {
	background: rgba( 9, 13, 24, 0.9 );
}

.bauuc-promo__close:focus-visible {
	outline: 2px solid var( --wp--preset--color--white );
	outline-offset: 2px;
}

/* --- Entrance --------------------------------------------------------------- */

.bauuc-promo[open] {
	animation: bauuc-promo-in 0.3s ease-out;
}

.bauuc-promo[open]::backdrop {
	animation: bauuc-promo-fade 0.3s ease-out;
}

@keyframes bauuc-promo-in {
	from {
		opacity: 0;
		transform: translateY( 16px );
	}
}

@keyframes bauuc-promo-fade {
	from {
		opacity: 0;
	}
}

/* --- Mobile: bottom sheet --------------------------------------------------- */

@media ( max-width: 40rem ) {
	.bauuc-promo {
		width: 100%;
		max-height: 60vh;
		margin: auto 0 0;
		border-radius: 16px 16px 0 0;
	}

	.bauuc-promo__card {
		grid-template-columns: 1fr;
	}

	.bauuc-promo__media,
	.bauuc-promo--img-right .bauuc-promo__media {
		order: 0;
		min-height: 0;
		aspect-ratio: 16 / 9; /* safe here: one column, so the width is definite */
	}

	.bauuc-promo__body {
		padding: var( --wp--preset--spacing--40 );
	}

	.bauuc-promo__title {
		font-size: var( --wp--preset--font-size--x-large );
	}
}

/* --- Reduced motion --------------------------------------------------------- */

@media ( prefers-reduced-motion: reduce ) {
	.bauuc-promo[open],
	.bauuc-promo[open]::backdrop {
		animation: none;
	}

	.bauuc-promo__close {
		transition: none;
	}
}
