/* ==========================================================================
   Masonry Posts Block
   ========================================================================== */

.masonry-posts-block {
	padding: 2rem 0;
}

.masonry-posts-block__header {
	max-width: 1200px;
	margin: 0 auto 1.5rem;
	padding: 0 1rem;
}

.masonry-posts-block__title {
	font-size: 1.75rem;
	font-weight: 700;
	margin: 0;
	color: var(--wdg-color-primary);
}

/* Grid container
   ========================================================================== */

.masonry-posts-grid {
	max-width: 1200px;
	margin: 0 auto;
	padding: 0 1rem;
}

.masonry-posts-grid::after {
	content: '';
	display: block;
	clear: both;
}

.masonry-posts-sizer {
	width: calc(33.333% - 12px);
	height: 0;
	float: left;
}

/* Tile
   ========================================================================== */

.masonry-posts-item {
	display: block;
	position: relative;
	overflow: hidden;
	float: left;
	width: calc(33.333% - 12px);
	margin-bottom: 16px;
	border-radius: 8px;
	border: 4px solid var(--masonry-tile-edge, white);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	background-color: transparent;
	text-decoration: none;
	transition: border 0.25s ease;
	cursor: pointer;
	box-sizing: border-box;
}

.masonry-posts-item:hover,
.masonry-posts-item:focus-visible {
	border: 4px solid var(--wdg-color-secondary);
	outline: none;
}

/* Imageless tiles: render as a light branded card, not a dark ("black") box */

.masonry-posts-item--noimg {
	background-image: linear-gradient(
		135deg,
		color-mix(in srgb, var(--wdg-color-primary) 10%, white),
		white
	);
	border-color: color-mix(in srgb, var(--wdg-color-primary) 18%, white);
}

/* Fallback for browsers without color-mix */
@supports not (color: color-mix(in srgb, red, blue)) {
	.masonry-posts-item--noimg {
		background-image: linear-gradient(135deg, #e6ecf6, #ffffff);
		border-color: #dbe3f1;
	}
}

.masonry-posts-item--noimg .masonry-posts-item__overlay {
	display: none;
}

.masonry-posts-item--noimg .masonry-posts-item__title,
.masonry-posts-item--noimg .masonry-posts-item__date {
	color: var(--wdg-color-primary);
	text-shadow: none;
}

.masonry-posts-item--noimg .masonry-posts-item__date {
	opacity: 0.7;
}

/* Height variations — all tiles same width for gap-free packing */

.masonry-posts-item--tall {
	height: 360px;
}

.masonry-posts-item--medium {
	height: 280px;
}

.masonry-posts-item--short {
	height: 220px;
}

/* Gradient overlay.

   NO CSS GRADIENTS HERE, ON PURPOSE. Firefox's hardware WebRender
   (D3D11, seen on Intel + FF 153) dithers gradient shaders into 1-2px
   scanlines across the tiles — driver/element screenshots render clean,
   only the real composited window shows it (bisect + OS-level screen
   grabs in \.dbx_tmp\person-cards\ff-iterate.py: photo-only clean,
   gradient-only maximally striped, solid fill clean, image-sampled ramp
   clean). Each overlay layer is therefore a SOLID brand-color fill
   shaped by a tiny base64 PNG alpha ramp via mask-image — image
   sampling, no gradient shader — and the brand primary stays a CSS
   variable (IRI's masonry pages tint plum). Rest and hover are separate
   pseudo-elements crossfaded on opacity. */

.masonry-posts-item__overlay {
	position: absolute;
	inset: 0;
	pointer-events: none;
	border-radius: inherit;
}

/* Rest state: >=50% tint up top for contrast, solid brand at the base. */
.masonry-posts-item__overlay::before {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--wdg-color-primary);
	-webkit-mask-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAIACAYAAACl/81BAAAAUklEQVR42u3UwQ0AIAgEwdNYuJ3jVy1Bh+cmGxI4aFU1s1XPVQAAAADwMhhJGoVCcUAUCsUzoFAongFFTikUoaO8kKC/wm9iFqWtRZmYthZ11AKZOwj6lxrnKgAAAABJRU5ErkJggg==');
	-webkit-mask-size: 100% 100%;
	mask-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAIACAYAAACl/81BAAAAUklEQVR42u3UwQ0AIAgEwdNYuJ3jVy1Bh+cmGxI4aFU1s1XPVQAAAADwMhhJGoVCcUAUCsUzoFAongFFTikUoaO8kKC/wm9iFqWtRZmYthZ11AKZOwj6lxrnKgAAAABJRU5ErkJggg==');
	mask-size: 100% 100%;
	border-radius: inherit;
	opacity: 1;
	transition: opacity 0.5s ease;
}

