/* ==========================================================================
   M1 首页高级动效层
   说明：本文件只新增 m1- 前缀的类，不修改任何既有类的基础样式，
        避免与 animate.css / bootstrap / main.css 冲突。
        变量挂在 body#index 上（而非 :root），因为 public/header 里后加载的
        main.css 会在 :root 覆盖同名主题变量。
   ========================================================================== */

#index {
  --m1-primary: #9d9ecb;
  --m1-deep: #7a7ba8;
  --m1-ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ===== 1. 滚动入场系统（reveal） =====
   基础态由 JS 添加 .m1-in 解除；动画结束后 JS 会移除这些类，
   使元素回到完全干净的样式（避免 filter/transform 留下的层叠上下文
   影响内部 backdrop-filter、sticky 等特性）。 */
.m1-rv {
  opacity: 0;
  transform: translate3d(0, 28px, 0);
  filter: blur(6px);
  will-change: opacity, transform;
  transition:
    opacity 0.85s var(--m1-ease) var(--m1-d, 0s),
    transform 0.85s var(--m1-ease) var(--m1-d, 0s),
    filter 0.85s var(--m1-ease) var(--m1-d, 0s);
}

/* 左右方向：文字在左则右滑入，视觉在右则左滑入 */
.m1-rv.m1-rv-l {
  transform: translate3d(-38px, 0, 0);
}

.m1-rv.m1-rv-r {
  transform: translate3d(38px, 0, 0);
}

.m1-rv.m1-rv-zoom {
  transform: scale(0.94);
}

/* 大区块用无模糊版本：容器内含 backdrop-filter / sticky 时更安全，也更省性能 */
.m1-rv.m1-rv-plain {
  filter: none;
}

.m1-rv.m1-in {
  opacity: 1;
  transform: none;
  filter: blur(0);
}

/* ===== 3. 卡片流光 + 鼠标跟随微光晕 =====
   .m1-fx 由 JS 注入为真实子元素（不占用伪元素，避免与 index.css 中
   大量 ::before/::after 规则冲突），仅在支持 hover 的精确指针设备上注入。 */
.m1-fx-host {
  position: relative;
}

.m1-fx {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 5;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  background-image:
    radial-gradient(180px circle at var(--m1-mx, 50%) var(--m1-my, 50%), rgba(157, 158, 203, 0.16), rgba(157, 158, 203, 0) 62%),
    linear-gradient(105deg, rgba(255, 255, 255, 0) 42%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 58%);
  background-repeat: no-repeat;
  background-size: 100% 100%, 220% 100%;
  background-position: 0 0, 165% 0;
  transition: opacity 0.35s ease;
}

.m1-fx-host:hover > .m1-fx {
  opacity: 1;
  background-position: 0 0, -65% 0;
  transition:
    opacity 0.25s ease,
    background-position 0.95s var(--m1-ease);
}

/* ===== 4. 缓慢浮动（业务迁移插画） ===== */
.m1-float {
  animation: m1FloatY 7s ease-in-out infinite;
}

@keyframes m1FloatY {

  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }

  50% {
    transform: translate3d(0, -10px, 0);
  }
}

/* 解决方案展开面板的图标做极轻微呼吸，强化"当前项"感知 */
.solution-panel.active .solution-icon {
  animation: m1FloatY 5s ease-in-out infinite;
}

/* ===== 5. 顶部滚动进度条（元素由 JS 创建） ===== */
#m1-progress {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 9999;
  width: 0;
  height: 2px;
  pointer-events: none;
  background: linear-gradient(90deg, var(--m1-primary) 0%, var(--m1-deep) 60%, #c9cae8 100%);
  box-shadow: 0 0 8px rgba(157, 158, 203, 0.6);
  transition: width 0.12s linear, opacity 0.3s ease;
}

/* ===== 6. 数字滚动 ===== */
.m1-count {
  font-variant-numeric: tabular-nums;
}

/* ===== 7. 移动端与无障碍降级 ===== */
@media (max-width: 768px) {

  /* 移动端收敛位移幅度，避免横向滑入造成视口抖动 */
  .m1-rv,
  .m1-rv.m1-rv-l,
  .m1-rv.m1-rv-r {
    transform: translate3d(0, 20px, 0);
    filter: none;
  }

  #index .solution-panel.active .solution-icon {
    animation: none;
  }
}

@media (prefers-reduced-motion: reduce) {

  .m1-rv,
  .m1-rv.m1-rv-l,
  .m1-rv.m1-rv-r,
  .m1-rv.m1-rv-zoom {
    opacity: 1;
    transform: none;
    filter: none;
    transition: none;
  }

  .m1-float,
  .solution-panel.active .solution-icon {
    animation: none;
  }

  .m1-fx,
  #m1-progress {
    display: none;
  }
}
