#!/usr/bin/env python3
"""Hero para piloto 04 — ângulo CURIOSIDADE (Opção A).

Cena enigmática: tela de computador em close-up com milhares de fotos
passando em alta velocidade (motion blur), overlay HUD verde-lima sutil
(scan lines, elementos minimalistas), e uma mão humana PARADA ao lado
do notebook — não digitando, não clicando, só assistindo a máquina
trabalhar sozinha. Vibe tech noturna, iluminação só da tela, fundo
preto profundo.
"""
import os
import base64
from pathlib import Path

env_path = Path("/opt/mia/.env")
for line in env_path.read_text().splitlines():
    if line.startswith("OPENAI_API_KEY="):
        os.environ["OPENAI_API_KEY"] = line.split("=", 1)[1].strip()
        break

try:
    from openai import OpenAI
except ImportError:
    os.system("pip install --break-system-packages openai -q")
    from openai import OpenAI

client = OpenAI()
OUT = Path("/opt/mia/workspace/clientes/px3lab/lancamento_photorf2/criativos_oferta")
OUT.mkdir(parents=True, exist_ok=True)

prompt = (
    "Photorealistic cinematic close-up of a modern laptop screen on a dark wooden desk at night, "
    "the screen displays a dense grid of tiny photo thumbnails blurring past in high-speed motion, "
    "visible vertical motion blur streaks on the thumbnails showing the system is auto-processing them extremely fast, "
    "a subtle lime-green (hex #87C925) scan-line HUD overlay on top of the screen with minimalist tech markers and faint grid lines, "
    "soft lime-green glow emanating from the screen illuminating the surrounding darkness, "
    "a single human hand resting completely still on the desk beside the laptop, palm down, relaxed, NOT touching the keyboard, NOT clicking, just observing, "
    "the hand is lit only by the green reflected light of the screen, "
    "deep black background, no other light sources, "
    "atmosphere: tech noir, nocturnal, mysterious, as if the machine is doing all the work on its own, "
    "shallow depth of field focused on the screen with the hand slightly out of focus in the foreground, "
    "editorial technology photography, highly detailed, 4k, "
    "no text, no readable logos, no watermarks, no visible brand on the laptop, "
    "square 1:1 composition, framed so the laptop screen occupies the upper 65% of the image and the hand sits in the lower-right area"
)

print("Gerando hero curiosidade (Opção A) via gpt-image-1 (pode levar 20-40s)...")
r = client.images.generate(
    model="gpt-image-1",
    prompt=prompt,
    size="1024x1024",
    quality="high",
    n=1,
)
b64 = r.data[0].b64_json
dest = OUT / "hero_curiosidade_A.png"
dest.write_bytes(base64.b64decode(b64))
print(f"OK -> {dest}")
