/* ND Home Image Popup */
html.ndhp-lock {
	overflow: hidden !important;
	scroll-behavior: auto !important;
}

.ndhp {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 2147483000;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
	opacity: 0;
	visibility: hidden;
	overscroll-behavior: contain;
	transition: opacity .25s ease, visibility 0s linear .25s;
}

.ndhp[hidden] {
	display: none !important;
}

.ndhp.is-open {
	opacity: 1;
	visibility: visible;
	transition: opacity .25s ease, visibility 0s;
}

.ndhp__overlay {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: rgba(0, 0, 0, .78);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

.ndhp__overlay[data-ndhp-close] {
	cursor: pointer;
}

.ndhp__dialog {
	position: relative;
	display: flex;
	max-width: min(560px, 100%);
	max-height: 100%;
	outline: none;
	transform: translateY(12px) scale(.97);
	transition: transform .25s ease;
}

.ndhp.is-open .ndhp__dialog {
	transform: none;
}

.ndhp__media {
	display: block;
	line-height: 0;
	border-radius: 10px;
	overflow: hidden;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
}

.ndhp__media:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 3px;
}

.ndhp .ndhp__img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100vh - 48px);
	max-height: calc(100dvh - 48px);
	margin: 0;
	object-fit: contain;
}

/* Close button – hard reset so theme button styles don't leak in */
.ndhp .ndhp__close {
	position: absolute;
	top: -16px;
	right: -16px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 2px solid #fff;
	border-radius: 50%;
	background: #111;
	color: #fff;
	box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
	font: inherit;
	line-height: 1;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
	transition: transform .15s ease, background-color .15s ease;
}

.ndhp .ndhp__close:hover {
	background: #000;
	transform: rotate(90deg);
}

.ndhp .ndhp__close:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
}

.ndhp .ndhp__close svg {
	display: block;
	pointer-events: none;
}

@media (max-width: 600px) {
	.ndhp {
		padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
	}

	.ndhp .ndhp__img {
		max-height: calc(100vh - 32px);
		max-height: calc(100dvh - 32px);
	}

	/* Keep the button inside the viewport on small screens */
	.ndhp .ndhp__close {
		top: 8px;
		right: 8px;
		width: 36px;
		height: 36px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.ndhp,
	.ndhp.is-open,
	.ndhp__dialog,
	.ndhp .ndhp__close {
		transition: none;
	}

	.ndhp__dialog {
		transform: none;
	}
}
