/**
 * Instagram Gallery Widget styles.
 * Scoped under .igw-gallery to avoid theme collisions.
 */

/* Engagement counts — always-visible, bottom-right corner */
.igw-gallery__engagement {
	position: absolute;
	bottom: 8px;
	right: 8px;
	display: flex;
	align-items: center;
	gap: 10px;
	color: #fff;
	font-size: 12px;
	font-weight: 600;
	pointer-events: none;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}

.igw-gallery__engagement-item {
	display: flex;
	align-items: center;
	gap: 4px;
}

/* Title */
.igw-title-wrap {
	margin-bottom: 16px;
}

.igw-title {
	display: flex;
	align-items: center;
	gap: 0.4em;
	margin: 0;
	padding: 0;
	font-size: 1.5rem;
	font-weight: 700;
	line-height: 1.2;
}

.igw-title__icon {
	flex-shrink: 0;
	vertical-align: middle;
}

.igw-gallery {
	--igw-columns: 3;
	--igw-gap: 8px;
	--igw-aspect: 1 / 1;
	--igw-radius: 4px;
	display: grid;
	grid-template-columns: repeat(var(--igw-columns), minmax(0, 1fr));
	gap: var(--igw-gap);
	width: 100%;
}

.igw-gallery__item {
	position: relative;
	display: block;
	overflow: hidden;
	aspect-ratio: var(--igw-aspect);
	background: #f3f3f3;
	border-radius: var(--igw-radius);
	text-decoration: none;
	color: inherit;
	/* Reset button styles when rendered as <button> for carousels. */
	padding: 0;
	border: 0;
	cursor: pointer;
	font: inherit;
	width: 100%;
}

.igw-gallery__item--carousel,
.igw-gallery__item--lightbox {
	cursor: zoom-in;
}

.igw-gallery__badge {
	position: absolute;
	top: 8px;
	right: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	border-radius: 50%;
	pointer-events: none;
	z-index: 1;
}

.igw-gallery__badge svg {
	display: block;
}

.igw-gallery__image {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.4s ease;
}

.igw-gallery__item:hover .igw-gallery__image,
.igw-gallery__item:focus-visible .igw-gallery__image {
	transform: scale(1.04);
}

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

.igw-gallery__caption {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: flex-end;
	justify-content: flex-start;
	padding: 12px;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0) 50%);
	color: #fff;
	font-size: 13px;
	line-height: 1.4;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.igw-gallery__item:hover .igw-gallery__caption,
.igw-gallery__item:focus-visible .igw-gallery__caption {
	opacity: 1;
}

/* ------------------------------------------------------------------
   View variants
   ------------------------------------------------------------------ */

.igw-gallery--strip {
	display: flex;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-padding-inline: var(--igw-gap);
	scroll-snap-type: x mandatory;
}

.igw-gallery--strip .igw-gallery__item {
	flex: 0 0 clamp(140px, 22vw, 220px);
	scroll-snap-align: start;
}

.igw-gallery--featured .igw-gallery__item:first-child {
	min-height: 100%;
}

@media (min-width: 640px) {
	.igw-gallery--featured {
		grid-auto-flow: dense;
	}

	.igw-gallery--featured:not(.igw-gallery--columns-1) .igw-gallery__item:first-child {
		grid-column: span 2;
		grid-row: span 2;
	}
}

.igw-gallery--minimal .igw-gallery__item {
	overflow: visible;
	aspect-ratio: auto;
	background: transparent;
}

.igw-gallery--minimal .igw-gallery__image {
	height: auto;
	aspect-ratio: var(--igw-aspect);
	border-radius: var(--igw-radius);
	background: #f3f3f3;
}

.igw-gallery--minimal .igw-gallery__item:hover .igw-gallery__image,
.igw-gallery--minimal .igw-gallery__item:focus-visible .igw-gallery__image {
	transform: none;
}

.igw-gallery--minimal .igw-gallery__caption {
	position: static;
	inset: auto;
	display: block;
	padding: 8px 0 0;
	background: transparent;
	color: inherit;
	opacity: 1;
}

.igw-gallery--masonry {
	display: block;
	column-count: var(--igw-columns);
	column-gap: var(--igw-gap);
}

.igw-gallery--masonry .igw-gallery__item {
	display: block;
	overflow: hidden;
	aspect-ratio: auto;
	break-inside: avoid;
	margin-bottom: var(--igw-gap);
}

.igw-gallery--masonry .igw-gallery__image {
	height: auto;
	aspect-ratio: auto;
}

.igw-gallery--carousel {
	display: flex;
	overflow-x: auto;
	overflow-y: hidden;
	scroll-padding-inline: var(--igw-gap);
	scroll-snap-type: x mandatory;
}

