/*
Theme Name: Broadsheet
Theme URI: https://github.com/levieta/broadsheet
Author: levieta
Author URI: https://github.com/levieta
Description: A news and magazine block theme in the style of a printed newspaper: a newsprint palette, Newsreader headlines and Libre Franklin labels, both with full Vietnamese character sets. Magazine front-page patterns, related and most-discussed lists, story badges, reserved ad space and a reading-first article, built from core blocks only so it works without any plugin.
Version: 0.0.1
Requires at least: 7.1
Tested up to: 7.1
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: broadsheet
Tags: news, blog, grid-layout, one-column, wide-blocks, block-patterns, block-styles, custom-colors, custom-logo, custom-menu, editor-style, featured-images, full-site-editing, style-variations, translation-ready, accessibility-ready
*/

/*
 * Only what theme.json cannot express. Every value comes from a theme.json preset, so a child
 * theme or style variation that changes the presets restyles these rules too.
 */

/* ---------------------------------------------------------------------------------------------
 * Header (patterns/header.php).
 * ------------------------------------------------------------------------------------------- */

/*
 * Height of the sticky bar: a 44px control plus the bar's padding and border. In-page targets
 * (table of contents, footnotes) stop below it instead of under it.
 */
:root {
	--broadsheet-header-h: calc(44px + 2 * var(--wp--preset--spacing--30) + 1px);
}

:where([id]) {
	scroll-margin-top: calc(var(--broadsheet-header-h) + var(--wp--preset--spacing--40));
}

/*
 * Header stays reachable while reading long articles. The sticky element is the template part's
 * own <header>: the .broadsheet-header group inside it is exactly as tall as its parent, so a
 * sticky rule on the group has no room to move and scrolls away with the page.
 */
.wp-site-blocks > header.wp-block-template-part:has(> .broadsheet-header) {
	position: sticky;
	top: 0;
	z-index: 20;
}

.admin-bar .wp-site-blocks > header.wp-block-template-part:has(> .broadsheet-header) {
	top: var(--wp-admin--admin-bar--height, 32px);
}

@media (max-width: 600px) {
	/* The admin bar scrolls away on small screens, so the header must not leave a gap for it. */
	.admin-bar .wp-site-blocks > header.wp-block-template-part:has(> .broadsheet-header) {
		top: 0;
	}
}

.broadsheet-header__bar {
	align-items: center;
	gap: var(--wp--preset--spacing--30);
}

/* The brand takes what is left and gives way first: a long title is cut, never wrapped. Two
 * classes, because core resets the margins of flex children with `body .is-layout-flex > *`. */
.broadsheet-header__bar > .broadsheet-header__brand {
	flex: 0 1 auto;
	margin-right: auto;
	min-width: 0;
}

.broadsheet-header__brand .wp-block-site-title {
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Icon controls (search, menu) are 44px squares on every screen. */
.broadsheet-header .wp-block-navigation__responsive-container-open,
.broadsheet-search-compact .wp-block-search__button {
	align-items: center;
	display: inline-flex;
	height: 44px;
	justify-content: center;
	margin: 0;
	width: 44px;
}

.broadsheet-search-wide .wp-block-search__input {
	min-height: 44px;
}

/*
 * 1100px: below it, logo + search icon + menu icon; from it, logo + inline menu + search field.
 * Measured with a four-item menu beside the search field; a child theme with a longer or shorter
 * menu repeats these two blocks with its own width.
 */
@media (max-width: 1099px) {
	.broadsheet-header .broadsheet-nav-inline,
	.broadsheet-header .broadsheet-search-wide {
		display: none;
	}
}

@media (min-width: 1100px) {
	.broadsheet-header .broadsheet-nav-overlay,
	.broadsheet-header .broadsheet-search-compact {
		display: none;
	}

	.broadsheet-header__bar > .broadsheet-header__brand {
		margin-right: 0;
	}

	.broadsheet-header__bar > .broadsheet-nav-inline {
		margin-inline: auto;
	}

	.broadsheet-search-wide {
		flex: 0 0 17rem;
	}
}

/* Block style: card. A bordered surface for teasers, callouts and boxes. */
.is-style-broadsheet-card {
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--card);
	padding: var(--wp--preset--spacing--50);
}

/* Block style: kicker. A section heading with a short accent rule above it. */
.is-style-broadsheet-kicker {
	font-size: var(--wp--preset--font-size--small);
	letter-spacing: 0.02em;
	padding-top: var(--wp--preset--spacing--30);
	position: relative;
}

