#!/usr/bin/env python3
"""Hero piloto 03 — formando + pai + mãe (3 pessoas) em fundo PRETO PROFUNDO
no estilo da referência landing oferta.px3lab.com.br.

Objetivo: compor cena limpa, 3 rostos bem definidos, pra receber face-detection
no estilo da referência (cantos luminosos verdes + scan grid + badges MATCH%).
"""
import os
import base64
from pathlib import Path
from openai import OpenAI

env_path = Path("/opt/mia/.env")
if env_path.exists():
    for line in env_path.read_text().splitlines():
        if line.strip() and not line.startswith("#") and "=" in line:
            k, v = line.split("=", 1)
            os.environ.setdefault(k.strip(), v.strip())

OUT = Path("/opt/mia/workspace/clientes/px3lab/lancamento_photorf2/criativos_oferta/hero_familia_formatura_03.png")

client = OpenAI()

PROMPT = """Cinematic studio portrait of a Brazilian graduation moment — ONLY 3 PEOPLE:
the graduate in the CENTER (young adult, early 20s, wearing a traditional black graduation
gown and black mortarboard cap with tassel, confident proud smile), the FATHER on the left
(40s-50s, warm expression, hand gently on graduate's shoulder), and the MOTHER on the right
(40s-50s, emotional proud smile, embracing the graduate). All three faces clearly visible,
heads at roughly the same height, slight closeness — a tight family group portrait, chest-up framing.

CRITICAL: deep solid black background (#000000), seamless studio backdrop, zero environment,
zero bokeh, zero party decoration. Pure black void behind them.

Lighting: dramatic directional key light from upper-left, soft rim light on the right side
to separate silhouettes from the black background. Clean highlights on faces, deep rich
shadows on sides. Studio portrait feel, cinematic.

Mood: proud, warm, emotional but composed — not laughing hysterically, more like a solemn
proud smile. Authentic Brazilian family, can be any ethnicity (mixed or Latino preferred).

Style: shot on 85mm f/1.4, photorealistic, high-end editorial portrait, sharp focus on
all three faces, slight film grain. No text, no overlays, no graphics. Documentary-editorial
portrait photography.

Composition: tight medium shot, 3 heads form a horizontal line across the frame,
graduate center with cap slightly higher. All 3 faces must be fully visible and well-lit,
no face partially hidden, no hats blocking faces.
"""

print("Gerando hero_familia_formatura_03 (1024x1024, bg preto, 3 pessoas)...")
resp = client.images.generate(
    model="gpt-image-1",
    prompt=PROMPT,
    size="1024x1024",
    quality="high",
    n=1,
)

img_b64 = resp.data[0].b64_json
OUT.write_bytes(base64.b64decode(img_b64))
print(f"OK -> {OUT} ({OUT.stat().st_size//1024}KB)")
