/*
 * Article page (single.html): a frame as wide as the text column plus a
 * side column. Order of the markup = reading order on phones:
 *   In breve → text → issue and sponsors (moved from the end of the text,
 *   see functions.php) → FAQ → tags, author, previous/next.
 * From 1024px a grid puts "In breve" and the issue/sponsors box in the
 * side column, next to the text. CSS only, no script.
 */

/* Frame: text column + gap + side column, centered in the page. */
main .local-news-article.alignwide {
	--local-news-side: 20rem;
	--local-news-gap: clamp(2rem, 4vw, 4rem);
	max-width: calc(var(--wp--style--global--content-size) + var(--local-news-gap) + var(--local-news-side));
}

/* Without a side column (no "In breve", nothing moved): the usual single column. */
main .local-news-article.alignwide:not(:has(.wp-block-brief-faq-brief, .local-news-extras)) {
	max-width: var(--wp--style--global--content-size);
}

.local-news-post-header,
.local-news-article > .wp-block-post-featured-image {
	max-width: var(--wp--style--global--content-size);
}

.local-news-article-body {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	row-gap: var(--wp--preset--spacing--60);
}

/*
 * Not stretched to the row: a stretched item has a definite height, and
 * percentage heights inside the text (some images) would grow to it.
 */
.local-news-article-body > * {
	align-self: start;
	margin-block: 0;
}

/* The text keeps its own column: no extra padding or full-bleed blocks. */
.local-news-article-body > .wp-block-post-content {
	padding-inline: 0;
}

.local-news-article-body > .wp-block-post-content > .alignfull {
	margin-inline: 0;
}

/* --- Issue and sponsors box ------------------------------------------- */
.local-news-extras {
	display: grid;
	gap: var(--wp--preset--spacing--30);
}

.local-news-extras > * {
	margin: 0;
}

/* "Leggi tutti gli articoli" and "Scarica la tua copia": full width, stacked. */
.local-news-extras .wp-block-buttons {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	margin: 0;
}

.local-news-extras .wp-block-button,
.local-news-extras .wp-block-button__link {
	inline-size: 100%;
}

.local-news-extras .wp-block-button__link {
	box-sizing: border-box;
	text-align: center;
}

/* "oppure" between the two buttons. */
.local-news-extras > p.has-text-align-center:not(:has(img)) {
	color: var(--wp--preset--color--muted);
	font-size: var(--wp--preset--font-size--xs);
	letter-spacing: 0.06em;
	text-transform: uppercase;
}

/* "Questo numero è offerto da:" as a section label, then the logos in a grid. */
.local-news-extras > p.has-text-align-center:has(+ .wp-block-columns) {
	margin-block-start: var(--wp--preset--spacing--40);
	padding-block-start: var(--wp--preset--spacing--30);
	border-block-start: 1px solid var(--wp--preset--color--border);
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--xs);
	font-weight: 800;
	letter-spacing: 0.08em;
	text-align: start;
	text-transform: uppercase;
}

.local-news-extras .wp-block-columns {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
	gap: var(--wp--preset--spacing--40);
	align-items: center;
	margin: 0;
}

.local-news-extras .wp-block-column {
	display: grid;
	gap: var(--wp--preset--spacing--30);
	align-content: center;
	justify-items: center;
	min-inline-size: 0;
}

.local-news-extras .wp-block-column > * {
	margin: 0;
}

.local-news-extras .wp-block-image,
.local-news-extras .wp-block-image img {
	max-inline-size: 100%;
	block-size: auto;
}

.local-news-extras p:empty {
	display: none;
}

/* --- Two columns from 1024px ------------------------------------------ */
@media (min-width: 1024px) {

	.local-news-article-body:has(> .wp-block-brief-faq-brief, > .local-news-extras) {
		grid-template-columns: minmax(0, var(--wp--style--global--content-size)) var(--local-news-side);
		grid-template-rows: auto 1fr;
		justify-content: space-between;
		column-gap: var(--local-news-gap);
	}

	.local-news-article-body:has(> .wp-block-brief-faq-brief, > .local-news-extras) > * {
		grid-column: 1;
	}

	.local-news-article-body:has(> .wp-block-brief-faq-brief, > .local-news-extras) > .wp-block-post-content {
		grid-row: 1 / span 2;
	}

	.local-news-article-body:has(> .wp-block-brief-faq-brief, > .local-news-extras) > .wp-block-brief-faq-brief {
		grid-column: 2;
		grid-row: 1;
	}

	.local-news-article-body:has(> .wp-block-brief-faq-brief, > .local-news-extras) > .local-news-extras {
		position: sticky;
		inset-block-start: calc(var(--wp-admin--admin-bar--height, 0px) + 6rem);
		grid-column: 2;
		grid-row: 2;
		align-self: start;
	}

	/* The column is narrow: the "In breve" text a little smaller. */
	.local-news-article-body > .wp-block-brief-faq-brief {
		padding-inline: var(--wp--preset--spacing--40);
	}

	body .local-news-article-body > .wp-block-brief-faq-brief .wp-block-brief-faq-brief__summary {
		font-size: var(--wp--preset--font-size--md);
	}

	body .local-news-article-body > .wp-block-brief-faq-brief .wp-block-brief-faq-brief__points li {
		font-size: var(--wp--preset--font-size--sm);
	}

	/* Without "In breve" the box opens the column, from the top. */
	.local-news-article-body:not(:has(> .wp-block-brief-faq-brief)) > .local-news-extras {
		grid-row: 1 / span 2;
	}
}