.is-style-broadsheet-kicker::before {
	background: var(--wp--preset--color--accent);
	content: "";
	height: 3px;
	left: 0;
	position: absolute;
	top: 0;
	width: 2.5rem;
}

/* Post meta line: author · date · reading time, separated without extra markup. */
.broadsheet-post-meta > * + *::before {
	color: var(--wp--preset--color--border);
	content: "·";
	margin-right: var(--wp--preset--spacing--20);
}

/* Teaser images keep one ratio so rows of cards line up, and always fill the card's width: the
 * teaser is a vertical flex box that would otherwise size the image to the file the browser picked
 * from srcset, which can be narrower than the card. */
/* An explicit width, not align-self: stretch, because a stretched width does not feed
 * aspect-ratio, which the no-image tile below relies on for its height. */
.broadsheet-teaser > .wp-block-post-featured-image {
	width: 100%;
}

.broadsheet-teaser .wp-block-post-featured-image img {
	aspect-ratio: 16 / 9;
	object-fit: cover;
	width: 100%;
}

/* Touch targets in navigation meet the 44px minimum. */
.wp-block-navigation .wp-block-navigation-item__content {
	min-height: 44px;
	display: inline-flex;
	align-items: center;
}

/* Visible focus for keyboard users on every interactive element. */
:where(a, button, input, select, textarea, summary):focus-visible {
	outline: 2px solid var(--wp--preset--color--accent);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	* {
		scroll-behavior: auto !important;
		transition: none !important;
	}
}

/* ---------------------------------------------------------------------------------------------
 * Teasers and the grids that hold them.
 *
 * Rule shared by every grid below: a curated set (editor's picks, a section's three stories,
 * related stories) never leaves an empty cell and never spans rows, because a row-spanning card
 * only balances when its text happens to be as tall as the cards beside it. Only a long paginated
 * list may end on a partial row. Grids read their container's width, not the window's, so the same
 * grid works in a full-width section and in the article column.
 * ------------------------------------------------------------------------------------------- */

/* The category above a teaser title is a link: 24px tall, the WCAG 2.5.8 minimum. */
.broadsheet-teaser .wp-block-post-terms a {
	align-items: center;
	display: inline-flex;
	min-height: 24px;
}

/* A teaser without a featured image keeps the image slot as a typographic tile, so its title
 * starts on the same line as its neighbours' (broadsheet_featured_image_tile() in functions.php). */
.broadsheet-noimage {
	aspect-ratio: 16 / 9;
	flex-shrink: 0; /* unlike an image it has no intrinsic height, so a vertical teaser could squeeze it */
	background: var(--wp--preset--color--surface);
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--control);
	margin: 0;
	overflow: hidden;
}

.broadsheet-noimage > a,
.broadsheet-noimage > span {
	align-content: center;
	color: var(--wp--preset--color--primary);
	display: grid;
	gap: var(--wp--preset--spacing--20);
	height: 100%;
	justify-items: start;
	padding: var(--wp--preset--spacing--40);
	text-decoration: none;
}

.broadsheet-noimage__type {
	color: var(--wp--preset--color--muted);
	font-family: var(--wp--preset--font-family--ui);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	letter-spacing: 0.02em;
}

.broadsheet-noimage__label {
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	line-height: 1.2;
}

/*
 * Blog index (templates/home.html): on page 1 the newest story is a horizontal card across the
 * whole first row, image 7/12 and text 5/12; the rest fill the auto-fill grid below it.
 * body.paged marks page 2 and later, which have no lead.
 */
body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child {
	grid-column: 1 / -1;
}

body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child .wp-block-post-title {
	font-size: var(--wp--preset--font-size--x-large);
	line-height: 1.2;
	text-wrap: balance;
}

@media (min-width: 782px) {
	body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child > .broadsheet-teaser {
		align-items: start;
		column-gap: var(--wp--preset--spacing--50);
		display: grid;
		grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
		grid-template-rows: 1fr auto auto auto auto 1fr;
	}

	body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child .broadsheet-teaser > * {
		grid-column: 2;
		margin: 0;
	}

	body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child .broadsheet-teaser > .wp-block-post-featured-image {
		grid-column: 1;
		grid-row: 1 / -1;
	}

	body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child .wp-block-post-terms { grid-row: 2; }
	body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child .wp-block-post-title { grid-row: 3; }
	body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child .wp-block-post-excerpt { grid-row: 4; }

	body:not(.paged) .broadsheet-lead-grid > .wp-block-post-template > li:first-child .wp-block-post-date {
		grid-row: 5;
		margin-top: 0;
	}
}

