/* ============================================================
   寻古迹 · 全局动画与装饰系统
   依据《设计.md》第六章动画规范 + 第五章装饰元素
   所有页面共享，通过 base.html 引入
   ============================================================ */

/* ====== 1. 滚动进入动画（IntersectionObserver 触发） ====== */
.scroll-animate {
  opacity: 0;
  transform: translateY(28px);
  transition:
    opacity 0.8s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.8s cubic-bezier(0.22, 1, 0.36, 1);
  will-change: opacity, transform;
}
.scroll-animate.is-visible {
  opacity: 1;
  transform: translateY(0);
}

/* 进入方向变体 */
.scroll-animate.from-left  { transform: translateX(-40px); }
.scroll-animate.from-right { transform: translateX(40px); }
.scroll-animate.from-top   { transform: translateY(-32px); }
.scroll-animate.scale-in   { transform: scale(0.92); }
.scroll-animate.from-left.is-visible,
.scroll-animate.from-right.is-visible,
.scroll-animate.from-top.is-visible,
.scroll-animate.scale-in.is-visible { transform: translate(0, 0) scale(1); }

/* 错落延迟（由 JS 自动按 data-delay 或顺序注入） */
.scroll-animate[data-delay="1"] { transition-delay: 0.08s; }
.scroll-animate[data-delay="2"] { transition-delay: 0.16s; }
.scroll-animate[data-delay="3"] { transition-delay: 0.24s; }
.scroll-animate[data-delay="4"] { transition-delay: 0.32s; }
.scroll-animate[data-delay="5"] { transition-delay: 0.40s; }
.scroll-animate[data-delay="6"] { transition-delay: 0.48s; }

/* 尊重「减少动画」偏好 */
@media (prefers-reduced-motion: reduce) {
  .scroll-animate {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
  .float, .sparkle, .pulse-ring, .gold-shine, .scroll-wheel-anim {
    animation: none !important;
  }
}

/* ====== 2. 漂浮动画（墨团 / 装饰球） ====== */
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33%      { transform: translate(40px, -30px) scale(1.08); }
  66%      { transform: translate(-30px, 40px) scale(0.95); }
}
.float { animation: float 18s ease-in-out infinite; }
.float-slow { animation: float 26s ease-in-out infinite; }

/* ====== 3. 闪光点 ====== */
@keyframes spark {
  0%, 100% { opacity: 0.2; transform: scale(0.5); }
  50%      { opacity: 1;   transform: scale(1.4); }
}
.sparkle { animation: spark 3.5s ease-in-out infinite; }
.sparkle-2 { animation-delay: 0.8s; }
.sparkle-3 { animation-delay: 1.6s; }
.sparkle-4 { animation-delay: 2.4s; }

/* ====== 4. 金色文字发光 ====== */
@keyframes goldShine {
  0%, 100% {
    text-shadow:
      0 0 40px rgba(212, 160, 74, 0.6),
      0 0 80px rgba(212, 160, 74, 0.4);
  }
  50% {
    text-shadow:
      0 0 60px rgba(244, 213, 141, 0.85),
      0 0 30px rgba(212, 160, 74, 0.6);
  }
}
.gold-shine { animation: goldShine 2.4s ease-in-out infinite; }

/* ====== 5. 按钮脉冲环 ====== */
@keyframes pulseRing {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(244, 213, 141, 0.55); }
  50%      { transform: scale(1.04); box-shadow: 0 0 0 14px rgba(244, 213, 141, 0); }
}
.pulse-ring { animation: pulseRing 2s ease-out infinite; }

/* ====== 6. 滚动指示器滚轮动画 ====== */
@keyframes scrollDown {
  0%   { transform: scaleY(0); transform-origin: top; }
  50%  { transform: scaleY(1); transform-origin: top; }
  51%  { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}
.scroll-wheel-anim { animation: scrollDown 2s ease-in-out infinite; }

/* ====== 7. 页面首次加载淡入 ====== */
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}
.main-content { animation: pageFadeIn 0.6s ease-out both; }

/* ====== 8. 导航栏进入 ====== */
@keyframes navSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}
.navbar { animation: navSlideDown 0.7s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ====== 9. 区块标题装饰线 ====== */
.head-deco {
  width: 200px;
  height: 20px;
  margin: 18px auto 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.head-deco::before {
  content: '';
  position: absolute;
  left: 12px; right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold) 30%, var(--gold-light) 50%, var(--gold) 70%, transparent);
}
.head-deco::after,
.head-deco span {
  content: '';
  position: absolute;
  top: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold-light);
  box-shadow: 0 0 10px var(--gold), 0 0 4px var(--gold-light);
  transform: translateY(-50%);
}
.head-deco::after { left: 0; }
.head-deco span { right: 0; }

