/**
 * ImageViewer 样式 - 前台内容详情页图片查看器（PC / mobile 双端共用）
 * 依赖：r/cms/www/default/js/imgviewer.js（DOM 由 JS 动态构建）
 * 类名前缀 iv-，与站点既有样式完全隔离
 */

/* ---------- 遮罩与舞台 ---------- */

.iv-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 2147483000;
	background: rgba(8, 9, 12, 0.96);
	animation: iv-fade-in 0.24s ease both;
	overscroll-behavior: contain;
	-webkit-tap-highlight-color: transparent;
}

.iv-overlay.iv-closing {
	animation: iv-fade-out 0.2s ease both;
}

@keyframes iv-fade-in {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes iv-fade-out {
	from { opacity: 1; }
	to { opacity: 0; }
}

.iv-stage {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	overflow: hidden;
	/* 阻止浏览器默认手势（双击缩放页面 / 长按选择），由查看器接管 */
	touch-action: none;
	-webkit-touch-callout: none;
}

/* ---------- 图片画布 ---------- */

.iv-canvas {
	position: absolute;
	transform-origin: center center;
	will-change: transform;
	cursor: grab;
}

.iv-canvas:active {
	cursor: grabbing;
}

/* 平滑过渡：拖拽跟手时不加此类，松手回弹 / 旋转 / 切换时加上 */
.iv-canvas.iv-easing {
	transition: transform 0.28s cubic-bezier(0.22, 0.61, 0.36, 1), opacity 0.22s ease;
}

.iv-img {
	display: block;
	width: 100%;
	height: 100%;
	/* 原图完整分辨率呈现，由 transform 缩放；不做任何额外压缩 */
	image-rendering: -webkit-optimize-contrast;
	user-select: none;
	-webkit-user-select: none;
	-webkit-user-drag: none;
	pointer-events: none;   /* 手势统一由 stage 接管，避免 img 原生行为干扰 */
}

/* ---------- 加载与错误 ---------- */

.iv-loading {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	text-align: center;
	display: none;
	pointer-events: none;
}

.iv-loading.iv-show {
	display: block;
}

.iv-spinner {
	width: 44px;
	height: 44px;
	margin: 0 auto 12px;
	border: 3px solid rgba(255, 255, 255, 0.18);
	border-top-color: #fff;
	border-radius: 50%;
	animation: iv-spin 0.8s linear infinite;
}

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

.iv-loadtext {
	color: rgba(255, 255, 255, 0.75);
	font-size: 13px;
	letter-spacing: 2px;
}

.iv-error {
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%);
	text-align: center;
	display: none;
	pointer-events: none;
	color: #fff;
}

.iv-error.iv-show {
	display: block;
}

.iv-errtext {
	font-size: 16px;
	margin-bottom: 8px;
}

.iv-errsub {
	font-size: 12px;
	color: rgba(255, 255, 255, 0.55);
}

/* ---------- 顶栏：计数 + 关闭 ---------- */

.iv-topbar {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	height: 52px;
	padding: 0 14px;
	display: flex;
	align-items: center;
	justify-content: flex-end;
	background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0));
	pointer-events: none;
}

.iv-count {
	position: absolute;
	left: 16px;
	top: 50%;
	transform: translateY(-50%);
	color: rgba(255, 255, 255, 0.9);
	font-size: 14px;
	letter-spacing: 1px;
	pointer-events: none;
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* ---------- 通用按钮 ---------- */

.iv-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.08);
	color: #fff;
	cursor: pointer;
	pointer-events: auto;
	transition: background 0.18s ease, transform 0.18s ease;
	-webkit-tap-highlight-color: transparent;
}

.iv-btn:hover {
	background: rgba(255, 255, 255, 0.22);
}

.iv-btn:active {
	transform: scale(0.92);
}

.iv-btn:disabled {
	opacity: 0.3;
	cursor: default;
	pointer-events: none;
}

.iv-btn.iv-on {
	background: rgba(255, 255, 255, 0.3);
}

.iv-ic {
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.8;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.iv-close {
	margin-left: 6px;
	background: rgba(255, 255, 255, 0.14);
}

/* ---------- 左右切换 ---------- */

.iv-nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	background: rgba(0, 0, 0, 0.35);
}

.iv-nav:hover {
	background: rgba(0, 0, 0, 0.6);
}

.iv-prev {
	left: 16px;
}

.iv-next {
	right: 16px;
}

/* ---------- 底部工具栏 ---------- */

.iv-toolbar {
	position: absolute;
	bottom: 20px;
	left: 50%;
	transform: translateX(-50%);
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 6px 10px;
	border-radius: 44px;
	background: rgba(20, 22, 26, 0.72);
	backdrop-filter: blur(8px);
	-webkit-backdrop-filter: blur(8px);
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.45);
}

/* ---------- 缩略图条 ---------- */

.iv-thumbs {
	position: absolute;
	bottom: 78px;
	left: 0;
	right: 0;
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 16px;
	overflow-x: auto;
	overflow-y: hidden;
	-webkit-overflow-scrolling: touch;
	scrollbar-width: thin;
	/* 渐隐两侧提示可滚动 */
	-webkit-mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
	mask-image: linear-gradient(to right, transparent, #000 24px, #000 calc(100% - 24px), transparent);
}

.iv-thumbs:empty {
	display: none !important;
}

.iv-thumb {
	flex: 0 0 auto;
	width: 58px;
	height: 58px;
	border-radius: 6px;
	overflow: hidden;
	cursor: pointer;
	opacity: 0.55;
	outline: 2px solid transparent;
	outline-offset: 1px;
	transition: opacity 0.18s ease, outline-color 0.18s ease, transform 0.18s ease;
}

.iv-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
}

.iv-thumb:hover {
	opacity: 0.85;
}

.iv-thumb.iv-active {
	opacity: 1;
	outline-color: #fff;
	transform: translateY(-2px);
}

/* ---------- 正文图片可点击暗示（跨端详情页正文容器） ---------- */

.context img:hover,
.txtMessage img:hover {
	cursor: zoom-in;
}

/* ---------- 移动端适配 ---------- */

@media (max-width: 768px), (pointer: coarse) and (max-width: 1024px) {
	.iv-topbar {
		height: 46px;
	}

	.iv-count {
		left: 12px;
		font-size: 13px;
	}

	.iv-btn {
		width: 36px;
		height: 36px;
	}

	.iv-ic {
		width: 20px;
		height: 20px;
	}

	.iv-nav {
		top: auto;
		bottom: 84px;
		transform: none;
		background: rgba(0, 0, 0, 0.45);
	}

	.iv-prev {
		left: 10px;
	}

	.iv-next {
		right: 10px;
	}

	/* 移动端工具栏精简：纵向节奏更贴近拇指热区 */
	.iv-toolbar {
		bottom: 12px;
		gap: 2px;
		padding: 5px 8px;
	}

	.iv-thumbs {
		bottom: 66px;
		gap: 6px;
		padding: 6px 12px;
	}

	.iv-thumb {
		width: 46px;
		height: 46px;
	}
}

/* 超宽屏（PC 全屏查看）留白收紧，画面更大 */
@media (min-width: 1600px) {
	.iv-toolbar {
		bottom: 24px;
	}
}
