/**
 * progress-bar.js
 * Reading progress indicator for articles
 */

(function() {
  'use strict';

  const progressBar = document.getElementById('progress-bar');
  if (!progressBar) return;

  window.addEventListener('scroll', () => {
    const windowHeight = document.documentElement.scrollHeight - window.innerHeight;
    const scrolled = window.scrollY;
    const progress = windowHeight > 0 ? (scrolled / windowHeight) * 100 : 0;

    progressBar.style.width = progress + '%';
    progressBar.setAttribute('aria-valuenow', Math.round(progress));
  }, { passive: true });
})();
