/* News (news.html): a wall of clippings. Linked only by these pages (i18n-util.mjs renderNgHeadAssets).
   The feed is generated by tg-news.mjs between the TG:FEED markers (article.tgPost: time.tgPostDate,
   h2.tgPostTitle, optional img.tgPostPhoto, optional div.tgPostText, a.tgPostLink); every clipping has the
   same markup, so the variety comes from :first-child / :nth-child here. #tgFeed is display: contents, so the
   page head, the clippings and the follow strip share one wall grid. Accent roles on this page: the dates. */

/* ─── Wall ───────────────────────────────────────────────────────────────── */

/* five unequal tracks (3 1 3 2 3): head slip 4, lead 12, older clippings in pairs 7 + 5, 4 + 8 */
main.ng-page {
	display: grid;
	grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 3fr) minmax(0, 2fr) minmax(0, 3fr);
	gap: var(--s7) var(--s6);
	align-items: start;
	width: min(1240px, calc(100% - 2 * var(--s5)));
	padding: var(--s4) 0 0;
	background: none;
	box-shadow: none;
}

main.ng-page::before,
main.ng-page::after {
	content: none;
}

.ng-feed {
	display: contents;
}

/* Tape strips drawn on the sheets themselves (the generated markup has no tape spans):
   one strip top middle on a small sheet, two far apart on the lead. */
.ng-pagehead::before,
.tgPost::before,
.tgPost:first-child::after {
	content: "";
	position: absolute;
	z-index: 6;
	top: -14px;
	left: calc(50% - var(--w, 92px) / 2);
	width: var(--w, 92px);
	height: 28px;
	background: var(--tape);
	box-shadow: inset 0 7px 0 var(--tape), inset 0 10px 0 color-mix(in srgb, var(--tape-hi) 55%, var(--tape));
	clip-path: polygon(0 5%, 100% 0, 98% 100%, 2% 95%);
	transform: rotate(var(--r, -3deg));
	pointer-events: none;
}

/* ─── Page head: the h1 on a small slip ──────────────────────────────────── */

.ng-pagehead {
	grid-column: 1 / 3;
	grid-row: 1;
	justify-self: start;
	position: relative;
	margin-top: var(--s5);
	padding: var(--s6) var(--s6) var(--s3) var(--s5);
	background-color: var(--panel);
	background-image: var(--grain);
	box-shadow: 5px 7px 1px var(--shadow);
	transform: rotate(-1.4deg);
}

.ng-pagehead::before {
	--w: 70px;
	--r: -4deg;
}

.ng-pagehead h1 {
	margin: 0;
	font: 300 var(--t6)/1 var(--f-disp);
	overflow-wrap: anywhere;
}

.ng-pagehead p {
	margin: var(--s2) 0 0;
}

#newsRoadmap a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	font: 400 var(--t1)/1.3 var(--f-read);
	text-decoration: underline;
	text-underline-offset: 4px;
}

#newsRoadmap a:hover,
#newsRoadmap a:focus-visible {
	text-decoration-thickness: 2px;
}

/* ─── Clippings ──────────────────────────────────────────────────────────── */

.tgPost {
	position: relative;
	container-type: inline-size;
	padding: var(--s6) var(--s5) var(--s4);
	background-color: var(--panel);
	background-image: var(--grain);
	box-shadow: 5px 7px 1px var(--shadow);
	transform: rotate(var(--tilt, 0deg));
}

/* the date: console face, tabular figures, the accent's role on this page */
.tgPostDate {
	display: block;
	margin: 0 0 var(--s3);
	color: var(--accent); /* gate-allow: accent-spread the date is a written accent role (visual-voice: stamp · date); news dates only */
	font: 400 var(--t1)/1.5 var(--f-con);
	font-variant-numeric: tabular-nums;
	-webkit-font-smoothing: none;
}

.tgPostTitle {
	margin: 0;
	font: 500 var(--t3)/1.2 var(--f-disp);
	overflow-wrap: anywhere;
}

