import sys, json
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
    b=p.chromium.launch(args=["--font-render-hinting=none","--force-color-profile=srgb","--disable-lcd-text"])
    pg=b.new_page(viewport={"width":1536,"height":864})
    pg.goto("file:///home/ubuntu/standalone/builds/23-tate-2/src/index.html")
    pg.wait_for_function("document.fonts.status==='loaded'")
    pg.wait_for_timeout(400)
    print(pg.evaluate("""() => {
      const out={root: getComputedStyle(document.documentElement).fontSize,
                 bodyY: document.body.getBoundingClientRect().y,
                 docW: document.documentElement.scrollWidth,
                 docH: document.documentElement.scrollHeight};
      for (const sel of ['.logo','.nav','.nav__skip','.hero-copy','.headline','.sub','.actions','.btn','.link','.meta','.strip','.strip img','.hero-plate']) {
        const e=document.querySelector(sel); if(!e) continue;
        const r=e.getBoundingClientRect();
        const cs=getComputedStyle(e);
        out[sel]=[Math.round(r.x),Math.round(r.y),Math.round(r.width),Math.round(r.height),cs.fontSize,cs.lineHeight];
      }
      const h=document.querySelector('.headline');
      const rg=document.createRange(); rg.selectNodeContents(h);
      out.headlineRects=[...rg.getClientRects()].map(r=>[Math.round(r.x),Math.round(r.y),Math.round(r.width),Math.round(r.height)]);
      return out;
    }"""))
    b.close()
