#!/usr/bin/env python3
"""Generate styled versions of slide11 hero — image 1 direction (golden fat in square glass bowl)
but with a rich, high-end kitchen/table scene. No grapes, no nuts."""

import google.genai as genai
import os
from PIL import Image

client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])

prompt = """Photorealistic editorial food photograph, 3:4 portrait orientation. Shot on Phase One IQ4 150MP medium format digital back with Schneider Kreuznach 120mm LS f/4 Macro lens at f/3.5. Bon Appetit / Kinfolk magazine cover quality.

CENTER SUBJECT: A small square clear glass ramekin filled with dense solid rendered golden animal fat (like ghee or schmaltz). The fat is rich golden-yellow, firm and waxy like cold European butter — opaque, dense, with visible knife scoop marks showing it yields to a knife but does not flow. Satiny waxy sheen on the surface.

HIGH-END STYLED TABLE SCENE around it:
- Dark moody wooden table surface — aged oak or walnut with visible grain and patina, NOT white marble
- Behind the ramekin: a thick slice of freshly cut rustic sourdough bread showing its beautiful open crumb structure, resting on a small ceramic plate in matte cream/off-white
- A brass butter knife with dark wooden handle laid casually beside the ramekin
- A small ceramic pinch bowl of flaky Maldon sea salt, slightly behind and to the right
- Warm linen napkin in oatmeal/natural color, loosely gathered to the left side, partially under the ramekin
- In the soft background: the edge of a dark green ceramic bottle (olive oil) and a worn copper pot, both heavily out of focus
- Fresh rosemary sprigs — two, laid naturally on the wooden surface near the bread

LIGHTING: Warm directional side-light from the left, like late afternoon sun through a kitchen window. Beautiful golden caustics through the glass bowl onto the wood surface. Rich, warm shadows on the right side. NOT flat or clinical — moody and inviting.

DEPTH OF FIELD: Very shallow — ramekin tack sharp, bread slightly soft, background objects dissolved into creamy bokeh.

MOOD: Warm, artisanal, lived-in kitchen. Like a beautiful weekend morning in a French countryside kitchen. Premium but not sterile. The scene should feel FULL and STYLED but not cluttered.

ABSOLUTELY NO grapes, no nuts, no berries, no fruit of any kind. Only bread, fat, salt, herbs, and kitchen objects."""

OUT = "/root/.openclaw/workspace/phat-visuals"
os.makedirs(OUT, exist_ok=True)

# Generate with gemini-2.5-flash for image gen
for shot in range(1, 7):
    print(f"Shot {shot}, gemini-2.5-flash-image, attempt 1...")
    try:
        response = client.models.generate_content(
            model="gemini-2.5-flash-image",
            contents=prompt,
            config=genai.types.GenerateContentConfig(
                response_modalities=["image", "text"],
            ),
        )
        for part in response.candidates[0].content.parts:
            if part.inline_data and part.inline_data.mime_type.startswith("image/"):
                raw_path = f"{OUT}/slide11-v16-raw-{shot}.png"
                with open(raw_path, "wb") as f:
                    f.write(part.inline_data.data)
                # Resize to 768x1024 (3:4)
                img = Image.open(raw_path)
                img = img.resize((768, 1024), Image.LANCZOS)
                final_path = f"{OUT}/slide11-v16-{shot}.png"
                img.save(final_path)
                print(f"  Saved: {final_path} ({img.size[0]}x{img.size[1]})")
                break
        else:
            print(f"  No image in response for shot {shot}")
    except Exception as e:
        print(f"  Error shot {shot}: {e}")

print("Done — v16 styled kitchen scene generation complete.")
