/* Games catalogue (ourgames.html). Linked only by these pages (i18n-util.mjs renderNgHeadAssets).
   A wall of sheets: the newest release on one wide sheet with its cover pasted at native size,
   Collapse on a tall sheet, the older games as clippings of the second paper, each of its own
   size, crop and tilt; every game's DLC in a console box with a tree pane (real dlc-*.html links).
   The DOM keeps the generator shapes (article.ng-game, a.ng-game-name, p.ng-game-line,
   div.ng-game-shot, ul.ng-shelf li) and the heading order; the grid places the sheets. */

/* ─── Board ──────────────────────────────────────────────────────────────── */

main.ng-page {
	width: min(1320px, calc(100% - 2 * var(--s5)));
	margin-top: var(--s7);
	padding: 0;
	background: none;
	box-shadow: none;
}

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

/* the page's own headline: a slip pasted over the lead sheet's top-left edge */
.ng-pagehead {
	z-index: 7;
	display: inline-block;
	margin: 0 0 calc(-1 * var(--s6)) 5%;
	padding: var(--s5) var(--s6) var(--s4);
	transform: rotate(-1.6deg);
}

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

.ng-catalogue {
	display: grid;
	/* unequal tracks (1 5 1 1 4 1): the sheets start and end on different lines */
	grid-template-columns: minmax(0, 1fr) minmax(0, 5fr) minmax(0, 1fr) minmax(0, 1fr) minmax(0, 4fr) minmax(0, 1fr);
	gap: var(--s7) var(--s6);
	align-items: start;
}

/* the older games' wrapper lets its slip and clippings sit on the board's own grid */
.ng-older-games {
	display: contents;
}

.ng-game {
	position: relative;
	margin: 0;
	transform: rotate(var(--tilt, 0deg));
}

/* A game's sheet shrinks with its age (release dates in the game pages' Steam facts):
   The Cold War 2025 (lead) > Collapse 2021 > Mao 2019 > Ostalgie 2018 > Crisis 2017.
   Two columns of sheets after the lead: Collapse, then Ostalgie on the left; the slip, Mao, then
   Crisis on the right. Each sheet spans two rows, so the next one starts where its neighbour ends. */
.ng-cat-1922740 { grid-column: 1 / -1; grid-row: 1; --tilt: -.25deg; }
.ng-cat-990260  { grid-column: 1 / 4; grid-row: 2 / span 2; margin-top: var(--s5); --tilt: -.7deg; }
.ng-older-slip  { grid-column: 4 / 7; grid-row: 2; align-self: end; justify-self: start; margin-left: var(--s7); }
.ng-cat-950740  { grid-column: 4 / 7; grid-row: 3; margin-left: var(--s7); --tilt: .8deg; }
.ng-cat-774091  { grid-column: 2 / 4; grid-row: 4; margin-right: var(--s7); --tilt: -1.3deg; }
.ng-cat-599750  { grid-column: 5 / 7; grid-row: 4; margin-left: var(--s5); --tilt: .45deg; }

/* ─── Shared parts of a game sheet ───────────────────────────────────────── */

/* the cover: a print pasted on the sheet, framed by the second paper */
.ng-game-shot {
	margin: 0 0 var(--s5);
	padding: var(--s2);
	background-color: var(--panel-2);
	box-shadow: 3px 4px 0 var(--shadow);
	transform: rotate(var(--print, .6deg));
}

.ng-game-older .ng-game-shot {
	background-color: var(--panel);
}

.ng-game-shot img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 600 / 338;
	object-fit: cover;
}

.ng-game-copy > * {
	margin: 0;
}

.ng-game-title {
	margin: 0;
	font: 300 var(--t4)/1.1 var(--f-disp);
	overflow-wrap: anywhere;
}

/* inline padding widens the hit area to 44 px without moving the line */
.ng-game-name {
	padding: var(--s2) 0;
	text-decoration: none;
}

.ng-game-name:hover,
.ng-game-name:focus-visible {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 5px;
}

.ng-game-copy .ng-game-line {
	margin-top: var(--s3);
	font-size: var(--t2);
	line-height: 1.5;
}

.ng-meta {
	margin-top: var(--s3);
	font-size: var(--t1);
	font-variant-numeric: tabular-nums;
}

.ng-rev-l {
	display: block;
	color: var(--dim);
}

.ng-cta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--s3) var(--s5);
	margin-top: var(--s5);
}

.ng-about-l {
	font-size: var(--t2);
}

/* ─── DLC: a console box with a tree pane, each branch with the DLC's cover ─ */

