/* 动效层：照 scaffold-peek 的能量语态落地，用 CSS + 原生 JS 实现，不引 GSAP。
   放 Discharge：按压回弹、主按钮涟漪、弹窗从触发点展开
   导 Conduct：可点卡片悬停抬起
   结 Crystallize：进场级联、数字落定、阶段胶囊弹入
   停摆 Halt：收起比展开快（200ms，缩放回 0.94） */

:root {
  --ease-reveal: cubic-bezier(.16, 1, .3, 1);   /* expo.out   显现 */
  --ease-glide:  cubic-bezier(.22, 1, .36, 1);  /* power4.out 滑行 */
  --ease-exit:   cubic-bezier(.4, 0, 1, 1);     /* power2.in  退场 */
  --ease-settle: cubic-bezier(.34, 1.56, .64, 1); /* back.out 落定 */
  --dur-press: 140ms;
  --dur-release: 460ms;
  --dur-hover: 340ms;
}

/* ── 放：按下缩到 .955，松手用回弹曲线回来（原先是 translateY(1px)，没有手感） ── */
.btn, .icon-btn, .stage-quick {
  transition: transform var(--dur-release) var(--ease-settle),
    background var(--transition-fast), border-color var(--transition-fast),
    color var(--transition-fast), box-shadow var(--transition-fast);
}
.btn:active:not(:disabled), .icon-btn:active, .stage-quick:active {
  transform: scale(.955);
  transition-duration: var(--dur-press);
  transition-timing-function: var(--ease-exit);
}

/* 涟漪：从真正被点到的位置化开；键盘触发时落回中心（JS 负责坐标与半径） */
.btn--primary, .btn--go, .btn--danger { position: relative; }
.ripple-clip {
  position: absolute; inset: 0; overflow: hidden;
  border-radius: inherit; pointer-events: none;
}
.ripple-dot {
  position: absolute; left: 50%; top: 50%;
  width: 20px; height: 20px; border-radius: 50%;
  background: rgba(255, 255, 255, .32);
  transform: translate(-50%, -50%) scale(0);
  animation: ripple-grow 620ms var(--ease-reveal) forwards;
}
@keyframes ripple-grow {
  to { transform: translate(-50%, -50%) scale(var(--ripple-scale, 14)); opacity: 0; }
}

/* ── 导：只有真能点开的卡片才抬手，列表行不动（密集列表跟着动会晕） ── */
@media (hover: hover) {
  .page-dashboard .task {
    transition: transform var(--dur-hover) var(--ease-glide),
      box-shadow var(--dur-hover) var(--ease-glide),
      border-color var(--dur-hover) var(--ease-glide);
  }
  .page-dashboard .task:hover { transform: translateY(-3px); box-shadow: var(--sh-card); }
}

/* ── 结：进场级联。并列卡片从中间向两侧（JS 写 --i），表格行按阅读序 25ms 一条 ── */
@keyframes rise-in {
  from { opacity: 0; transform: translateY(12px); }
}
.page-dashboard .lede,
.page-dashboard .tasks,
.page-dashboard .card {
  animation: rise-in 620ms var(--ease-reveal) backwards;
  animation-delay: calc(var(--i, 0) * 45ms);
}
.page-leads .leads-table tbody tr,
.page-leads .table--cards tbody tr {
  animation: rise-in 500ms var(--ease-reveal) backwards;
  animation-delay: calc(var(--i, 0) * 25ms);
}

/* 数字落定：JS 逐帧推到终值；这里只保证等宽，跳动时不抖列 */
.page-dashboard .kpi__v { font-variant-numeric: tabular-nums; }

/* 阶段胶囊：改完阶段弹一下确认，再落定 */
.stage-quick.is-settling { animation: settle-pop 420ms var(--ease-settle); }
@keyframes settle-pop {
  from { transform: scale(.86); }
}

/* ── 浮层：遮罩淡入，面板从按下的位置长出来；收起更快、往回收 ── */
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes modal-in {
  from { opacity: 0; transform: translateY(14px) scale(.975); }
}
@keyframes modal-out {
  to { opacity: 0; transform: scale(.94); }
}
.modal-backdrop { animation: fade-in 220ms var(--ease-exit) both; }
.modal-backdrop .modal {
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  animation: modal-in 480ms var(--ease-reveal) both;
}
.modal-backdrop.is-closing { animation: fade-out 200ms var(--ease-exit) both; }
.modal-backdrop.is-closing .modal { animation: modal-out 200ms var(--ease-exit) both; }

/* 底部抽屉：从下往上推，遮罩同步淡入 */
@keyframes sheet-in {
  from { opacity: 0; transform: translateY(28px) scale(.99); }
}
@keyframes sheet-out {
  to { opacity: 0; transform: translateY(20px); }
}
dialog[open] {
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  animation: sheet-in 520ms var(--ease-glide) both;
}
dialog[open]::backdrop { animation: fade-in 260ms var(--ease-exit) both; }
dialog.is-closing { animation: sheet-out 200ms var(--ease-exit) both; }
dialog.is-closing::backdrop { animation: fade-out 200ms var(--ease-exit) both; }

/* ── Toast：从右侧滑入（只在出现时动，消失不拖时间） ── */
@keyframes toast-in {
  from { opacity: 0; transform: translateX(16px) scale(.98); }
}
.toast { animation: toast-in 420ms var(--ease-reveal) both; }

