/* ============================================================================
 * 锤锤 (chuichui.eu) · 全站三级动效与视觉精品化基础体系 (cc-motion.css)
 * ----------------------------------------------------------------------------
 * 原则：90% 安静，10% 灵动；静态时精美，操作时丝滑，互动时有趣，长期使用不疲劳。
 *   L1 全站基础交互：统一物理按压、Tab 滑块、弹窗空间来源、页面连续性、骨架与反馈
 *   L2 功能专属气质：各模块按业务性格扩展，不强行统一成单一橙色模板
 *   L3 品牌惊喜彩蛋：极少量高情感瞬间（星光、吉祥物互动、排盘流光）
 * ============================================================================ */

:root {
  /* 统一动效缓动曲线 */
  --cc-ease-out: cubic-bezier(0.22, 1, 0.36, 1);       /* Apple 式自然减速 */
  --cc-ease-snappy: cubic-bezier(0.2, 0.8, 0.2, 1);     /* Notion/工具类干脆利落 */
  --cc-ease-spring: cubic-bezier(0.34, 1.48, 0.64, 1);  /* Nintendo/Duolingo 轻盈回弹 */
  --cc-ease-ceremony: cubic-bezier(0.16, 1, 0.3, 1);    /* 东方仪式感舒展曲线 */

  /* 统一动效时长（毫秒） */
  --cc-dur-press: 110ms;     /* 80–150ms 按压触感 */
  --cc-dur-ui: 190ms;        /* 150–220ms 普通组件切换 */
  --cc-dur-page: 230ms;      /* 180–280ms 页面衔接 */
  --cc-dur-modal: 260ms;     /* 200–300ms 弹窗与抽屉 */
  --cc-dur-brand: 440ms;     /* 300–600ms 品牌轻互动 */
}

/* ============================================================================
 * 1. 全站页面连续性（渐进增强：支持原生 MPA View Transitions + 无闪烁安全降级）
 * ============================================================================ */
@media (prefers-reduced-motion: no-preference) {
  @view-transition {
    navigation: auto;
  }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation-duration: 220ms;
  animation-timing-function: var(--cc-ease-out);
}

::view-transition-old(root) {
  animation-name: ccVtFadeOut;
}

::view-transition-new(root) {
  animation-name: ccVtFadeIn;
}

html[data-cc-nav="back"]::view-transition-old(root) {
  animation-name: ccVtBackOut;
}

html[data-cc-nav="back"]::view-transition-new(root) {
  animation-name: ccVtBackIn;
}

@keyframes ccVtFadeOut {
  from { opacity: 1; transform: translate3d(0, 0, 0); }
  to { opacity: 0.72; transform: translate3d(-8px, 0, 0); }
}

