/* ============================================================
   全站动效系统 · UI/UX 微交互增强
   原则：短时（150-450ms）、缓动统一、可降级（prefers-reduced-motion）
   ============================================================ */
:root {
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------------- 路由视图切换 ---------------- */
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(16px) scale(0.995); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
#view.view-enter { animation: viewEnter 0.38s var(--ease-out) both; }
#view.view-enter > * {
  animation: childRise 0.5s var(--ease-out) both;
}
#view.view-enter > *:nth-child(1) { animation-delay: 0.02s; }
#view.view-enter > *:nth-child(2) { animation-delay: 0.07s; }
#view.view-enter > *:nth-child(3) { animation-delay: 0.12s; }
#view.view-enter > *:nth-child(4) { animation-delay: 0.17s; }
#view.view-enter > *:nth-child(5) { animation-delay: 0.22s; }
#view.view-enter > *:nth-child(n+6) { animation-delay: 0.26s; }
@keyframes childRise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------------- 侧栏导航：滑动高亮 + 按压 ---------------- */
.nav-item {
  position: relative;
  transition: color 0.2s ease, background 0.25s ease, border-color 0.25s ease, transform 0.15s ease;
}
.nav-item:hover { transform: translateX(3px); }
.nav-item:active { transform: translateX(3px) scale(0.98); }
.nav-item.active { animation: navPop 0.35s var(--ease-spring); }
@keyframes navPop {
  0% { transform: scale(0.96); }
  60% { transform: scale(1.025); }
  100% { transform: scale(1); }
}
.nav-group-label { animation: fadeIn 0.4s var(--ease-out) both; }

/* ---------------- 按钮微交互 ---------------- */
.btn {
  transition: transform 0.15s ease, box-shadow 0.25s ease, background 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn:disabled { transform: none; }

/* 点击涟漪 */
.ripple-host { position: relative; overflow: hidden; }
.ripple {
  position: absolute; border-radius: 50%; pointer-events: none;
  background: rgba(255, 255, 255, 0.35);
  transform: scale(0);
  animation: ripple 0.55s var(--ease-out) forwards;
}
@keyframes ripple {
  to { transform: scale(2.6); opacity: 0; }
}

/* ---------------- 卡片悬浮抬升 ---------------- */
.card, .panel, .ipr-card, .chat-card, .mon-card, .sel-card {
  transition: transform 0.25s var(--ease-out), box-shadow 0.25s ease, border-color 0.25s ease;
}
.card:hover, .panel:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

/* ---------------- 列表行 stagger 入场 ---------------- */
.stagger-in > * {
  animation: rowIn 0.42s var(--ease-out) both;
}
.stagger-in > *:nth-child(1) { animation-delay: 0.02s; }
.stagger-in > *:nth-child(2) { animation-delay: 0.06s; }
.stagger-in > *:nth-child(3) { animation-delay: 0.1s; }
.stagger-in > *:nth-child(4) { animation-delay: 0.14s; }
.stagger-in > *:nth-child(5) { animation-delay: 0.18s; }
.stagger-in > *:nth-child(6) { animation-delay: 0.22s; }
.stagger-in > *:nth-child(7) { animation-delay: 0.26s; }
.stagger-in > *:nth-child(8) { animation-delay: 0.3s; }
.stagger-in > *:nth-child(n+9) { animation-delay: 0.34s; }
@keyframes rowIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
tbody tr { transition: background 0.18s ease; }

/* ---------------- 数据/状态 chip 呼吸与数字翻转 ---------------- */
.status-chip, .pill, .mode-pill { transition: transform 0.2s ease; }
.status-chip:hover { transform: scale(1.05); }
@keyframes balancePop {
  0% { transform: scale(1); color: var(--text); }
  40% { transform: scale(1.12); color: var(--accent-2); }
  100% { transform: scale(1); color: var(--text); }
}
.balance-pop { animation: balancePop 0.5s var(--ease-spring); }

/* ---------------- 模态/抽屉 ---------------- */
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { opacity: 0; transform: translateY(22px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-backdrop { animation: backdropIn 0.25s ease both; }
.modal-panel { animation: modalIn 0.35s var(--ease-out) both; }

/* ---------------- Toast 升级（滑入 + 进度感） ---------------- */
.toast {
  animation: toastIn 0.4s var(--ease-spring) both;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.95); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* ---------------- 骨架屏 shimmer ---------------- */
.skeleton {
  position: relative; overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 8px;
}
.skeleton::after {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(100deg, transparent 20%, rgba(255, 255, 255, 0.09) 50%, transparent 80%);
  animation: shimmer 1.5s linear infinite;
}

/* ---------------- 通用淡入 ---------------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.fade-in { animation: fadeIn 0.35s var(--ease-out) both; }

/* ---------------- 旋转加载 ---------------- */
@keyframes spin { to { transform: rotate(360deg); } }
.spin { animation: spin 0.8s linear infinite; }

/* ---------------- 顶部店铺/用户芯片 ---------------- */
.store-chip, .user-chip {
  transition: transform 0.18s ease, border-color 0.2s ease, box-shadow 0.25s ease;
}
.store-chip:hover, .user-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(124, 139, 255, 0.45);
  box-shadow: 0 8px 22px -10px rgba(124, 139, 255, 0.55);
}
.user-chip .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: #080b16;
  background: var(--accent-grad);
}
.user-menu {
  position: absolute; right: 0; top: calc(100% + 10px);
  min-width: 230px; z-index: 40;
  background: var(--panel-solid);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  animation: modalIn 0.28s var(--ease-out) both;
}
.user-menu .menu-item {
  display: flex; align-items: center; gap: 9px;
  padding: 9px 11px; border-radius: 9px;
  color: var(--text-2); cursor: pointer; font-size: 12.5px;
  transition: background 0.18s ease, color 0.18s ease;
}
.user-menu .menu-item:hover { background: rgba(124, 139, 255, 0.14); color: var(--text); }
.user-menu .menu-item.danger:hover { background: rgba(251, 113, 133, 0.14); color: var(--rose); }

/* ---------------- 额度中心专属 ---------------- */
.credit-hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  padding: 26px 28px;
  background: linear-gradient(135deg, rgba(124, 139, 255, 0.18), rgba(77, 227, 255, 0.08));
  border: 1px solid rgba(124, 139, 255, 0.28);
}
.credit-hero::before {
  content: ''; position: absolute; width: 260px; height: 260px; right: -70px; top: -110px;
  background: radial-gradient(circle, rgba(77, 227, 255, 0.35), transparent 65%);
  animation: heroGlow 7s ease-in-out infinite alternate;
}
@keyframes heroGlow {
  from { transform: translate(0, 0) scale(1); opacity: 0.7; }
  to { transform: translate(-30px, 24px) scale(1.2); opacity: 1; }
}
.credit-balance {
  font-family: var(--font-display);
  font-size: 44px; font-weight: 700; line-height: 1.1;
  background: var(--accent-grad);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.plan-card {
  cursor: pointer;
  transition: transform 0.22s var(--ease-out), border-color 0.22s ease, box-shadow 0.25s ease;
}
.plan-card:hover { transform: translateY(-4px); border-color: rgba(124, 139, 255, 0.5); box-shadow: var(--shadow); }
.plan-card.selected {
  border-color: rgba(77, 227, 255, 0.6);
  box-shadow: 0 0 0 1px rgba(77, 227, 255, 0.35), var(--shadow);
}

/* ---------------- 降级：减少动态 ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