.igw-gallery--carousel .igw-gallery__item {
	flex: 0 0 clamp(220px, 72vw, 420px);
	scroll-snap-align: start;
}

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

.igw-carousel__controls {
	display: flex;
	justify-content: flex-end;
	gap: 8px;
	margin-bottom: 10px;
}

.igw-carousel__nav {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 34px;
	height: 34px;
	border: 1px solid rgba(0, 0, 0, 0.16);
	border-radius: 50%;
	background: #fff;
	color: #111;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
	transition: background 0.2s ease, border-color 0.2s ease;
}

.igw-carousel__nav:hover,
.igw-carousel__nav:focus-visible {
	background: #f5f5f5;
	border-color: rgba(0, 0, 0, 0.32);
}

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

.igw-carousel__nav:disabled {
	cursor: default;
	opacity: 0.4;
}

.igw-carousel__dots {
	display: flex;
	justify-content: center;
	gap: 7px;
	margin-top: 10px;
}

.igw-carousel__dot {
	width: 8px;
	height: 8px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.28);
	cursor: pointer;
}

.igw-carousel__dot.is-active {
	background: rgba(0, 0, 0, 0.78);
}

.igw-placeholder {
	padding: 24px;
	background: #fafafa;
	border: 1px dashed #ccc;
	border-radius: 4px;
	color: #555;
	text-align: center;
	font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
	.igw-gallery__image,
	.igw-gallery__caption {
		transition: none;
	}
	.igw-gallery__item:hover .igw-gallery__image {
		transform: none;
	}
	.igw-carousel__nav {
		transition: none;
	}
}

@media (max-width: 768px) {
	.igw-gallery--columns-4,
	.igw-gallery--columns-5,
	.igw-gallery--columns-6 {
		--igw-columns: 3;
	}

	.igw-gallery--masonry.igw-gallery--columns-4,
	.igw-gallery--masonry.igw-gallery--columns-5,
	.igw-gallery--masonry.igw-gallery--columns-6 {
		column-count: 3;
	}
}

@media (max-width: 480px) {
	.igw-gallery--columns-3,
	.igw-gallery--columns-4,
	.igw-gallery--columns-5,
	.igw-gallery--columns-6 {
		--igw-columns: 2;
	}

	.igw-gallery--masonry.igw-gallery--columns-3,
	.igw-gallery--masonry.igw-gallery--columns-4,
	.igw-gallery--masonry.igw-gallery--columns-5,
	.igw-gallery--masonry.igw-gallery--columns-6 {
		column-count: 2;
	}
}

/* ------------------------------------------------------------------
   Lightbox / carousel slider
   ------------------------------------------------------------------ */

.igw-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: none;
	align-items: center;
	justify-content: center;
}

.igw-lightbox.is-open {
	display: flex;
}

body.igw-lightbox-open {
	overflow: hidden;
}

.igw-lightbox__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.85);
	cursor: pointer;
}

.igw-lightbox__stage {
	position: relative;
	width: min(92vw, 900px);
	max-height: 92vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	z-index: 1;
}

.igw-lightbox__media {
	width: 100%;
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
}

.igw-lightbox__image,
.igw-lightbox__video {
	max-width: 100%;
	max-height: 80vh;
	display: block;
	border-radius: 6px;
	background: #000;
}

.igw-lightbox__close,
.igw-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(255, 255, 255, 0.15);
	color: #fff;
	border: 0;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	font-size: 20px;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	transition: background 0.2s ease;
}

.igw-lightbox__close:hover,
.igw-lightbox__nav:hover {
	background: rgba(255, 255, 255, 0.3);
}

.igw-lightbox__close {
	top: 12px;
	right: 12px;
	transform: none;
	font-size: 28px;
	line-height: 1;
}

.igw-lightbox__nav--prev {
	left: -60px;
}

.igw-lightbox__nav--next {
	right: -60px;
}

.igw-lightbox__footer {
	margin-top: 14px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	width: 100%;
	color: #fff;
	font-size: 13px;
}

.igw-lightbox__counter {
	background: rgba(255, 255, 255, 0.15);
	padding: 4px 10px;
	border-radius: 999px;
}

.igw-lightbox__permalink {
	color: #fff;
	text-decoration: underline;
	font-weight: 500;
}

.igw-lightbox__permalink:hover {
	opacity: 0.85;
}

@media (max-width: 768px) {
	.igw-lightbox__nav--prev {
		left: 8px;
	}
	.igw-lightbox__nav--next {
		right: 8px;
	}
	.igw-lightbox__nav,
	.igw-lightbox__close {
		width: 38px;
		height: 38px;
	}
}