/* ── 登录页：一次进场 + 一层很慢的环境光 ──
   这页没有可点的任务，动效只做两件事：让页面看起来是「活的」，
   再把视线从左边的叙事带引到右边的表单。所有位移都走 transform/opacity，
   不占布局，也不会把输入框顶得跳一下。 */
@keyframes auth-rise {
  from { opacity: 0; transform: translateY(14px); }
}
@keyframes auth-mark-in {
  from { opacity: 0; transform: scale(.82) rotate(-6deg); }
}
@keyframes auth-glow-drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); opacity: .8; }
  100% { transform: translate3d(-30px, 46px, 0) scale(1.14); opacity: 1; }
}
@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(2px); }
}
@keyframes auth-card-in {
  from { opacity: 0; transform: translateY(18px) scale(.992); }
}

/* 左边：品牌一行先站住，口号跟上，四条卖点依次浮起，最后是脚注。
   背景那团暖光用 18 秒走一个来回——慢到不会分散注意力，
   但盯着看时能感觉到它不是一张静态海报。 */
.app--auth .auth-brand__glow {
  animation: auth-glow-drift 18s var(--ease-glide) infinite alternate;
}
/* 第二团光错开半圈，两块亮斑不会像同一只手在同步推。 */
.app--auth .auth-brand__glow--low {
  animation-duration: 26s;
  animation-delay: -11s;
}
.app--auth .auth-brand__top {
  animation: auth-rise 480ms var(--ease-reveal) 40ms backwards;
}
.app--auth .auth-brand__mark {
  animation: auth-mark-in 560ms var(--ease-settle) 40ms backwards;
}
.app--auth .auth-brand__slogan {
  animation: auth-rise 560ms var(--ease-reveal) 110ms backwards;
}
.app--auth .auth-brand__points li {
  animation: auth-rise 480ms var(--ease-reveal) backwards;
}
.app--auth .auth-brand__points li:nth-child(1) { animation-delay: 200ms; }
.app--auth .auth-brand__points li:nth-child(2) { animation-delay: 260ms; }
.app--auth .auth-brand__points li:nth-child(3) { animation-delay: 320ms; }
.app--auth .auth-brand__points li:nth-child(4) { animation-delay: 380ms; }
.app--auth .auth-brand__foot {
  animation: auth-rise 560ms var(--ease-reveal) 460ms backwards;
}

/* 右边：白卡先落位，标题、输入框逐行跟上，按钮最后到位。
   报错时不换进场，改成横向抖一下——比重新淡入更能说明「刚才那次没成」。 */
.app--auth .auth-form__card {
  animation: auth-card-in 520ms var(--ease-reveal) 0ms backwards;
}
.app--auth .auth-form__title,
.app--auth .auth-form__sub,
.app--auth .auth-form__hint,
.app--auth .auth-form__body .field,
.app--auth .auth-form__body .btn {
  animation: auth-rise 480ms var(--ease-reveal) backwards;
}
.app--auth .auth-form__title { animation-delay: 80ms; }
.app--auth .auth-form__sub { animation-delay: 120ms; }
.app--auth .auth-form__body > .field:nth-of-type(1) { animation-delay: 170ms; }
.app--auth .auth-form__body > .field:nth-of-type(2) { animation-delay: 220ms; }
.app--auth .auth-form__body .btn { animation-delay: 290ms; }
.app--auth .auth-form__hint { animation-delay: 360ms; }
/* 切标签后不再重放逐行入场：每次切换都等半秒才看清输入框，比不动画更糟。
   这个类一旦加上就不再移除，隐藏面板被显示时也不会重新开始动画。 */
.app--auth .auth-form__card.has-switched .auth-form__body .field,
.app--auth .auth-form__card.has-switched .auth-form__body .btn,
.app--auth .auth-form__card.has-switched .auth-form__hint { animation: none; }
.app--auth .auth-form__card > .alert--danger {
  animation: auth-shake 480ms var(--ease-glide) 160ms both;
}
@media (hover: hover) {
  .app--auth .auth-form__body .btn--primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 22px 36px -18px rgba(210, 85, 0, .55);
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn, .icon-btn, .stage-quick,
  .page-dashboard .task { transition: none; }
  .btn:active:not(:disabled), .icon-btn:active, .stage-quick:active,
  .page-dashboard .task:hover { transform: none; }
  .page-dashboard .lede, .page-dashboard .tasks, .page-dashboard .card,
  .page-leads .leads-table tbody tr, .page-leads .table--cards tbody tr,
  .modal-backdrop, .modal-backdrop .modal, dialog[open], dialog[open]::backdrop,
  dialog.is-closing, dialog.is-closing::backdrop,
  .toast, .stage-quick.is-settling, .ripple-dot { animation: none; }
  .app--auth .auth-brand__glow, .app--auth .auth-brand__top,
  .app--auth .auth-brand__mark, .app--auth .auth-brand__slogan,
  .app--auth .auth-brand__points li, .app--auth .auth-brand__foot,
  .app--auth .auth-form__card,
  .app--auth .auth-form__title, .app--auth .auth-form__sub,
  .app--auth .auth-form__hint, .app--auth .auth-form__body .field,
  .app--auth .auth-form__body .btn,
  .app--auth .auth-form__card > .alert--danger { animation: none; }
  .auth-panel.is-entering { animation: none; }
  .auth-tabs__thumb { transition: none; }
  .app--auth .auth-form__body .btn--primary:hover,
  .app--auth .auth-form__body .auth-submit:hover .auth-submit__ico { transform: none; }
}