.tgPostText {
	margin: var(--s3) 0 0;
	font: 400 var(--t1)/1.6 var(--f-read);
	overflow-wrap: anywhere;
}

.tgPostText a {
	text-underline-offset: 3px;
}

.tgPostLink {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	margin-top: var(--s2);
	font: 400 var(--t1)/1.3 var(--f-read);
	text-decoration: underline;
	text-underline-offset: 4px;
}

.tgPostLink:hover,
.tgPostLink:focus-visible,
.tgPostText a:hover,
.tgPostText a:focus-visible {
	text-decoration-thickness: 2px;
}

/* a photo is a print pasted onto the clipping: matte of the second paper, a slight tilt */
.tgPost .tgPostPhoto {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 16 / 10;
	object-fit: cover;
	margin: var(--s4) 0 var(--s2);
	padding: var(--s2);
	background: var(--panel-2);
	box-shadow: 3px 4px 0 var(--shadow);
	transform: rotate(var(--ptilt, 1.2deg));
}

/* a wide clipping takes its print to the right of the text */
@container (min-width: 520px) {
	.tgPost:not(:first-child) .tgPostPhoto {
		float: right;
		width: 46%;
		margin: 0 0 var(--s4) var(--s5);
	}

	.tgPost:not(:first-child) .tgPostLink {
		clear: none;
	}
}

/* ─── Lead clipping: the newest post ─────────────────────────────────────── */

/* the wall reads like a page: the head, then the newest clipping across the row, then the older ones two to a
   row, left before right, a row never starting above the one before (DOM order = newest first) */
.tgPost:first-child {
	grid-column: 1 / -1;
	padding: var(--s7) var(--s6) var(--s6);
	--tilt: -.4deg;
}

.tgPost:first-child::before {
	left: 9%;
	--w: 104px;
	--r: -5deg;
}

.tgPost:first-child::after {
	left: auto;
	right: 9%;
	--w: 92px;
	--r: 3deg;
}

.tgPost:first-child .tgPostDate {
	margin-bottom: var(--s4);
	font-size: var(--t3);
}

.tgPost:first-child .tgPostTitle {
	font: 300 var(--t5)/1.08 var(--f-disp);
}

.tgPost:first-child .tgPostText {
	font-size: var(--t2);
}

/* with a photo: the big print on the left, the date, headline, text and link in the column beside it */
.tgPost:first-child:has(.tgPostPhoto) {
	display: grid;
	grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
	grid-template-rows: auto auto auto 1fr;
	column-gap: var(--s6);
}

.tgPost:first-child:has(.tgPostPhoto) > * {
	grid-column: 2;
	justify-self: start;
}

.tgPost:first-child:has(.tgPostPhoto) > .tgPostDate {
	grid-row: 1;
}

.tgPost:first-child:has(.tgPostPhoto) > .tgPostTitle {
	grid-row: 2;
}

.tgPost:first-child:has(.tgPostPhoto) > .tgPostPhoto {
	grid-column: 1;
	grid-row: 1 / span 4;
	justify-self: stretch;
	margin: 0 0 0 var(--s2);
	padding: var(--s3);
	--ptilt: 1.4deg;
}

.tgPost:first-child:has(.tgPostPhoto) > .tgPostText {
	grid-row: 3;
	margin-top: var(--s5);
}

.tgPost:first-child:has(.tgPostPhoto) > .tgPostLink {
	grid-row: 4;
	align-self: end;
}

/* ─── Older clippings: two to a row, each its own width, tilt and tape; the right one hangs a little lower ── */

.tgPost:nth-child(2) {
	grid-column: 1 / 4;
	--tilt: .9deg;
	--ptilt: -1.4deg;
}

.tgPost:nth-child(2)::before {
	--w: 70px;
	--r: 4deg;
}

.tgPost:nth-child(3) {
	grid-column: 4 / -1;
	margin-top: var(--s5);
	--tilt: -.6deg;
}

.tgPost:nth-child(3)::before {
	left: 14%;
	--w: 100px;
	--r: -6deg;
}

