/* ============================================================
   佣金到账的庆祝动效（C2.115）
   ------------------------------------------------------------
   与 cb-*（交制作 / 标结果 / 投流）是两套视觉：
     过程节点 = 单色金，1.2 秒，克制；
     到账     = 红金，2.6 秒，热闹——烟花、彩带、金币全上。

   时间轴（毫秒）
     0    红光晕炸开                0 / 300 / 620  三朵烟花错开上天
     60+  金币从中央弹起            100+           彩带从顶部飘落
     0    金额弹出、45% 过冲到 1.12  200            胶囊文案上浮
     1620 金额与文案退场（给彩带让出视线）
     2340 整层淡出                  2600           由 ui/celebrate.js 移除

   层次（自下而上）：红光晕 → 烟花 → 彩带 → 金币 → 金额与文案。
   金额永远在最上层，彩带金币都从它下面绕过去，不遮金额。
   全部 pointer-events:none + 只用 transform/opacity，不挡操作也不触发重排。
   ============================================================ */

.cp-layer {
  position: fixed;
  inset: 0;
  z-index: 110; /* 高于弹窗(100)，低于提示条(120) */
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden; /* 彩带落到 100vh 之外不该出现滚动条 */
  pointer-events: none;
  animation: cp-out 260ms 2340ms ease-in forwards;
}

/* 红光晕：喜庆的底子，压得很淡，只负责把中央「烘」热，不盖任何字 */
.cp-glow {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 760px;
  height: 760px;
  margin: -380px 0 0 -380px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(232, 69, 44, 0.32), rgba(255, 150, 40, 0.15) 44%, transparent 68%);
  animation: cp-glow 900ms ease-out both;
}

/* ---------- 烟花 ---------- */
/* 容器是个 0×0 的点，粒子靠 rotate + translateX 沿各自角度飞出，
   比在 JS 里算 cos/sin 省事，也省掉一堆内联 px。 */
.cp-fw {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 0;
  height: 0;
}
/* 炸开的那一下：中心一颗亮点，短促，撑起「砰」的感觉 */
.cp-fw::after {
  content: "";
  position: absolute;
  left: -3px;
  top: -3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #fff8dc;
  box-shadow: 0 0 16px 6px rgba(255, 200, 90, 0.75);
  animation: cp-fw-core 520ms var(--d) ease-out both;
}
.cp-fw i {
  position: absolute;
  left: 0;
  top: 0;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  /* 白芯 + 本色外圈：浅色背景上纯金点会糊进页面，白芯让它「跳」出来 */
  background: radial-gradient(circle, #fff 0%, var(--c) 62%);
  box-shadow: 0 0 10px 1px var(--c), 0 0 20px rgba(232, 69, 44, 0.35);
  will-change: transform, opacity;
  /* 延迟沿用父级的 --d，三朵烟花才是一朵接一朵，而不是同时炸 */
  animation: cp-fw-part 920ms var(--d) cubic-bezier(0.15, 0.7, 0.3, 1) both;
}

/* ---------- 彩带 ---------- */
.cp-conf {
  position: absolute;
  left: var(--x);
  top: 0;
  width: var(--w);
  height: var(--h);
  border-radius: 2px;
  background: var(--c);
  opacity: 0;
  /* 一点点落影：浅色背景上金色彩带和白底会糊在一起 */
  box-shadow: 0 1px 2px rgba(120, 40, 0, 0.16);
  will-change: transform, opacity;
  animation: cp-conf var(--dur) var(--d) cubic-bezier(0.35, 0.1, 0.7, 0.95) both;
}
/* 一部分加内高光，飘落翻转时才有「纸片反光」的层次，不然是纯色块 */
.cp-conf:nth-of-type(3n) {
  border-radius: 1px;
  box-shadow: 0 1px 2px rgba(120, 40, 0, 0.16), inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}
.cp-conf:nth-of-type(4n) {
  background: linear-gradient(180deg, var(--c), rgba(255, 255, 255, 0.85));
}

/* ---------- 金币 ---------- */
.cp-coin {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 28px;
  height: 28px;
  margin: -14px 0 0 -14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 15px;
  font-weight: 800;
  line-height: 1;
  color: #7a4500;
  background: radial-gradient(circle at 34% 28%, #fff7d0, #ffd75e 42%, #f0a41c 78%, #c97c08);
  box-shadow: 0 0 12px rgba(255, 190, 60, 0.75), inset 0 0 0 2px rgba(255, 255, 255, 0.55);
  will-change: transform, opacity;
  animation: cp-coin 1120ms var(--d) cubic-bezier(0.2, 0.6, 0.35, 1) both;
}

/* ---------- 金额与文案 ---------- */
.cp-core {
  position: relative;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transform: translateY(-4px);
  /* 1.62 秒后主动退场：彩带还在飘，但中央的字要让开，别一直压着屏幕 */
  animation: cp-core-out 380ms 1620ms ease-in both;
}

.cp-amount {
  font-size: 64px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  /* 顶端不再用近白（在浅色背景上发虚），整条渐变都留在金→橙区间里，
     再压一层暖色落影，字才「立」得住 */
  background: linear-gradient(180deg, #ffe98a, #ffc12e 38%, #f59300 72%, #e0641c);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 3px 0 rgba(180, 90, 0, 0.14)) drop-shadow(0 6px 20px rgba(226, 110, 20, 0.42))
    drop-shadow(0 0 34px rgba(232, 69, 44, 0.34));
  animation: cp-pop 820ms cubic-bezier(0.16, 1.2, 0.3, 1) both;
}

/* 胶囊做成「红包」：红底金字。这是这一屏唯一强烈饱和的实心块，
   只有它衬得住这么大一个金额。 */
.cp-label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  color: #ffe9a8;
  background: linear-gradient(180deg, #d63b1f, #a52610);
  border: 1px solid rgba(255, 206, 100, 0.8);
  border-radius: 999px;
  padding: 5px 15px;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(160, 35, 12, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.22);
  animation: cp-label 440ms 200ms ease-out both;
}

@keyframes cp-glow {
  0% {
    opacity: 0.95;
    transform: scale(0.42);
  }
  100% {
    opacity: 0;
    transform: scale(1.45);
  }
}

@keyframes cp-fw-core {
  0% {
    opacity: 0;
    transform: scale(0.2);
  }
  14% {
    opacity: 1;
    transform: scale(1.5);
  }
  100% {
    opacity: 0;
    transform: scale(0.4);
  }
}

@keyframes cp-fw-part {
  0% {
    opacity: 0;
    transform: rotate(var(--a)) translateX(0) scale(0.4);
  }
  12% {
    opacity: 1;
  }
  62% {
    opacity: 1;
    transform: rotate(var(--a)) translateX(calc(var(--dist) * 0.82)) scale(1);
  }
  100% {
    opacity: 0;
    transform: rotate(var(--a)) translateX(var(--dist)) scale(0.15);
  }
}

@keyframes cp-conf {
  0% {
    opacity: 0;
    transform: translate3d(0, -14vh, 0) rotate(0deg);
  }
  8% {
    opacity: 1;
  }
  88% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift), 116vh, 0) rotate(var(--rot));
  }
}

