#!/usr/bin/env python3
"""Concept #46 Void Absence Design — Playwright 캡처 스크립트"""

from pathlib import Path
from playwright.sync_api import sync_playwright

HTML_PATH = Path(__file__).parent / "template.html"
OUTPUT_DIR = Path(__file__).parent

def capture():
    with sync_playwright() as p:
        browser = p.chromium.launch()
        page = browser.new_page(viewport={"width": 1080, "height": 1080})

        file_url = f"file://{HTML_PATH.resolve()}"
        page.goto(file_url, wait_until="networkidle")
        page.wait_for_timeout(800)

        sample_path = OUTPUT_DIR / "sample.png"
        copy_path = OUTPUT_DIR / "46-void-absence-design.png"

        page.screenshot(path=str(sample_path), clip={"x": 0, "y": 0, "width": 1080, "height": 1080})
        print(f"Saved: {sample_path}")

        import shutil
        shutil.copy2(sample_path, copy_path)
        print(f"Saved: {copy_path}")

        browser.close()

        # 파일 크기 확인
        size_kb = sample_path.stat().st_size / 1024
        print(f"File size: {size_kb:.1f} KB")
        assert size_kb > 50, f"파일이 너무 작습니다: {size_kb:.1f} KB"
        print("SUCCESS")

if __name__ == "__main__":
    capture()
