/*!
 * WP Justified Grid — v2.0.0
 *
 * Two states:
 *   .wjg-container            pre-JS / no-JS fallback, flexbox
 *   .wjg-container.wjg-ready  JS has measured, items are absolutely positioned
 */

.wjg-container {
	--wjg-gap: 5px;
	--wjg-target: 250px;

	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 0;
}

.wjg-container *,
.wjg-container *::before,
.wjg-container *::after {
	box-sizing: border-box;
}

.wjg-item {
	position: relative;
	display: block;
	overflow: hidden;
	margin: 0;
	padding: 0;
	background: rgba(0, 0, 0, 0.04);
}

.wjg-item .wjg-link {
	display: block;
	width: 100%;
	height: 100%;
	text-decoration: none;
	border: 0;
}

.wjg-item img {
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	object-fit: cover;
	vertical-align: bottom;
}

/* ---------------------------------------------------------------
 * Fallback layout — used before the script runs, and forever if it
 * never does. Rows are approximately justified using flex-grow
 * weighted by each image's aspect ratio.
 * ------------------------------------------------------------ */

.wjg-container:not(.wjg-ready) {
	display: flex;
	flex-wrap: wrap;
	gap: var(--wjg-gap);
}

.wjg-container:not(.wjg-ready) .wjg-item {
	height: var(--wjg-target);
	flex: 1 1 calc(var(--wjg-ar, 1) * var(--wjg-target));
}

/* ---------------------------------------------------------------
 * Measured layout
 * ------------------------------------------------------------ */

.wjg-container.wjg-ready {
	position: relative;
	display: block;
	overflow: hidden;
}

.wjg-container.wjg-ready .wjg-item {
	position: absolute;
	top: 0;
	left: 0;
	will-change: transform;
}

/* Applied one frame after the first layout, so items don't animate
   in from the top-left corner on page load. */
.wjg-container.wjg-animate .wjg-item {
	transition:
		transform 0.28s cubic-bezier(0.2, 0, 0.2, 1),
		width 0.28s cubic-bezier(0.2, 0, 0.2, 1),
		height 0.28s cubic-bezier(0.2, 0, 0.2, 1);
}

/* ---------------------------------------------------------------
 * Captions
 * ------------------------------------------------------------ */

.wjg-caption {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	margin: 0;
	padding: 2.5em 0.75em 0.6em;
	color: #fff;
	font-size: 0.8125rem;
	line-height: 1.35;
	text-align: left;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.72), rgba(0, 0, 0, 0));
	opacity: 0;
	transform: translateY(6px);
	transition: opacity 0.2s ease, transform 0.2s ease;
	pointer-events: none;
}

.wjg-item:hover .wjg-caption,
.wjg-item:focus-within .wjg-caption {
	opacity: 1;
	transform: translateY(0);
}

/* ---------------------------------------------------------------
 * Focus — keyboard users need to see where they are, and the outline
 * has to sit inside the item because the item clips its overflow.
 * ------------------------------------------------------------ */

.wjg-item .wjg-link:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: -3px;
}

@media (prefers-reduced-motion: reduce) {
	.wjg-container.wjg-animate .wjg-item,
	.wjg-caption {
		transition: none;
	}
}
