/**
 * Page Transition Loading Bar
 * - Top loading bar: 3px height, fixed top, full width
 * - Gold (#ffd700) in dark theme, amber (#b45309) in light theme
 * - Anti-flash: sets background immediately via CSS
 * - No dependencies
 */

/* Anti-flash: immediate background color to prevent white flash between pages */
html {
  background-color: #0d1117;
}
html[data-theme="light"],
[data-theme="light"] html {
  background-color: #f8fafc;
}

/* Loading bar container */
#page-transition-bar {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  z-index: 99999;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  background: linear-gradient(90deg, #ffd700 0%, #ffb300 50%, #ffd700 100%);
}

/* Light theme bar color */
[data-theme="light"] #page-transition-bar,
html[data-theme="light"] #page-transition-bar {
  background: linear-gradient(90deg, #b45309 0%, #d97706 50%, #b45309 100%);
}

/* Active state: bar is visible and animating */
#page-transition-bar.active {
  opacity: 1;
  animation: page-transition-progress 8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Complete state: fills to 100% and fades out */
#page-transition-bar.complete {
  width: 100% !important;
  opacity: 0;
  transition: width 0.15s ease-out, opacity 0.4s ease 0.15s;
  animation: none;
}

/* Progress animation: fast start, slow crawl, stops at ~85% */
@keyframes page-transition-progress {
  0% {
    width: 0;
  }
  10% {
    width: 30%;
  }
  30% {
    width: 55%;
  }
  50% {
    width: 70%;
  }
  70% {
    width: 78%;
  }
  100% {
    width: 85%;
  }
}

/* Shimmer effect on the bar tip */
#page-transition-bar.active::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  animation: page-transition-shimmer 1.5s ease-in-out infinite;
}

@keyframes page-transition-shimmer {
  0% {
    opacity: 0;
    transform: translateX(-80px);
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(20px);
  }
}
