/**
 * Frontend gallery styles for Impact Gallery Pro
 *
 * @package ImpactGalleryPro
 */

/* ==========================================================================
   Base Gallery Styles
   ========================================================================== */

.igp-gallery {
	margin: 2rem 0;
	clear: both;
}

.igp-gallery-items {
	margin: 0;
	padding: 0;
	list-style: none;
}

.igp-gallery-item {
	position: relative;
	overflow: hidden;
	background: #f5f5f5;
}

/* Override backgrounds for masonry - no colored backgrounds that would show as gaps */
.igp-layout-masonry .igp-gallery-item,
.igp-layout-masonry .igp-item-image,
.igp-layout-masonry .igp-item-video,
.igp-layout-masonry .igp-gallery-item a {
	background: none !important;
}

.igp-gallery-item a {
	display: block;
	position: relative;
	text-decoration: none;
}

.igp-item-image,
.igp-item-video {
	position: relative;
	overflow: hidden;
	background: #000;
	display: flex;
	align-items: flex-start;
}


.igp-gallery-image,
.igp-video-thumbnail {
	display: block;
	width: 100%;
	height: auto;
	transition: transform 0.3s ease, opacity 0.3s ease;
}

.igp-gallery-item a:hover .igp-gallery-image,
.igp-gallery-item a:hover .igp-video-thumbnail {
	transform: scale(1.05);
}

.igp-gallery-item a:focus {
	outline: 3px solid #0073aa;
	outline-offset: 3px;
}

/* ==========================================================================
   Caption Styles
   ========================================================================== */

.igp-caption-overlay {
	position: absolute;
	bottom: 0;
	left: 0;
	right: 0;
	background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
	padding: 20px 15px 15px;
	transform: translateY(100%);
	transition: transform 0.3s ease;
	color: #fff;
}

.igp-gallery-item a:hover .igp-caption-overlay,
.igp-gallery-item a:focus .igp-caption-overlay {
	transform: translateY(0);
}

.igp-caption-content {
	font-size: 14px;
	line-height: 1.5;
}

/* ==========================================================================
   Play Button for Videos
   ========================================================================== */

.igp-play-button {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	transition: transform 0.3s ease, opacity 0.3s ease;
	opacity: 0.9;
	pointer-events: none;
}

.igp-gallery-item a:hover .igp-play-button,
.igp-gallery-item a:focus .igp-play-button {
	transform: translate(-50%, -50%) scale(1.1);
	opacity: 1;
}

/* ==========================================================================
   Grid Layout
   ========================================================================== */