/* 弹起 → 到最高点 → 落下去，全程带 Y 轴翻转，像真的铜板在翻 */
@keyframes cp-coin {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.3) rotateY(0deg);
  }
  12% {
    opacity: 1;
  }
  44% {
    opacity: 1;
    transform: translate(calc(var(--dx) * 0.55), var(--dy)) scale(1.06) rotateY(200deg);
  }
  86% {
    opacity: 0.9;
    transform: translate(var(--dx), calc(var(--dy) * -0.2 + 210px)) scale(0.86) rotateY(560deg);
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), calc(var(--dy) * -0.1 + 250px)) scale(0.7) rotateY(720deg);
  }
}

@keyframes cp-pop {
  0% {
    opacity: 0;
    transform: translateY(16px) scale(0.5);
    filter: blur(9px);
  }
  45% {
    opacity: 1;
    transform: translateY(0) scale(1.12);
    filter: blur(0);
  }
  64% {
    transform: translateY(0) scale(0.98);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes cp-label {
  0% {
    opacity: 0;
    transform: translateY(10px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: none;
  }
}

@keyframes cp-core-out {
  to {
    opacity: 0;
    transform: translateY(-14px) scale(0.94);
  }
}

@keyframes cp-out {
  to {
    opacity: 0;
  }
}

/* ---------- 移动端 ---------- */
/* 手机屏幕窄、GPU 填充率也低：字号降一档、光晕收小，元素数量已在 JS 里减半 */
@media (max-width: 640px) {
  .cp-amount {
    font-size: 42px;
    letter-spacing: -1px;
  }
  .cp-label {
    font-size: 12px;
    padding: 4px 12px;
  }
  .cp-glow {
    width: 520px;
    height: 520px;
    margin: -260px 0 0 -260px;
  }
  .cp-coin {
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    font-size: 13px;
  }
}

/* ---------- 系统开了「减少动态效果」 ---------- */
/* 不放烟花不放彩带（JS 也没生成），只做一次 0.82 秒的静态确认 */
.cp-layer.is-quiet {
  animation: cp-quiet 820ms ease-out both;
}
.cp-layer.is-quiet .cp-core,
.cp-layer.is-quiet .cp-amount,
.cp-layer.is-quiet .cp-label {
  animation: none;
}

@keyframes cp-quiet {
  0% {
    opacity: 0;
  }
  16% {
    opacity: 1;
  }
  76% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
