/* pages/home_products.css — 首页「产品」：产品条（.products / .product-card 抽屉式四卡 + hover 揭示）
   拆自 pages/home.css（2026-10-12 拆分，纯搬移）；页面源 bundle 2:53「终稿-首页-初稿 5.0」（1920×6660）。 */

/* ---------- 产品（1920×1440） ---------- */
.products {
  background: var(--color-bg-page);
}

.products__head {
  text-align: center;
}

.products__title {
  margin-top: var(--space-5);
  font-weight: var(--font-weight-bold);
  max-width: 52rem; /* 832 —— 约束钉宽，让词揭示遮罩块不太宽、动效更明显 */
  margin-inline: auto; /* 配合 max-width 居中（products__head 是 text-align:center） */
}

.products__desc {
  max-width: 52rem;
  margin: var(--space-5) auto 0;
  font-size: clamp(1.25rem, 1.2rem + 1.25vw, var(--font-size-h2));
  line-height: 1.39;
  text-align: center;
}

.products__strip {
  display: flex;
  gap: 0;
  height: 30rem;
  margin-top: var(--space-12);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
}

.product-card {
  position: relative;
  flex: none;
  width: 80vw;
  scroll-snap-align: start;
  background-color: var(--color-text-1);
  overflow: hidden;
}

/* 图片层（::before 承载图片以便单独灰度化，::after 为遮罩） */
.product-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  background-image: var(--card-img); /* 数据驱动：无 --card-img 时计算为 none，露出卡身深色底 */
}

.product-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, .2);
}

.product-card__icon {
  position: absolute;
  top: var(--space-10);
  right: var(--space-8);
  z-index: 1;
  display: grid;
  place-items: center;
  width: 4rem;
  height: 4rem;
  border-radius: var(--radius-sm);
  background: linear-gradient(180deg, #000, #666);
}

.product-card__icon img {
  width: 2.25rem;
  height: 2.25rem;
}

.product-card__title {
  position: absolute;
  left: 2.0625rem;
  bottom: 12.1875rem; /* 标题块底 859-3-120≈距底 118 */
  z-index: 1;
  font-size: clamp(1.75rem, 1.2rem + 1.8vw, var(--font-size-h1));
  font-weight: var(--font-weight-medium);
  line-height: var(--line-height-title);
  color: #fff;
}

.product-card__title .title-break {
  display: inline;
}

.product-card .btn-more {
  position: absolute;
  left: 2.0625rem;
  bottom: 3.75rem;
  z-index: 1;
  color: #fff;
}

@media (min-width: 1280px) {
  .products__head.section__flow {
    padding: 7.875rem 0 0; /* 眉题 y=126 */
  }

  .products__desc {
    max-width: 95rem; /* 1520 */
  }

  .products__strip {
    height: 60rem;
    overflow: hidden;
    margin-top: 5rem;
  }

  /* 4 卡抽屉式：宽度由 JS 设为 px 值，过渡由 CSS 管。
     ⚠⚠ 这里的特异性必须 ≥ (0,3,0)：motion.css 的 `.m-ready [data-m-anim]`（特异性 0,2,0）
     会给本元素设 transition（opacity/translate/scale）+ transition-delay，会把下面这条
     width 过渡**整条盖掉** —— 卡片宽度于是永远是「瞬跳」，这才是 hover 卡顿的真正根因
     （只改渲染成本救不了「根本没有动画」）。故把 motion 的三条过渡原样抄回，再追加 width。 */
  .section .products__strip .product-card {
    flex: none;
    width: 25%;
    transition:
      opacity var(--m-dur) ease var(--m-delay, 0ms),
      translate var(--m-dur) var(--m-ease) var(--m-delay, 0ms),
      scale var(--m-dur) var(--m-ease) var(--m-delay, 0ms),
      width .5s cubic-bezier(0.22, 0.61, 0.36, 1);
  }

  /* 图片层：尺寸钉死为 hover 宽度（不再随卡宽变化）→ 卡宽动画期间不重采样位图。
     图片层中心与卡中心重合，故与原「按卡宽 cover 居中」渲染逐像素一致。
     注：不要加 will-change —— 它会把图片层提升为合成层，与相邻卡之间出现 1px 白缝。 */
  .product-card::before {
    inset: 0 auto 0 50%;
    width: 28.125vw; /* strip 宽 = 视口宽，1920 时为 540 */
    translate: -50% 0;
    filter: grayscale(1);
    transition: filter .5s cubic-bezier(0.22, 0.61, 0.36, 1);
  }

  /* hover 卡：彩色 */
  .product-card:hover::before,
  .product-card:focus-within::before {
    filter: grayscale(0);
  }

  .product-card__icon,
  .product-card__title,
  .product-card .btn-more {
    opacity: 0;
    transition: opacity .5s cubic-bezier(0.25, 0.1, 0.25, 1);
    transition-delay: .1s; /* 等 flex-basis 过半再淡入，避免同时动太杂 */
  }

  .product-card:hover .product-card__icon,
  .product-card:hover .product-card__title,
  .product-card:hover .btn-more,
  .product-card:focus-within .product-card__icon,
  .product-card:focus-within .product-card__title,
  .product-card:focus-within .btn-more {
    opacity: 1;
  }

  .product-card__icon {
    top: 2.5rem;
    right: 2.9375rem;
  }

  .product-card__title {
    top: 44.625rem;   /* y=714 */
    bottom: auto;
  }

  .product-card .btn-more {
    top: 53.6875rem;  /* y=859 */
    bottom: auto;
  }
}