/*
 * Editor's picks (patterns/section-featured.php): one to six stories.
 *
 *   container       narrow < 560px        medium 560-959px            wide >= 960px
 *   1               card                  horizontal lead             horizontal lead
 *   2               card + 1 row          lead + 1 row                two halves
 *   3               card + 2 rows         lead + 2 rows side by side  three thirds
 *   4               card + 3 rows         lead + 2 + 1 row            lead + three thirds
 *   5               card + 4 rows         lead + 2 + 2 rows           lead + four quarters
 *   6               card + 5 rows         lead + 2 + 2 + 1 row        two halves + four quarters
 *
 * "row" is a compact teaser: thumbnail, category, title, date. Title sizes are set here and not
 * by a fontSize attribute on the block, because a preset class carries !important.
 */
.broadsheet-picks {
	container: broadsheet-picks / inline-size;
}

.broadsheet-picks > .wp-block-post-template {
	display: grid;
	gap: var(--wp--preset--spacing--50);
	grid-template-columns: repeat(12, minmax(0, 1fr));
	list-style: none;
	padding: 0;
}

/* Kept at low specificity on purpose: every count rule below overrides it. */
.broadsheet-picks li {
	grid-column: span 12;
	min-width: 0;
}

.broadsheet-picks .broadsheet-teaser {
	height: 100%;
}

.broadsheet-picks .broadsheet-teaser > * {
	margin: 0;
}

.broadsheet-picks .wp-block-post-title {
	font-size: var(--wp--preset--font-size--large);
	line-height: 1.3;
	text-wrap: pretty;
}

.broadsheet-picks li:first-child .wp-block-post-title {
	font-size: var(--wp--preset--font-size--x-large);
	line-height: 1.2;
	text-wrap: balance;
}

.broadsheet-picks .wp-block-post-date {
	margin-top: auto;
}

/* Compact rows: narrow and medium containers, every story after the first. */
@container broadsheet-picks (max-width: 959px) {
	.broadsheet-picks li + li > .broadsheet-teaser {
		column-gap: var(--wp--preset--spacing--40);
		display: grid;
		grid-template-columns: 7.5rem minmax(0, 1fr);
		grid-template-rows: auto auto 1fr;
		row-gap: 0.125rem;
	}

	.broadsheet-picks li + li .wp-block-post-featured-image {
		grid-column: 1;
		grid-row: 1 / span 3;
	}

	.broadsheet-picks li + li .broadsheet-teaser > :not(.wp-block-post-featured-image) {
		grid-column: 2;
	}

	.broadsheet-picks li + li .wp-block-post-title {
		font-size: var(--wp--preset--font-size--medium);
		line-height: 1.35;
	}

	.broadsheet-picks li + li .wp-block-post-excerpt {
		display: none;
	}

	.broadsheet-picks li + li .wp-block-post-date {
		margin-top: 0;
	}

	.broadsheet-picks li + li .broadsheet-noimage > * {
		padding: var(--wp--preset--spacing--20);
	}

	.broadsheet-picks li + li .broadsheet-noimage__label {
		font-size: var(--wp--preset--font-size--x-small);
	}
}

/* Narrow: rows are divided by a rule instead of a gap. */
@container broadsheet-picks (max-width: 559px) {
	.broadsheet-picks > .wp-block-post-template {
		gap: 0;
	}

	.broadsheet-picks li:first-child {
		padding-bottom: var(--wp--preset--spacing--50);
	}

	.broadsheet-picks li + li {
		border-top: 1px solid var(--wp--preset--color--border);
		padding-block: var(--wp--preset--spacing--40);
	}
}

/* Medium: rows two per line; an odd last one takes the whole line. */
@container broadsheet-picks (min-width: 560px) and (max-width: 959px) {
	.broadsheet-picks li + li {
		grid-column: span 6;
	}

	.broadsheet-picks > .wp-block-post-template:has(> li:nth-child(even):last-child) > li:last-child {
		grid-column: span 12;
	}

	.broadsheet-picks li + li > .broadsheet-teaser {
		grid-template-columns: 8.5rem minmax(0, 1fr);
	}
}

