/* AT Image Popup – frontend */
.atip-overlay {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 2147483000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 28px;
	box-sizing: border-box;
	background: rgba(0, 0, 0, 0.55);
	opacity: 0;
	transition: opacity 0.25s ease;
	-webkit-tap-highlight-color: transparent;
	overscroll-behavior: contain;
}
.atip-overlay[hidden] {
	display: none !important;
}
.atip-overlay.atip-open {
	opacity: 1;
}

.atip-overlay *,
.atip-overlay *::before,
.atip-overlay *::after {
	box-sizing: border-box;
}

.atip-box {
	position: relative;
	display: block;
	flex: 0 0 auto;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	padding: 0;
	line-height: 0;
	transform: scale(0.95);
	transition: transform 0.25s ease;
}
.atip-open .atip-box {
	transform: none;
}

.atip-link {
	display: block;
	line-height: 0;
	border: 0 !important;
	outline-offset: 3px;
}

/* Ảnh: không bao giờ tràn khung, luôn giữ đúng tỉ lệ */
.atip-overlay .atip-img {
	display: block !important;
	width: auto;
	height: auto !important;
	max-width: min(var(--atip-max-w, 500px), calc(100vw - 56px)) !important;
	max-height: calc(100vh - 56px) !important;
	max-height: calc(100dvh - 56px) !important;
	object-fit: contain;
	margin: 0 !important;
	padding: 0 !important;
	border: 0 !important;
	border-radius: 8px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35);
	background: transparent;
	opacity: 1 !important;
	visibility: visible !important;
}

/* Nút đóng – nằm ở góc trên phải của ảnh */
.atip-overlay .atip-close {
	position: absolute;
	top: -14px;
	right: -14px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 2px solid #fff;
	border-radius: 50%;
	background: #ff0000;
	color: #fff;
	font: inherit;
	line-height: 1;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
	transition: background-color 0.15s ease, transform 0.15s ease;
}
.atip-overlay .atip-close:hover,
.atip-overlay .atip-close:focus-visible {
	background: #cc0000;
	color: #fff;
	transform: scale(1.06);
}
.atip-overlay .atip-close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}
.atip-overlay .atip-close svg {
	display: block;
	width: 18px;
	height: 18px;
	pointer-events: none;
}

@media (max-width: 600px) {
	.atip-overlay {
		padding: 24px 20px;
	}
	.atip-overlay .atip-img {
		max-width: min(var(--atip-max-w, 500px), calc(100vw - 40px)) !important;
		max-height: calc(100vh - 48px) !important;
		max-height: calc(100dvh - 48px) !important;
	}
	.atip-overlay .atip-close {
		top: -12px;
		right: -12px;
		width: 34px;
		height: 34px;
	}
	.atip-overlay .atip-close svg {
		width: 16px;
		height: 16px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.atip-overlay,
	.atip-box {
		transition: none;
	}
}
