@charset "UTF-8";

/* ==========================================================================
   home-mosaic.css — the homepage grid. Works are a mosaic of big and small
   tiles; Feed / Labs / Diary are one big tile each in a row below. Cells are
   squares sized from the container width (cqw), so every span stays square
   and both grids share the same cell system. js/home-grid.js assigns each
   work tile its span through custom properties: --c (columns), --r (rows),
   --cs (forced start column).
   ========================================================================== */

.mosaic { container-type: inline-size; }

.mosaic__grid {
	position: relative;   /* offsetParent for the hole-filling measurements */
	--cols: 6;
	--gap: 8px;
	display: grid;
	grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
	grid-auto-rows: calc((100cqw - (var(--cols) - 1) * var(--gap)) / var(--cols));
	grid-auto-flow: dense;
	gap: var(--gap);
}

/* --fs / --fc are set by js/home-grid.js only to close a hole (a tile is
   widened into it); they sit beside --cs / --c so the media-query !important
   overrides below don't fight them. */
.mosaic__grid > * {
	grid-column: var(--fs, var(--cs, auto)) / span var(--fc, var(--c, 1));
	grid-row: span var(--r, 1);
	min-width: 0;
}

.mosaic__grid > [hidden] { display: none; }

/* no-JS fallback: works are plain 2-wide tiles */
.workgrid__item { --c: 2; }

.mosaic--cats { margin-top: 8px; }

/* ---- tiles -------------------------------------------------------------- */

.mt {
	position: relative;
	display: block;
	overflow: hidden;
	padding: 0;
	border: 0;
	font: inherit;
	text-align: left;
	color: inherit;
	text-decoration: none;
	background: var(--img-ph);
}

/* works fade up once the script has taken over (so no-JS still shows everything) */
.mosaic__grid.is-ready > .mt {
	opacity: 0;
	transform: translateY(12px);
	transition: opacity .55s ease, transform .55s ease;
}

.mosaic__grid.is-ready > .mt.is-in { opacity: 1; transform: none; }

.mt img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform .7s ease, opacity .6s ease;
}

.mt:hover img,
.mt:focus-visible img { transform: scale(1.05); }

/* ---- category tiles: Feed / Labs / Diary -------------------------------- */

.cat {
	--c: 2;
	--r: 2;
	color: #fff;
	background: var(--panel);
}

.cat__name {
	position: absolute;
	left: 16px;
	top: 12px;
	z-index: 2;
	font-family: var(--ui);
	font-weight: 800;
	font-size: clamp(1.3rem, 1rem + 1.6cqw, 2rem);
	line-height: 1.1;
	letter-spacing: .01em;
	text-shadow: 0 2px 10px rgba(0, 0, 0, .45);
}

.cat__meta {
	position: absolute;
	left: 16px;
	bottom: 12px;
	z-index: 2;
	font-family: var(--ui);
	font-weight: 600;
	font-size: .8rem;
	letter-spacing: .04em;
	text-shadow: 0 1px 6px rgba(0, 0, 0, .5);
}

.cat--feed::after,
.cat--labs::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	pointer-events: none;
	background: linear-gradient(to bottom, rgba(0, 0, 0, .5), rgba(0, 0, 0, 0) 42%, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, .55));
}

.cat__quad {
	position: absolute;
	inset: 0;
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr 1fr;
	gap: 2px;
}

.cat__cell {
	position: relative;
	overflow: hidden;
	background: var(--img-ph);
}

.cat__cell img.is-swap-in { opacity: 0; }

.cat__latest {
	position: absolute;
	left: 16px;
	right: 16px;
	bottom: 36px;
	z-index: 2;
	font-family: var(--ui);
	font-weight: 700;
	font-size: .95rem;
	line-height: 1.3;
	text-shadow: 0 1px 6px rgba(0, 0, 0, .55);
}

/* diary: no image, the latest entry set as type */
.cat--diary {
	color: var(--ink);
	border: 1px solid var(--line-soft);
}

.cat--diary .cat__name,
.cat--diary .cat__meta { text-shadow: none; }

.cat__text {
	position: absolute;
	left: 16px;
	right: 16px;
	bottom: 38px;
	display: flex;
	flex-direction: column;
	gap: 6px;
}

.cat__text time {
	font-family: var(--ui);
	font-size: .72rem;
	font-weight: 600;
	color: var(--ink-soft);
}

.cat__text-title {
	font-family: var(--ui);
	font-weight: 700;
	font-size: .95rem;
	line-height: 1.35;
}

.cat__text-ex {
	font-family: var(--sans);
	font-size: .82rem;
	line-height: 1.65;
	color: var(--ink-soft);
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 5;
	overflow: hidden;
}

.cat--diary:hover { border-color: var(--line); }

/* ---- responsive: fewer columns, same pattern ------------------------------
   !important so these beat the inline custom properties the script sets. */

@media screen and (max-width: 900px) {
	.mosaic__grid { --cols: 4; }
	.mosaic__grid > [data-k] { --cs: auto !important; }
	.mosaic__grid > [data-k="big"] { --c: 4 !important; }
	.cat--diary { --c: 4; --r: 1; }
}

@media screen and (max-width: 560px) {
	.mosaic__grid { --cols: 2; --gap: 6px; }
	/* phones: small works sit two per row, the big ones become wide banners */
	.mosaic__grid > [data-k="big"] { --c: 2 !important; --r: 1 !important; }
	.mosaic__grid > [data-k="ws"] { --c: 1 !important; --r: 1 !important; }
	.cat { --c: 2; --r: 1; }
	.cat__quad { grid-template-columns: repeat(4, 1fr); grid-template-rows: 1fr; }
	.cat__text-ex { -webkit-line-clamp: 2; }
}

@media (prefers-reduced-motion: reduce) {
	.mosaic__grid.is-ready > .mt { opacity: 1; transform: none; transition: none; }
	.mt img { transition: none; }
}
