from playwright.sync_api import sync_playwright
import os

output_dir = os.path.expanduser("~/Documents/kaizen-campaign")

pages = [
    {"file": "01-the-proof.html", "output": "kaizen-s10-the-proof-1080x1080.png", "w": 1080, "h": 1080},
    {"file": "02-the-journey.html", "output": "kaizen-s10-the-journey-1080x1920.png", "w": 1080, "h": 1920},
    {"file": "03-the-hook.html", "output": "kaizen-s10-the-hook-1080x1080.png", "w": 1080, "h": 1080},
]

with sync_playwright() as p:
    browser = p.chromium.launch()
    for pg in pages:
        context = browser.new_context(
            viewport={"width": pg["w"], "height": pg["h"]},
            device_scale_factor=1
        )
        page = context.new_page()
        url = f"file://{os.path.join(output_dir, pg['file'])}"
        page.goto(url, wait_until="networkidle")
        page.wait_for_timeout(2000)  # let fonts load
        out_path = os.path.join(output_dir, pg["output"])
        page.screenshot(path=out_path, full_page=False)
        print(f"✅ Saved: {out_path}")
        context.close()
    browser.close()

print("Done!")
