/* ============================================================
   公用图片预览灯箱（配合 /js/imagePreview.js 使用）
   类名统一 ip- 前缀，避免与站点样式冲突
   ============================================================ */

/* 绑定了预览的图片：提示可点击放大 */
img.ip-target {
	cursor: zoom-in;
	-webkit-tap-highlight-color: transparent;
}

/* 预览打开时锁定背景滚动 */
html.ip-lock,
body.ip-lock {
	overflow: hidden;
}

/* 遮罩层：fixed + inset 定位，不依赖 100vh，规避移动端地址栏问题 */
.ip-overlay {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	flex-direction: column;
	background: rgba(0, 0, 0, .92);
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease, visibility .25s ease;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
	font-family: "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}

.ip-overlay.ip-open {
	opacity: 1;
	visibility: visible;
}

/* 图片舞台：flex 居中，touch-action:none 防止浏览器接管手势 */
.ip-stage {
	position: relative;
	flex: 1 1 auto;
	min-height: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	touch-action: none;
	padding: calc(16px + env(safe-area-inset-top)) calc(16px + env(safe-area-inset-right)) 0 calc(16px + env(safe-area-inset-left));
}

.ip-img {
	display: block;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 8px 40px rgba(0, 0, 0, .55);
	will-change: transform;
	-webkit-touch-callout: none;
}

.ip-img.ip-zoomed {
	cursor: grab;
}

/* 加载中转圈 */
.ip-stage.ip-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba(255, 255, 255, .25);
	border-top-color: #fff;
	border-radius: 50%;
	animation: ip-spin .8s linear infinite;
}

@keyframes ip-spin {
	to {
		transform: rotate(360deg);
	}
}

/* 加载失败 */
.ip-stage.ip-error::after {
	content: "图片加载失败";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	color: rgba(255, 255, 255, .75);
	font-size: 15px;
	letter-spacing: .05em;
}

.ip-stage.ip-error .ip-img {
	display: none;
}

/* 控制按钮（关闭/上一张/下一张），触控热区不小于 44px */
.ip-btn {
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(30, 30, 30, .55);
	color: #fff;
	font-size: 26px;
	line-height: 1;
	font-family: Arial, sans-serif;
	cursor: pointer;
	touch-action: manipulation;
	-webkit-tap-highlight-color: transparent;
	transition: background .2s ease;
}

.ip-btn:hover {
	background: rgba(0, 0, 0, .8);
}

.ip-close {
	top: calc(14px + env(safe-area-inset-top));
	right: calc(14px + env(safe-area-inset-right));
}

.ip-prev {
	left: 12px;
	top: 50%;
	transform: translateY(-50%);
}

.ip-next {
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
}

/* 只有一张图时隐藏切换按钮 */
.ip-overlay.ip-single .ip-prev,
.ip-overlay.ip-single .ip-next {
	display: none;
}

/* 底部标题 + 计数 */
.ip-caption {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 14px;
	min-height: 46px;
	padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
	background: rgba(0, 0, 0, .45);
}

.ip-caption-text {
	max-width: 70%;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	color: rgba(255, 255, 255, .9);
	font-size: 14px;
	line-height: 1.6;
}

.ip-counter {
	color: rgba(255, 255, 255, .5);
	font-size: 13px;
	line-height: 1.6;
}

/* 窄屏：按钮收窄贴边，标题整行显示 */
@media (max-width: 768px) {
	.ip-stage {
		padding-top: calc(12px + env(safe-area-inset-top));
	}

	.ip-close {
		top: calc(10px + env(safe-area-inset-top));
		right: calc(10px + env(safe-area-inset-right));
	}

	.ip-prev {
		left: 4px;
	}

	.ip-next {
		right: 4px;
	}

	.ip-caption {
		flex-direction: column;
		gap: 2px;
		min-height: 40px;
		padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
	}

	.ip-caption-text {
		max-width: 92%;
		font-size: 13px;
	}
}
