/*
 * Banner (cis/banner). Loaded with the block, front end and editor canvas.
 *
 * Moved here from the Etch styles of the Banner component (.bw-banner and its __watermark, __container,
 * __inner, __media, __overlay, __content, plus the heading and lede classes, which the cis/heading and
 * cis/paragraph blocks still print themselves). Etch only prints a style while an Etch block uses it.
 * Plain stylesheet, not compiled by Etch, so lengths are in rem and ACSS variables are used as is.
 *
 * Also folded in from assets/css/bmda-components.css, which overrides the Etch rules for these classes
 * on the live site (so the live look is Etch + those overrides, not Etch alone):
 *   - .bw-banner__content { gap: --space-s; padding-inline-end: --space-m }
 *   - from 64rem of screen width: .bw-banner { padding-block: --space-xl } and
 *     .bw-banner__content { min-block-size: 24.25rem }
 * That file stays as it is (Etch Banners still on the site keep using it).
 *
 * Left out on purpose:
 *   - The Etch rule "@media (inline-size >= 800px) { padding ... --space-xl }". "inline-size" is not a
 *     media feature, so browsers never matched it: the large padding never applied. Dropped so the banner
 *     looks exactly as it does today.
 *   - .bw-banner__text, the wrapper the Etch Banner put around heading and lede. Here the heading, lede
 *     and button are direct children of .bw-banner__content and a grid lays them out, so the editor and
 *     the front end share one set of rules. Same look.
 *   - .bw-banner__cta / __cta-icon: no banner uses them.
 */

.bw-banner {
	position: relative;
	overflow: hidden;
	inline-size: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	background-color: var(--secondary);
	padding-block: var(--space-l);
	padding-inline: var(--space-m);

	@media (width >= 64rem) {
		padding-block: var(--space-xl);
	}

	/* The button is a fixed-width call to action: it keeps its natural width next to the heading. */
	.bw-button {
		white-space: nowrap;
		flex-shrink: 0;

		&.btn--white {
			--focus-color: var(--white);
		}
	}
}

.bw-banner__watermark {
	position: absolute;
	inline-size: 126.8125rem;
	max-inline-size: 126.8125rem;
	pointer-events: none;
	inset-block-start: -28.9531rem;

	path {
		fill: var(--primary);
	}
}

.bw-banner__container {
	inline-size: 100%;
	display: flex;
	flex-direction: column;
	max-inline-size: var(--content-width, 1366px);
	align-self: center;
	margin-inline: auto;
}

.bw-banner__inner {
	container-type: inline-size;
	position: relative;
	overflow: hidden;
}

.bw-banner__media {
	position: absolute;
	inset: 0;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	filter: brightness(0.1) saturate(0.1);
	border-radius: 0;
}

.bw-banner__overlay {
	position: absolute;
	inset: 0;
	background: linear-gradient(0deg, rgba(175, 33, 13, 0.5), rgba(175, 33, 13, 0.5));
	mix-blend-mode: screen;
}

/*
 * Heading, lede and button, mobile first. The text is one column that is as wide as its longest line (up
 * to the full width) and the heading and lede fill it (they must not shrink to their own width: balanced
 * text would then wrap differently), the button sits under it. From 50rem of banner width the text (at most 74%) is on
 * the left and the button on the right, both centred on the same line.
 * In the editor each block is wrapped (data-type), so both ways of naming the blocks are listed.
 *
 * The selector is ".bw-banner .bw-banner__content" (two classes) on purpose: the old Etch Banner style for
 * .bw-banner__content stays in the Etch style store and Etch still prints it on any page that has this
 * class name in its markup (a flex layout with "gap: var(--space-m)"). Two classes beat it whatever the
 * print order, and every property it would otherwise leak into the grid is set here.
 */
.bw-banner .bw-banner__content {
	position: relative;
	z-index: 2;
	display: grid;
	grid-template-columns: fit-content(100%);
	justify-content: start;
	justify-items: stretch;
	align-items: start;
	align-content: center;
	row-gap: var(--space-xs);
	column-gap: var(--space-s);
	padding-block: var(--space-m);
	padding-inline-end: var(--space-m);
	min-block-size: 30.75rem;

	@media (width >= 64rem) {
		min-block-size: 24.25rem;
	}

	> :is(.bw-button, [data-type='cis/bw-button']) {
		justify-self: start;
		/* A full --space-s below the text on a phone, as the old flex gap was. */
		margin-block-start: calc(var(--space-s) - var(--space-xs));
	}

	@container (inline-size >= 50rem) {
		grid-template-columns: fit-content(74%) auto;
		justify-content: space-between;
		align-items: center;
		padding-block: calc(var(--space-l) + 0.375rem);

		> :is(.heading-component, [data-type='cis/heading']) {
			grid-column: 1;
			grid-row: 1;
		}

		> :is(.paragraph, [data-type='cis/paragraph']) {
			grid-column: 1;
			grid-row: 2;
		}

		> :is(.bw-button, [data-type='cis/bw-button']) {
			grid-column: 2;
			grid-row: 1 / span 2;
			margin-block-start: 0;
		}
	}
}

/* The heading and lede keep their own Etch classes (.bw-banner__heading / __description) through the
   cis/heading and cis/paragraph blocks. */

/* Editor only: a hidden button stays on the canvas, dimmed, so it can be switched back on. */
.bw-banner--no-button [data-type='cis/bw-button'] {
	opacity: 0.35;
}

/* Narrow banners: a long button label wraps instead of widening the column (2026-12-01).
   Below the two-column breakpoint only, so the wide layout is untouched. */
.bw-banner .bw-banner__content {
	@container (inline-size < 50rem) {
		grid-template-columns: minmax(0, 1fr);

		> :is(.bw-button, [data-type='cis/bw-button']) {
			white-space: normal;
			text-align: center;
		}
	}
}
