from playwright.sync_api import sync_playwright
import json
with sync_playwright() as p:
    b=p.chromium.launch(args=["--force-color-profile=srgb","--font-render-hinting=none","--disable-lcd-text"])
    pg=b.new_page(viewport={"width":1536,"height":864}, device_scale_factor=1)
    pg.goto("file:///home/ubuntu/standalone/builds/25-aesop-1/src/index.html")
    pg.wait_for_timeout(500)
    print(pg.evaluate("""() => {
      const out = {};
      const root = getComputedStyle(document.documentElement).fontSize;
      out.root = root;
      out.body = document.body.getBoundingClientRect().toJSON();
      for (const sel of ['.hero','.eyebrow','.rule--head','.headline','.headline .ln:nth-child(1)','.headline .ln:nth-child(2)','.headline .ln:nth-child(3)','.sub','.actions','.btn','.link','.rule--foot','.list','.list li']) {
        const e = document.querySelector(sel);
        if (!e) { out[sel] = null; continue; }
        const r = e.getBoundingClientRect();
        const cs = getComputedStyle(e);
        out[sel] = {x:+r.x.toFixed(1), y:+r.y.toFixed(1), w:+r.width.toFixed(1), h:+r.height.toFixed(1),
                    fs:cs.fontSize, lh:cs.lineHeight, ls:cs.letterSpacing};
      }
      return out;
    }"""))
    b.close()