.ng-game-dlc {
	margin-top: var(--s6);
}

.ng-game-dlc .ng-dlc-h {
	font-weight: 400;
}

.ng-shelf.ng-tree li {
	display: flex;
	align-items: center;
	gap: var(--s3);
	padding: var(--s2) 0 var(--s2) var(--s6);
}

/* the branch elbow meets each row at its middle; the trunk runs on to the next row */
.ng-shelf.ng-tree li::before {
	height: 50%;
}

.ng-shelf.ng-tree li:not(:last-child)::after {
	top: 50%;
	bottom: -50%;
}

.ng-shelf img {
	flex: none;
	display: block;
	width: 96px;
	height: auto;
	aspect-ratio: 460 / 215;
	object-fit: cover;
}

.ng-shelf .ng-dlc-name {
	flex: 1 1 0;
	min-width: 0;
	overflow-wrap: anywhere;
}

/* one DLC: its cover gets room */
.ng-shelf li:only-child img {
	width: 168px;
}

/* «Показать все»: shown only where a sheet lists its first few DLC at rest (the phone block; on a wider screen
   Mao, below). The «Оборот» manner in console colours: a dashed key, solid on hover / focus and while open;
   its own background covers the tree trunk running down to it */
.ng-dlc-more {
	display: none;
	position: relative;
	align-items: center;
	min-height: 44px;
	margin-top: var(--s2);
	padding: 0 var(--s2);
	border: 2px dashed var(--con-dim);
	background: var(--con-bg);
	color: var(--con-dim);
	font: 400 var(--t1)/1.5 var(--f-con);
	text-align: left;
	cursor: pointer;
}

.ng-dlc-more:hover,
.ng-dlc-more:focus-visible,
.ng-dlc-more[aria-expanded="true"] {
	border-style: solid;
	border-color: var(--con-ink);
	color: var(--con-ink);
}

/* the count (script.js) runs on in the label's own text, so the label wraps as one line of words */
.ng-dlc-n {
	display: contents;
}

/* Chinese: the CJK fallback sits low in the pixel face's line (ng.css .ng-kl); a bottom pad lifts the label */
.ng-dlc-more:lang(zh) {
	padding-bottom: .3125em;
}

/* Wider than a tablet, Mao's seven DLC would make its sheet taller than Collapse's in most locales: it lists four
   at rest, the key opens the rest in flow (no JS or no :has(): all listed, key hidden); up to 1100 px, the cut below */
@media (min-width: 1101px) {
	@supports selector(:has(a)) {
		.js .ng-cat-950740 .ng-shelf:not(.is-open) > li:nth-child(n+5) {
			display: none;
		}

		.js .ng-cat-950740 .ng-shelf:has(> li:nth-child(5)) + .ng-dlc-more {
			display: inline-flex;
		}
	}
}

/* The board's side margin is 24 px until the page's 1200 px cap lets it grow (about 1248 px); the right-hand
   sheets' top-right strip (43-44 deg, 28 px beyond the sheet) then ends 10 px past the window edge: 1101-1279 px
   pulls it in 12 px so it still straddles the corner and the page does not scroll sideways. */
@media (min-width: 1101px) and (max-width: 1279px) {
	.ng-cat-950740 .ng-tape.tr,
	.ng-cat-599750 .ng-tape.tr {
		right: -16px;
	}
}

/* ─── The lead: the newest release on one wide sheet ─────────────────────── */

.ng-game-lead {
	display: grid;
	grid-template-columns: minmax(0, 660px) minmax(0, 1fr);
	grid-template-areas:
		"shot copy"
		"dlc dlc";
	gap: 0 var(--s7);
	align-items: start;
	padding: var(--s8) var(--s7) var(--s7) var(--s6);
}

/* the cover print is a 4:3 landscape at its own height (it used to stretch to the copy column's height, which
   made it a near-square at desktop and a tall strip at tablet); the copy sits beside it, centred on it, and the
   DLC box runs under both */
.ng-game-lead .ng-game-shot img {
	aspect-ratio: 4 / 3;
	object-position: 40% 50%;
}

/* the left strip clears the headline slip, so both strips show */
.ng-game-lead .ng-tape.tm.ng-tape-l {
	left: 38%;
}

.ng-game-lead .ng-game-shot {
	grid-area: shot;
	margin: 0 0 0 calc(-1 * var(--s7));
	--print: -.8deg;
}

.ng-game-lead .ng-game-copy {
	grid-area: copy;
	align-self: center;
}

