:root {
	--ar-gallery-title-bg: rgba(0, 0, 0, 0.9);
	--ar-gallery-title-text: #f6f6f6;
}

.ar-gallery {
	display: flex;
	align-items: flex-start;
	gap: 0;
	margin: 0;
	margin-top: 0 !important;
	margin-block-start: 0 !important;
	padding: 1rem 1rem 2rem !important;
	position: relative;
	isolation: isolate;
}

/* Top/bottom fade overlays — sit behind the image cards */
.ar-gallery::before,
.ar-gallery::after {
	content: '';
	position: absolute;
	left: 0;
	right: 0;
	height: 35%;
	pointer-events: none;
	z-index: -1;
}

.ar-gallery::before {
	top: 0;
	background: linear-gradient(
		to bottom,
		var(--ar-gallery-fade-top, transparent) 0%,
		transparent 100%
	);
}

.ar-gallery::after {
	bottom: 0;
	background: linear-gradient(
		to top,
		var(--ar-gallery-fade-bottom, transparent) 0%,
		transparent 100%
	);
}

.ar-gallery-col {
	flex: 1;
	display: flex;
	flex-direction: column;
}

.ar-gallery-card {
	position: relative;
	margin: 10px 8px;
	break-inside: avoid;
	overflow: hidden;
	background: #fff;
	border: 10px solid #fff;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28), 0 1px 4px rgba(0, 0, 0, 0.14);
	transition: transform 220ms ease, box-shadow 220ms ease;
	z-index: 0;
}

.ar-gallery-card img {
	display: block;
	width: 100%;
	height: auto;
}

.wp-block-annual-report-gallery.ar-gallery .ar-gallery-card .ar-gallery-link,
.ar-gallery .ar-gallery-card .ar-gallery-link {
	display: block;
	color: inherit !important;
	text-decoration: none !important;
}

.wp-block-annual-report-gallery.ar-gallery .ar-gallery-card > figcaption,
.ar-gallery .ar-gallery-card > figcaption,
.ar-gallery-card figcaption {
	position: absolute;
	inset: auto 0 0;
	padding: 0.65rem 0.7rem 0.6rem !important;
	padding-inline: 0.7rem !important;
	padding-left: 0.7rem !important;
	padding-right: 0.7rem !important;
	line-height: 1.2;
	letter-spacing: 0.01em;
	text-align: left;
	color: var(--ar-gallery-title-text);
	background: linear-gradient(
		to top,
		var(--ar-gallery-title-bg) 0%,
		rgba(0, 0, 0, 0.72) 52%,
		rgba(0, 0, 0, 0) 100%
	);
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 180ms ease, transform 180ms ease;
}

.wp-block-annual-report-gallery.ar-gallery .ar-gallery-card:hover > figcaption,
.wp-block-annual-report-gallery.ar-gallery .ar-gallery-card:focus-within > figcaption,
.ar-gallery .ar-gallery-card:hover > figcaption,
.ar-gallery .ar-gallery-card:focus-within > figcaption,
.ar-gallery-card:hover figcaption,
.ar-gallery-card:focus-within figcaption {
	opacity: 1 !important;
	transform: translateY(0) !important;
}

/* Straighten + lift on hover/focus */
.ar-gallery-card:hover,
.ar-gallery-card:focus-within {
	transform: rotate(0deg) scale(1.04) !important;
	box-shadow: 0 10px 32px rgba(0, 0, 0, 0.34), 0 2px 6px rgba(0, 0, 0, 0.18) !important;
	z-index: 3;
}

.wp-block-annual-report-gallery.ar-gallery .ar-gallery-card figcaption h3,
.ar-gallery .ar-gallery-card figcaption h3 {
	margin: 0;
	font-size: 0.72rem !important;
	font-weight: 700 !important;
	line-height: 1.25 !important;
	letter-spacing: normal;
	text-transform: none;
	text-align: left !important;
	color: var(--ar-gallery-title-text) !important;
}

.wp-block-annual-report-gallery.ar-gallery .ar-gallery-card figcaption p,
.ar-gallery .ar-gallery-card figcaption p {
	margin: 0.2rem 0 0;
	font-size: 0.65rem !important;
	font-weight: 400 !important;
	line-height: 1.3 !important;
	opacity: 0.94;
	overflow: hidden;
	text-overflow: ellipsis;
	display: -webkit-box;
	line-clamp: 3;
	-webkit-line-clamp: 3;
	-webkit-box-orient: vertical;
	letter-spacing: normal;
	text-transform: none;
	text-align: left !important;
	color: var(--ar-gallery-title-text) !important;
}

/* Stagger every even column so all column edges are uneven (zig-zag pattern). */
.ar-gallery-col:nth-child(even) {
	margin-top: 80px;
}

/* Alternating photo-print rotations — odd columns lean left, even lean right */
.ar-gallery-col:nth-child(odd) .ar-gallery-card:nth-child(1),
.ar-gallery-col:nth-child(odd) .ar-gallery-card:nth-child(5) { transform: rotate(-2.4deg); }
.ar-gallery-col:nth-child(odd) .ar-gallery-card:nth-child(2),
.ar-gallery-col:nth-child(odd) .ar-gallery-card:nth-child(6) { transform: rotate(-1.3deg); }
.ar-gallery-col:nth-child(odd) .ar-gallery-card:nth-child(3) { transform: rotate(-2.9deg); }
.ar-gallery-col:nth-child(odd) .ar-gallery-card:nth-child(4) { transform: rotate(-1.8deg); }

.ar-gallery-col:nth-child(even) .ar-gallery-card:nth-child(1),
.ar-gallery-col:nth-child(even) .ar-gallery-card:nth-child(5) { transform: rotate(2.2deg); }
.ar-gallery-col:nth-child(even) .ar-gallery-card:nth-child(2),
.ar-gallery-col:nth-child(even) .ar-gallery-card:nth-child(6) { transform: rotate(1.4deg); }
.ar-gallery-col:nth-child(even) .ar-gallery-card:nth-child(3) { transform: rotate(2.8deg); }
.ar-gallery-col:nth-child(even) .ar-gallery-card:nth-child(4) { transform: rotate(1.1deg); }

@media (max-width: 1100px) {
	.ar-gallery {
		display: grid;
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: clamp(0.8rem, 1.8vw, 1.4rem);
		padding: 1rem !important;
	}

	.ar-gallery-col {
		display: contents;
	}

	.ar-gallery-col:nth-child(even) {
		margin-top: 0;
	}
}

@media (max-width: 800px) {
	.ar-gallery {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 560px) {
	.ar-gallery {
		grid-template-columns: minmax(0, 1fr);
	}
}
