﻿/* ===== 全局防溢出（仅限制 body 滚动条） ===== */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* ===== 商品标题强制省略（不影响标签等行内元素） ===== */
.hero-title,
.sm-title,
.prod-title {
    width: -moz-available;
    width: -webkit-fill-available;
    width: stretch;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    display: block !important;
    contain: inline-size;
    max-width: 100% !important;
}

/* ===== 通用区块标题 ===== */
.section { padding: 50px 0; }
.section-header {
  text-align: center;
  margin-bottom: 32px;
}
.section-header h2 {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.section-header p {
  font-size: 14px;
  color: var(--text-muted);
}

/* ===== 功能特色块 ===== */
.features-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 28px 20px;
  text-align: center;
  transition: var(--transition);
  box-shadow: var(--shadow-card);
  min-width: 0;
  overflow: hidden;
}
.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.feature-card .feat-icon {
  width: 52px; height: 52px;
  margin: 0 auto 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  font-size: 24px;
}
.feature-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.feature-card p {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== 精品源码推荐 ===== */
.featured-wrap {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  align-items: stretch;
}
.featured-left,
.featured-right {
  min-width: 0;
  overflow: hidden;
}

/* 左边大图 */
.featured-left .product-card-hero {
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
  height: 100%;
  min-height: 380px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-width: 0;
}
.featured-left .product-card-hero .hero-bg {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.featured-left .product-card-hero:hover .hero-bg {
  transform: scale(1.05);
}
.featured-left .product-card-hero .hero-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, rgba(0,0,0,0.1) 60%, rgba(0,0,0,0.05) 100%);
}
.featured-left .product-card-hero .hero-content {
  position: relative;
  z-index: 2;
  padding: 30px 24px 20px;
  min-width: 0;
}
.featured-left .product-card-hero .hero-tags {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
  flex-wrap: wrap;
  max-width: 100%;
  overflow: hidden;
}
.featured-left .product-card-hero .hero-tags span {
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  /* 保持行内块，不破坏 flex 布局 */
  display: inline-block;
}
.featured-left .product-card-hero .hero-title {
  font-size: 20px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 6px;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.featured-left .product-card-hero .hero-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 12px;
  color: rgba(255,255,255,0.7);
}
.featured-left .product-card-hero .hero-meta span {
  display: flex;
  align-items: center;
  gap: 4px;
}
.featured-left .product-card-hero .hero-meta .hero-price {
  font-size: 20px;
  font-weight: 700;
  color: #ff6b6b;
}

/* 右边小卡片 */
.featured-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.featured-right .product-card-sm {
  position: relative;
  display: flex;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  transition: var(--transition);
  cursor: pointer;
  flex: 1;
  min-height: 76px;
  min-width: 0;
}
.featured-right .product-card-sm a,
.featured-right .product-card-sm a:hover {
  color: inherit;
}
.featured-right .product-card-sm:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-2px);
}
.featured-right .product-card-sm .sm-img-wrap {
  width: 100px;
  min-width: 100px;
  height: 100%;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}
.featured-right .product-card-sm .sm-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
}
.featured-right .product-card-sm:hover .sm-img-wrap img {
  transform: scale(1.08);
}
.featured-right .product-card-sm .sm-info {
  flex: 1;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}
.featured-right .product-card-sm .sm-info .sm-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary) !important;
  margin-bottom: 3px;
}
.featured-right .product-card-sm .sm-info .sm-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary) !important;
}
.featured-right .product-card-sm .sm-info .sm-meta {
  font-size: 11px;
  color: var(--text-muted) !important;
  display: flex;
  gap: 10px;
  margin-top: 2px;
}

/* ===== 最新推荐 & 聚合源码 ===== */
.products-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}
.product-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: var(--transition);
  position: relative;
  min-width: 0;
}
.product-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-4px);
}
.product-card .prod-img-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--bg-body);
}
.product-card .prod-img-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .5s ease;
}
.product-card:hover .prod-img-wrap img {
  transform: scale(1.08);
}
.product-card .prod-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #ff6b6b;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 4px;
  z-index: 2;
}
.product-card .prod-tags {
  position: absolute;
  bottom: 8px;
  left: 8px;
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  max-width: calc(100% - 16px);
  overflow: hidden;
  z-index: 2;
}
.product-card .prod-tags span {
  font-size: 10px;
  padding: 1px 8px;
  border-radius: 3px;
  background: rgba(0,0,0,0.55);
  color: #fff;
  white-space: nowrap;
}
.product-card .prod-body {
  padding: 12px 14px 14px;
  min-width: 0;
}
.product-card .prod-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.product-card .prod-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 8px;
}
.product-card .prod-meta span { display: flex; align-items: center; gap: 3px; }
.product-card .prod-meta i { font-size: 12px; }
.product-card .prod-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
}
.product-card .prod-price .original {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-muted);
  text-decoration: line-through;
  margin-left: 6px;
}

