/* ════════════════════════════════════════════════════════════════
 * GlimmerAI 页面过渡动画 (升级版)
 * 圆形遮罩展开 + View Transition API 渐进增强
 * ════════════════════════════════════════════════════════════════ */

/* ── 页面级淡入 ── */
.page-fade {
  opacity: 0;
  animation: pageFadeIn 0.35s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)) 0.05s forwards;
}

@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 点击链接时的淡出（配合 JS） ── */
.page-fade-out {
  opacity: 0 !important;
  transition: opacity 0.15s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1));
}

/* ── 正文内容渐进 ── */
main > * {
  animation: contentSlideIn 0.4s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)) both;
}
main > *:nth-child(1) { animation-delay: 0.05s; }
main > *:nth-child(2) { animation-delay: 0.10s; }
main > *:nth-child(3) { animation-delay: 0.15s; }
main > *:nth-child(4) { animation-delay: 0.20s; }
main > *:nth-child(5) { animation-delay: 0.25s; }

@keyframes contentSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── 圆形遮罩转场 ── */
.page-circle-transition {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  pointer-events: none;
  background: var(--paper, #F7F4ED);
  clip-path: circle(0% at var(--circle-x, 50%) var(--circle-y, 50%));
  opacity: 0;
  transition: clip-path 0.6s var(--ease-out-expo, cubic-bezier(0.16, 1, 0.3, 1)),
              opacity 0.3s var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1));
}

.page-circle-transition.active {
  opacity: 1;
  clip-path: circle(150% at var(--circle-x, 50%) var(--circle-y, 50%));
  pointer-events: all;
}

/* ── 页面加载进度条 ── */
.page-loading-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: linear-gradient(90deg, var(--monet-pond, #7BA7A6), var(--monet-gold, #C9A96E));
  z-index: 10000;
  transition: width 0.3s var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1));
}

.page-loading-bar.active {
  width: 100%;
}

/* ── View Transition API 增强 (渐进增强) ── */
@supports (view-transition-name: none) {
  /* 共享元素转场 */
  ::view-transition-old(root) {
    animation: view-exit 0.4s var(--ease-in-quart, cubic-bezier(0.5, 0, 0.75, 0)) forwards;
  }

  ::view-transition-new(root) {
    animation: view-enter 0.5s var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1)) forwards;
  }

  @keyframes view-exit {
    to { 
      opacity: 0; 
      transform: scale(0.96) translateY(10px);
      filter: blur(4px);
    }
  }

  @keyframes view-enter {
    from { 
      opacity: 0; 
      transform: scale(1.04) translateY(-10px);
      filter: blur(4px);
    }
    to {
      opacity: 1;
      transform: scale(1) translateY(0);
      filter: blur(0);
    }
  }

  /* 共享元素动画 */
  ::view-transition-old(hero-image),
  ::view-transition-new(hero-image) {
    animation-duration: 0.5s;
    animation-timing-function: var(--ease-out-quart, cubic-bezier(0.25, 1, 0.5, 1));
  }
}

/* ── 减少动画偏好 ── */
@media (prefers-reduced-motion: reduce) {
  .page-fade,
  main > * {
    animation: none !important;
    opacity: 1 !important;
  }
  
  .page-circle-transition {
    transition: opacity 0.15s ease-out !important;
    clip-path: none !important;
  }
  
  .page-circle-transition.active {
    opacity: 1;
  }
  
  .page-loading-bar {
    transition: width 0.1s linear !important;
  }
}
