/**
 * NProgress 自定义样式
 * 现代化的进度条设计，与博客主题保持一致
 */

/* 进度条容器 */
#nprogress {
  pointer-events: none;
}

/* 进度条主体 */
#nprogress .bar {
  background: linear-gradient(90deg, var(--primary, #007acc), #00a8ff);
  position: fixed;
  z-index: 1031;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  border-radius: 0 0 2px 2px;
  box-shadow: 0 0 10px rgba(0, 122, 204, 0.5);
}

/* 进度条发光效果 */
#nprogress .bar::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: nprogress-shimmer 2s infinite;
}

@keyframes nprogress-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

/* 进度条尾部动画 */
#nprogress .peg {
  display: block;
  position: absolute;
  right: 0px;
  width: 100px;
  height: 100%;
  background: linear-gradient(to right, 
    rgba(0, 122, 204, 0) 0%, 
    rgba(0, 122, 204, 0.8) 50%, 
    rgba(0, 168, 255, 1) 100%);
  transform: rotate(3deg) translate(0px, -4px);
  border-radius: 0 100px 100px 0;
  box-shadow: 0 0 15px rgba(0, 122, 204, 0.6);
}

/* 旋转器（如果启用） */
#nprogress .spinner {
  display: block;
  position: fixed;
  z-index: 1031;
  top: 20px;
  right: 20px;
}

#nprogress .spinner-icon {
  width: 18px;
  height: 18px;
  box-sizing: border-box;
  border: solid 2px transparent;
  border-top-color: var(--primary, #007acc);
  border-left-color: var(--primary, #007acc);
  border-radius: 50%;
  animation: nprogress-spinner 400ms linear infinite;
}

@keyframes nprogress-spinner {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
  #nprogress .bar {
    background: linear-gradient(90deg, #4fc3f7, #29b6f6);
    box-shadow: 0 0 10px rgba(79, 195, 247, 0.5);
  }
  
  #nprogress .peg {
    background: linear-gradient(to right, 
      rgba(79, 195, 247, 0) 0%, 
      rgba(79, 195, 247, 0.8) 50%, 
      rgba(41, 182, 246, 1) 100%);
    box-shadow: 0 0 15px rgba(79, 195, 247, 0.6);
  }
  
  #nprogress .spinner-icon {
    border-top-color: #4fc3f7;
    border-left-color: #4fc3f7;
  }
}

/* 手机端适配 */
@media (max-width: 768px) {
  #nprogress .bar {
    height: 2px;
  }
  
  #nprogress .peg {
    width: 80px;
  }
  
  #nprogress .spinner {
    top: 15px;
    right: 15px;
  }
  
  #nprogress .spinner-icon {
    width: 16px;
    height: 16px;
  }
}

/* 高对比度模式 */
@media (prefers-contrast: high) {
  #nprogress .bar {
    background: var(--primary, #007acc);
    box-shadow: none;
  }
  
  #nprogress .bar::before {
    display: none;
  }
  
  #nprogress .peg {
    background: var(--primary, #007acc);
    box-shadow: none;
  }
}

/* 减少动画模式 */
@media (prefers-reduced-motion: reduce) {
  #nprogress .bar::before {
    animation: none;
  }
  
  #nprogress .spinner-icon {
    animation: none;
  }
}

/* 阅读进度指示器 */
.reading-progress-indicator {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  z-index: 1030;
  pointer-events: none;
}

.reading-progress-indicator::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--primary, #007acc), #00a8ff);
  transition: width 0.3s ease;
  width: var(--progress, 0%);
}

/* 与 Tocbot 的协调样式 */
body.toc-active #nprogress .bar {
  top: 0;
  z-index: 99; /* 确保在目录下方 */
}

/* 页面加载时的全屏遮罩（可选） */
.nprogress-loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(2px);
  z-index: 1030;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.nprogress-loading-overlay.active {
  opacity: 1;
}

@media (prefers-color-scheme: dark) {
  .nprogress-loading-overlay {
    background: rgba(0, 0, 0, 0.8);
  }
}