/* Hover state: the lighter bottom-weighted wash. */
.masonry-posts-item__overlay::after {
	content: '';
	position: absolute;
	inset: 0;
	background: var(--wdg-color-primary);
	-webkit-mask-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAIACAYAAACl/81BAAAASElEQVR42u3WIQ4AIAwEwYPw/y8XSzBoYConWXWmraqyXs92AAAAwDUwkjQAAAAAAAB28Dm+O+V5W4lEIpFIJBKJRCKRSP5IJhKpCfrSMML+AAAAAElFTkSuQmCC');
	-webkit-mask-size: 100% 100%;
	mask-image: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAIACAYAAACl/81BAAAASElEQVR42u3WIQ4AIAwEwYPw/y8XSzBoYConWXWmraqyXs92AAAAwDUwkjQAAAAAAAB28Dm+O+V5W4lEIpFIJBKJRCKRSP5IJhKpCfrSMML+AAAAAElFTkSuQmCC');
	mask-size: 100% 100%;
	border-radius: inherit;
	opacity: 0;
	transition: opacity 0.5s ease;
}

/* Browsers without mask support fall back to the old CSS gradients. */
@supports not ((mask-size: 100% 100%) or (-webkit-mask-size: 100% 100%)) {
	.masonry-posts-item__overlay::before {
		background: linear-gradient(
			to bottom,
			rgba(0, 50, 160, 0.5) 0%,
			rgba(0, 50, 160, 0.5) 20%,
			rgba(0, 50, 160, 0.73) 55%,
			rgba(0, 50, 160, 0.86) 75%,
			rgb(0, 50, 160) 100%
		);
	}

	.masonry-posts-item__overlay::after {
		background: linear-gradient(
			to bottom,
			rgba(0, 50, 160, 0) 20%,
			rgba(0, 50, 160, 0.7) 55%,
			rgb(0, 50, 160) 100%
		);
	}
}

.masonry-posts-item:hover .masonry-posts-item__overlay::before,
.masonry-posts-item:focus-visible .masonry-posts-item__overlay::before {
	opacity: 0;
}

.masonry-posts-item:hover .masonry-posts-item__overlay::after,
.masonry-posts-item:focus-visible .masonry-posts-item__overlay::after {
	opacity: 1;
}

/* Content area (title + pill + date) */

.masonry-posts-item__content {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	padding: 1rem 1.125rem;
	z-index: 1;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
}

.masonry-posts-item__title {
	color: var(--wdg-color-white);
	font-size: 1.25rem;
	font-weight: 600;
	line-height: 1.3;
	margin: 0;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

.masonry-posts-item__date {
	color: var(--wdg-color-white);
	font-size: 0.75rem;
	opacity: 0.85;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
	padding-top: 0;
	margin-top: 0;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 900px) {
	.masonry-posts-sizer,
	.masonry-posts-item {
		width: calc(50% - 10px);
	}

	.masonry-posts-item--tall {
		height: 300px;
	}

	.masonry-posts-item--medium {
		height: 240px;
	}

	.masonry-posts-item--short {
		height: 200px;
	}
}

@media (max-width: 560px) {
	.masonry-posts-sizer,
	.masonry-posts-item {
		width: 100%;
	}

	.masonry-posts-item--tall {
		height: 280px;
	}

	.masonry-posts-item--medium {
		height: 240px;
	}

	.masonry-posts-item--short {
		height: 200px;
	}

	.masonry-posts-block__title {
		font-size: 1.375rem;
	}
}
