/* Guides (guides.html): one paper sheet per game, the community guides on it as index cards.
   Linked only by these pages (i18n-util.mjs renderNgHeadAssets). The cards are generated by guides-sync.mjs
   between the GUIDES:<appid> markers (a.guideCard: optional img.guideThumb, .guideInfo > .guideTitle with an
   optional img.guideStars, optional .guideAuthor, optional .guideDesc), all with the same markup, so a sheet's
   size comes from its real number of cards (:has(.guideCard:nth-child(n))) and the variety from nth-child. */

/* ─── Wall: the sheets wrap in rows and grow in proportion to their guide count ─── */

main.ng-page {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-start;
	gap: var(--s7) var(--s6);
	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;
}

/* Tape strips drawn on the sheets (the markup has no tape spans): two far apart on a
   medium or large sheet, one at the top middle on a small one. */
.ng-pagehead h1::before,
.guideGame::before,
.guideGame::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 {
	flex: 0 0 100%;
	margin-top: var(--s5);
}

.ng-pagehead h1 {
	position: relative;
	display: inline-block;
	margin: 0 0 0 var(--s2);
	padding: var(--s6) var(--s6) var(--s4) var(--s5);
	background-color: var(--panel);
	background-image: var(--grain);
	box-shadow: 5px 7px 1px var(--shadow);
	font: 300 var(--t6)/1 var(--f-disp);
	overflow-wrap: anywhere;
	transform: rotate(-1.2deg);
}

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

/* ─── Game sheets ────────────────────────────────────────────────────────── */

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

/* grow = number of guides; basis by size class (small <= 4, medium 5-7, large 8+) */
.guideGame:has(.guideCard:nth-child(2)) { flex-grow: 2; }
.guideGame:has(.guideCard:nth-child(3)) { flex-grow: 3; }
.guideGame:has(.guideCard:nth-child(4)) { flex-grow: 4; }
.guideGame:has(.guideCard:nth-child(5)) { flex-grow: 5; flex-basis: 420px; }
.guideGame:has(.guideCard:nth-child(6)) { flex-grow: 6; }
.guideGame:has(.guideCard:nth-child(7)) { flex-grow: 7; }
.guideGame:has(.guideCard:nth-child(8)) { flex-grow: 8; flex-basis: 520px; }
.guideGame:has(.guideCard:nth-child(9)) { flex-grow: 9; }
.guideGame:has(.guideCard:nth-child(10)) { flex-grow: 10; }

.guideGame:nth-of-type(5n+1) { --tilt: -.4deg; }
.guideGame:nth-of-type(5n+2) { --tilt: .7deg; }
.guideGame:nth-of-type(5n+3) { --tilt: -.9deg; }
.guideGame:nth-of-type(5n+4) { --tilt: .5deg; }
.guideGame:nth-of-type(5n) { --tilt: -.3deg; }

.guideGame::before {
	left: 8%;
	--w: 100px;
	--r: -4deg;
}

.guideGame::after {
	left: auto;
	right: 8%;
	--w: 88px;
	--r: 3deg;
}

.guideGame:nth-of-type(even)::before {
	--w: 92px;
	--r: 5deg;
}

.guideGame:nth-of-type(even)::after {
	--w: 104px;
	--r: -2deg;
}

.guideGame:not(:has(.guideCard:nth-child(5)))::before {
	left: calc(50% - 35px);
	--w: 70px;
	--r: -3deg;
}

.guideGame:not(:has(.guideCard:nth-child(5)))::after {
	content: none;
}

.guideGameHeader {
	margin: 0 0 var(--s5);
	font: 400 var(--t4)/1.1 var(--f-disp);
	overflow-wrap: anywhere;
}

/* the game with the most guides is set loudest */
.guideGame:has(.guideCard:nth-child(8)) .guideGameHeader {
	font-weight: 300;
	font-size: var(--t5);
}

/* ─── Index cards ────────────────────────────────────────────────────────── */

.guideList {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	gap: var(--s4) var(--s5);
	align-items: start;
}

@container (min-width: 600px) {
	.guideList {
		grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
	}
}

.guideCard {
	display: grid;
	grid-template-columns: 72px minmax(0, 1fr);
	gap: var(--s4);
	align-items: start;
	padding: var(--s3);
	background-color: var(--panel-2);
	box-shadow: 2px 3px 0 var(--shadow);
	color: var(--ink);
	text-decoration: none;
}

.guideCard:not(:has(.guideThumb)) {
	grid-template-columns: minmax(0, 1fr);
}

/* the thumbnail is a small print: a paper matte, its own tilt; it straightens under the pointer */
.guideThumb {
	display: block;
	width: 72px;
	height: 72px;
	object-fit: cover;
	padding: var(--s1);
	background: var(--panel);
	box-shadow: 2px 3px 0 var(--shadow);
	transform: rotate(-2deg);
	transition: transform 140ms cubic-bezier(.2, .7, .2, 1);
}

.guideCard:nth-child(even) .guideThumb {
	transform: rotate(1.6deg);
}

.guideCard:nth-child(3n) .guideThumb {
	transform: rotate(-.8deg);
}

.guideCard:hover .guideThumb,
.guideCard:focus-visible .guideThumb {
	transform: rotate(0deg);
}

.guideInfo {
	min-width: 0;
}

.guideTitle {
	font: 500 var(--t2)/1.3 var(--f-disp);
	overflow-wrap: anywhere;
}

.guideStars {
	display: inline-block;
	width: auto;
	height: 16px;
	margin-left: var(--s1);
	vertical-align: -2px;
}

.guideAuthor {
	margin: var(--s1) 0 0;
	color: var(--dim);
	font: 400 var(--t1)/1.4 var(--f-read);
	overflow-wrap: anywhere;
}

.guideDesc {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	overflow: hidden;
	margin: var(--s2) 0 0;
	font: 400 var(--t1)/1.5 var(--f-read);
	overflow-wrap: anywhere;
}

.guideCard:hover .guideTitle,
.guideCard:focus-visible .guideTitle {
	text-decoration: underline;
	text-decoration-thickness: 2px;
	text-underline-offset: 4px;
}

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

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

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

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

	.guideGame {
		flex-basis: 100%;
		padding: var(--s6) var(--s3) var(--s4);
	}

	.guideGame:nth-of-type(odd) {
		--tilt: -.4deg;
	}

	.guideGame:nth-of-type(even) {
		--tilt: .5deg;
	}

	.guideCard {
		grid-template-columns: 64px minmax(0, 1fr);
		gap: var(--s3);
	}

	.guideThumb {
		width: 64px;
		height: 64px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.guideThumb {
		transition: none;
	}
}
