.dp-gallery {
	--dp-gallery-cols: 4;
	--dp-gallery-gap: 1rem;
	display: grid;
	grid-template-columns: repeat(1, minmax(0, 1fr));
	gap: var(--dp-gallery-gap);
	margin: 0 0 2rem;
}

@media (min-width: 768px) {
	.dp-gallery {
		grid-template-columns: repeat(min(3, var(--dp-gallery-cols)), minmax(0, 1fr));
	}
}

@media (min-width: 1024px) {
	.dp-gallery {
		grid-template-columns: repeat(var(--dp-gallery-cols), minmax(0, 1fr));
	}
}

.dp-gallery__item {
	position: relative;
	display: block;
	overflow: hidden;
	border: 1px solid #d9d9d9;
	line-height: 0;
	background: #f5f5f5;
	aspect-ratio: 1 / 1;
	text-decoration: none;
}

.dp-gallery__item:focus-visible {
	outline: 2px solid var(--dp-color-primary, #e44003);
	outline-offset: 2px;
}

.dp-gallery__item img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
}

.dp-gallery__item::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
	background: rgba(0, 0, 0, 0);
	transition: background-color 0.2s ease;
	pointer-events: none;
}

.dp-gallery__item:hover::before,
.dp-gallery__item:focus-visible::before {
	background: rgba(0, 0, 0, 0.35);
}

.dp-gallery__item::after {
	content: "";
	position: absolute;
	right: 0.5rem;
	bottom: 0.5rem;
	z-index: 2;
	width: 2.25rem;
	height: 2.25rem;
	border-radius: 999px;
	background-color: rgba(107, 114, 128, 0.45);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-3.5-3.5'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 1.25rem 1.25rem;
	pointer-events: none;
}

/* Lightbox */
.dp-gallery-lb {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.92);
	padding: 1rem;
	box-sizing: border-box;
}

.dp-gallery-lb[hidden] {
	display: none !important;
}

.dp-gallery-lb__figure {
	margin: 0;
	max-width: min(96vw, 1400px);
	max-height: 90vh;
	display: flex;
	align-items: center;
	justify-content: center;
}

.dp-gallery-lb__img {
	display: block;
	max-width: 100%;
	max-height: 90vh;
	width: auto;
	height: auto;
	object-fit: contain;
}

.dp-gallery-lb__btn {
	appearance: none;
	border: 0;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	width: 44px;
	height: 44px;
	border-radius: 999px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 1.5rem;
	line-height: 1;
	padding: 0;
	transition: background-color 0.15s ease;
}

.dp-gallery-lb__btn:hover,
.dp-gallery-lb__btn:focus-visible {
	background: rgba(255, 255, 255, 0.22);
	outline: none;
}

.dp-gallery-lb__btn:focus-visible {
	outline: 2px solid var(--dp-color-primary, #e44003);
	outline-offset: 2px;
}

.dp-gallery-lb__close {
	position: absolute;
	top: max(0.75rem, env(safe-area-inset-top));
	right: max(0.75rem, env(safe-area-inset-right));
	z-index: 2;
	font-size: 1.75rem;
}

.dp-gallery-lb__prev,
.dp-gallery-lb__next {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
}

.dp-gallery-lb__prev {
	left: max(0.5rem, env(safe-area-inset-left));
}

.dp-gallery-lb__next {
	right: max(0.5rem, env(safe-area-inset-right));
}

.dp-gallery-lb__counter {
	position: absolute;
	bottom: max(0.75rem, env(safe-area-inset-bottom));
	left: 50%;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.85);
	font-size: 0.875rem;
	letter-spacing: 0.02em;
	pointer-events: none;
}

@media (max-width: 600px) {
	.dp-gallery-lb__prev,
	.dp-gallery-lb__next {
		top: auto;
		bottom: max(3.25rem, calc(env(safe-area-inset-bottom) + 2.5rem));
		transform: none;
	}
}
