/* 基础变量：统一管理，命名清晰，与实际样式对应 */
:root {
  /* 布局间距 */
  --homewhy-padding-top: clamp(40px, 5vw, 90px);
  /* 字体尺寸 - 响应式clamp替代多断点变量 */
  --homewhy-top-title-size: clamp(40px, 6vw, 97px);
  --homewhy-top-title-leading: clamp(36px, 5vw, 86px);
  --homewhy-sub-title-size: clamp(24px, 3vw, 40px);
  --homewhy-title-text-size: clamp(16px, 1.2vw, 20px);
  --homewhy-sub-text-size: clamp(14px, 1vw, 16px);
  /* 行高 */
  --homewhy-text-leading: 1.8;
  --homewhy-sub-text-leading: 1.9;
}

/* 核心容器：Flex布局标准化，消除宽度偏移 */
.mach-homewhy {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  width: 100%; /* 固定宽度，避免自适应偏移 */
  padding-top: var(--homewhy-padding-top); /* 启用变量，统一控制 */
  box-sizing: border-box; /* 盒模型统一 */
  margin: 0 auto; /* 居中，防止左右偏移 */
  max-width: 1920px; /* 最大宽度兜底，大屏不拉伸 */
}

/* 顶部装饰标题：修复尺寸塌陷，保留设计效果 */
.mach-homewhy .top-title {
  width: 100%; /* 占满容器，避免宽度自适应 */
  height: auto; /* 取消固定高度，防止塌陷 */
  min-height: 50px; /* 最小高度兜底 */
  overflow: hidden;
  text-align: center;
  border-bottom: 1px solid #f5f5f5;
  margin-bottom: 30px; /* 固定底边距，避免偏移 */
  position: relative;
}

.mach-homewhy .top-title h2 {
  font-size: var(--homewhy-top-title-size);
  line-height: var(--homewhy-top-title-leading);
  color: #f5f5f5;
  margin: 0; /* 消除默认边距 */
  /* 定位优化，避免文字溢出 */
  position: relative;
  top: -20px;
}

/* 副标题区域：统一边距，消除偏移 */
.mach-homewhy .sub-title {
  width: 100%; /* 占满容器 */
  margin-bottom: 45px;
}

.mach-homewhy .sub-title h2 {
  margin: 0 0 20px 0; /* 重置默认边距 */
  text-align: center;
  color: var(--title-text-color);
  font-family: var(--title-font-family);
  font-size: var(--homewhy-sub-title-size);
  line-height: 1.4;
  font-weight: 600;
}

.mach-homewhy .sub-title p {
  margin: 0 auto 45px; /* 统一边距 */
  width: clamp(80%, 92.78%, 1200px); /* 响应式宽度，小屏更窄 */
  text-align: center;
  font-size: var(--homewhy-sub-text-size);
  line-height: var(--homewhy-sub-text-leading);
  box-sizing: border-box;
}

/* 列表容器：Flex布局优化，均匀分布 */
.mach-homewhy ul {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 0 auto;
  padding: 0;
  list-style: none;
  width: 100%; /* 占满容器 */
  gap: 20px; /* 间距替代margin，布局更稳定 */
}

/* 列表项：响应式宽度，均匀分布 */
.mach-homewhy ul li {
  /* 桌面端4列（可根据需求调整为3列：31%） */
  flex: 0 0 calc(25% - 15px);
  min-width: 280px; /* 最小宽度，小屏不挤压 */
  margin-bottom: 38px;
  box-sizing: border-box;
}

/* 卡片内容：Flex垂直居中，消除高度不一致 */
.mach-homewhy ul li .content {
  height: 100%;
  text-align: center;
  border: 1px solid #d8e0ee;
  transition: .3s all;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* 垂直居中，内容对齐一致 */
  padding: clamp(20px, 3vw, 40px) clamp(10px, 2vw, 20px);
  border-radius: 8px; /* 轻微圆角，提升体验 */
  box-sizing: border-box;
  min-height: 300px; /* 最小高度，防止内容少导致塌陷 */
}

/* 卡片图片：固定尺寸，防止缩放异常 */
.mach-homewhy ul li .content img {
  width: clamp(60px, 5vw, 80px); /* 响应式宽度 */
  aspect-ratio: 1;
  object-fit: cover;
  margin-bottom: clamp(20px, 2vw, 29px);
  /* 硬件加速，优化渲染 */
  backface-visibility: hidden;
}

/* 卡片标题：统一边距，响应式字体 */
.mach-homewhy ul li .content h3 {
  margin: 0 0 clamp(10px, 1.5vw, 17px) 0; /* 响应式底边距 */
  font-size: var(--homewhy-title-text-size);
  font-weight: 600;
  color: var(--title-text-color);
  line-height: 1.4;
}

/* 卡片文本：修复截断，统一高度 */
.mach-homewhy ul li .content p {
  font-size: var(--homewhy-sub-text-size);
  line-height: var(--homewhy-text-leading);
  color: var(--text-color);
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  /* 固定行高，确保截断高度一致 */
  max-height: calc(16px * 1.8 * 5); /* 字体大小*行高*行数 */
  width: 100%; /* 占满卡片宽度 */
  margin: 0; /* 消除默认边距 */
}

/* 响应式断点：精简，只保留关键尺寸 */
@media screen and (max-width: 1280px) {
  /* 平板横屏：3列布局 */
  .mach-homewhy ul li {
    flex: 0 0 calc(33.333% - 13px);
  }
  /* 微调行高，提升可读性 */
  :root {
    --homewhy-text-leading: 1.6;
  }
}

@media screen and (max-width: 992px) {
  /* 平板竖屏：2列布局 */
  .mach-homewhy ul li {
    flex: 0 0 calc(50% - 10px);
  }
  .mach-homewhy .sub-title p {
    margin-bottom: 30px;
  }
  /* 顶部标题微调，适配小屏 */
  .mach-homewhy .top-title h2 {
    top: -15px;
  }
}

@media screen and (max-width: 768px) {
  /* 移动端：1列布局 */
  .mach-homewhy ul li {
    flex: 0 0 100%;
    min-width: unset;
  }
  /* 卡片内边距减小，适配小屏 */
  .mach-homewhy ul li .content {
    padding: 30px 15px;
    min-height: 250px;
  }
}

@media screen and (max-width: 576px) {
  /* 小屏移动端：进一步精简 */
  .mach-homewhy .sub-title p {
    width: 95%; /* 更宽的文本区域 */
  }
  .mach-homewhy ul {
    gap: 15px; /* 减小间距 */
  }
}