/* 中文产品详情图库。 */
body.product-details-gallery {
	--product-gallery-image-size: 400px;
	--product-gallery-thumb-size: clamp(60px, 4.8vw, 76px);
	--product-gallery-gap: 12px;
	--product-gallery-rail-space: calc(var(--product-gallery-thumb-size) + var(--product-gallery-gap) + 6px);
	--product-gallery-column-gap: 24px;
}

body.product-details-gallery .automotive .details-img.product-gallery {
	position: relative;
	display: block;
	box-sizing: border-box;
	float: left;
	width: 50%;
	max-width: 100%;
	margin: 1% 0;
	box-shadow: none;
}

body.product-details-gallery .product-gallery__content {
	--product-gallery-content-ideal-size: calc(var(--product-gallery-image-size) + var(--product-gallery-rail-space));
	--product-gallery-content-size: min(var(--product-gallery-content-ideal-size), calc(100% - var(--product-gallery-column-gap)));
	position: relative;
	width: var(--product-gallery-content-size);
	max-width: calc(100% - var(--product-gallery-column-gap));
	margin: 0;
	margin-left: max(0px, calc((100% - var(--product-gallery-content-ideal-size) - var(--product-gallery-wal-gutter, 100px)) / 2));
	padding-left: var(--product-gallery-rail-space);
}

body.product-details-gallery .automotive .details-info {
	width: 50%;
}

body.product-details-gallery .product-gallery *,
body.product-details-gallery .product-gallery *::before,
body.product-details-gallery .product-gallery *::after {
	box-sizing: border-box;
}

body.product-details-gallery .product-gallery [hidden] {
	display: none !important;
}

body.product-details-gallery .product-gallery button {
	font: inherit;
	color: inherit;
	cursor: pointer;
	-webkit-tap-highlight-color: transparent;
}

body.product-details-gallery .product-gallery button:focus-visible {
	outline: 2px solid #d32f2f;
	outline-offset: 2px;
}

body.product-details-gallery .product-gallery__rail {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
	width: calc(var(--product-gallery-thumb-size) + 6px);
	min-height: 0;
}

body.product-details-gallery .product-gallery__viewport {
	flex: 1 1 0;
	min-height: 0;
	overflow: hidden;
	overscroll-behavior: contain;
}

body.product-details-gallery .product-gallery__list {
	display: flex;
	flex-direction: column;
	gap: 8px;
	margin: 0;
	padding: 0 3px;
	list-style: none;
}

body.product-details-gallery .product-gallery__thumb {
	display: flex;
	flex: 0 0 auto;
	align-items: center;
	justify-content: center;
	width: var(--product-gallery-thumb-size);
	height: var(--product-gallery-thumb-size);
	margin: 0;
	padding: 4px;
	overflow: hidden;
	border: 1px solid #d6d6d6;
	border-radius: 0;
	background: #fff;
	transition: border-color 0.3s ease-in-out, opacity 0.3s ease-in-out;
	box-shadow: 0 0 3px rgb(226, 226, 226);
}

body.product-details-gallery .product-gallery__thumb:hover,
body.product-details-gallery .product-gallery__thumb.is-active,
body.product-details-gallery .product-gallery__thumb[aria-current="true"] {
	border-color: #d32f2f;
}

body.product-details-gallery .product-gallery__thumb.is-active,
body.product-details-gallery .product-gallery__thumb[aria-current="true"] {
	border-width: 2px;
	padding: 3px;
}

body.product-details-gallery .product-gallery__thumb img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: 100%;
	max-height: 100%;
	object-fit: contain;
	pointer-events: none;
}

body.product-details-gallery .product-gallery button.product-gallery__scroll {
	display: flex;
	flex: 0 0 24px;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 24px;
	margin: 0;
	padding: 2px;
	border: 0;
	border-radius: 0;
	background: #fff;
	color: #777;
	line-height: 1;
	transition: color 0.3s ease-in-out, opacity 0.3s ease-in-out;
}

