/**
 * Portfolio Gallery fullscreen modal and PhotoSwipe additions.
 */

body.pgallery-modal-open {
	overflow: hidden;
}

.pgallery-modal[hidden] {
	display: none;
}

.pgallery-modal {
	position: fixed;
	inset: 0;
	z-index: 999990;
	background: #fff;
	color: #1a1a1a;
	opacity: 0;
	visibility: hidden;
	transition: opacity 180ms ease, visibility 180ms ease;
}

.pgallery-modal.is-open {
	opacity: 1;
	visibility: visible;
}

.pgallery-modal__body {
	display: grid;
	grid-template-columns: 320px minmax(0, 1fr);
	width: 100%;
	height: 100vh;
	height: 100dvh;
	overflow: auto;
	overscroll-behavior: contain;
	background: #fff;
}

.pgallery-modal__close {
	position: fixed;
	top: 18px;
	right: 22px;
	z-index: 999995;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid #d8d8d8;
	border-radius: 999px;
	background: rgba(255, 255, 255, 0.96);
	color: #111;
	font: inherit;
	font-size: 32px;
	line-height: 1;
	cursor: pointer;
	box-shadow: 0 3px 18px rgba(0, 0, 0, 0.12);
}

.pgallery-modal__close:hover {
	background: #f1f2f4;
}

.pgallery-modal__close:focus-visible,
.pgallery-modal__nav-button:focus-visible,
.pgallery-modal__image-link:focus-visible {
	outline: 3px solid #1769e0;
	outline-offset: 3px;
}

.pgallery-modal__sidebar {
	position: sticky;
	top: 0;
	align-self: start;
	height: 100vh;
	height: 100dvh;
	padding: 32px 22px;
	overflow-y: auto;
	border-right: 1px solid #e4e6e8;
	background: #fff;
}

.pgallery-modal__nav-list {
	display: flex;
	flex-direction: column;
	gap: 4px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.pgallery-modal__nav-button {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	width: 100%;
	padding: 12px 14px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: #242424;
	font: inherit;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.4;
	text-align: left;
	cursor: pointer;
}

.pgallery-modal__nav-button:hover {
	background: #f3f5f7;
}

.pgallery-modal__nav-button.is-active {
	background: #eaf2ff;
	color: #004cb8;
}

.pgallery-modal__nav-count {
	color: #616a73;
	font-weight: 500;
}

.pgallery-modal__nav-button.is-active .pgallery-modal__nav-count {
	color: currentColor;
}

.pgallery-modal__content {
	min-width: 0;
	padding: 76px clamp(24px, 4vw, 64px) 80px;
}

.pgallery-modal__section {
	content-visibility: auto;
	contain-intrinsic-size: 900px;
	scroll-margin-top: 24px;
}

.pgallery-modal__section + .pgallery-modal__section {
	margin-top: 64px;
	padding-top: 4px;
	border-top: 1px solid #eceef0;
}

.pgallery-modal__heading {
	margin: 0 0 22px;
	color: #161616;
	font-size: clamp(24px, 2.5vw, 38px);
	font-weight: 750;
	line-height: 1.15;
}

.pgallery-modal__images {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 14px;
}

.pgallery-modal__figure {
	position: relative;
	min-width: 0;
	margin: 0;
	overflow: hidden;
	border-radius: 10px;
	background: #eef0f2;
	aspect-ratio: 4 / 3;
}

.pgallery-modal__image-link {
	display: block;
	width: 100%;
	height: 100%;
	color: inherit;
	text-decoration: none;
}

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

@media (hover: hover) {
	.pgallery-modal__image-link:hover .pgallery-modal__image {
		transform: scale(1.02);
		filter: brightness(0.94);
	}
}

.pswp__custom-caption {
	position: absolute;
	left: 50%;
	bottom: 18px;
	z-index: 10;
	width: calc(100% - 32px);
	max-width: 720px;
	padding: 10px 14px;
	border-radius: 8px;
	background: rgba(0, 0, 0, 0.66);
	color: #fff;
	font-size: 15px;
	line-height: 1.45;
	text-align: center;
	transform: translateX(-50%);
	pointer-events: none;
}

.pswp__custom-caption[hidden] {
	display: none;
}

@media (max-width: 1024px) {
	.pgallery-modal__body {
		grid-template-columns: 240px minmax(0, 1fr);
	}

	.pgallery-modal__sidebar {
		padding: 28px 16px;
	}

	.pgallery-modal__images {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@media (max-width: 767px) {
	.pgallery-modal__body {
		display: block;
	}

	.pgallery-modal__close {
		top: 10px;
		right: 12px;
		width: 40px;
		height: 40px;
		font-size: 29px;
	}

	.pgallery-modal__sidebar {
		position: sticky;
		top: 0;
		z-index: 3;
		height: auto;
		padding: 12px 58px 12px 12px;
		overflow: hidden;
		border-right: 0;
		border-bottom: 1px solid #e4e6e8;
		box-shadow: 0 4px 14px rgba(0, 0, 0, 0.06);
	}

	.pgallery-modal__nav-list {
		flex-direction: row;
		gap: 8px;
		overflow-x: auto;
		padding-bottom: 2px;
		scrollbar-width: thin;
	}

	.pgallery-modal__nav-item {
		flex: 0 0 auto;
	}

	.pgallery-modal__nav-button {
		gap: 6px;
		width: auto;
		padding: 9px 12px;
		white-space: nowrap;
	}

	.pgallery-modal__content {
		padding: 32px 14px 56px;
	}

	.pgallery-modal__section {
		scroll-margin-top: 78px;
	}

	.pgallery-modal__section + .pgallery-modal__section {
		margin-top: 46px;
	}

	.pgallery-modal__heading {
		margin-bottom: 16px;
		font-size: 26px;
	}

	.pgallery-modal__images {
		grid-template-columns: 1fr;
		gap: 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pgallery-modal,
	.pgallery-modal__image {
		transition: none;
	}
}
