/**
 * Gallery Masonry Component Styles
 * CSS Multi-Column Masonry Layout
 * 
 * Approach: CSS Columns (CodePen style)
 * - Uses column-count for responsive masonry layout
 * - No JavaScript required - pure CSS solution
 * - Natural aspect ratios preserved
 * - Minimal vertical gaps with break-inside: avoid
 * 
 * @package Standfast
 * @since 1.0.0
 */

.gallery-masonry {
	padding: var(--spacing-xl) 0;
	background-color: var(--white);
}

/* ============================================
   Masonry Grid - Base Layout (CSS Columns)
   ============================================ */

.masonry-grid {
	column-count: 3;
	column-gap: 15px;
	width: 100%;
}

/* ============================================
   Masonry Item - Individual Image Container
   ============================================ */

.masonry-item {
	display: inline-block;
	width: 100%;
	margin: 0 0 15px;
	position: relative;
	border-radius: 8px;
	overflow: hidden;
	background-color: #f3f4f6;
	transition: transform 0.3s ease, box-shadow 0.3s ease;
	
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
	page-break-inside: avoid;
	
	opacity: 0;
	animation: fadeIn 0.4s ease forwards;
}

.masonry-item.loaded {
	opacity: 1;
}

@keyframes fadeIn {
	from {
		opacity: 0;
	}
	to {
		opacity: 1;
	}
}

.masonry-item:hover {
	transform: translateY(-4px);
	box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
}

/* ============================================
   Masonry Item Link & Image
   ============================================ */

.masonry-item__link {
	display: block;
	position: relative;
	width: 100%;
	text-decoration: none;
	color: inherit;
	overflow: hidden;
	
	border: none;
	background: none;
	padding: 0;
	margin: 0;
	cursor: pointer;
	font: inherit;
	text-align: inherit;
}

.masonry-item__image {
	width: 100%;
	height: auto;
	display: block;
	
	object-fit: cover;
	
	transition: transform 0.3s ease;
}

.masonry-item:hover .masonry-item__image {
	transform: scale(1.05);
}

/* ============================================
   Overlay & Icon
   ============================================ */

.masonry-item__overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.4);
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.masonry-item:hover .masonry-item__overlay {
	opacity: 1;
}

.masonry-item__icon {
	color: var(--white);
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: rgba(255, 255, 255, 0.2);
	border-radius: 50%;
	backdrop-filter: blur(4px);
}

.masonry-item__icon svg {
	width: 24px;
	height: 24px;
}

/* ============================================
   Responsive Breakpoints
   ============================================ */


@media (max-width: 900px) {
	.gallery-masonry {
		padding: var(--spacing-xxl) 0;
	}

	.masonry-grid {
		column-count: 2;
		column-gap: 15px;
	}
}

@media (max-width: 600px) {
	.masonry-grid {
		column-count: 2;
		column-gap: 15px;
	}
}

@media (max-width: 400px) {
	.masonry-grid {
		column-count: 1;
		column-gap: 15px;
	}
}

@media (min-width: 1280px) {
	.masonry-grid {
		max-width: 1400px;
		margin: 0 auto;
		column-gap: 15px;
	}
}

/* ============================================
   Empty State
   ============================================ */

.gallery-masonry__empty {
	padding: var(--spacing-xxl) 0;
	text-align: center;
}

.gallery-masonry__empty-message {
	font-family: var(--font-body);
	font-size: 16px;
	color: var(--muted-foreground);
	margin: 0;
	padding: var(--spacing-lg);
	background-color: #f9fafb;
	border-radius: 8px;
	border: 1px dashed #d1d5db;
}

/* ============================================
   Gallery Modal
   ============================================ */

.gallery-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background-color: rgba(0, 0, 0, 0.95);
	display: flex;
	align-items: center;
	justify-content: center;
	z-index: 99999;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0.3s ease;
	padding: 20px;
	pointer-events: none;
}

.gallery-modal[hidden] {
	display: none !important;
}

.gallery-modal--active {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
}

.gallery-modal__content {
	position: relative;
	max-width: 90vw;
	max-height: 90vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
}

.gallery-modal__image {
	max-width: 100%;
	max-height: 85vh;
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 8px;
	box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.gallery-modal__caption {
	margin-top: 20px;
	color: var(--white);
	font-size: 16px;
	text-align: center;
	max-width: 800px;
	line-height: 1.5;
}

.gallery-modal__caption:empty {
	display: none;
}

.gallery-modal__close {
	position: absolute;
	top: 20px;
	right: 20px;
	width: 48px;
	height: 48px;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: rgba(255, 255, 255, 0.1);
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 50%;
	color: var(--white);
	cursor: pointer;
	transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
	z-index: 10000;
}

.gallery-modal__close:hover {
	background-color: rgba(255, 255, 255, 0.2);
	border-color: rgba(255, 255, 255, 0.5);
	transform: scale(1.1);
}

.gallery-modal__close svg {
	width: 24px;
	height: 24px;
}

.gallery-modal__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 56px;
	height: 56px;
	display: flex;
	align-items: center;
	justify-content: center;
	background-color: rgba(255, 255, 255, 0.1);
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-radius: 50%;
	color: var(--white);
	cursor: pointer;
	transition: background-color 0.3s ease, border-color 0.3s ease, transform 0.2s ease;
	z-index: 10000;
}

.gallery-modal__nav:hover {
	background-color: rgba(255, 255, 255, 0.2);
	border-color: rgba(255, 255, 255, 0.5);
	transform: translateY(-50%) scale(1.1);
}

.gallery-modal__nav svg {
	width: 24px;
	height: 24px;
}

.gallery-modal__nav--prev {
	left: 20px;
}

.gallery-modal__nav--next {
	right: 20px;
}

.gallery-modal__nav[style*="display: none"],
.gallery-modal__nav[hidden] {
	display: none !important;
}

@media (max-width: 768px) {
	.gallery-modal {
		padding: 10px;
	}

	.gallery-modal__image {
		max-height: 80vh;
	}

	.gallery-modal__close {
		top: 10px;
		right: 10px;
		width: 40px;
		height: 40px;
	}

	.gallery-modal__close svg {
		width: 20px;
		height: 20px;
	}

	.gallery-modal__nav {
		width: 44px;
		height: 44px;
	}

	.gallery-modal__nav svg {
		width: 20px;
		height: 20px;
	}

	.gallery-modal__nav--prev {
		left: 10px;
	}

	.gallery-modal__nav--next {
		right: 10px;
	}

	.gallery-modal__caption {
		font-size: 14px;
		margin-top: 15px;
	}
}

