/*
 * xw-mobile-motion3.css —— 第三批手机端动画增强（12 项）
 * 门控：所有规则仅在 body.xw-motion3-on 下生效；
 *      该 class 由 xw-mobile-motion3.js 判定「手机端 + 未开启减少动态效果」后才添加。
 * 原则：只动 opacity / transform，不碰布局，不动业务逻辑；
 *      JS 不跑 = 无 class = 无动画 = 内容照常显示（天然降级）。
 * 与前两批 xw-mobile-motion / motion2 完全独立，删除只需去掉 2 行引入。
 */
@media (max-width: 768px) {
  body.xw-motion3-on { --m3-brand: #ff7a1a; }

  /* ⑦ 页面转场：主内容区从右淡入 */
  body.xw-motion3-on .m3-page-in {
    animation: m3PageIn .5s cubic-bezier(.2,.7,.3,1) both;
  }
  @keyframes m3PageIn {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: none; }
  }

  /* ③ 余额光扫：数字到账时的金光扫过（循环） */
  body.xw-motion3-on .m3-shine {
    position: relative;
    overflow: hidden;
  }
  body.xw-motion3-on .m3-shine::after {
    content: "";
    position: absolute;
    top: -10%; left: -70%;
    width: 45%; height: 120%;
    background: linear-gradient(100deg, transparent, rgba(255,214,120,.7), transparent);
    transform: skewX(-18deg);
    animation: m3Shine 3.4s linear infinite;
    pointer-events: none;
  }
  @keyframes m3Shine {
    0%       { left: -70%; }
    55%,100% { left: 130%; }
  }

  /* ④ 倒计时翻牌：数字块的翻页脉冲 */
  body.xw-motion3-on .m3-flip {
    display: inline-block;
    transform-origin: center center;
    backface-visibility: hidden;
    animation: m3Flip 1.8s ease-in-out infinite;
  }
  @keyframes m3Flip {
    0%,40%   { transform: rotateX(0); }
    50%      { transform: rotateX(-86deg); }
    60%,100% { transform: rotateX(0); }
  }

  /* ① 签到打卡翻转：点击后卡片 3D 翻面 */
  body.xw-motion3-on .m3-signflip {
    perspective: 500px;
  }
  body.xw-motion3-on .m3-signflip .m3-flip-inner {
    transform-style: preserve-3d;
    animation: m3SignFlip .75s cubic-bezier(.2,.8,.3,1) both;
  }
  @keyframes m3SignFlip {
    0%   { transform: perspective(500px) rotateY(0); }
    100% { transform: perspective(500px) rotateY(180deg); }
  }

  /* ② 开箱兑换：彩带飞出（点击生成，绝对定位装饰） */
  .m3-confetti {
    position: fixed;
    width: 9px; height: 14px;
    top: 0; left: 0;
    border-radius: 2px;
    pointer-events: none;
    z-index: 9999;
    animation: m3ConfettiFall var(--m3-dur, 1.2s) cubic-bezier(.2,.6,.4,1) forwards;
  }
  @keyframes m3ConfettiFall {
    0%   { opacity: 1; transform: translate3d(0,0,0) rotate(0); }
    100% { opacity: 0; transform: translate3d(var(--m3-dx,0),var(--m3-dy,340px),0) rotate(var(--m3-rot,540deg)); }
  }

  /* ⑤ 按钮水波纹：点击位置扩散圆波 */
  .m3-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255,255,255,.55);
    transform: translate(-50%,-50%) scale(0);
    pointer-events: none;
    animation: m3Rip .62s ease-out forwards;
  }
  @keyframes m3Rip {
    to { transform: translate(-50%,-50%) scale(1); opacity: 0; }
  }

  /* ⑥ 左滑操作：列表项左滑位移 + 底层色块（纯视觉，不触发真实操作） */
  body.xw-motion3-on .m3-swipe-item {
    transition: transform .24s cubic-bezier(.2,.7,.3,1), background-color .24s ease;
    background-color: transparent;
  }
  body.xw-motion3-on .m3-swipe-item.m3-swiped {
    transform: translateX(-60px);
    background-color: rgba(255,122,26,.14);
  }

  /* ⑧ 深色模式切换 wipe：点击开关时圆形遮罩扩散 */
  .m3-wipe {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
    transform: translate(-50%,-50%) scale(0);
    animation: m3Wipe .62s ease-out forwards;
  }
  @keyframes m3Wipe {
    0%   { transform: translate(-50%,-50%) scale(0);   opacity: .55; }
    100% { transform: translate(-50%,-50%) scale(1);   opacity: 0; }
  }

  /* ⑨ 星光粒子背景：轻量浮动星点（装饰层，不拦截点击） */
  .m3-stars {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
  }
  .m3-star {
    position: absolute;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 6px rgba(255,255,255,.9);
    animation: m3Twinkle var(--m3-dur, 3s) ease-in-out infinite;
    animation-delay: var(--m3-delay, 0s);
  }
  html.xw-dark .m3-star { background: #ffe9a8; box-shadow: 0 0 7px rgba(255,233,168,.95); }
  @keyframes m3Twinkle {
    0%,100% { opacity: .12; transform: translateY(0) scale(.7); }
    50%     { opacity: .9;  transform: translateY(-7px) scale(1.35); }
  }

  /* ⑩ 页头视差：banner 随滚动微位移（JS 写 transform） */
  body.xw-motion3-on .m3-parallax {
    will-change: transform;
  }

  /* ⑪ 空状态插画：无数据时轻微浮动 */
  body.xw-motion3-on .m3-float {
    animation: m3Float 3.2s ease-in-out infinite;
  }
  @keyframes m3Float {
    0%,100% { transform: translateY(0) rotate(-1deg); }
    50%     { transform: translateY(-7px) rotate(1deg); }
  }

  /* ⑫ 新消息光环：未读红点呼吸扩散 */
  body.xw-motion3-on .m3-halo {
    position: relative;
  }
  body.xw-motion3-on .m3-halo::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2px solid var(--m3-brand);
    animation: m3Halo 2.1s ease-out infinite;
    pointer-events: none;
  }
  @keyframes m3Halo {
    0%   { transform: scale(.7);  opacity: .85; }
    100% { transform: scale(1.9); opacity: 0; }
  }

  /* 系统开启「减少动态效果」→ 全部动画停掉，内容保持可见 */
  @media (prefers-reduced-motion: reduce) {
    body.xw-motion3-on *,
    .m3-confetti, .m3-ripple, .m3-wipe, .m3-star {
      animation: none !important;
      transition: none !important;
    }
  }
}
