/*
 * xw-mobile-motion4.css —— 第四批手机端动画增强（10 项，无转盘/进度圆环）
 * 门控：所有规则仅在 body.xw-motion4-on 下生效；该 class 由
 *      xw-mobile-motion4.js 判定「手机端 + 未开启减少动态效果」后才添加。
 * 原则：只动 opacity / transform / box-shadow，不碰布局，不动业务逻辑。
 * 独立门控，与前 3 批完全解耦；删除只需去掉 2 行引入 + 2 个文件。
 */
@media (max-width: 768px) {
  body.xw-motion4-on { --m4-brand: #ff7a1a; }

  /* ① 升级光效爆发：等级数字放大 + 光芒放射 */
  body.xw-motion4-on .m4-levelup {
    position: relative;
    animation: m4LvPop .95s cubic-bezier(.2,.8,.3,1) both;
  }
  body.xw-motion4-on .m4-levelup::before {
    content: "";
    position: absolute;
    inset: -60%;
    background: repeating-conic-gradient(from 0deg, rgba(255,214,120,.75) 0deg 7deg, transparent 7deg 20deg);
    border-radius: 50%;
    -webkit-mask-image: radial-gradient(circle, transparent 32%, #000 33%, #000 58%, transparent 60%);
    mask-image: radial-gradient(circle, transparent 32%, #000 33%, #000 58%, transparent 60%);
    animation: m4LvRay .95s ease-out both;
    pointer-events: none;
    z-index: 2;
  }
  @keyframes m4LvPop {
    0%   { transform: scale(1); }
    45%  { transform: scale(1.5); color: #ffbb00; }
    100% { transform: scale(1); }
  }
  @keyframes m4LvRay {
    0%   { opacity: 0; transform: scale(.5) rotate(0); }
    45%  { opacity: 1; transform: scale(1) rotate(24deg); }
    100% { opacity: 0; transform: scale(1.15) rotate(40deg); }
  }

  /* ② 徽章解锁弹出：徽章从中心弹出 + 星光 */
  body.xw-motion4-on .m4-badge-unlock {
    animation: m4BadgePop .8s cubic-bezier(.2,.8,.3,1) both;
  }
  .m4-badge-star {
    position: fixed;
    color: #ffd93d;
    font-size: 14px;
    pointer-events: none;
    z-index: 9999;
    animation: m4BadgeStar .9s ease-out forwards;
  }
  @keyframes m4BadgePop {
    0%   { opacity: 0; transform: scale(0) rotate(-25deg); }
    60%  { opacity: 1; transform: scale(1.2) rotate(8deg); }
    100% { opacity: 1; transform: scale(1) rotate(0); }
  }
  @keyframes m4BadgeStar {
    0%   { opacity: 0; transform: translate(0,0) scale(.6); }
    40%  { opacity: 1; }
    100% { opacity: 0; transform: translate(var(--m4-x,0),var(--m4-y,-40px)) scale(1.1); }
  }

  /* ④ 刮刮卡：涂层滑开露出奖励 */
  body.xw-motion4-on .m4-scratch {
    position: relative;
    overflow: hidden;
  }
  body.xw-motion4-on .m4-scratch .m4-scratch-coat {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(45deg, #b9b9b9 0 6px, #d0d0d0 6px 12px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #555;
    z-index: 3;
    transition: transform .7s cubic-bezier(.2,.7,.3,1), opacity .7s ease;
  }
  body.xw-motion4-on .m4-scratch.m4-scratched .m4-scratch-coat {
    transform: translateX(110%);
    opacity: .9;
  }

  /* ⑤ 悬浮按钮展开：主按钮点击，子项气泡式弹出 */
  body.xw-motion4-on .m4-fab {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
  }
  body.xw-motion4-on .m4-fab-sub {
    position: absolute;
    bottom: 110%;
    opacity: 0;
    transform: translateY(10px) scale(.5);
    transition: opacity .26s ease, transform .26s cubic-bezier(.2,.8,.3,1);
    pointer-events: none;
    z-index: 5;
  }
  body.xw-motion4-on .m4-fab.m4-open .m4-fab-sub {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
  }
  body.xw-motion4-on .m4-fab.m4-open .m4-fab-sub:nth-of-type(1) { transition-delay: .04s; }
  body.xw-motion4-on .m4-fab.m4-open .m4-fab-sub:nth-of-type(2) { transition-delay: .09s; }
  body.xw-motion4-on .m4-fab.m4-open .m4-fab-sub:nth-of-type(3) { transition-delay: .14s; }

  /* ⑥ 长按菜单：从目标元素底部弹出操作菜单 */
  .m4-longmenu {
    position: absolute;
    background: #fff;
    color: #333;
    border-radius: 8px;
    padding: 5px 8px;
    display: flex;
    gap: 10px;
    font-size: 12px;
    z-index: 9997;
    box-shadow: 0 4px 16px rgba(0,0,0,.22);
    transform-origin: bottom center;
    animation: m4Longmenu .28s cubic-bezier(.2,.8,.3,1) both;
    white-space: nowrap;
  }
  @keyframes m4Longmenu {
    0%   { opacity: 0; transform: scale(.7) translateY(8px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
  }

  /* ⑦ 公告打字机：文字逐字显现 + 光标 */
  body.xw-motion4-on .m4-typewriter {
    display: inline-block;
    white-space: nowrap;
    overflow: hidden;
    border-right: 2px solid var(--m4-brand);
    vertical-align: bottom;
  }
  body.xw-motion4-on .m4-typewriter.m4-typing {
    animation: m4Type var(--m4-dur, 3s) steps(var(--m4-steps, 20), end) both;
  }
  @keyframes m4Type {
    0%   { width: 0; }
    90%  { width: var(--m4-w, 100%); border-right-color: var(--m4-brand); }
    100% { width: var(--m4-w, 100%); border-right-color: transparent; }
  }

  /* ⑧ 卡片 3D 翻转：正面/背面翻面 */
  body.xw-motion4-on .m4-flipcard {
    perspective: 600px;
  }
  body.xw-motion4-on .m4-flipcard .m4-flip-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
    transition: transform .7s cubic-bezier(.2,.7,.3,1);
  }
  body.xw-motion4-on .m4-flipcard.m4-flipped .m4-flip-inner {
    transform: rotateY(180deg);
  }
  body.xw-motion4-on .m4-flipcard .m4-face-front,
  body.xw-motion4-on .m4-flipcard .m4-face-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  body.xw-motion4-on .m4-flipcard .m4-face-back {
    transform: rotateY(180deg);
  }

  /* ⑩ Toast 滑入：提示条弹性滑入 */
  body.xw-motion4-on .m4-toast-in {
    animation: m4ToastIn .5s cubic-bezier(.2,.8,.3,1) both;
  }
  @keyframes m4ToastIn {
    0%   { opacity: 0; transform: translateY(-28px) scale(.94); }
    70%  { opacity: 1; transform: translateY(4px) scale(1.01); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
  }

  /* ⑪ 福利雨：节日红包飘落彩蛋（装饰层，不拦截点击） */
  .m4-rain {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 9996;
    overflow: hidden;
  }
  .m4-rain i {
    position: absolute;
    top: -20px;
    width: 14px;
    height: 18px;
    background: linear-gradient(#ff6b6b, #c92a2a);
    border-radius: 2px;
    font-style: normal;
    color: #ffd93d;
    font-size: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
    animation: m4RainFall var(--m4-dur, 2.8s) linear forwards;
    animation-delay: var(--m4-delay, 0s);
  }
  @keyframes m4RainFall {
    0%   { transform: translateY(0) rotate(0); opacity: 0; }
    12%  { opacity: 1; }
    100% { transform: translateY(105vh) rotate(var(--m4-rot, 300deg)); opacity: .9; }
  }

  /* ⑫ 拖拽排序反馈：列表项抬起 + 阴影 */
  body.xw-motion4-on .m4-drag {
    transition: transform .18s ease, box-shadow .18s ease;
  }
  body.xw-motion4-on .m4-drag.m4-dragging {
    transform: scale(1.04);
    box-shadow: 0 8px 20px rgba(0,0,0,.24);
    z-index: 8;
    position: relative;
  }

  /* 系统开启「减少动态效果」→ 全部动画停掉，内容保持可见 */
  @media (prefers-reduced-motion: reduce) {
    body.xw-motion4-on *,
    .m4-badge-star, .m4-longmenu, .m4-rain i {
      animation: none !important;
      transition: none !important;
    }
    body.xw-motion4-on .m4-scratch .m4-scratch-coat { display: none !important; }
  }
}
