/* Scroll Progress Component Styles */
/* Base styles apply to both primary and secondary bars */
.scroll-progress-bar, #scroll-progress {
  --scroll-pct: 0; /* 0-100 */
  --flow-offset: 0px; /* animated internal pattern offset */
  --loading-reveal: 0; /* 0-1 for loader fade in at end */
  --footer-mask-height: 0px; /* dynamically set from JS to fade bar beneath footer */
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  isolation: isolate; /* keep blending subtle */
  will-change: height, filter;
  /* Layer 1: faint chroma “plasma” gradient; Layer 2: micro filament pattern */
  background:
    linear-gradient(to bottom,
      rgba(59,130,246,0.00) 0%,
      rgba(59,130,246,0.18) 10%,
      rgba(99,102,241,0.25) 52%,
      rgba(124,58,237,0.30) 70%,
      rgba(236,72,153,0.38) 100%),
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.18) 0px,
      rgba(255,255,255,0.10) 2px,
      rgba(255,255,255,0.02) 4px,
      rgba(255,255,255,0.02) 12px
    );
  background-blend-mode: overlay, normal;
  background-position: 0 0, 0 var(--flow-offset);
  background-size: 100% 100%, 100% 140px; /* slow flowing band */
  border-radius: 999px;
  opacity: 0.85;
  /* Soft ambient glow kept restrained */
  box-shadow:
    0 0 0 1px rgba(59,130,246,0.18),
    0 0 4px 1px rgba(99,102,241,0.25),
    0 6px 18px -4px rgba(124,58,237,0.28);
  transition: height 0.45s cubic-bezier(.22,.9,.28,1), filter 0.75s ease, opacity 0.45s ease, box-shadow 0.8s ease;
  /* Mask so bar visually slides under footer: keep full height for percentage math, fade last footer-mask-height */
  -webkit-mask-image: linear-gradient(to bottom, rgba(0,0,0,1) calc(100% - var(--footer-mask-height)), rgba(0,0,0,0) 100%);
  mask-image: linear-gradient(to bottom, rgba(0,0,0,1) calc(100% - var(--footer-mask-height)), rgba(0,0,0,0) 100%);
}
/* sheen layer for both bars */
#scroll-progress::before, .scroll-progress-bar::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to bottom, rgba(255,255,255,0.55) 0%, rgba(255,255,255,0.0) 55%),
    radial-gradient(circle at 60% 18%, rgba(255,255,255,0.18), transparent 55%),
    radial-gradient(circle at 35% 68%, rgba(255,255,255,0.12), transparent 60%),
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.25) 0px,
      rgba(255,255,255,0.07) 1px,
      rgba(255,255,255,0.0) 2px,
      rgba(255,255,255,0.0) 6px
    );
  background-blend-mode: screen, normal, normal, overlay;
  mix-blend-mode: plus-lighter;
  opacity: 0.28;
  pointer-events: none;
  mask: linear-gradient(to bottom, rgba(0,0,0,0.9), rgba(0,0,0,0.25) 70%, rgba(0,0,0,0) 100%);
  animation: scroll-progress-speckle 22s linear infinite;
}
/* tooltip: only show for primary bar (primary keeps default left tooltip) */
#scroll-progress::after, .scroll-progress-bar.primary::after {
  content: attr(data-pct) '%';
  position: absolute;
  top: calc(var(--scroll-pct) * 1%);
  left: 100%;
  transform: translate(8px, -50%);
  background: rgba(17,24,39,0.88);
  backdrop-filter: blur(6px) saturate(170%);
  -webkit-backdrop-filter: blur(6px) saturate(170%);
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .5px;
  padding: 2px 6px 3px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  box-shadow: 0 4px 10px -2px rgba(0,0,0,0.5), 0 0 0 1px rgba(59,130,246,0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
  white-space: nowrap;
}
/* hover/active states */
#scroll-progress:hover::after, .scroll-progress-bar.primary:hover::after { opacity: 1; }
#scroll-progress.scroll-progress-active, .scroll-progress-bar.scroll-progress-active, .scroll-progress-bar.primary.scroll-progress-active { box-shadow: 0 0 0 1px rgba(59,130,246,0.28), 0 0 10px 2px rgba(99,102,241,0.40), 0 6px 18px -2px rgba(236,72,153,0.40); }
#scroll-progress:hover, .scroll-progress-bar:hover { opacity: 1; }
/* Inline loader that reveals near the end of the scroll */
/* loaders only visible for primary bar; secondary uses aria-hidden and no tooltip */
.scroll-progress-bar.primary .progress-loader, #scroll-progress .progress-loader, .scroll-progress-bar.primary .progress-loader {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 70%) scale(.60);
  display: flex;
  gap: 2px;
  align-items: center;
  opacity: var(--loading-reveal);
  /* pointer-events managed in JS after reveal threshold */
  filter: drop-shadow(0 0 calc(var(--loading-reveal)*3px) rgba(124,58,237, calc(var(--loading-reveal)*0.25)));
  transition: opacity .9s cubic-bezier(.22,.9,.28,1), transform 1.2s cubic-bezier(.22,.9,.28,1), filter 1.1s ease;
  z-index: 9999;
}
/* loader transform */
#scroll-progress[style] .progress-loader, .scroll-progress-bar.primary[style] .progress-loader { transform: translate(-50%, calc(72% - (var(--loading-reveal) * 46%))) scale(calc(.62 + var(--loading-reveal)*.18)); }
.scroll-progress-bar .progress-loader .pl-orb,
#scroll-progress .progress-loader .pl-orb {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffffff, #e2e8f0 55%, #6366f1 100%);
  box-shadow: 0 0 0 1px rgba(255,255,255,0.10), 0 0 4px -1px rgba(99,102,241,0.45), 0 0 10px -3px rgba(236,72,153,0.35);
  animation: loader-pulse 2.6s cubic-bezier(.25,.8,.3,1) infinite;
  opacity: .55;
}
.scroll-progress-bar .progress-loader .orb-b, #scroll-progress .progress-loader .orb-b { animation-delay: .18s; }
.scroll-progress-bar .progress-loader .orb-c, #scroll-progress .progress-loader .orb-c { animation-delay: .36s; }
@keyframes loader-pulse {
  0%, 72%, 100% { transform: scale(.62); opacity: .28; }
  40% { transform: scale(.92); opacity: .85; }
}

