/*
 * Layout: page grid (content-grid / alignwide / alignfull), main content, grid helpers,
 * two-column page grid (main + sidebar), sections, borders.
 */

/* Content grid ------------------------------------------------------------------------- */
.content-grid {
	--padding-inline: 1rem;
	--content-max-width: 1440px;
	--breakout-max-width: 1540px;

	--breakout-size: calc(
		(var(--breakout-max-width) - var(--content-max-width)) / 2
	);

	display: grid;
	grid-template-columns:
		[full-width-start] minmax(var(--padding-inline), 1fr)
		[breakout-start] minmax(0, var(--breakout-size))
		[content-start] min(
			100% - (var(--padding-inline) * 2),
			var(--content-max-width)
		)
		[content-end]
		minmax(0, var(--breakout-size)) [breakout-end]
		minmax(var(--padding-inline), 1fr) [full-width-end];
}

.content-grid > :not(.alignwide, .alignfull),
.alignfull > :not(.alignwide, .alignfull) {
	grid-column: content;
}

.content-grid > .alignwide,
.alignfull > .alignwide {
	grid-column: breakout;
}

.content-grid > .alignfull {
	grid-column: full-width;
	display: grid;
	grid-template-columns: inherit;
}

.alignfull > .alignfull {
	grid-column: full-width;
}

img.alignfull {
	width: 100%;
	max-height: 45vh;
	object-fit: cover;
}

/* Main content ------------------------------------------------------------------------- */
.mainContent {
	position: relative;
	z-index: 1;
	padding-top: 4.8rem;
	margin-bottom: 0;
	background-color: var(--paper);
}

/* Grid helpers ------------------------------------------------------------------------- */
.grid {
	display: grid;
	gap: 2.4rem;
}

.col2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.col3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.col4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }

.col2thirds {
	display: grid;
	grid-template-columns: 2fr 1fr;
	grid-template-rows: auto;
}

.colBalanced {
	display: grid;
	grid-template-columns: 1fr 2fr 1fr;
	grid-template-rows: auto;
}

.grid--layout {
	column-gap: 4.8rem;
}


/* Borders ------------------------------------------------------------------------------ */
.borderLeft,
.borderBottom {
	position: relative;
}

.borderLeft:before {
	content: "";
	display: block;
	width: 1px;
	height: 100%;
	border-left: 1px solid var(--line);
	position: absolute;
	top: 0;
	left: -2.4rem;
}

.borderBottom {
	padding-bottom: 2.4rem;
	margin-bottom: 2.4rem;
	border-bottom: 1px solid var(--line);
}

/* Page grid: main column + sidebar ------------------------------------------------------ */
.pageGrid {
	display: grid;
	/* The sidebar starts level with the page header and runs down beside the article. */
	grid-template-areas: "articleHeader sidebar"
	                     "article sidebar";
	/* minmax(0, ...): a wide child (table, embed) can no longer stretch its column. */
	grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
	/* 1fr: a sidebar taller than the header + article grows the second row, never the header row. */
	grid-template-rows: auto 1fr;
	column-gap: 4.8rem;
}

.pageGrid__main,
.pageGrid__sidebar {
	min-width: 0;
}

.pageGrid__mainHeader { grid-area: articleHeader; }

.pageGrid__main { grid-area: article; }

.pageGrid__sidebar.grid {
	grid-area: sidebar; /* gap, flex column: sidebar.css */
}

.pageGrid__sidebar .borderBottom:last-child {
	margin-bottom: 0;
}

/* Sections ----------------------------------------------------------------------------- */
.section {
	margin-bottom: 4.8rem;
}

.section--bg {
	background-color: var(--surface);
	padding: 2.4rem 0;
}

.section__header {
	font-size: 1.2rem;
	margin-bottom: 1.6rem;
}

.section__header .headingSmall {
	display: inline-block;
	margin-right: 1rem;
}

/* Empty states: no search results, 404 (search.php, 404.php) ------------------------------ */
.notFound {
	display: grid;
	gap: 2.4rem;
	justify-items: start;
}