/* 加载更多 */
.load-more-wrap { text-align: center; margin-top: 36px; }
.load-more-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 40px;
  border: 1px solid var(--border-color);
  border-radius: 50px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 14px;
  cursor: pointer;
  transition: var(--transition);
}
.load-more-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ===== 聚合源码 ===== */
.random-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* ===== 内容分隔 ===== */
.section-divider { height: 1px; background: var(--border-color); margin: 0; }

/* ===== 响应式 ===== */
@media (max-width: 992px) {
  .products-grid, .random-grid { grid-template-columns: repeat(3, 1fr); }
  .featured-wrap { grid-template-columns: 1fr; }
  .featured-left .product-card-hero { min-height: 280px; }
  .featured-right { display: flex; flex-direction: column; gap: 12px; }
  .featured-right .product-card-sm { height: auto; flex-direction: row; }
  .featured-right .product-card-sm .sm-img-wrap { width: 100px; min-width: 100px; aspect-ratio: auto; height: 90px; }
}

@media (max-width: 768px) {
  .section { padding: 30px 0; }
  .section-header { margin-bottom: 20px; }
  .section-header h2 { font-size: 18px; }
  .features-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .feature-card { padding: 16px 10px; }
  .feature-card .feat-icon { width: 40px; height: 40px; font-size: 18px; margin-bottom: 8px; }
  .feature-card h3 { font-size: 13px; }
  .feature-card p { display: none; }
  .products-grid, .random-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .featured-left .product-card-hero .hero-title { font-size: 17px; }
  .featured-left .product-card-hero .hero-content { padding: 20px 16px 14px; }
  .featured-right { display: flex; flex-direction: column; gap: 10px; }
  .featured-right .product-card-sm { height: auto; flex-direction: row; min-height: 76px; }
  .featured-right .product-card-sm .sm-img-wrap { width: 80px; min-width: 80px; height: 76px; aspect-ratio: auto; }
  .featured-right .product-card-sm .sm-info { padding: 8px 10px; }
  .featured-right .product-card-sm .sm-info .sm-title { font-size: 13px; }
  .product-card .prod-body { padding: 8px 10px 10px; }
  .product-card .prod-title { font-size: 13px; }
}

@media (max-width: 480px) {
  .features-grid { gap: 6px; }
  .feature-card { padding: 12px 8px; }
  .feature-card .feat-icon { width: 34px; height: 34px; font-size: 16px; margin-bottom: 6px; }
  .feature-card h3 { font-size: 12px; }
  .products-grid, .random-grid { gap: 8px; }
  .product-card .prod-body { padding: 8px 10px 10px; }
  .product-card .prod-title { font-size: 13px; }
  .load-more-btn { padding: 8px 28px; font-size: 13px; }
}

/*兼容补丁*/

/* ===== Grid 列宽强制收缩（兼容所有支持 Grid 的浏览器） ===== */
@supports (display: grid) {
  .products-grid,
  .random-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  @media (max-width: 992px) {
    .products-grid,
    .random-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
  }
  @media (max-width: 768px) {
    .products-grid,
    .random-grid {
      grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
  }
}

/* ===== 图片容器降级：针对不支持 aspect-ratio 的浏览器 ===== */
@supports not (aspect-ratio: 1/1) {
  .prod-img-wrap {
    position: relative !important;
    width: 100% !important;
    height: 0 !important;
    padding-top: 100% !important;
    overflow: hidden !important;
  }
  .prod-img-wrap img {
    position: absolute !important;
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;   /* Chrome 83 支持，即使不支持也不影响布局 */
  }
}
/* ===== 相关推荐网格（与 products-grid 相同修复） ===== */
@supports (display: grid) {
  .related-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
  }
  @media (max-width: 992px) {
    .related-grid {
      grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
  }
  @media (max-width: 768px) {
    .related-grid {
      grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
  }
}