/* V6.20 — mark light-surface dialogs and remove stale automatic contrast. */
(()=>{
  'use strict';
  const panelSelector='.apu-cookie-panel,.zip-access__panel';
  const copySelector=[
    '.apu-cookie-panel__label','.apu-cookie-panel h2','.apu-cookie-panel p','.apu-cookie-panel p a',
    '.zip-access__eyebrow','.zip-access h2','.zip-access__copy','.zip-access__project',
    '.zip-access__email','.zip-access__note','.zip-access__deploy-note','.zip-access__check','.zip-access__check span',
    '.zip-access__check strong','.zip-access__check a'
  ].join(',');
  let queued=false;
  const repair=()=>{
    queued=false;
    document.querySelectorAll(panelSelector).forEach(panel=>{
      panel.dataset.apuContrastLock='ink';
      panel.style.setProperty('background-color','#fff','important');
      panel.style.setProperty('color','#090d15','important');
      panel.style.setProperty('-webkit-text-fill-color','#090d15','important');
    });
    document.querySelectorAll(copySelector).forEach(node=>{
      delete node.dataset.apuAutoContrast;
      node.style.setProperty('color','#090d15','important');
      node.style.setProperty('-webkit-text-fill-color','#090d15','important');
      node.style.setProperty('opacity','1','important');
      node.style.setProperty('text-shadow','none','important');
    });
  };
  const schedule=()=>{if(!queued){queued=true;requestAnimationFrame(repair)}};
  new MutationObserver(schedule).observe(document.documentElement,{subtree:true,childList:true,attributes:true,attributeFilter:['class','style','data-front-theme','data-apu-theme']});
  addEventListener('load',()=>{schedule();setTimeout(schedule,100);setTimeout(schedule,700)},{once:true});
  document.addEventListener('apu:front-theme-change',schedule);
  document.addEventListener('apu:viewer-theme-change',schedule);
  schedule();
})();
