/*
 * Portfolio (Work) grid — REBUILD-MASTER §1 "Work/Portfolio grid cards" + §6.
 * Bordered default: 1px solid border, 16px radius, NO shadow.
 */

/* Soft health-check link in the hero. The site's global link style has no
   underline (color alone carries it), but here the link is white text on the
   white-ish hero copy with no color difference — underline it so it reads as
   a link. */
.jjd-hero .jjd-microcopy a {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.jjd-work-grid .wp-block-post-template {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 28px;
	list-style: none;
	margin: 0;
	padding: 0;
}

/* WP's Query Loop injects a 600px responsive rule with high specificity —
 * override needs !important to win reliably (REBUILD-MASTER gotcha #7). */
@media (max-width: 900px) {
	.jjd-work-grid .wp-block-post-template {
		grid-template-columns: repeat(2, 1fr) !important;
	}
}
@media (max-width: 600px) {
	.jjd-work-grid .wp-block-post-template {
		grid-template-columns: 1fr !important;
	}
}

/* WP's flow-layout rule (:root :where(.is-layout-flow) > *) puts a
   margin-block-start: 1.5rem on every card except the first. In this grid that
   left card 1 filling its track while every other card came up ~24px short.
   Reset it — the grid's own `gap` handles spacing. */
.jjd-work-grid .wp-block-post-template > .wp-block-post {
	margin: 0;
}

.jjd-work-grid .wp-block-post {
	position: relative;         /* anchor for the stretched title link */
	border: 1px solid var(--wp--preset--color--border);
	border-radius: 16px;
	overflow: hidden;
	display: flex;
	flex-direction: column;
	transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}
/* Every card the same height: the image is a fixed ratio, and the title and
   excerpt each reserve a fixed number of lines (clamped if longer). */

.jjd-work-grid .wp-block-post-featured-image {
	position: relative;
	margin: 0;
	flex: none;                 /* the flex card must not stretch or squash it */
	aspect-ratio: 3 / 4;
	overflow: hidden;
	background: var(--wp--preset--color--section-subtle);
}
.jjd-work-grid .wp-block-post-featured-image img {
	position: absolute;         /* out of flow so aspect-ratio governs the box */
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: top;
	transition: transform 0.3s ease;
}

/* The whole card is a link to the project write-up (title carries the <a>;
   ::after stretches its hit area over the entire card). */
.jjd-work-grid .wp-block-post-title a {
	color: inherit;
	text-decoration: none;
}
.jjd-work-grid .wp-block-post-title a::after {
	content: "";
	position: absolute;
	inset: 0;
}
.jjd-work-grid .wp-block-post:hover {
	border-color: var(--wp--preset--color--field-border);
	box-shadow: 0 12px 28px rgba(15, 23, 42, 0.1);
	transform: translateY(-3px);
}
.jjd-work-grid .wp-block-post:hover .wp-block-post-featured-image img {
	transform: scale(1.04);
}
.jjd-work-grid .wp-block-post:hover .wp-block-post-title a {
	color: var(--wp--preset--color--accent-blue);
}
/* Keyboard focus lands on the title link — ring the whole card, keyboard only. */
.jjd-work-grid .wp-block-post:has(a:focus-visible) {
	outline: 2px solid var(--wp--preset--color--accent-blue);
	outline-offset: 2px;
}
.jjd-work-grid .wp-block-post-title a:focus {
	outline: none;
}

@media (prefers-reduced-motion: reduce) {
	.jjd-work-grid .wp-block-post,
	.jjd-work-grid .wp-block-post-featured-image img {
		transition: none;
	}
	.jjd-work-grid .wp-block-post:hover {
		transform: none;
	}
	.jjd-work-grid .wp-block-post:hover .wp-block-post-featured-image img {
		transform: none;
	}
}

.jjd-work-grid .wp-block-post-title {
	margin: 0;
	padding: 20px 20px 0;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.35;
	color: var(--wp--preset--color--heading);
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	overflow: hidden;
	min-height: calc(20px + 2 * 1.35em); /* padding-top + 2 lines */
}

.jjd-work-grid .wp-block-post-excerpt {
	margin: 0;
	padding: 8px 20px 20px;
}
.jjd-work-grid .wp-block-post-excerpt p {
	margin: 0;
	font-size: 0.875rem;
	line-height: 1.6;
	color: var(--wp--preset--color--body-text);
	display: -webkit-box;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 3;
	line-clamp: 3;
	overflow: hidden;
	min-height: calc(3 * 1.6em); /* reserve 3 lines so every card matches */
}
.jjd-work-grid .wp-block-post-excerpt__more-text { display: none; }