.notFound .search-form {
	display: flex;
	gap: 0.8rem;
	width: 100%;
	max-width: 56rem;
}

.notFound .search-form label {
	flex: 1;
}

.notFound .search-field {
	width: 100%;
	padding: 1.2rem 1.6rem;
	border: 1px solid var(--line);
	border-radius: 2px;
	background: var(--surface);
	font-family: var(--fontFamily);
	font-size: 1.6rem;
}

.notFound .search-submit {
	padding: 1.2rem 2.4rem;
	border: 0;
	border-radius: 2px;
	background: var(--accent-text);
	color: var(--surface);
	font-family: var(--fontFamilyHeadings);
	font-size: 1.4rem;
	text-transform: uppercase;
	cursor: pointer;
}

.notFound .search-submit:hover {
	background: var(--ink);
}

.notFound__links {
	margin: 0;
	padding-left: 2rem;
	line-height: 2;
}

/* 404 (404.php): a lead line, a large search box, the main destinations as buttons, then the
   editors' top stories. */
.notFound__header {
	display: grid;
	gap: 0.8rem;
	margin-bottom: 1.6rem;
}

.notFound__kicker {
	font-size: 1.4rem;
	letter-spacing: 0.02em;
	color: var(--accent-text);
}

.notFound--404 {
	gap: 2rem;
}

.notFound__lead {
	margin: 0;
	max-width: 56rem;
	font-size: 1.8rem;
	line-height: 1.5;
	color: var(--ink-muted);
}

.notFound--404 .search-form {
	max-width: 64rem;
}

.notFound--404 .search-field {
	min-height: 5.2rem;
	border-radius: 999px;
	padding-inline: 2.4rem;
	font-size: 1.7rem;
}

.notFound--404 .search-submit {
	border-radius: 999px;
	padding-inline: 2.8rem;
}

.notFound__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 0.8rem;
}

.notFound__chips a {
	display: inline-flex;
	align-items: center;
	min-height: 4rem;
	padding: 0 1.6rem;
	border: 1.5px solid var(--line);
	border-radius: 999px;
	background: var(--surface);
	color: var(--ink);
	font-weight: 700;
	font-size: 1.4rem;
	text-decoration: none;
	transition: border-color 0.2s, background-color 0.2s, color 0.2s;
}

.notFound__chips a:hover,
.notFound__chips a:focus-visible {
	border-color: var(--ink);
	background: var(--ink);
	color: var(--surface);
}

.notFound__top {
	margin-top: 4.8rem;
}

.notFound__cards {
	row-gap: 3.2rem;
}

@media screen and (max-width: 599px) {
	.notFound--404 .search-form {
		flex-direction: column;
	}

	.notFound--404 .search-submit {
		min-height: 4.8rem;
	}

	.notFound__cards {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Responsive --------------------------------------------------------------------------- */
@media screen and (max-width: 1023px) {
	.mainContent {
		padding-top: 2.4rem;
	}

	.col2,
	.col3,
	.col4,
	.col2thirds,
	.colBalanced {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	}

	.pageGrid {
		grid-template-areas: "articleHeader"
		                     "article"
		                     "sidebar";
		grid-template-columns: minmax(0, 1fr);
		grid-template-rows: auto;
	}

	.pageGrid__sidebar {
		margin-top: 4.8rem;
	}
}

@media screen and (max-width: 800px) {
	.col2,
	.col3,
	.col4,
	.col2thirds,
	.colBalanced {
		grid-template-columns: minmax(0, 1fr);
	}
}

/* Header leaderboard (parts/header/header_banner.php: home under the hero, articles under the
   photo, categories under the title). The slot box is reserved by the ad registry
   (.adSlot--leaderboard / --narrow); never wider than its column (UX-05). */
.headerBanner {
	max-width: 100%;
	overflow: hidden;
}

.pageGrid__main .headerBanner {
	margin-block: 0 2.4rem;
}