/* Toast (EG badge) */
.scroll-progress-toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  display: inline-flex;
  align-items: center;
  padding: .55rem .70rem;
  background: linear-gradient(145deg, rgba(17,24,39,0.78), rgba(31,41,55,0.82));
  backdrop-filter: blur(10px) saturate(160%);
  -webkit-backdrop-filter: blur(10px) saturate(160%);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  box-shadow: 0 4px 18px -4px rgba(0,0,0,0.55), 0 0 0 1px rgba(99,102,241,0.20), 0 0 22px -4px rgba(236,72,153,0.35);
  color: #e5e7eb;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .3px;
  line-height: 1.1;
  max-width: 260px;
  animation: toast-in .65s cubic-bezier(.6,.15,.15,1);
  opacity: 0;
  transform: translateY(14px) scale(.92);
  will-change: transform, opacity;
  z-index: 99999;
}
.scroll-progress-toast[data-state="open"] { opacity: 1; transform: translateY(0) scale(1); transition: opacity .55s ease, transform .75s cubic-bezier(.55,.1,.1,1); }
.scroll-progress-toast[data-state="closing"] { opacity: 0; transform: translateY(10px) scale(.96); transition: opacity .4s ease, transform .5s ease; }

.scroll-progress-toast .eg-badge {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .5px;
  padding: 2px 6px 3px;
  border-radius: 6px;
  position: relative;
  background: linear-gradient(130deg,#64748b,#94a3b8 50%,#e2e8f0);
  -webkit-background-clip: text;
  color: transparent;
  text-shadow: 0 0 6px rgba(99,102,241,0.35), 0 0 14px rgba(236,72,153,0.25);
}

@keyframes toast-in {
  0% { opacity:0; transform: translateY(14px) scale(.94); }
  55% { opacity:1; transform: translateY(-2px) scale(1.01); }
  100% { opacity:1; transform: translateY(0) scale(1); }
}

@media (max-width: 640px) {
  .scroll-progress-toast { right: .85rem; bottom: .85rem; font-size: 11px; padding: .50rem .65rem; }
}

/* Screen reader only helper */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
@keyframes scroll-progress-speckle {
  0% { background-position: 0 0, 60% 18%, 35% 68%, 0 0; }
  50% { background-position: 0 0, 59% 20%, 36% 66%, 0 28px; }
  100% { background-position: 0 0, 60% 18%, 35% 68%, 0 56px; }
}
@media (prefers-reduced-motion: reduce) {
  #scroll-progress, .scroll-progress-bar { transition: height 0.2s linear; filter: none !important; background-size: 100% 100%, 100% 140px; }
  #scroll-progress::before, .scroll-progress-bar::before { animation: none; }
  #scroll-progress .progress-loader, .scroll-progress-bar .progress-loader { transition:none; animation: loader-pulse 1.4s ease-in-out infinite; }
}

/* Mobile adjustments: push bar further left & add extra top spacing */
@media (max-width: 640px) {
  .scroll-progress-wrapper {
  /* Subtle inward nudge (compromise between earlier 8px and too-tight 4px). */
  left: 6px !important;
    top: 0 !important; /* If you want a gap below mobile nav, change to something like 72px */
    bottom: 0 !important;
  }
  /* Slightly enlarge the hit-area for better accessibility on touch */
  #scroll-progress::after {
    font-size: 9px;
    transform: translate(8px, -50%);
  }
  /* Add inward left padding / shift for logo so it doesn't hug edge */
  /* Apply to primary loader only */
  .scroll-progress-wrapper #scroll-progress .progress-loader, .scroll-progress-wrapper .scroll-progress-bar.primary .progress-loader {
    padding-left: 2px;
    transform: translate(-50%, calc(70% - (var(--loading-reveal) * 50%))) scale(calc(.65 + var(--loading-reveal)*.25)) translateX(2px);
  }
}

/* Right-side specific adjustments: ensure inner bar sits at right edge of wrapper
   and the percentage tooltip flips to the left so it doesn't overflow the viewport */
.scroll-progress-bar[data-side="right"] {
  left: auto !important;
  right: 0 !important;
  z-index: 5; /* lift above some page content so it's visible */
}
.scroll-progress-bar[data-side="right"]::after {
  left: auto;
  right: 100%;
  transform: translate(-10px, -50%);
}

/* Secondary bar visuals: thinner, subtle offset for the double-line look */
.scroll-progress-bar.secondary {
  width: 2px;
  left: 50%;
  transform: translateX(3px);
  opacity: 0.75;
  background: linear-gradient(to bottom, rgba(59,130,246,0.06), rgba(99,102,241,0.08));
  box-shadow: none;
}
.scroll-progress-bar.secondary::before { display:none; }
.scroll-progress-bar.secondary::after { display:none; }