/* The horizontal lead, medium and wide: text beside the image, centred by the two 1fr rows. */
@container broadsheet-picks (min-width: 560px) {
	.broadsheet-picks li:first-child > .broadsheet-teaser {
		align-items: start;
		column-gap: var(--wp--preset--spacing--50);
		display: grid;
		grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
		grid-template-rows: 1fr auto auto auto auto 1fr;
		row-gap: var(--wp--preset--spacing--20);
	}

	.broadsheet-picks li:first-child .broadsheet-teaser > * {
		grid-column: 2;
	}

	.broadsheet-picks li:first-child .broadsheet-teaser > .wp-block-post-featured-image {
		grid-column: 1;
		grid-row: 1 / -1;
	}

	.broadsheet-picks li:first-child .wp-block-post-terms { grid-row: 2; }
	.broadsheet-picks li:first-child .wp-block-post-title { grid-row: 3; }

	.broadsheet-picks li:first-child .wp-block-post-excerpt {
		font-size: var(--wp--preset--font-size--medium);
		grid-row: 4;
	}

	.broadsheet-picks li:first-child .wp-block-post-date {
		grid-row: 5;
		margin-top: 0;
	}
}

@container broadsheet-picks (min-width: 960px) {
	/* 4: lead + thirds; 5: lead + quarters. Small cards carry no excerpt. */
	.broadsheet-picks li + li {
		grid-column: span 4;
	}

	.broadsheet-picks li + li .wp-block-post-excerpt {
		display: none;
	}

	.broadsheet-picks > .wp-block-post-template:has(> li:nth-child(5):last-child) > li + li {
		grid-column: span 3;
	}

	/* 2 and 3: equal cards, no lead. */
	.broadsheet-picks > .wp-block-post-template:has(> li:nth-child(2):last-child) > li {
		grid-column: span 6;
	}

	.broadsheet-picks > .wp-block-post-template:has(> li:nth-child(3):last-child) > li {
		grid-column: span 4;
	}

	/* 6: two halves, then four quarters. */
	.broadsheet-picks > .wp-block-post-template:has(> li:nth-child(6):last-child) > li {
		grid-column: span 3;
	}

	.broadsheet-picks > .wp-block-post-template:has(> li:nth-child(6):last-child) > li:nth-child(-n + 2) {
		grid-column: span 6;
	}

	/* Equal cards (2, 3, and the two halves of 6) go back to the vertical card with an excerpt. */
	.broadsheet-picks > .wp-block-post-template:is(:has(> li:nth-child(2):last-child), :has(> li:nth-child(3):last-child), :has(> li:nth-child(6):last-child)) > li:first-child > .broadsheet-teaser {
		display: flex;
	}

	.broadsheet-picks > .wp-block-post-template:is(:has(> li:nth-child(2):last-child), :has(> li:nth-child(3):last-child), :has(> li:nth-child(6):last-child)) > li:first-child .wp-block-post-title {
		font-size: var(--wp--preset--font-size--large);
	}

	.broadsheet-picks > .wp-block-post-template:is(:has(> li:nth-child(2):last-child), :has(> li:nth-child(3):last-child)) .wp-block-post-excerpt,
	.broadsheet-picks > .wp-block-post-template:has(> li:nth-child(6):last-child) > li:nth-child(-n + 2) .wp-block-post-excerpt {
		display: block;
		font-size: var(--wp--preset--font-size--small);
	}

	.broadsheet-picks > .wp-block-post-template:is(:has(> li:nth-child(2):last-child), :has(> li:nth-child(3):last-child), :has(> li:nth-child(6):last-child)) > li:first-child .wp-block-post-date {
		margin-top: auto;
	}
}

/* Fallback for the server rule that drops an empty picks section. */
.broadsheet-picks-section:not(:has(.wp-block-post-template > li)) {
	display: none;
}

/*
 * Card row: two to four teasers from one query (a category section, related stories). Add the
 * class broadsheet-card-row to the Query block and give its Post Template the default layout.
 *   narrow < 680px   compact rows: thumbnail, category, title, date
 *   wide  >= 680px   one row of equal columns; four become 2 x 2 until 960px
 */
.broadsheet-card-row {
	container: broadsheet-card-row / inline-size;
}

.broadsheet-card-row > .wp-block-post-template {
	display: grid;
	gap: var(--wp--preset--spacing--50);
	list-style: none;
	padding: 0;
}

.broadsheet-card-row .broadsheet-teaser > * {
	margin: 0;
}

.broadsheet-card-row .wp-block-post-title {
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.35;
	text-wrap: pretty;
}

.broadsheet-card-row .wp-block-post-excerpt {
	display: none;
}

