const { chromium } = require('playwright');
const URL = 'https://studiosfeedback.com';
const OUT = '/home/claude/agency-web/audit';
const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 16_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.0 Mobile/15E148 Safari/604.1';

(async () => {
  const browser = await chromium.launch();
  const ctx = await browser.newContext({ viewport: { width: 390, height: 844 }, userAgent: UA, deviceScaleFactor: 2, isMobile: true, hasTouch: true });
  const page = await ctx.newPage();
  await page.goto(URL, { waitUntil: 'networkidle', timeout: 60000 }).catch(()=>{});
  await page.evaluate(async () => { await new Promise(r=>{let y=0;const s=()=>{window.scrollTo(0,y);y+=400;if(y<document.body.scrollHeight)setTimeout(s,110);else{window.scrollTo(0,0);setTimeout(r,400);}};s();}); });
  await page.waitForTimeout(800);
  const total = await page.evaluate(()=>document.body.scrollHeight);
  console.log('mobile pageHeight:', total);
  const vh=844; let i=0;
  for (let y=0;y<total;y+=vh){ await page.evaluate(yy=>window.scrollTo(0,yy),y); await page.waitForTimeout(450); i++; await page.screenshot({path:`${OUT}/m-sec-${String(i).padStart(2,'0')}.png`}); }
  console.log('mobile sections:', i);
  await browser.close();
})();