.ng-game-lead .ng-game-dlc {
	grid-area: dlc;
}

.ng-game-lead .ng-shelf li:only-child img {
	width: 128px;
}

.ng-tag {
	margin: 0 0 var(--s5);
}

.ng-game-lead .ng-game-title {
	font-size: var(--t6);
	line-height: 1.02;
}

.ng-game-lead .ng-game-line {
	margin-top: var(--s5);
	font: 300 var(--t3)/1.3 var(--f-disp);
}

.ng-game-lead .ng-meta {
	margin-top: var(--s5);
}

.ng-game-lead .ng-cta {
	margin-top: var(--s6);
}

/* ─── Collapse: a tall sheet, the cover across its top (the picture's own 16:9, never cropped) ─ */

.ng-cat-990260 {
	padding: var(--s6) var(--s6) var(--s6);
}

.ng-cat-990260 .ng-game-shot {
	margin: 0 calc(-1 * var(--s3)) var(--s5) 0;
	--print: .5deg;
}

.ng-cat-990260 .ng-game-title {
	font-size: var(--t5);
	line-height: 1.05;
}

/* Collapse's one DLC at every width: the cover on top, at most 280 px, and the name under it, so the name wraps
   at the spaces only and the sheet, its cover now the picture's own 16:9, stays taller than Mao's */
.ng-cat-990260 .ng-shelf li:only-child {
	flex-direction: column;
	align-items: stretch;
}

.ng-cat-990260 .ng-shelf li:only-child img {
	width: min(100%, 280px);
}

/* ─── Older games: clippings of the second paper ─────────────────────────── */

.ng-older-slip {
	position: relative;
	padding: var(--s5) var(--s5) var(--s3);
	transform: rotate(1.4deg);
}

.ng-older-slip h2 {
	margin: 0;
	font: 300 var(--t5)/1.05 var(--f-disp);
}

.ng-game-older {
	padding: var(--s5) var(--s5) var(--s5);
}

/* headline step follows the age: Mao --t4, Ostalgie --t3, Crisis --t2 */
.ng-cat-774091 .ng-game-title {
	font-size: var(--t3);
}

.ng-cat-599750 .ng-game-title {
	font-size: var(--t2);
	font-weight: 400;
}

/* an older game's DLC tree is compact: small covers, tight rows (all links stay listed) */
.ng-game-older .ng-game-dlc {
	margin-top: var(--s5);
}

.ng-game-older .ng-shelf.ng-tree li {
	padding-top: 0;
	padding-bottom: 0;
}

.ng-game-older .ng-shelf img {
	width: 48px;
}

/* Mao: a big clipping, the cover cropped to the map */
.ng-cat-950740 .ng-game-shot {
	--print: -.9deg;
}

.ng-cat-950740 .ng-game-shot img {
	aspect-ratio: 16 / 9;
	object-position: 58% 50%;
}

/* Ostalgie: a narrow clipping (narrower than Mao's), the cover a landscape crop */
.ng-cat-774091 .ng-game-shot {
	margin: 0 calc(-1 * var(--s5)) var(--s4) calc(-1 * var(--s2));
	--print: .4deg;
}

.ng-cat-774091 .ng-game-shot img {
	aspect-ratio: 16 / 9;
	object-position: 50% 45%;
}

/* Crisis: the smallest clipping, the narrowest sheet, the cover cropped to the ministers' list */
.ng-cat-599750 .ng-game-shot {
	--print: -1.4deg;
}

.ng-cat-599750 .ng-game-shot img {
	aspect-ratio: 16 / 9;
	object-position: 22% 40%;
}

.ng-cat-599750 .ng-game-dlc {
	margin-top: var(--s4);
}

/* ─── Narrow desktop / tablet: two columns, same order ───────────────────── */