@container broadsheet-card-row (max-width: 679px) {
	.broadsheet-card-row > .wp-block-post-template {
		gap: 0;
	}

	.broadsheet-card-row li {
		padding-block: var(--wp--preset--spacing--40);
	}

	.broadsheet-card-row li:first-child {
		padding-top: 0;
	}

	.broadsheet-card-row li + li {
		border-top: 1px solid var(--wp--preset--color--border);
	}

	.broadsheet-card-row .broadsheet-teaser {
		column-gap: var(--wp--preset--spacing--40);
		display: grid;
		grid-template-columns: 7.5rem minmax(0, 1fr);
		grid-template-rows: auto auto 1fr;
		row-gap: 0.125rem;
	}

	.broadsheet-card-row .wp-block-post-featured-image {
		grid-column: 1;
		grid-row: 1 / span 3;
	}

	.broadsheet-card-row .broadsheet-teaser > :not(.wp-block-post-featured-image) {
		grid-column: 2;
	}

	.broadsheet-card-row .broadsheet-teaser > .wp-block-post-date {
		margin-top: 0;
	}

	.broadsheet-card-row .broadsheet-noimage > * {
		padding: var(--wp--preset--spacing--20);
	}

	.broadsheet-card-row .broadsheet-noimage__label {
		font-size: var(--wp--preset--font-size--x-small);
	}
}

@container broadsheet-card-row (min-width: 680px) {
	.broadsheet-card-row > .wp-block-post-template {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}

	.broadsheet-card-row > .wp-block-post-template:is(:has(> li:only-child), :has(> li:nth-child(2):last-child), :has(> li:nth-child(4):last-child)) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.broadsheet-card-row > .wp-block-post-template:has(> li:only-child) > li {
		grid-column: 1 / -1;
	}
}

