/*
 * Hero (cis/hero). Loaded with the block, front end and editor canvas.
 *
 * Moved here from the Etch styles of the Hero component (.bw-hero, .bw-hero__container, __inner,
 * __media, __content-wrapper, __heading, __watermark, .bw-homepage-hero and its watermark), because
 * Etch only prints a style while an Etch block uses it. Plain stylesheet, not compiled by Etch, so:
 *   - lengths are in rem (to-rem(440px) = 27.5rem) and ACSS variables are used directly;
 *   - the Etch @custom-media tokens do not exist here, so their conditions are written out:
 *       --block-query-large / --container-query-large  = inline-size >= 800px  (50rem)
 *       --browser-query-xlarge / --media-query-xlarge  = width > 1024px
 *   - the Etch default section and container rules ([data-etch-element]) are repeated on the block,
 *     so a page with no Etch block on it still gets them.
 *
 * Left out on purpose: the .single-event / .single-article rules of the old .bw-hero style. Those
 * templates still use the Etch Hero component and keep their own styles.
 *
 * Mobile first: the base rules are the small screen; the container (hero width) and a single
 * viewport query scale it up.
 */

.bw-hero {
	position: relative;
	overflow: hidden;
	inline-size: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.bw-hero:not(.bw-homepage-hero) {
	background-color: var(--secondary);
	padding-block-start: var(--section-padding-block);

	@media (width > 1024px) {
		padding-block-start: 0;
	}
}

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

.bw-hero__inner {
	position: relative;
	overflow: hidden;
	inline-size: 100%;
	display: flex;
	align-items: flex-end;
	padding-block: var(--space-xxl);
	background-color: var(--primary);
	min-block-size: 27.5rem;

	@container (min-width: 50rem) {
		min-block-size: var(--hero-inner-min-height-large);
	}
}

.bw-hero__media {
	position: absolute;
	inset: 0;
	z-index: 0;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	object-position: center bottom;
	border-radius: 0;
}

.bw-hero__content-wrapper {
	position: relative;
	z-index: 2;
	flex: 1 1 auto;
	min-inline-size: 0;
}

.bw-hero__heading {
	text-transform: uppercase;
	white-space: pre-line;
	overflow-wrap: break-word;
}

/* The title is a cis/heading: a scoped override of its own classes. */
.bw-hero {
	.heading-component {
		text-transform: uppercase;
		white-space: pre-line;
		overflow-wrap: break-word;

		&:not([data-heading-color]) {
			color: var(--white);
		}

		&:where(h1) {
			font-size: calc(var(--h1) + 2.25rem);

			@container (min-width: 50rem) {
				font-size: 11.25rem;
			}
		}
	}
}

.bw-hero__watermark {
	position: absolute;
	inset-block-start: 56%;
	inset-inline-start: 71%;
	transform: translate(-50%, -50%);
	inline-size: 64%;
	aspect-ratio: 822 / 917;
	opacity: 0.4;
	z-index: 0;
	color: var(--secondary);
	pointer-events: none;

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

/* Optional pill (an inner cis/pill block) above the title. */
.bw-hero__pill {
	margin-block-end: var(--space-xs);
}

/*
 * Title size "medium" (the ByWard 200 hero): a smaller title that scales with the hero width
 * (the hero container is the size container) and is not held to 8ch by the home layout.
 */
.bw-hero--title-medium .bw-hero__content-wrapper .heading-component:where(h1) {
	font-size: clamp(2rem, 9.6cqi, 8.5rem);
	max-inline-size: none;
}

/* Opt-in: a very long word (e.g. "Developments") shrinks to fit a phone instead of overflowing. */
.bw-hero--fit-title .bw-hero__content-wrapper .heading-component:where(h1) {
	@container (max-width: 28rem) {
		font-size: 17.8vw;
	}
}

/* Home page layout: pulled up under the header, dark overlay on the image, a second big watermark. */
.bw-homepage-hero {
	background-color: var(--primary);

	@media (width > 1024px) {
		padding-block-start: var(--hero-padding-block-start, 9.1rem);
		margin-block-start: calc(var(--hero-padding-block-start, 9.1rem) * -1);
	}

	.bw-hero__inner {
		padding-block-start: 4.75rem;
		padding-block-end: 2.25rem;
		min-block-size: 30rem;

		&::after {
			content: '';
			position: absolute;
			inset: 0;
			z-index: 1;
			pointer-events: none;
			background: linear-gradient(to bottom, rgba(255, 255, 255, 0.36) 0%, rgba(0, 0, 0, 0.36) 100%);
			mix-blend-mode: multiply;
		}
	}

	.heading-component {
		max-inline-size: 8ch;
	}
}

.bw-homepage-hero__watermark {
	position: absolute;
	inset-block-start: -16vw;
	inset-inline-start: -4vw;
	inline-size: 110%;
	aspect-ratio: 822 / 917;
	z-index: 0;
	color: var(--secondary);
	pointer-events: none;

	path {
		fill: currentcolor;
	}
}
