/* ==============================================
   Product Grid Widget
   ============================================== */

.cpg-wrap {
	width: 100%;
}

.cpg-grid {
	display: grid;
	grid-template-columns: repeat(4, 1fr);
	column-gap: 30px;
	row-gap: 40px;
}

.cpg-item {
	display: flex;
	flex-direction: column;
	height: 100%;
}

.cpg-info {
	display: flex;
	flex-direction: column;
	flex: 1 1 auto;
}

/* --- 图片 --- */
.cpg-image {
	display: block;
	position: relative;
	width: 100%;
	height: 280px;
	overflow: hidden;
	background-color: #f3f4f6;
	text-decoration: none;
}

.cpg-image img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	object-fit: cover;
	transition: opacity .45s ease, transform .55s ease;
}

.cpg-img-main {
	opacity: 1;
	z-index: 1;
}

.cpg-img-hover {
	opacity: 0;
	z-index: 2;
}

/* 默认仅缩放 */
.cpg-wrap.cpg-hover-none .cpg-item:hover .cpg-img-main {
	transform: scale(1.05);
}

/* gallery 模式：主图淡出，第二图淡入 */
.cpg-wrap.cpg-hover-gallery .cpg-item:hover .cpg-img-main {
	opacity: 0;
	transform: scale(1.04);
}
.cpg-wrap.cpg-hover-gallery .cpg-item:hover .cpg-img-hover {
	opacity: 1;
}

/* overlay 模式：蒙版覆盖 */
.cpg-overlay {
	position: absolute;
	inset: 0;
	background-color: rgba(0, 0, 0, 0.4);
	opacity: 0;
	transition: opacity .35s ease;
	z-index: 3;
	pointer-events: none;
}
.cpg-wrap.cpg-hover-overlay .cpg-item:hover .cpg-overlay {
	opacity: 1;
}
.cpg-wrap.cpg-hover-overlay .cpg-item:hover .cpg-img-main {
	transform: scale(1.05);
}

/* --- 信息区 --- */
.cpg-info {
	text-align: center;
	padding-top: 18px;
	position: relative;
}

.cpg-title-link {
	text-decoration: none;
	color: inherit;
	display: block;
}

.cpg-title {
	margin: 0 0 16px 0;
	font-size: 16px;
	font-weight: 600;
	line-height: 1.4;
	color: #1f2937;
	transition: color .3s ease;
	display: -webkit-box;
	-webkit-line-clamp: var(--cpg-title-lines, 2);
	line-clamp: var(--cpg-title-lines, 2);
	-webkit-box-orient: vertical;
	overflow: hidden;
	/* 预留固定高度：行数 × line-height，保证不同行数标题等高 */
	min-height: calc(1.4em * var(--cpg-title-lines, 2));
}

/* 把线条推到信息区底部，标题行数差异不会让线条错位 */
.cpg-info .cpg-line {
	margin-top: auto;
}

/* --- 下方线条（悬停从中间向两边延伸） --- */
.cpg-line {
	display: block;
	position: relative;
	width: 100%;
	height: 2px;
	background-color: #e5e7eb;
	overflow: hidden;
}

.cpg-line::before {
	content: "";
	position: absolute;
	top: 0;
	left: 50%;
	width: 0;
	height: 2px;
	background-color: #2b4182;
	transform: translateX(-50%);
	transition: width .4s ease;
}

.cpg-item:hover .cpg-line::before {
	width: 100%;
}

/* --- 分页 --- */
.cpg-pagination {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 8px;
	margin-top: 48px;
	width: 100%;
}

.cpg-pagination a,
.cpg-pagination span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 44px;
	height: 44px;
	line-height: 44px;
	padding: 0 12px;
	font-size: 14px;
	font-weight: 600;
	color: #1f2937;
	background-color: #ffffff;
	border: 1px solid #e5e7eb;
	border-radius: 4px;
	text-decoration: none;
	transition: background-color .25s ease, color .25s ease, border-color .25s ease, transform .2s ease;
	box-sizing: border-box;
	user-select: none;
}

.cpg-pagination a:hover {
	color: #ffffff;
	background-color: #2b4182;
	border-color: #2b4182;
	transform: translateY(-1px);
}

.cpg-pagination .cpg-page-current {
	color: #ffffff;
	background-color: #2b4182;
	border-color: #2b4182;
	cursor: default;
}

.cpg-pagination .cpg-page-disabled {
	opacity: 0.4;
	cursor: not-allowed;
	background-color: #f9fafb;
}

.cpg-pagination .cpg-page-dots {
	border: none;
	background: transparent;
	min-width: auto;
	padding: 0 4px;
	color: #9ca3af;
}

.cpg-page-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.cpg-page-icon i {
	font-size: 14px;
}

.cpg-page-icon svg {
	width: 14px;
	height: 14px;
	fill: currentColor;
}

/* --- 响应式 --- */
@media (max-width: 1024px) {
	.cpg-grid {
		grid-template-columns: repeat(2, 1fr);
	}
}

@media (max-width: 600px) {
	.cpg-grid {
		grid-template-columns: 1fr;
	}
	.cpg-pagination a,
	.cpg-pagination span {
		min-width: 38px;
		height: 38px;
		line-height: 38px;
		padding: 0 8px;
		font-size: 13px;
	}
}
