/* Gallery wrapper spacing */
.media-gallery-wrapper {
	margin: 20px 0;
}

/* Dropdown spacing */
.gallery-selector-div {
	display: flex;
	justify-content: center;
	margin-bottom: 2rem;
}

.media-gallery-filter {
	margin-bottom: 20px;
	font-family: sans-serif;
}

.media-gallery-filter label {
	margin-right: 10px;
	font-weight: bold;
}

/* Enhanced Masonry Grid Styles */
.custom-gallery {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	grid-auto-rows: 150px; /* Smaller base unit for more flexibility */
	grid-gap: 15px;
	align-items: start;
	grid-auto-flow: row dense; /* Fill gaps automatically */
}

/* Default: all items span 1 column & 1 row */
.custom-gallery > * {
	grid-column: span 1;
	grid-row: span 1;
	height: 100%;
}

/* Create varied masonry patterns - using more flexible pattern */
/* Large featured items - span multiple columns and rows */
.custom-gallery > :nth-child(4n+1) {
	grid-column: span 2;
	grid-row: span 2;
}

/* Wide horizontal items */
.custom-gallery > :nth-child(6n+2) {
	grid-column: span 2;
	grid-row: span 1;
}

/* Tall vertical items */
.custom-gallery > :nth-child(5n+3) {
	grid-column: span 1;
	grid-row: span 2;
}

.custom-gallery > :nth-child(8n+5) {
	grid-column: span 1;
	grid-row: span 3;
}

/* Medium square items */
.custom-gallery > :nth-child(7n+4) {
	grid-column: span 1;
	grid-row: span 2;
}

/* Occasional wide items */
.custom-gallery > :nth-child(12n+6) {
	grid-column: span 2;
	grid-row: span 1;
}

/* Make images fill their cells nicely */
.custom-gallery img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.3s ease;
}

/* Subtle hover effect on images */
.custom-gallery img:hover {
	transform: scale(1.02);
}

/* Tablet layout - 3 columns */
@media (max-width: 1024px) and (min-width: 769px) {
	.custom-gallery {
		grid-template-columns: repeat(3, 1fr);
		grid-auto-rows: 180px;
		grid-auto-flow: row dense; /* Fill gaps automatically */
	}
	
	/* Adjust spans for tablet - use patterns that work better with 3 columns */
	.custom-gallery > :nth-child(5n+1) {
		grid-column: span 2;
		grid-row: span 2;
	}
	
	.custom-gallery > :nth-child(7n+3) {
		grid-column: span 1;
		grid-row: span 2;
	}
	
	.custom-gallery > :nth-child(8n+2) {
		grid-column: span 2;
		grid-row: span 1;
	}
}

/* Mobile layout - 2 columns for better use of space */
@media (max-width: 768px) and (min-width: 481px) {
	.custom-gallery {
		grid-template-columns: repeat(2, 1fr);
		grid-auto-rows: 160px;
		grid-gap: 12px;
		grid-auto-flow: row dense; /* Fill gaps automatically */
	}
	
	/* Reset most spans for mobile, keep some variety */
	.custom-gallery > * {
		grid-column: span 1;
		grid-row: span 1;
	}
	
	/* Keep some featured items spanning both columns */
	.custom-gallery > :nth-child(6n+1) {
		grid-column: span 2;
		grid-row: span 2;
	}
	
	/* Some tall items */
	.custom-gallery > :nth-child(8n+3) {
		grid-row: span 2;
	}
	
	/* Some wide items */
	.custom-gallery > :nth-child(9n+5) {
		grid-column: span 2;
		grid-row: span 1;
	}
}

/* Small mobile - single column */
@media (max-width: 480px) {
	.custom-gallery {
		grid-template-columns: 1fr;
		grid-auto-rows: auto;
		grid-gap: 10px;
	}
	
	.custom-gallery > * {
		grid-column: span 1;
		grid-row: span 1;
		height: auto;
	}
	
	.custom-gallery img {
		height: auto;
		min-height: 200px;
	}
}

/* Gallery item positioning */
.gallery-item {
	position: relative;
	overflow: hidden; /* Ensures hover effects stay contained */
}

/* Enhanced overlay with better visual hierarchy */
.gallery-overlay {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, rgba(184, 17, 17, 0.85), rgba(184, 17, 17, 0.75));
	opacity: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 20px;
	transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
	backdrop-filter: blur(2px);
}

/* Show overlay on hover with smooth animation */
.gallery-item:hover .gallery-overlay {
	opacity: 1;
}

/* Enhanced overlay buttons */
.overlay-btn {
	color: #fff;
	font-size: 24px;
	text-decoration: none;
	padding: 12px;
	border: 2px solid rgba(255, 255, 255, 0.8);
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
	width: 50px;
	height: 50px;
	background: rgba(255, 255, 255, 0.1);
	backdrop-filter: blur(10px);
}

.overlay-btn:hover {
	background: rgba(255, 255, 255, 0.2);
	border-color: #fff;
	transform: scale(1.15);
	box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

/* Optional: Add loading animation for dynamic content */
.gallery-item.loading {
	background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
	background-size: 200% 100%;
	animation: loading 1.5s infinite;
}

@keyframes loading {
	0% { background-position: 200% 0; }
	100% { background-position: -200% 0; }
}