/**
 * 尘渊 - UI增强样式
 * 动画、交互、视觉效果
 */

/* ========== 页面加载动画 ========== */
.page-loader {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--md-sys-color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.page-loader.hidden {
  opacity: 0;
  visibility: hidden;
}

.loader {
  width: 48px;
  height: 48px;
  border: 3px solid var(--md-sys-color-outline-variant);
  border-top-color: var(--md-sys-color-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========== 滚动显示动画 ========== */
.reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}

.reveal-left {
  opacity: 0;
  transform: translateX(-50px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-left.active {
  opacity: 1;
  transform: translateX(0);
}

.reveal-right {
  opacity: 0;
  transform: translateX(50px);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-right.active {
  opacity: 1;
  transform: translateX(0);
}

.reveal-scale {
  opacity: 0;
  transform: scale(0.9);
  transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.reveal-scale.active {
  opacity: 1;
  transform: scale(1);
}

/* 延迟类 */
.delay-1 { transition-delay: 0.1s; }
.delay-2 { transition-delay: 0.2s; }
.delay-3 { transition-delay: 0.3s; }
.delay-4 { transition-delay: 0.4s; }
.delay-5 { transition-delay: 0.5s; }

/* ========== 卡片增强效果 ========== */
.card-glow {
  position: relative;
  overflow: hidden;
}

.card-glow::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(144, 202, 249, 0.1),
    transparent
  );
  transition: left 0.5s ease;
}

.card-glow:hover::before {
  left: 100%;
}

.card-glow:hover {
  box-shadow: 
    0 0 0 1px rgba(144, 202, 249, 0.3),
    0 20px 40px rgba(0, 0, 0, 0.4);
}

/* ========== 按钮增强 ========== */
.btn-shine {
  position: relative;
  overflow: hidden;
}

.btn-shine::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(
    45deg,
    transparent 30%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 70%
  );
  transform: translateX(-100%) rotate(45deg);
  transition: transform 0.6s ease;
}

.btn-shine:hover::after {
  transform: translateX(100%) rotate(45deg);
}

/* ========== 文字效果 ========== */
.text-gradient {
  background: linear-gradient(135deg, #90caf9 0%, #64b5f6 50%, #42a5f5 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.text-glow {
  text-shadow: 0 0 20px rgba(144, 202, 249, 0.5);
}

/* ========== 悬浮粒子效果 ========== */
.particles {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: rgba(144, 202, 249, 0.3);
  border-radius: 50%;
  animation: float-up 15s infinite;
}

@keyframes float-up {
  0% {
    transform: translateY(100vh) scale(0);
    opacity: 0;
  }
  10% {
    opacity: 1;
  }
  90% {
    opacity: 1;
  }
  100% {
    transform: translateY(-100vh) scale(1);
    opacity: 0;
  }
}

/* ========== 导航栏增强 ========== */
.nav-blur {
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.nav-link-hover {
  position: relative;
}

.nav-link-hover::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--md-sys-color-primary);
  transition: all 0.3s ease;
  transform: translateX(-50%);
}

.nav-link-hover:hover::after {
  width: 100%;
}

/* ========== 图片悬停效果 ========== */
.img-zoom {
  overflow: hidden;
}

.img-zoom img {
  transition: transform 0.5s ease;
}

.img-zoom:hover img {
  transform: scale(1.05);
}

/* ========== 列表项动画 ========== */
.list-item-animate {
  opacity: 0;
  transform: translateX(-20px);
  animation: slide-in 0.4s ease forwards;
}

.list-item-animate:nth-child(1) { animation-delay: 0.1s; }
.list-item-animate:nth-child(2) { animation-delay: 0.2s; }
.list-item-animate:nth-child(3) { animation-delay: 0.3s; }
.list-item-animate:nth-child(4) { animation-delay: 0.4s; }
.list-item-animate:nth-child(5) { animation-delay: 0.5s; }

@keyframes slide-in {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ========== 脉动效果 ========== */
.pulse {
  animation: pulse-animation 2s ease-in-out infinite;
}

@keyframes pulse-animation {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(144, 202, 249, 0.4);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(144, 202, 249, 0);
  }
}

/* ========== 边框流动效果 ========== */
.border-flow {
  position: relative;
  background: var(--md-sys-color-surface-container);
}

.border-flow::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(
    45deg,
    var(--md-sys-color-primary),
    transparent,
    var(--md-sys-color-primary)
  );
  border-radius: inherit;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.border-flow:hover::before {
  opacity: 1;
}

/* ========== 打字机效果 ========== */
.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--md-sys-color-primary);
  animation: 
    typing 3s steps(40, end),
    blink-caret 0.75s step-end infinite;
}

@keyframes typing {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes blink-caret {
  from, to { border-color: transparent; }
  50% { border-color: var(--md-sys-color-primary); }
}

/* ========== 磁吸按钮效果 ========== */
.magnetic-btn {
  transition: transform 0.2s ease;
}

/* ========== 滚动进度条 ========== */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #90caf9, #64b5f6);
  z-index: 10000;
  transition: width 0.1s ease;
}

/* ========== 工具提示 ========== */
.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(-8px);
  padding: 8px 12px;
  background: var(--md-sys-color-surface-container-highest);
  color: var(--md-sys-color-on-surface);
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  border: 1px solid var(--md-sys-color-outline-variant);
}