.igp-layout-grid .igp-gallery-items {
	display: grid;
	gap: 20px;
	grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

.igp-layout-grid[data-columns="2"] .igp-gallery-items {
	grid-template-columns: repeat(2, 1fr);
}

.igp-layout-grid[data-columns="3"] .igp-gallery-items {
	grid-template-columns: repeat(3, 1fr);
}

.igp-layout-grid[data-columns="4"] .igp-gallery-items {
	grid-template-columns: repeat(4, 1fr);
}

.igp-layout-grid[data-columns="5"] .igp-gallery-items {
	grid-template-columns: repeat(5, 1fr);
}

.igp-layout-grid[data-columns="6"] .igp-gallery-items {
	grid-template-columns: repeat(6, 1fr);
}

.igp-layout-grid .igp-gallery-item {
	border-radius: 8px;
	overflow: hidden;
}

/* ==========================================================================
   Masonry Layout (Using Masonry.js)
   ========================================================================== */

.igp-layout-masonry .igp-masonry-grid {
	/* Masonry.js handles all positioning */
	position: relative;
}

.igp-layout-masonry .igp-gallery-item {
	width: calc(33.333% - 14px); /* 3 columns with 20px gutter */
	margin-bottom: 20px;
	border-radius: 8px;
	overflow: hidden;
	display: block;
	/* Masonry.js will position items absolutely */
}

/* Size variations for visual interest */
.igp-layout-masonry .igp-gallery-item.igp-size-wide {
	width: calc(66.666% - 7px); /* 2 columns span */
}

.igp-layout-masonry .igp-gallery-item.igp-size-small {
	width: calc(33.333% - 14px); /* Standard 1 column */
}

.igp-layout-masonry .igp-gallery-item a {
	display: block;
	line-height: 0;
}

.igp-layout-masonry .igp-gallery-item img {
	display: block;
	width: 100%;
	height: auto;
	vertical-align: bottom;
}

.igp-layout-masonry .igp-item-image,
.igp-layout-masonry .igp-item-video {
	display: block;
	line-height: 0;
	font-size: 0;
}

/* Responsive columns for masonry */
@media screen and (max-width: 1024px) {
	.igp-layout-masonry .igp-gallery-item {
		width: calc(50% - 10px); /* 2 columns */
	}

	.igp-layout-masonry .igp-gallery-item.igp-size-wide {
		width: 100%; /* Full width on tablet */
	}
}

@media screen and (max-width: 768px) {
	.igp-layout-masonry .igp-gallery-item,
	.igp-layout-masonry .igp-gallery-item.igp-size-wide,
	.igp-layout-masonry .igp-gallery-item.igp-size-small {
		width: 100%; /* 1 column on mobile - all same width */
		margin-bottom: 20px;
	}
}

/* ==========================================================================
   Carousel Layout
   ========================================================================== */

.igp-layout-carousel {
	position: relative;
}

.igp-layout-carousel .igp-swiper {
	padding: 0 50px;
}

.igp-layout-carousel .swiper-slide {
	height: auto;
}

.igp-layout-carousel .igp-gallery-item {
	border-radius: 8px;
	overflow: hidden;
	height: 100%;
}

.igp-carousel-caption {
	padding: 15px;
	background: #fff;
	text-align: center;
	font-size: 14px;
	color: #333;
	border-top: 1px solid #e0e0e0;
}

.igp-layout-carousel .swiper-button-prev,
.igp-layout-carousel .swiper-button-next {
	width: 44px;
	height: 44px;
	background: rgba(0, 0, 0, 0.5);
	border-radius: 50%;
	color: #fff;
}

.igp-layout-carousel .swiper-button-prev:after,
.igp-layout-carousel .swiper-button-next:after {
	font-size: 20px;
}

.igp-layout-carousel .swiper-button-prev:hover,
.igp-layout-carousel .swiper-button-next:hover {
	background: rgba(0, 0, 0, 0.7);
}

.igp-layout-carousel .swiper-pagination-bullet {
	width: 12px;
	height: 12px;
	background: #ccc;
	opacity: 1;
}

.igp-layout-carousel .swiper-pagination-bullet-active {
	background: #0073aa;
}

/* ==========================================================================
   Cards Layout
   ========================================================================== */

.igp-layout-cards .igp-filter-buttons {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	margin-bottom: 30px;
	justify-content: center;
}

.igp-filter-btn {
	padding: 10px 20px;
	border: 2px solid #0073aa;
	background: #fff;
	color: #0073aa;
	border-radius: 25px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: all 0.3s ease;
	outline: none;
}

.igp-filter-btn:hover,
.igp-filter-btn:focus {
	background: #0073aa;
	color: #fff;
	transform: translateY(-2px);
	box-shadow: 0 4px 8px rgba(0, 115, 170, 0.2);
}

.igp-filter-btn.active {
	background: #0073aa;
	color: #fff;
}

.igp-filter-btn:focus {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

.igp-layout-cards .igp-gallery-items {
	display: grid;
	gap: 30px;
	grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

.igp-layout-cards[data-columns="2"] .igp-gallery-items {
	grid-template-columns: repeat(2, 1fr);
}

.igp-layout-cards[data-columns="3"] .igp-gallery-items {
	grid-template-columns: repeat(3, 1fr);
}

.igp-layout-cards[data-columns="4"] .igp-gallery-items {
	grid-template-columns: repeat(4, 1fr);
}

.igp-layout-cards .igp-card {
	background: #fff;
	border-radius: 12px;
	overflow: hidden;
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
	transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.igp-layout-cards .igp-card:hover {
	transform: translateY(-5px);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.igp-layout-cards .igp-card-media {
	position: relative;
	overflow: hidden;
	background: #000;
	aspect-ratio: 16 / 9;
}

.igp-layout-cards .igp-card-image {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.igp-layout-cards .igp-card-content {
	padding: 20px;
}

.igp-layout-cards .igp-card-title {
	margin: 0 0 10px;
	font-size: 18px;
	font-weight: 600;
	color: #333;
	line-height: 1.4;
}

.igp-layout-cards .igp-card-caption {
	font-size: 14px;
	color: #666;
	line-height: 1.6;
}

.igp-layout-cards .igp-gallery-item.hidden {
	display: none;
}

.igp-no-results {
	text-align: center;
	padding: 40px 20px;
	color: #666;
	font-size: 16px;
	grid-column: 1 / -1;
}

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

/* Tablets (portrait and landscape) */
@media screen and (max-width: 1024px) {
	.igp-layout-grid[data-columns="5"] .igp-gallery-items,
	.igp-layout-grid[data-columns="6"] .igp-gallery-items {
		grid-template-columns: repeat(3, 1fr);
	}

	.igp-layout-cards[data-columns="4"] .igp-gallery-items {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media screen and (max-width: 768px) {
	.igp-layout-grid[data-columns="4"] .igp-gallery-items,
	.igp-layout-grid[data-columns="5"] .igp-gallery-items,
	.igp-layout-grid[data-columns="6"] .igp-gallery-items {
		grid-template-columns: repeat(2, 1fr);
	}

	.igp-layout-cards[data-columns="3"] .igp-gallery-items,
	.igp-layout-cards[data-columns="4"] .igp-gallery-items {
		grid-template-columns: repeat(2, 1fr);
	}

	.igp-layout-carousel .igp-swiper {
		padding: 0 40px;
	}

	.igp-layout-carousel .swiper-button-prev,
	.igp-layout-carousel .swiper-button-next {
		width: 36px;
		height: 36px;
	}

	.igp-layout-carousel .swiper-button-prev:after,
	.igp-layout-carousel .swiper-button-next:after {
		font-size: 16px;
	}
}

/* Mobile phones */
@media screen and (max-width: 480px) {
	.igp-gallery {
		margin: 1.5rem 0;
	}

	.igp-layout-grid .igp-gallery-items,
	.igp-layout-masonry .igp-masonry-grid,
	.igp-layout-cards .igp-gallery-items {
		grid-template-columns: 1fr;
		gap: 15px;
	}

	.igp-layout-carousel .igp-swiper {
		padding: 0 30px;
	}

	.igp-layout-carousel .swiper-button-prev,
	.igp-layout-carousel .swiper-button-next {
		width: 32px;
		height: 32px;
	}

	.igp-layout-carousel .swiper-button-prev:after,
	.igp-layout-carousel .swiper-button-next:after {
		font-size: 14px;
	}

	.igp-filter-buttons {
		gap: 8px;
		margin-bottom: 20px;
	}

	.igp-filter-btn {
		padding: 8px 16px;
		font-size: 13px;
	}

	.igp-caption-content {
		font-size: 13px;
	}
}

/* ==========================================================================
   Loading State
   ========================================================================== */

.igp-gallery.loading {
	opacity: 0.6;
	pointer-events: none;
	min-height: 200px;
	position: relative;
}

.igp-gallery.loading::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 40px;
	height: 40px;
	margin: -20px 0 0 -20px;
	border: 4px solid #f3f3f3;
	border-top: 4px solid #0073aa;
	border-radius: 50%;
	animation: igp-spin 1s linear infinite;
}

@keyframes igp-spin {
	0% { transform: rotate(0deg); }
	100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

.igp-gallery:focus-visible {
	outline: 2px solid #0073aa;
	outline-offset: 2px;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border-width: 0;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
	.igp-filter-buttons,
	.igp-play-button,
	.swiper-button-prev,
	.swiper-button-next,
	.swiper-pagination {
		display: none;
	}

	.igp-gallery-item {
		break-inside: avoid;
		page-break-inside: avoid;
	}
}

/* ==========================================================================
   Dark Mode Support
   ========================================================================== */

@media (prefers-color-scheme: dark) {
	.igp-layout-cards .igp-card {
		background: #1e1e1e;
		box-shadow: 0 2px 12px rgba(255, 255, 255, 0.05);
	}

	.igp-layout-cards .igp-card-title {
		color: #f0f0f0;
	}

	.igp-layout-cards .igp-card-caption {
		color: #b0b0b0;
	}

	.igp-filter-btn {
		background: #1e1e1e;
		border-color: #0073aa;
		color: #0073aa;
	}

	.igp-filter-btn.active,
	.igp-filter-btn:hover,
	.igp-filter-btn:focus {
		background: #0073aa;
		color: #fff;
	}

	.igp-carousel-caption {
		background: #1e1e1e;
		color: #f0f0f0;
		border-top-color: #333;
	}
}