@keyframes ccVtFadeIn {
  from { opacity: 0.01; transform: translate3d(10px, 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes ccVtBackOut {
  from { opacity: 1; transform: translate3d(0, 0, 0); }
  to { opacity: 0.72; transform: translate3d(8px, 0, 0); }
}

@keyframes ccVtBackIn {
  from { opacity: 0.01; transform: translate3d(-10px, 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

/* 非 View-Transition 浏览器（旧版 Safari / 微信内置浏览器）轻量无阻断入场 */
@keyframes ccSoftArrive {
  from { opacity: 0.92; transform: translate3d(0, 6px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes ccSoftBackArrive {
  from { opacity: 0.94; transform: translate3d(-6px, 0, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.cc-arrive-forward {
  animation: ccSoftArrive 210ms var(--cc-ease-out) both;
}

.cc-arrive-back {
  animation: ccSoftBackArrive 190ms var(--cc-ease-out) both;
}

/* 共享主题到达轻脉冲：让从首页点进来的模块图标与标题产生自然视觉衔接 */
@keyframes ccHandoffEmblem {
  0% { transform: scale(0.88); opacity: 0.65; }
  65% { transform: scale(1.04); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.cc-handoff-emblem {
  animation: ccHandoffEmblem 340ms var(--cc-ease-out) both;
}

/* ============================================================================
 * 2. L1 统一物理按压反馈（防滚动误触：由 cc-motion.js 精准托管 .cc-is-pressed）
 * ============================================================================ */
.cc-pressable {
  transition:
    transform var(--cc-dur-press) var(--cc-ease-snappy),
    box-shadow var(--cc-dur-ui) var(--cc-ease-out),
    background-color var(--cc-dur-ui) var(--cc-ease-out),
    border-color var(--cc-dur-ui) var(--cc-ease-out);
  touch-action: manipulation;
}

.cc-pressable.cc-is-pressed {
  transform: scale(0.968) translateY(0.5px) !important;
}

.cc-pressable-soft.cc-is-pressed {
  transform: scale(0.98) !important;
}

.cc-pressable-spring.cc-is-pressed {
  transform: scale(0.94) !important;
}

/* ============================================================================
 * 3. L1 通用弹窗、底部抽屉与面板过渡（明确空间来源）
 * ============================================================================ */
@keyframes ccDialogPop {
  from {
    opacity: 0;
    transform: translate3d(0, 12px, 0) scale(0.965);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@keyframes ccSheetRise {
  from {
    opacity: 0.6;
    transform: translate3d(0, 26px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes ccBackdropFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes ccContentSwap {
  from {
    opacity: 0.35;
    transform: translate3d(0, 5px, 0);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

.cc-swap-in {
  animation: ccContentSwap 190ms var(--cc-ease-out) both;
}

/* 原生 <dialog class="cc-modal"> 统一精致进场 */
dialog.cc-modal[open] {
  animation: ccDialogPop var(--cc-dur-modal) var(--cc-ease-out) both;
}

dialog.cc-modal[open]::backdrop {
  animation: ccBackdropFade 200ms ease-out both;
}

/* ============================================================================
 * 4. L1 复制 / 提交 / 收藏 微交互反馈与骨架加载
 * ============================================================================ */
.cc-copied-flash {
  animation: ccCopiedPop 280ms var(--cc-ease-spring) both;
}

@keyframes ccCopiedPop {
  0% { transform: scale(0.96); }
  55% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

/* 温和的错误提示出现（禁用夸张左右抖动，以清晰渐显+细微上移呈现） */
@keyframes ccGentleNotice {
  from { opacity: 0; transform: translate3d(0, -4px, 0); }
  to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.cc-notice-in {
  animation: ccGentleNotice 200ms var(--cc-ease-out) both;
}

/* L1 轻量结构化骨架屏（仅在真实加载等待时显示） */
.cc-skeleton-line,
.cc-skeleton-box {
  position: relative;
  overflow: hidden;
  background: #f1ede8;
  border-radius: 8px;
}

.cc-skeleton-line::after,
.cc-skeleton-box::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.72) 50%, transparent 100%);
  transform: translate3d(-100%, 0, 0);
  animation: ccSkeletonSweep 1.35s var(--cc-ease-out) infinite;
}

@keyframes ccSkeletonSweep {
  to { transform: translate3d(100%, 0, 0); }
}

/* ============================================================================
 * 5. L3 轻量金色星光粒子容器（纯 transform/opacity 合成层，自动销毁）
 * ============================================================================ */
.cc-spark-layer {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 10050;
}

.cc-spark-star {
  position: fixed;
  width: 11px;
  height: 11px;
  margin: -5.5px 0 0 -5.5px;
  pointer-events: none;
  will-change: transform, opacity;
}

/* L1 轻量网格错峰轻拂入场（极速紧凑：总延迟 ≤120ms，绝不拖慢操作） */
@keyframes ccTileCascade {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0) scale(0.975);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

.cc-stagger-grid > * {
  animation: ccTileCascade 260ms var(--cc-ease-out) both;
  animation-delay: calc(min(var(--i, 0), 8) * 16ms);
}

/* ============================================================================
 * 6. 全站共享组件视觉适配（任意门经典竖排贴纸样式统一由 cc-icons.js 托管）
 * ============================================================================ */
body[data-cc-hide-fab="1"] #ccFab {
  display: none !important;
}

/* 禁用漂浮在报价和按钮上的遮挡式黑色小气泡提示 */
body #ccFabTip {
  display: none !important;
}

/* 任意门弹出抽屉丝滑化 */
#ccQuickNav {
  transition: opacity 200ms var(--cc-ease-out);
}

#ccQuickNav.open .cc-qn-sheet {
  animation: ccSheetRise 260ms var(--cc-ease-out) both !important;
}

#ccQuickNav .cc-qn-item {
  transition: transform 130ms var(--cc-ease-snappy), border-color 180ms ease, background-color 180ms ease, box-shadow 180ms ease !important;
}

/* 深色主题页面（如 /ziwei）自动适配通透墨玉鎏金分享按钮，消除白底突兀感 */
html[data-cc-theme="dark"] .cc-uni-share-btn {
  background: rgba(20, 25, 38, 0.76) !important;
  border: 1px solid rgba(214, 184, 124, 0.34) !important;
  color: #f2dfb3 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.32) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

html[data-cc-theme="dark"] .cc-uni-share-btn:active {
  background: rgba(34, 42, 62, 0.92) !important;
  border-color: rgba(214, 184, 124, 0.56) !important;
}

/* ============================================================================
 * 7. 性能与无障碍铁律：后台暂停动画 + 尊重系统减少动态效果
 * ============================================================================ */
html.cc-bg-paused *,
html.cc-bg-paused *::before,
html.cc-bg-paused *::after {
  animation-play-state: paused !important;
}

@media (prefers-reduced-motion: reduce) {
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation-duration: 0.01ms !important;
  }
  .cc-arrive-forward,
  .cc-arrive-back,
  .cc-handoff-emblem,
  .cc-swap-in,
  .cc-stagger-grid > *,
  .cc-copied-flash,
  .cc-notice-in,
  dialog.cc-modal[open],
  dialog.cc-modal[open]::backdrop,
  #ccQuickNav.open .cc-qn-sheet,
  body #ccFabTip {
    animation: none !important;
  }
  .cc-skeleton-line::after,
  .cc-skeleton-box::after,
  html body a.cc-home-pill::after {
    animation: none !important;
  }
  .cc-pressable,
  .cc-pressable.cc-is-pressed {
    transition-duration: 0.01ms !important;
    transform: none !important;
  }
}
