/* The projects page (grid.js): a bento grid of tiles that open into
   each project's own page across the content panel (page.css). Tiles take
   M3's large corners (16px) with 8px between them. */

.projects-note {
	display: flex;
	align-items: center;
	gap: var(--s2);
	margin: calc(-1 * var(--s4)) 0 var(--s5);
	font-size: 13px;
	color: var(--muted);
}

.projects-note[hidden] {
	display: none;
}

.projects-note svg {
	width: 16px;
	height: 16px;
	flex: none;
}

.projects-retry {
	appearance: none;
	padding: 4px 12px;
	border: 1px solid var(--border);
	border-radius: 999px;
	background: none;
	color: var(--text);
	font: inherit;
	font-size: 13px;
}

.projects-retry:hover {
	background: color-mix(in srgb, var(--text) 8%, transparent);
}

/* --- The grid ----------------------------------------------------------------- */

/* A row leaves a small tile its cover, a little over two to one, above the
   four lines of its text. */
.bento {
	--row: clamp(222px, calc(17vw + 22px), 282px);
	display: grid;
	grid-template-columns: repeat(var(--columns, 4), minmax(0, 1fr));
	grid-auto-rows: var(--row);
	gap: var(--s2);
	margin: 0;
	padding: 0;
	list-style: none;
}

.bento[hidden],
.bento-heading[hidden],
.projects-activity[hidden] {
	display: none;
}

/* Activity across every project, after them. */
.projects-activity {
	margin-bottom: var(--s7);
}

.bento-heading {
	margin: var(--s7) 0 var(--s4);
	font-size: 12px;
	font-weight: 400;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

.bento-cell {
	min-width: 0;
}

.project-tile {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	border: 0;
	border-radius: var(--s4);
	background: var(--surface);
	color: var(--text);
	overflow: hidden;
}

/* Pressed, a tile gives a little, and springs back when let go
   (grid.js sets the spring easings). */
.project-tile {
	transition: scale var(--spring-release-duration, 400ms) var(--spring-release, ease);
}

.project-tile:active {
	scale: 0.97;
	transition: scale var(--spring-press-duration, 150ms) var(--spring-press, ease);
}

/* The M3 state layer. */
.project-tile::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: currentColor;
	opacity: 0;
	transition: opacity 150ms var(--ease-effects);
	pointer-events: none;
}

.project-tile:hover::before {
	opacity: 0.08;
}

.project-tile:active::before {
	opacity: 0.12;
}

.project-tile:focus-visible {
	outline-offset: 2px;
}

/* The cover takes whatever space the text leaves: above it on small and
   large tiles, beside it on wide ones. */
.tile-cover {
	position: relative;
	flex: 1 1 0;
	min-height: 0;
}

.tile-cover canvas {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
}

.tile-text {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: var(--s1) var(--s5) var(--s5);
}

.bento-cell[data-size="wide"] .project-tile {
	display: grid;
	grid-template-columns: minmax(0, 2fr) minmax(0, 3fr);
	grid-template-areas: "text cover";
}

.bento-cell[data-size="wide"] .tile-cover {
	grid-area: cover;
}

.bento-cell[data-size="wide"] .tile-text {
	grid-area: text;
	align-self: end;
}

/* The kind sits over the title on every tile, where M3 puts a list
   item's overline, with its icon and its name together: read in the same
   place from tile to tile, and never an icon alone (NN/g, "Cards:
   UI-Component Definition" and "Icon Usability"). It takes M3's label
   line height. */
.tile-kind {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-bottom: 4px;
	font-size: 12px;
	line-height: 16px;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--muted);
}

.tile-kind:empty {
	display: none;
}

.tile-kind svg {
	width: 14px;
	height: 14px;
	flex: none;
}

.tile-title {
	font-size: 18px;
	font-weight: 700;
	line-height: 24px;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bento-cell[data-size="large"] .tile-title {
	font-size: clamp(24px, 2.4vw, 32px);
	line-height: 1.25;
}

.tile-description {
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	overflow: hidden;
	font-size: 13px;
	line-height: 19px;
	color: var(--muted);
}

.bento-cell[data-size="small"] .tile-description {
	-webkit-line-clamp: 1;
}

.bento-cell[data-size="large"] .tile-description {
	max-width: 56ch;
	font-size: 15px;
	line-height: 22px;
}

.tile-description:empty {
	display: none;
}

.tile-meta {
	display: flex;
	flex-wrap: wrap;
	column-gap: 6px;
	margin-top: 4px;
	font-size: 12px;
	line-height: 18px;
	color: var(--muted);
}

.tile-meta:empty {
	display: none;
}

@media (max-width: 559px) {
	.bento {
		--row: 270px;
	}
}

/* Skeleton tiles hold the grid's shape until the forge first answers
   (grid.js): a cover's place and two lines of text (skeleton.css), with
   M3's subtle pulse. */
.tile-skeleton {
	display: flex;
	flex-direction: column;
	gap: var(--s2);
	height: 100%;
	padding: var(--s3) var(--s5) var(--s5);
	border-radius: var(--s4);
	background: var(--surface);
	animation: skeletonArrive 400ms var(--ease-arrive) backwards;
}

.tile-skeleton-cover {
	flex: 1 1 0;
	min-height: 0;
	margin: 0 calc(var(--s5) * -1 + var(--s3)) var(--s2);
	border-radius: var(--s3);
	background: color-mix(in srgb, var(--text) 6%, transparent);
	animation: skeletonPulse 1s ease-in-out infinite alternate;
}

.tile-skeleton .skeleton {
	width: 45%;
	margin: 0;
}

.tile-skeleton .skeleton + .skeleton {
	width: 75%;
}

@keyframes skeletonArrive {
	from {
		opacity: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	.project-tile,
	.project-tile:active,
	.project-tile::before {
		transition: none;
	}

	.tile-skeleton,
	.tile-skeleton-cover {
		animation: none;
	}
}