/* ====== 10. 卡片四角金色装饰 ====== */
.corner-deco {
  position: relative;
}
.corner-deco > .c-tl,
.corner-deco > .c-tr,
.corner-deco > .c-bl,
.corner-deco > .c-br {
  position: absolute;
  width: 18px; height: 18px;
  border: 2px solid var(--gold);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity .3s, transform .3s;
}
.corner-deco > .c-tl { top: 8px;    left: 8px;  border-right: none; border-bottom: none; }
.corner-deco > .c-tr { top: 8px;    right: 8px; border-left: none;  border-bottom: none; }
.corner-deco > .c-bl { bottom: 8px; left: 8px;  border-right: none; border-top: none; }
.corner-deco > .c-br { bottom: 8px; right: 8px; border-left: none;  border-top: none; }
.corner-deco:hover > .c-tl,
.corner-deco:hover > .c-tr,
.corner-deco:hover > .c-bl,
.corner-deco:hover > .c-br {
  opacity: 1;
  transform: scale(1.1);
}

/* ====== 11. 通用卡片悬浮上移 ====== */
.lift-on-hover {
  transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.45s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.45s ease;
}
.lift-on-hover:hover {
  transform: translateY(-6px);
  box-shadow: 0 18px 40px rgba(15, 39, 68, 0.22),
              0 4px 12px rgba(212, 160, 74, 0.25);
}

/* ====== 12. 链接下划线金光扫过 ====== */
.nav-link {
  position: relative;
}
.nav-link::after {
  content: '';
  position: absolute;
  left: 50%; bottom: 4px;
  width: 0; height: 2px;
  transform: translateX(-50%);
  background: linear-gradient(90deg, var(--gold), var(--gold-light), var(--gold));
  box-shadow: 0 0 8px var(--gold);
  transition: width 0.35s ease;
}
.nav-link:hover::after,
.nav-link.active::after {
  width: 70%;
}

/* ====== 13. 图片悬浮放大容器 ====== */
.zoom-img-wrap { overflow: hidden; }
.zoom-img-wrap img {
  transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.zoom-img-wrap:hover img { transform: scale(1.06); }

/* ====== 14. 序号标签（壹/贰/叁） ====== */
.section-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 48px;
  height: 48px;
  padding: 0 14px;
  font-family: var(--font-brush);
  font-size: 22px;
  letter-spacing: 2px;
  color: var(--gold-light);
  background: linear-gradient(135deg, rgba(212, 160, 74, 0.18), rgba(157, 118, 40, 0.12));
  border: 1px solid var(--gold);
  border-radius: 4px;
  box-shadow: inset 0 0 12px rgba(212, 160, 74, 0.15);
  margin-bottom: 18px;
}

/* ====== 15. 页脚印章呼吸 ====== */
@keyframes sealBreath {
  0%, 100% { transform: scale(1)    rotate(0deg);    box-shadow: 0 6px 20px rgba(212, 160, 74, 0.4); }
  50%      { transform: scale(1.05) rotate(2deg);    box-shadow: 0 10px 28px rgba(212, 160, 74, 0.6); }
}
/* ====== 16. 标题入场（页内大标题） ====== */
@keyframes titleReveal {
  from { opacity: 0; transform: translateY(20px); letter-spacing: 20px; }
  to   { opacity: 1; transform: translateY(0);    letter-spacing: 8px; }
}
.title-reveal { animation: titleReveal 1s cubic-bezier(0.22, 1, 0.36, 1) both; }

/* ====== 17. 滚动条美化 ====== */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--paper-dark); }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  border-radius: 10px;
  border: 2px solid var(--paper-dark);
}
::-webkit-scrollbar-thumb:hover { background: linear-gradient(180deg, var(--gold-light), var(--gold)); }

/* ====== 18. 文字选中高亮 ====== */
::selection {
  background: rgba(212, 160, 74, 0.35);
  color: var(--ink-deep);
}

/* ====== 19. 焦点可见性（无障碍） ====== */
a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ====== 20. 页面过渡动画 ====== */
.page-transition {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, var(--ink-deep) 0%, transparent 100%);
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
}

.page-transition.active {
  opacity: 1;
}

@keyframes ink-spread {
  0% {
    transform: scale(0);
    opacity: 0.8;
  }
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

.ink-transition {
  position: fixed;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, var(--gold) 0%, transparent 70%);
  border-radius: 50%;
  filter: blur(30px);
  z-index: 9998;
  pointer-events: none;
  animation: ink-spread 0.6s ease-out forwards;
}
