/**
 * Portfolio Gallery initial layout.
 */

.pgallery {
	--pgallery-desktop-height: 380px;
	--pgallery-gap: 10px;
	--pgallery-radius: 10px;
	position: relative;
	width: 100%;
}

.pgallery__layout {
	display: grid;
	grid-template-columns: repeat(12, minmax(0, 1fr));
	grid-template-rows: repeat(2, minmax(0, 1fr));
	gap: var(--pgallery-gap);
	height: var(--pgallery-desktop-height);
	margin: 0;
	overflow: hidden;
	border-radius: var(--pgallery-radius);
	background: #fff;
}

.pgallery__item {
	position: relative;
	min-width: 0;
	min-height: 0;
	overflow: hidden;
	background: #e9eaec;
}

.pgallery__hero {
	grid-column: 1 / 7;
	grid-row: 1 / 3;
}

.pgallery__layout--count-1 .pgallery__hero {
	grid-column: 1 / -1;
}

.pgallery__layout--count-2 .pgallery__hero {
	grid-column: 1 / 9;
}

.pgallery__layout--count-2 .pgallery__item:nth-child(2) {
	grid-column: 9 / 13;
	grid-row: 1 / 3;
}

.pgallery__layout--count-3 .pgallery__hero {
	grid-column: 1 / 8;
}

.pgallery__layout--count-3 .pgallery__item:nth-child(2) {
	grid-column: 8 / 13;
	grid-row: 1;
}

.pgallery__layout--count-3 .pgallery__item:nth-child(3) {
	grid-column: 8 / 13;
	grid-row: 2;
}

.pgallery__layout--count-4 .pgallery__item:nth-child(2) {
	grid-column: 7 / 13;
	grid-row: 1;
}

.pgallery__layout--count-4 .pgallery__item:nth-child(3) {
	grid-column: 7 / 10;
	grid-row: 2;
}

.pgallery__layout--count-4 .pgallery__item:nth-child(4) {
	grid-column: 10 / 13;
	grid-row: 2;
}

.pgallery__layout--count-5 .pgallery__item:nth-child(2),
.pgallery__layout--count-6 .pgallery__item:nth-child(2) {
	grid-column: 7 / 10;
	grid-row: 1;
}

.pgallery__layout--count-5 .pgallery__item:nth-child(3),
.pgallery__layout--count-6 .pgallery__item:nth-child(3) {
	grid-column: 10 / 13;
	grid-row: 1;
}

.pgallery__layout--count-5 .pgallery__item:nth-child(4) {
	grid-column: 7 / 10;
	grid-row: 2;
}

.pgallery__layout--count-5 .pgallery__item:nth-child(5) {
	grid-column: 10 / 13;
	grid-row: 2;
}

.pgallery__layout--count-6 .pgallery__item:nth-child(4) {
	grid-column: 7 / 9;
	grid-row: 2;
}

.pgallery__layout--count-6 .pgallery__item:nth-child(5) {
	grid-column: 9 / 11;
	grid-row: 2;
}

.pgallery__layout--count-6 .pgallery__item:nth-child(6) {
	grid-column: 11 / 13;
	grid-row: 2;
}

.pgallery__layout--dense {
	grid-template-columns: repeat(4, minmax(0, 1fr));
	grid-template-rows: repeat(3, minmax(0, 1fr));
}

.pgallery__layout--dense .pgallery__hero {
	grid-column: span 2;
	grid-row: span 2;
}

.pgallery__trigger,
.pgallery__media {
	position: relative;
	display: block;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: 0;
	overflow: hidden;
	border: 0;
	border-radius: 0;
	background: transparent;
}

.pgallery__trigger {
	cursor: pointer;
}

.pgallery__trigger:focus-visible {
	outline: 3px solid #1769e0;
	outline-offset: -4px;
}

.pgallery__image {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
	transition: transform 220ms ease;
}

@media (hover: hover) {
	.pgallery__trigger:hover .pgallery__image {
		transform: scale(1.025);
	}
}

.pgallery__overlay {
	position: absolute;
	inset: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 4px;
	padding: 20px;
	background: rgba(0, 0, 0, 0.58);
	color: #fff;
	text-align: center;
}

.pgallery__overlay-text {
	font-size: clamp(16px, 1.8vw, 24px);
	font-weight: 700;
	line-height: 1.2;
}

.pgallery__overlay-count {
	font-size: clamp(13px, 1.2vw, 17px);
	font-weight: 500;
	line-height: 1.3;
}

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

@media (max-width: 1024px) {
	.pgallery__layout,
	.pgallery__layout--dense {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		grid-template-rows: none;
		grid-auto-rows: 280px;
		height: auto;
	}

	.pgallery__layout .pgallery__item {
		grid-column: auto;
		grid-row: auto;
	}

	.pgallery__layout .pgallery__hero {
		grid-column: 1 / -1;
		grid-row: auto;
		height: 360px;
	}
}

@media (max-width: 767px) {
	.pgallery__layout,
	.pgallery__layout--dense {
		display: flex;
		gap: var(--pgallery-gap);
		height: auto;
		overflow-x: auto;
		overflow-y: hidden;
		padding-bottom: 6px;
		border-radius: 0;
		scroll-snap-type: x mandatory;
		scroll-padding-inline: 0;
		overscroll-behavior-inline: contain;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: thin;
	}

	.pgallery__layout .pgallery__item,
	.pgallery__layout .pgallery__hero {
		flex: 0 0 min(82vw, 88%);
		height: clamp(240px, 65vw, 420px);
		border-radius: var(--pgallery-radius);
		scroll-snap-align: start;
	}

	.pgallery__layout--count-1 .pgallery__item {
		flex-basis: 100%;
	}

	.pgallery__overlay-text {
		font-size: 20px;
	}

	.pgallery__overlay-count {
		font-size: 15px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pgallery__image {
		transition: none;
	}
}