.tgPost:nth-child(4) {
	grid-column: 1 / 3;
	--tilt: 1.1deg;
	--ptilt: -1deg;
}

.tgPost:nth-child(4)::before {
	--r: 2deg;
}

.tgPost:nth-child(5) {
	grid-column: 3 / -1;
	margin-top: var(--s5);
	--tilt: -1deg;
}

.tgPost:nth-child(5)::before {
	left: auto;
	right: 18%;
	--w: 84px;
	--r: -2deg;
}

/* more than five posts: a left and a right clipping per row */
.tgPost:nth-child(n+6):nth-child(even) {
	grid-column: 1 / 4;
	--tilt: .6deg;
}

.tgPost:nth-child(n+6):nth-child(odd) {
	grid-column: 4 / -1;
	margin-top: var(--s5);
	--tilt: -.7deg;
}

/* ─── Follow strip: a console line, not paper ────────────────────────────── */

.ng-follow {
	grid-column: 2 / 5;
	align-self: end;
	margin: 0;
	padding: var(--s4) var(--s4) var(--s3);
	background: var(--con-bg);
	color: var(--con-ink);
	border: 6px double var(--con-ink);
	font: 400 var(--t1)/1.75 var(--f-con);
	-webkit-font-smoothing: none;
}

/* the five channels: a list on the console line, gaps instead of separators */
.ng-follow-l {
	display: inline-flex;
	flex-wrap: wrap;
	gap: 0 var(--s2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.ng-follow a {
	display: inline-flex;
	align-items: center;
	min-height: 44px;
	padding: 0 var(--s2);
	color: var(--con-ink);
	text-decoration: underline;
	text-decoration-color: var(--con-dim);
	text-underline-offset: 4px;
}

.ng-follow a:hover,
.ng-follow a:focus-visible {
	background: var(--con-inv-bg);
	color: var(--con-inv-ink);
	text-decoration: none;
	outline-offset: -3px;
}

/* ─── Narrower desks: the lead takes the full row ────────────────────────── */

@media (max-width: 1080px) {
	main.ng-page {
		gap: var(--s7) var(--s5);
	}

	.ng-pagehead {
		grid-column: 1 / -1;
	}

	.tgPost:nth-child(4) {
		grid-column: 1 / 4;
	}

	.tgPost:nth-child(5) {
		grid-column: 4 / -1;
	}

	.ng-follow {
		grid-column: 2 / -1;
	}
}

/* ─── Phone: one column of clippings, recomposed ─────────────────────────── */

@media (max-width: 760px) {
	main.ng-page {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--s7);
		width: auto;
		margin: var(--s6) var(--s4) 0;
		overflow-x: clip;
	}

	.ng-pagehead,
	.tgPost:nth-child(n),
	.ng-follow {
		grid-column: 1;
		grid-row: auto;
		margin: 0;
	}

	.ng-pagehead {
		padding: var(--s6) var(--s5) var(--s2) var(--s4);
	}

	.tgPost:first-child,
	.tgPost:first-child:has(.tgPostPhoto) {
		display: block;
		padding: var(--s7) var(--s4) var(--s4);
	}

	.tgPost:first-child:has(.tgPostPhoto) > .tgPostPhoto {
		margin: var(--s4) 0 var(--s2);
		padding: var(--s2);
	}

	.tgPost:first-child:has(.tgPostPhoto) > .tgPostText {
		margin-top: var(--s3);
	}

	.tgPost:nth-child(n+2) {
		padding: var(--s6) var(--s4) var(--s3);
	}

	/* the older clippings step left and right of the column, tilts kept small */
	.tgPost:nth-child(even):not(:first-child) {
		margin-right: var(--s5);
		--tilt: .7deg;
	}

	.tgPost:nth-child(odd):not(:first-child) {
		margin-left: var(--s5);
		--tilt: -.6deg;
	}

	.tgPost:first-child .tgPostDate {
		font-size: var(--t1);
	}

	.tgPostTitle {
		font-size: var(--t2);
	}

	.ng-follow {
		padding: var(--s3);
	}
}