.tooltip:hover::after {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(-4px);
}

/* ========== 骨架屏 ========== */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--md-sys-color-surface-container) 25%,
    var(--md-sys-color-surface-container-high) 50%,
    var(--md-sys-color-surface-container) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ========== 焦点效果 ========== */
.focus-ring:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(144, 202, 249, 0.3);
}

/* ========== 平滑滚动优化 ========== */
@media (prefers-reduced-motion: no-preference) {
  html {
    scroll-behavior: smooth;
  }
}

/* ========== 自定义滚动条 ========== */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--md-sys-color-surface-container);
}

::-webkit-scrollbar-thumb {
  background: var(--md-sys-color-outline);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--md-sys-color-outline-variant);
}

/* ========== 选中文字样式 ========== */
::selection {
  background: rgba(144, 202, 249, 0.3);
  color: var(--md-sys-color-on-surface);
}

/* ========== 移动端导航 ========== */
.mobile-menu-toggle {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  width: 48px;
  height: 48px;
  background: transparent;
  border: none;
  cursor: pointer;
  z-index: 1001;
}

.hamburger-line {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--md-sys-color-on-surface);
  margin: 3px 0;
  transition: all 0.3s ease;
  border-radius: 2px;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle.active .hamburger-line:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -6px);
}

.mobile-menu {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  visibility: hidden;
  opacity: 0;
  transition: all 0.3s ease;
}

.mobile-menu.active {
  visibility: visible;
  opacity: 1;
}

.mobile-menu-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
}

.mobile-menu-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: 320px;
  max-width: 85vw;
  height: 100%;
  background: var(--md-sys-color-surface-container);
  transform: translateX(100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.mobile-menu.active .mobile-menu-panel {
  transform: translateX(0);
}

.mobile-menu-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--md-sys-color-outline-variant);
}

.mobile-menu-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--md-sys-color-on-surface);
}

.mobile-menu-close {
  background: none;
  border: none;
  color: var(--md-sys-color-on-surface);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 4px;
}

.mobile-menu-nav {
  padding: 16px;
}

.mobile-nav-item {
  display: block;
  padding: 16px;
  color: var(--md-sys-color-on-surface-variant);
  text-decoration: none;
  font-size: 1rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  margin-bottom: 4px;
}

.mobile-nav-item:hover,
.mobile-nav-item.active {
  background: var(--md-sys-color-surface-container-high);
  color: var(--md-sys-color-on-surface);
}

.mobile-nav-item-primary {
  background: var(--md-sys-color-primary);
  color: var(--md-sys-color-on-primary);
  margin-top: 16px;
  text-align: center;
}

.mobile-nav-item-primary:hover {
  background: var(--primary-dark);
  color: var(--md-sys-color-on-primary);
}

/* ========== 响应式优化 ========== */
@media (max-width: 1024px) {
  .mui-nav {
    display: none;
  }
  
  .mobile-menu-toggle {
    display: flex;
  }
}

@media (max-width: 768px) {
  .reveal,
  .reveal-left,
  .reveal-right {
    opacity: 1;
    transform: none;
  }
  
  .particle {
    display: none;
  }
  
  .progress-bar {
    height: 2px;
  }
}

/* ========== 减少动画偏好 ========== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
