/**
 * Hero: dark surface, full-width photo under --color-overlay, content in
 * .bst-container. Markup in inc/hero.php.
 * See "Home hero" and "Page hero" in docs/design-system.md.
 *
 * Base .bst-hero (centered content) is shared by both variants:
 * .bst-hero--home adds the homepage height and a left-aligned block
 * (below); .bst-hero--page (shorter, title and breadcrumb) uses the base
 * padding only. .bst-hero--plain: no photo, solid forest.
 *
 * Layering: photo, overlay and content share one grid cell; the photo and
 * overlay have negative z-index. The hero itself is not positioned, so on
 * pages that start with a hero (`body.bst-has-hero`) the header, which
 * GeneratePress positions, paints over it without a z-index of its own.
 * That keeps the dropdowns and the mobile drawer in their existing
 * stacking order.
 */

.bst-hero {
	--focus-color: var(--color-white);
	--surface-color: var(--color-forest);

	display: grid;
	grid-template: 1fr / 1fr;
	overflow: hidden;
	color: var(--color-white);
}

.bst-hero > *,
.bst-hero::before {
	grid-area: 1 / 1;
}

/*
 * Photo (decorative): fills the cell without sizing it. `aspect-ratio:
 * auto` drops the ratio from the width/height attributes, which would
 * otherwise size the row (a portrait photo made the hero very tall).
 */
.bst-hero__photo {
	z-index: -2;
	width: 100%;
	max-width: none;
	height: 100%;
	aspect-ratio: auto;
	contain: size;
	background-color: var(--color-forest); /* while the photo loads */
	object-fit: cover;
}

.bst-hero::before {
	z-index: -1;
	background-color: var(--color-overlay);
	content: "";
}

/* No photo: the overlay layer becomes a solid forest background. */
.bst-hero--plain::before {
	background-color: var(--color-forest);
}

/* Centered column, proportions from home-01.jpg. */
.bst-hero__inner {
	display: flex;
	flex-direction: column;
	align-self: center;
	align-items: center;
	width: 100%;
	padding-top: var(--section-y);
	padding-bottom: var(--section-y);
	text-align: center;
}

.bst-hero .bst-eyebrow {
	color: var(--color-white);
}

.bst-hero__title {
	max-width: 14em;
	margin: 0 0 0.5em;
	color: var(--color-white);
	font-size: var(--text-h1);
	text-wrap: balance;
}

/*
 * On single posts the hero title is a paragraph (the h1 is the post
 * title): the same look as the heading (base.css headings).
 */
p.bst-hero__title {
	font-family: var(--font-heading);
	font-weight: 400;
	line-height: 1.3;
	letter-spacing: 0.02em;
	text-transform: uppercase;
}

.bst-hero__text {
	max-width: 32em;
	margin: 0 0 2em;
}

.bst-hero__actions {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: calc(var(--gap) / 2);
}

/*
 * Breadcrumb under the page hero title (bstieunhien_theme_breadcrumb(),
 * inc/template-tags.php): heading font italic, white; the home link is
 * underlined and the underline turns accent on hover and focus, like
 * inline links. Separator from CSS, hidden from screen readers.
 */
.bst-breadcrumb {
	font-family: var(--font-heading);
	font-size: var(--text-link);
	font-style: italic;
	line-height: 1.5;
}

.bst-breadcrumb__list {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	margin: 0;
	padding: 0;
	list-style: none;
}

.bst-breadcrumb__item + .bst-breadcrumb__item::before {
	margin: 0 0.6em;
	color: var(--color-accent);
	content: "\203A";
	content: "\203A" / "";
}

.bst-breadcrumb a,
.bst-breadcrumb a:hover,
.bst-breadcrumb a:focus {
	color: var(--color-white);
}

.bst-breadcrumb a:hover,
.bst-breadcrumb a:focus {
	text-decoration-color: var(--color-accent);
}

/*
 * Picture element (home hero with a mobile photo, art direction below
 * 1024px in portrait orientation): display: contents keeps the img as
 * the grid item with its class, layering and size rules. The img is not
 * a direct child of the hero then, so it gets its cell here
 * (`.bst-hero > *` misses it).
 */