@media (max-width: 1100px) {
	.ng-catalogue {
		grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
		gap: var(--s7) var(--s6);
	}

	.ng-cat-1922740 { grid-column: 1 / -1; }
	.ng-cat-990260  { grid-column: 1; }
	.ng-older-slip  { grid-column: 2; margin-left: var(--s4); }
	.ng-cat-950740  { grid-column: 2; margin: 0 var(--s4); }
	.ng-cat-774091  { grid-column: 1; margin: 0 var(--s6) 0 var(--s8); }
	.ng-cat-599750  { grid-column: 2; margin: 0 var(--s4) 0 var(--s6); }

	/* tablet and narrow desktop: the cover across the whole sheet at 16:9, copy and DLC side by side under it
	   (the copy column beside a cover is taller than the cover there) */
	.ng-game-lead {
		grid-template-columns: minmax(0, 6fr) minmax(0, 5fr);
		grid-template-areas:
			"shot shot"
			"copy dlc";
		padding: var(--s8) var(--s6) var(--s6);
	}

	.ng-game-lead .ng-game-shot img {
		aspect-ratio: 16 / 9;
	}

	.ng-game-lead .ng-game-copy {
		align-self: start;
		padding-top: var(--s2);
	}

	.ng-game-lead .ng-game-shot {
		margin-left: calc(-1 * var(--s5));
	}

	.ng-game-lead .ng-game-title {
		font-size: var(--t5);
	}

	.ng-cat-990260 .ng-game-title {
		font-size: var(--t4);
	}

	.ng-cat-950740 .ng-game-title {
		font-size: var(--t3);
	}

	.ng-cat-774091 .ng-game-title {
		font-size: var(--t2);
	}
}

/* Tablet only (the phone recomposes these sheets itself): widths fall with age at every width, the older two
   taking a share of their column rather than a fixed margin; the narrowest sheet still holds its frame title and
   its folded DLC key's longest word in every locale. Ostalgie's print stays inside its sheet, so the sheet ends
   above Mao's */
@media (min-width: 761px) and (max-width: 1100px) {
	.ng-catalogue   { column-gap: var(--s5); }
	.ng-cat-950740  { margin: 0 var(--s3) 0 0; }
	.ng-cat-774091  { width: 76%; margin: 0 0 0 var(--s7); }
	.ng-cat-599750  { width: 85%; margin: 0 0 0 var(--s5); padding: var(--s5) var(--s4) var(--s4); }

	.ng-cat-774091 .ng-game-shot {
		margin: 0 0 var(--s4);
	}

	/* the older sheets' two actions stay on one row, as on the phone */
	.ng-game-older .ng-cta {
		column-gap: var(--s4);
	}

	.ng-game-older .ng-buy {
		padding: 0 var(--s4);
	}

	.ng-cat-950740 .ng-shelf.ng-tree li {
		gap: var(--s2);
		padding-left: var(--s5);
	}

	/* the lead's one DLC: its cover across the box with the name under it, so the name has the box's whole
	   width and wraps at the spaces only (Collapse's, the same, above) */
	.ng-cat-1922740 .ng-shelf li:only-child {
		flex-direction: column;
		align-items: stretch;
	}

	.ng-cat-1922740 .ng-shelf li:only-child img {
		width: 100%;
	}
}

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

@media (max-width: 760px) {
	main.ng-page {
		width: 100%;
		margin-top: var(--s6);
		padding: 0 var(--s4);
		overflow-x: clip;
	}

	.ng-pagehead {
		margin: 0 0 calc(-1 * var(--s5)) var(--s2);
		padding: var(--s4) var(--s5) var(--s3);
	}

	.ng-catalogue {
		grid-template-columns: minmax(0, 1fr);
		gap: var(--s7);
	}

	.ng-catalogue > *,
	.ng-older-games > * {
		grid-column: 1;
		grid-row: auto;
	}

	.ng-cat-990260 { margin: 0 var(--s2) 0 0; --tilt: -.6deg; }
	.ng-older-slip { margin: 0 0 calc(-1 * var(--s4)) var(--s5); }
	.ng-cat-950740 { margin-left: var(--s2); --tilt: .6deg; }
	.ng-cat-774091 { margin: 0 var(--s6) 0 0; --tilt: -.9deg; }
	.ng-cat-599750 { margin: 0 0 0 var(--s7); --tilt: .5deg; }

	.ng-game-lead {
		display: block;
	}

	/* one column: the age order is told by cover height and headline step; the lead's cover keeps 4:3 */
	.ng-game-lead .ng-game-shot img {
		aspect-ratio: 4 / 3;
	}

	/* the covers are the pictures' own 16:9 (never cropped); the age order is told by the cover's width,
	   which falls sheet by sheet, and by the headline step: t4, t3, t2, t1 */
	.ng-cat-950740 .ng-game-shot img,
	.ng-cat-774091 .ng-game-shot img {
		aspect-ratio: 16 / 9;
	}

	.ng-cat-774091 .ng-game-shot {
		width: 82%;
	}

	.ng-cat-950740 .ng-game-title {
		font-size: var(--t3);
	}

	.ng-cat-774091 .ng-game-title {
		font-size: var(--t2);
	}

	.ng-cat-599750 .ng-game-title {
		font-size: var(--t1);
	}

	.ng-game-lead {
		padding: var(--s7) var(--s4) var(--s5);
	}

	/* on the phone the headline slip itself holds the sheet's left corner */
	.ng-game-lead .ng-tape.tm.ng-tape-l {
		left: 8%;
	}

	.ng-cat-990260,
	.ng-game-older {
		padding: var(--s5) var(--s4) var(--s4);
	}

	.ng-game-lead .ng-game-shot,
	.ng-cat-990260 .ng-game-shot,
	.ng-cat-774091 .ng-game-shot {
		margin: 0 0 var(--s5);
	}

	.ng-game-lead .ng-game-copy {
		padding-top: var(--s4);
	}

	.ng-game-lead .ng-game-title {
		font-size: var(--t6);
	}

	.ng-cat-990260 .ng-game-title {
		font-size: var(--t4);
	}

	.ng-game-lead .ng-game-line {
		font-size: var(--t2);
	}

	.ng-game-lead .ng-game-dlc {
		margin-top: var(--s6);
	}

	.ng-cat-599750 .ng-game-shot {
		width: 72%;
		margin: 0 0 var(--s5);
	}

	.ng-game-dlc.ng-con-box {
		padding: var(--s5) var(--s3) var(--s3);
		border-width: 4px;
	}

	.ng-shelf.ng-tree li {
		padding-left: var(--s5);
	}

	.ng-shelf img {
		width: 72px;
	}

	.ng-shelf li:only-child img {
		width: 112px;
	}

	/* an older game's buy button is a step smaller, so its two actions stay on one row */
	.ng-game-older .ng-cta {
		column-gap: var(--s4);
	}

	.ng-game-older .ng-buy {
		padding: 0 var(--s4);
	}
}