@container broadsheet-card-row (min-width: 960px) {
	.broadsheet-card-row > .wp-block-post-template:has(> li:nth-child(4):last-child) {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/*
 * Balanced grid: small fixed sets of text cards (sections, topics). The column count always
 * divides the item count, so 3 items never show as 2 + 1 and 4 never as 3 + 1. Add the class
 * broadsheet-balanced to the element that holds the list.
 */
.broadsheet-balanced {
	container: broadsheet-balanced / inline-size;
}

.broadsheet-balanced > :is(ul, ol) {
	display: grid;
	gap: var(--wp--preset--spacing--40);
	list-style: none;
	margin: 0;
	padding: 0;
}

@container broadsheet-balanced (min-width: 560px) {
	.broadsheet-balanced > :is(ul, ol):is(:has(> li:nth-child(2):last-child), :has(> li:nth-child(4):last-child), :has(> li:nth-child(6):last-child)) {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container broadsheet-balanced (min-width: 720px) {
	.broadsheet-balanced > :is(ul, ol):is(:has(> li:nth-child(3):last-child), :has(> li:nth-child(6):last-child)) {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@container broadsheet-balanced (min-width: 960px) {
	.broadsheet-balanced > :is(ul, ol):has(> li:nth-child(4):last-child) {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

/* Standfirst under the article title. */
.broadsheet-standfirst {
	line-height: 1.5;
}

/* Semantic badges a plugin or editor can use: an alert (for example a recall notice) and a
 * positive state (for example a document still in force). Colours come from the palette. */
.broadsheet-badge {
	border-radius: 999px;
	display: inline-block;
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
	padding: 0.125rem 0.625rem;
}

.broadsheet-badge--alert {
	background: var(--wp--preset--color--alert);
	color: var(--wp--preset--color--base);
}

.broadsheet-badge--positive {
	background: var(--wp--preset--color--positive);
	color: var(--wp--preset--color--base);
}

/* The author card disappears when the post has no author to show (e.g. imported content). */
.broadsheet-author-card:not(:has(.wp-block-post-author-name)) {
	display: none;
}

/* ---------------------------------------------------------------------------------------------
 * Magazine components (patterns/section-*.php, list-*.php, ticker.php, ad-space.php).
 * Spacing uses the spacing presets, radii the custom radius tokens, colours the palette, so
 * every style variation and child theme restyles them.
 * ------------------------------------------------------------------------------------------- */

/* Interface type: labels, meta and controls use the ui family, reading text the body family. */
.broadsheet-ticker,
.broadsheet-ad-label,
.broadsheet-badge,
.broadsheet-ranked .wp-block-post-template > li::before {
	font-family: var(--wp--preset--font-family--ui);
}

/* Stories in a list: thumbnail, then text. Shared by the lead and category sections. */
.broadsheet-story {
	display: grid;
	gap: var(--wp--preset--spacing--30);
}

.broadsheet-story__text {
	display: flex;
	flex-direction: column;
	gap: var(--wp--preset--spacing--20);
}

.broadsheet-story__text > *,
.broadsheet-story > * {
	margin-block: 0;
}

.broadsheet-story .wp-block-post-featured-image {
	margin: 0;
	border-radius: var(--wp--custom--radius--control);
	overflow: hidden;
}

.broadsheet-story .wp-block-post-featured-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.wp-block-post-template {
	margin-block: 0;
}

.wp-block-post-template > li {
	margin-block: 0;
}

/* Rows after the first story: small thumbnail on the left, title and date on the right. */
.broadsheet-section-list .wp-block-post-template > li + li .broadsheet-story,
.broadsheet-lead .wp-block-post-template > li + li .broadsheet-story {
	grid-template-columns: 6rem minmax(0, 1fr);
	align-items: start;
}

.broadsheet-section-list .wp-block-post-template > li + li .wp-block-post-featured-image,
.broadsheet-lead .wp-block-post-template > li + li .wp-block-post-featured-image {
	aspect-ratio: 4 / 3 !important;
}

.broadsheet-section-list .wp-block-post-template > li + li .wp-block-post-excerpt,
.broadsheet-lead .wp-block-post-template > li + li :is(.wp-block-post-excerpt, .wp-block-post-terms) {
	display: none;
}

.broadsheet-section-list .wp-block-post-template > li + li .wp-block-post-title,
.broadsheet-lead .wp-block-post-template > li + li .wp-block-post-title {
	font-size: var(--wp--preset--font-size--medium);
	line-height: 1.3;
	text-wrap: pretty;
}

.broadsheet-section-list .wp-block-post-template > li + li {
	margin-top: var(--wp--preset--spacing--40);
	padding-top: var(--wp--preset--spacing--40);
	border-top: 1px solid var(--wp--preset--color--border);
}

.broadsheet-section-list .wp-block-post-template > li:first-child .wp-block-post-title {
	font-size: var(--wp--preset--font-size--large);
	text-wrap: balance;
}

/* Lead section: the first story large on the left, the next three stacked beside it in three
 * equal rows that together match the lead story's height. */
@media (min-width: 782px) {
	.broadsheet-lead .wp-block-post-template {
		display: grid;
		grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
		grid-template-rows: repeat(3, minmax(0, 1fr));
		column-gap: var(--wp--preset--spacing--60);
	}

	.broadsheet-lead .wp-block-post-template > li:first-child {
		grid-row: 1 / 4;
	}

	.broadsheet-lead .wp-block-post-template > li + li {
		display: flex;
		align-items: center;
		border-top: 1px solid var(--wp--preset--color--border);
	}

	.broadsheet-lead .wp-block-post-template > li:nth-child(2) {
		align-items: flex-start;
		border-top: 0;
	}

	.broadsheet-lead .wp-block-post-template > li:last-child {
		align-items: flex-end;
	}

	.broadsheet-lead .wp-block-post-template > li + li > .broadsheet-story {
		width: 100%;
		grid-template-columns: 8.5rem minmax(0, 1fr);
	}

	.broadsheet-lead .wp-block-post-template > li + li :is(.wp-block-post-terms) {
		display: block;
	}
}

@media (max-width: 781px) {
	.broadsheet-lead .wp-block-post-template > li + li {
		margin-top: var(--wp--preset--spacing--40);
		padding-top: var(--wp--preset--spacing--40);
		border-top: 1px solid var(--wp--preset--color--border);
	}

	.broadsheet-lead .wp-block-post-template > li:first-child {
		margin-bottom: var(--wp--preset--spacing--30);
	}
}

.broadsheet-lead .wp-block-post-template > li:first-child .wp-block-post-title {
	font-size: var(--wp--preset--font-size--xx-large);
	line-height: 1.1;
	text-wrap: balance;
}

.broadsheet-lead .wp-block-post-template > li:first-child .wp-block-post-excerpt {
	font-size: var(--wp--preset--font-size--medium);
	color: var(--wp--preset--color--contrast);
}

/* Category sections side by side on the magazine front page. */
.broadsheet-section-grid {
	gap: var(--wp--preset--spacing--60);
	align-items: start;
}

@media (max-width: 781px) {
	.broadsheet-section-grid {
		grid-template-columns: minmax(0, 1fr) !important;
	}
}

/* Ranked list: number, title, thumbnail on the right so the number is read first. */
.broadsheet-ranked .wp-block-post-template {
	counter-reset: broadsheet-rank;
}

.broadsheet-ranked .wp-block-post-template > li {
	counter-increment: broadsheet-rank;
	display: grid;
	grid-template-columns: 1.75rem minmax(0, 1fr);
	column-gap: var(--wp--preset--spacing--30);
	padding-block: var(--wp--preset--spacing--40);
	border-top: 1px solid var(--wp--preset--color--border);
}

.broadsheet-ranked .wp-block-post-template > li:first-child {
	padding-top: 0;
	border-top: 0;
}

.broadsheet-ranked .wp-block-post-template > li::before {
	content: counter(broadsheet-rank);
	font-size: var(--wp--preset--font-size--large);
	font-weight: 700;
	line-height: 1.2;
	color: var(--wp--preset--color--accent);
	font-variant-numeric: tabular-nums;
}

.broadsheet-rank-row {
	display: grid;
	grid-template-columns: minmax(0, 1fr) 4.5rem;
	column-gap: var(--wp--preset--spacing--30);
	align-items: start;
}

.broadsheet-rank-row > * {
	margin-block: 0;
}

.broadsheet-rank-row .wp-block-post-title {
	font-size: var(--wp--preset--font-size--small);
	line-height: 1.35;
	text-wrap: pretty;
}

.broadsheet-rank-row .wp-block-post-featured-image {
	margin: 0;
	border-radius: var(--wp--custom--radius--control);
	overflow: hidden;
}

.broadsheet-rank-row .wp-block-post-featured-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* A story without a featured image keeps a text-only row. */
.broadsheet-rank-row:not(:has(.wp-block-post-featured-image)) {
	grid-template-columns: minmax(0, 1fr);
}

/* Headline strip. */
.broadsheet-ticker {
	border-bottom: 1px solid var(--wp--preset--color--border);
	padding-block: var(--wp--preset--spacing--30);
	font-size: var(--wp--preset--font-size--x-small);
}

.broadsheet-ticker > .wp-block-group {
	align-items: center;
	gap: var(--wp--preset--spacing--40);
}

.broadsheet-ticker__label {
	display: inline-flex;
	align-items: center;
	gap: var(--wp--preset--spacing--20);
	margin: 0;
	padding: 0.2rem 0.6rem;
	border-radius: 2px;
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
	font-weight: 600;
	white-space: nowrap;
}

/* The pulse is the theme's only animation. */
.broadsheet-ticker__label::before {
	content: "";
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 50%;
	background: var(--wp--preset--color--accent);
	box-shadow: 0 0 0 0 var(--wp--preset--color--accent);
	animation: broadsheet-pulse 1.8s ease-out infinite;
}

@keyframes broadsheet-pulse {
	70% { box-shadow: 0 0 0 0.45rem transparent; }
	100% { box-shadow: 0 0 0 0 transparent; }
}

@media (prefers-reduced-motion: reduce) {
	.broadsheet-ticker__label::before {
		animation: none;
	}
}

.broadsheet-ticker__items {
	min-width: 0;
	flex: 1;
	-webkit-mask-image: linear-gradient(90deg, #000 85%, transparent);
	mask-image: linear-gradient(90deg, #000 85%, transparent);
}

.broadsheet-ticker__items .wp-block-post-template {
	gap: var(--wp--preset--spacing--50);
	overflow-x: auto;
	scrollbar-width: none;
}

.broadsheet-ticker__items .wp-block-post-template > li {
	flex: 0 0 auto;
}

.broadsheet-ticker__items .wp-block-post-title {
	margin: 0;
	white-space: nowrap;
	font-family: var(--wp--preset--font-family--ui);
	font-size: var(--wp--preset--font-size--x-small);
	font-weight: 600;
}

/* Ad space: the height is reserved before the ad arrives. */
:is(.is-style-broadsheet-ad-leaderboard, .is-style-broadsheet-ad-rectangle, .is-style-broadsheet-ad-inline) {
	display: flex;
	align-items: center;
	justify-content: center;
	border: 1px dashed var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--control);
	contain: layout;
	overflow: hidden;
}

.is-style-broadsheet-ad-leaderboard {
	min-height: 90px;
	max-width: 970px;
	margin-inline: auto;
}

.is-style-broadsheet-ad-rectangle {
	min-height: 250px;
}

.is-style-broadsheet-ad-inline {
	min-height: 280px;
}

@media (max-width: 781px) {
	.is-style-broadsheet-ad-leaderboard {
		min-height: 100px;
	}

	.is-style-broadsheet-ad-inline {
		min-height: 250px;
	}
}

.broadsheet-ad-label {
	margin: 0;
	font-size: var(--wp--preset--font-size--x-small);
	color: var(--wp--preset--color--muted);
}

/* Story badges (Breaking, Live, Trending). Fixed size, inline before the headline. */
.broadsheet-badge--breaking,
.broadsheet-badge--live {
	background: var(--wp--preset--color--alert);
	color: var(--wp--preset--color--base);
}

.broadsheet-badge--trending {
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
}

.wp-block-post-title .broadsheet-badge {
	border-radius: 2px;
	font-size: 0.6875rem;
	line-height: 1.4;
	padding: 0.05rem 0.4rem;
	/* The markup has a real space after the badge, so it is not read together with the
	   headline; that space already separates them. */
	margin-right: 0.15em;
	vertical-align: 0.2em;
}

/* Core gives the title link inline-block, which pushes it under the badge. */
.wp-block-post-title > a {
	display: inline;
}

/* Reading progress (assets/js/reading-progress.js). */
.broadsheet-progress {
	position: fixed;
	inset: 0 0 auto 0;
	height: 3px;
	z-index: 100;
	pointer-events: none;
}

.admin-bar .broadsheet-progress {
	top: var(--wp-admin--admin-bar--height, 32px);
}

@media (max-width: 600px) {
	/* The admin bar scrolls away on small screens, so progress bar sits at the top edge. */
	.admin-bar .broadsheet-progress {
		top: 0;
	}
}

.broadsheet-progress > span {
	display: block;
	height: 100%;
	background: var(--wp--preset--color--accent);
	transform: scaleX(0);
	transform-origin: left;
	will-change: transform;
}

/* Teaser grids: dates sit on the bottom edge so a row of cards lines up. */
.wp-block-post-template.is-layout-grid > li {
	display: flex;
	flex-direction: column;
}

.wp-block-post-template.is-layout-grid > li > .broadsheet-teaser {
	flex: 1;
}

.broadsheet-teaser > .wp-block-post-date {
	margin-top: auto;
}

/* ---------------------------------------------------------------------------------------------
 * Navigation aids.
 * ------------------------------------------------------------------------------------------- */

/* Pagination: 44px boxes with a gap, so neighbouring page numbers are not mis-tapped. */
.wp-block-query-pagination {
	gap: var(--wp--preset--spacing--20);
}

.wp-block-query-pagination-numbers {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--20);
}

.wp-block-query-pagination :is(.page-numbers, .wp-block-query-pagination-previous, .wp-block-query-pagination-next) {
	align-items: center;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--control);
	display: inline-flex;
	justify-content: center;
	margin: 0;
	min-height: 44px;
	min-width: 44px;
	padding: 0 var(--wp--preset--spacing--30);
	text-decoration: none;
}

.wp-block-query-pagination .page-numbers.current {
	background: var(--wp--preset--color--primary);
	border-color: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
}

.wp-block-query-pagination .page-numbers.dots {
	border-color: transparent;
}

/* Breadcrumbs: 24px links, 44px on touch screens. */
.wp-block-breadcrumbs a {
	align-items: center;
	display: inline-flex;
	min-height: 24px;
}

@media (pointer: coarse) {
	.wp-block-breadcrumbs a {
		min-height: 44px;
	}
}

/* Phones: the last crumb repeats the page title printed right below it, so it is dropped and the
 * trail fits one line. The BreadcrumbList data of any SEO plugin is not affected. */
@media (max-width: 599px) {
	.wp-block-breadcrumbs li:last-child:not(:first-child) {
		display: none;
	}
}

/* Browse links on the 404 and no-results pages (patterns/browse.php): 44px chips. */
.broadsheet-browse :is(.wp-block-categories, .wp-block-tag-cloud) {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wp--preset--spacing--20);
	list-style: none;
	margin: 0;
	padding: 0;
}

.broadsheet-browse .wp-block-categories a,
.broadsheet-browse .wp-block-tag-cloud a {
	align-items: center;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 999px;
	display: inline-flex;
	font-family: var(--wp--preset--font-family--ui);
	font-size: var(--wp--preset--font-size--small) !important; /* the tag cloud prints an inline size per tag */
	margin: 0;
	min-height: 44px;
	padding: 0 var(--wp--preset--spacing--40);
	text-decoration: none;
}

/* The search template already has a search field above the results; the no-results message must
 * not print a second one. Other templates keep it. */
.search .broadsheet-no-results .wp-block-search {
	display: none;
}

/* Short pages (404, an empty search): the footer sits on the bottom edge, not above a blank band. */
.wp-site-blocks {
	display: flex;
	flex-direction: column;
	min-height: calc(100svh - var(--wp-admin--admin-bar--height, 0px));
}

.wp-site-blocks > footer.wp-block-template-part {
	margin-top: auto;
}