body.product-details-gallery .product-gallery__scroll:hover:not(:disabled) {
	color: #d32f2f;
}

body.product-details-gallery .product-gallery button.product-gallery__scroll:disabled {
	display: none;
	pointer-events: none;
}

body.product-details-gallery .product-gallery__stage {
	position: relative;
	width: 100%;
	min-width: 0;
	aspect-ratio: 1 / 1;
	background: #fff;
	box-shadow: 0 0 3px rgb(226, 226, 226);
}

/* 边框绘制在图框内侧，贴齐内容区时也不会被父级 overflow 裁掉。 */
body.product-details-gallery .product-gallery__stage::after {
	content: '';
	position: absolute;
	inset: 0;
	z-index: 3;
	border: 1px solid #e2e2e2;
	pointer-events: none;
}

body.product-details-gallery .product-gallery__image-box {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	min-width: 0;
	min-height: 0;
	background: #fff;
}

/* 保持图片元素与实际显示图像一致，供 ezPlus 正确计算放大坐标。 */
body.product-details-gallery .product-gallery__image-box #ezPlus-img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
	object-fit: initial;
}

body.product-details-gallery .product-gallery__stage .cert-icons {
	top: 3.7%;
	right: 3%;
	width: auto;
	max-width: 34%;
	height: clamp(18px, 2vw, 26px);
}

body.product-details-gallery .product-gallery__stage .cert-icons img {
	width: auto;
	height: 100%;
	max-width: 100%;
}

/* 单图取消缩略图占位，主图尺寸及视觉居中规则与多图共用。 */
body.product-details-gallery .product-gallery[data-single-image="true"] .product-gallery__content {
	--product-gallery-content-ideal-size: var(--product-gallery-image-size);
	--product-gallery-content-size: min(var(--product-gallery-content-ideal-size), calc(100% - var(--product-gallery-column-gap) - var(--product-gallery-rail-space)));
	max-width: calc(100% - var(--product-gallery-column-gap) - var(--product-gallery-rail-space));
	padding-left: 0;
}

body.product-details-gallery .product-gallery[data-single-image="true"] .product-gallery__rail {
	display: none;
}

@media (max-width: 800px) {
	body.product-details-gallery {
		--product-gallery-thumb-size: clamp(48px, 9vw, 56px);
		--product-gallery-gap: 10px;
	}

	body.product-details-gallery .product-gallery__list {
		gap: 6px;
	}

	body.product-details-gallery .product-gallery__scroll {
		flex-basis: 24px;
		min-height: 24px;
	}

	body.product-details-gallery .product-gallery__stage .cert-icons {
		height: clamp(16px, 3.5vw, 24px);
	}
}

/* 手机双列布局按实际图库宽度及面板左留白计算视觉中心。 */
@media (min-width: 576px) and (max-width: 1004px) {
	body.product-details-gallery .product-gallery__content {
		margin-left: max(0px, calc((100% - var(--product-gallery-content-size) - var(--product-gallery-wal-gutter, 0px)) / 2));
	}
}

/* 普通手机竖屏上下排列，展开后的折叠屏等较宽窗口保留左右两列。 */
@media (max-width: 575px) {
	body.product-details-gallery {
		--product-gallery-column-gap: 0px;
	}

	body.product-details-gallery .automotive .detail-pageTitle {
		float: none;
		clear: both;
		width: 100%;
		padding-top: 0;
	}

	body.product-details-gallery .automotive .details-img.product-gallery {
		float: none;
		clear: both;
		width: 100%;
		margin: 12px 0 24px;
	}

	body.product-details-gallery .product-gallery__content {
		margin: 0 auto;
	}

	body.product-details-gallery .automotive .details-info {
		float: none;
		clear: both;
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	body.product-details-gallery .product-gallery__viewport {
		scroll-behavior: auto;
	}

	body.product-details-gallery .product-gallery__thumb,
	body.product-details-gallery .product-gallery__scroll {
		transition: none;
	}
}