/* Tablet and phone: a sheet shows fewer DLC at rest the older it is (lead 4, Collapse 3, Mao 2, Ostalgie 1, Crisis 0),
   so sheet heights fall with age; «Показать все» (script.js) opens the rest in flow and the sheet grows.
   Without JS (no .js) or without :has() every DLC is listed and the button stays hidden. */
@media (max-width: 1100px) {
	@supports selector(:has(a)) {
		.js .ng-cat-1922740 .ng-shelf:not(.is-open) > li:nth-child(n+5),
		.js .ng-cat-990260 .ng-shelf:not(.is-open) > li:nth-child(n+4),
		.js .ng-cat-950740 .ng-shelf:not(.is-open) > li:nth-child(n+3),
		.js .ng-cat-774091 .ng-shelf:not(.is-open) > li:nth-child(n+2),
		.js .ng-cat-599750 .ng-shelf:not(.is-open) > li {
			display: none;
		}

		.js .ng-cat-1922740 .ng-shelf:has(> li:nth-child(5)) + .ng-dlc-more,
		.js .ng-cat-990260 .ng-shelf:has(> li:nth-child(4)) + .ng-dlc-more,
		.js .ng-cat-950740 .ng-shelf:has(> li:nth-child(3)) + .ng-dlc-more,
		.js .ng-cat-774091 .ng-shelf:has(> li:nth-child(2)) + .ng-dlc-more,
		.js .ng-cat-599750 .ng-shelf:has(> li) + .ng-dlc-more {
			display: inline-flex;
		}

		/* Crisis lists none at rest: its box folds into the key alone, a paper key in the «Оборот» manner whose
		   label names what it opens and how many (script.js fills the count); pressed, the box opens round the list */
		.js .ng-cat-599750 .ng-game-dlc:has(> .ng-shelf:not(.is-open) > li) {
			padding: 0;
			border: 0;
			background: none;
		}

		.js .ng-cat-599750 .ng-game-dlc:has(> .ng-shelf:not(.is-open) > li) .ng-dlc-h {
			position: absolute;
			width: 1px;
			height: 1px;
			overflow: hidden;
			clip-path: inset(50%);
			white-space: nowrap;
		}

		.js .ng-cat-599750 .ng-game-dlc:has(> .ng-shelf:not(.is-open) > li) .ng-dlc-more {
			margin-top: 0;
			padding-right: 10px;
			padding-left: 10px;
			border-color: var(--dim);
			background: none;
			color: var(--dim);
		}

		.js .ng-cat-599750 .ng-game-dlc:has(> .ng-shelf:not(.is-open) > li) .ng-dlc-more:hover,
		.js .ng-cat-599750 .ng-game-dlc:has(> .ng-shelf:not(.is-open) > li) .ng-dlc-more:focus-visible {
			border-color: var(--ink);
			color: var(--ink);
		}
	}
}