.bst-hero__picture {
	display: contents;
}

.bst-hero__picture > .bst-hero__photo {
	grid-area: 1 / 1;
}

/*
 * Home hero (layout adapted from home-01.jpg): the photo shows a person
 * on the right, so the content is left aligned, over the photo, and the
 * hero is at least 85% of the viewport height at every width. The
 * photo's focal point is right of center and above the middle.
 *
 * Below 1024px the block spans the container at the bottom of the hero,
 * with --gap below it, so it covers the body and the face above stays
 * clear. From 1024px (media query below) it is about 7 of 12 columns
 * wide at the left edge, vertically centered; the paragraph keeps its
 * 32em limit.
 */
.bst-hero--home {
	min-height: 85vh;
	min-height: 85svh;
}

.bst-hero--home .bst-hero__photo {
	object-position: 65% 35%;
}

.bst-hero--home .bst-hero__inner {
	align-self: end;
	align-items: flex-start;
	padding-bottom: var(--gap);
	text-align: left;
}

/*
 * Home hero title at --text-hero: one page line per typed line
 * (bstieunhien_theme_hero_title() prints a block span per line). The
 * text of a line is an inline-block, so the entrance in motion.css can
 * move it inside the line. Each line but the last ends with a space in
 * its own span: preserved (white-space: pre) so copying and screen
 * readers get "BẠN TRÊN", and zero width (font-size: 0) on screen. Not
 * limited by the block width; a line wraps only when it is wider than
 * the container.
 */
.bst-hero--home .bst-hero__title {
	max-width: none;
	font-size: var(--text-hero);
}

.bst-hero__line {
	display: block;
}

.bst-hero__line-text {
	display: inline-block;
}

.bst-hero__space {
	font-size: 0;
	letter-spacing: 0; /* the heading's spacing is inherited in px */
	white-space: pre;
}

.bst-hero--home .bst-hero__actions {
	justify-content: flex-start;
}

/*
 * Below 1024px in portrait (the same condition as the mobile photo's
 * <source> in inc/hero.php, where the person is in the middle): the
 * text is centered and the buttons are centered as a group. The mobile
 * photo is anchored to the top, so the face stays in frame when the
 * bottom is cropped. Landscape and from 1024px stay left aligned.
 */
@media (max-width: 1023px) and (orientation: portrait) {

	.bst-hero--mobile-photo .bst-hero__photo {
		object-position: 50% 0;
	}

	.bst-hero--home .bst-hero__inner {
		align-items: center;
		text-align: center;
	}

	.bst-hero--home .bst-hero__actions {
		justify-content: center;
	}
}

@media (min-width: 1024px) {

	.bst-hero--home .bst-hero__inner {
		/* 7 of 12 columns of the container, with --gap gutters. */
		--bst-hero-block: calc((100% - 11 * var(--gap)) / 12 * 7 + 6 * var(--gap));

		align-self: center;
		padding-bottom: var(--section-y);
	}

	.bst-hero--home .bst-hero__inner > * {
		max-width: var(--bst-hero-block);
	}

	.bst-hero--home .bst-hero__inner > .bst-hero__title {
		max-width: none;
	}

	.bst-hero--home .bst-hero__inner > .bst-hero__text {
		max-width: min(32em, var(--bst-hero-block));
	}
}

/*
 * Page starts with a hero: pull the hero up under the header and add the
 * header height to its top padding, so the photo runs behind the header
 * and the content stays clear of it. The homepage minimum height grows
 * by the same amount, so the hero is at least as tall below the header.
 */
.bst-has-hero .bst-hero {
	margin-top: calc(-1 * var(--header-height));
}

.bst-has-hero .bst-hero__inner {
	padding-top: calc(var(--section-y) + var(--header-height));
}

.bst-has-hero .bst-hero--home {
	min-height: calc(85vh + var(--header-height));
	min-height: calc(85svh + var(--header-height));
}
