#!/usr/bin/env python3
"""v17 — styled scene for image 1 direction using LOCKED visual-style.json v3.0.
Warm golden, clean, max 3 elements, no herbs/garnish. More styled than v15 but on-brand."""

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

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

prefix = "Warm golden food photography, bright abundant warm light flooding the scene like golden afternoon sun. Monochromatic warm palette — everything in gold, cream, amber family. Warm shadows (amber/brown, never cool). High luminosity, airy, lifted shadows. Clean warm background. Tight hero framing, shallow depth of field. Subtle warm sheen on all surfaces. Rich saturated warm yellow tones. Quiet luxury, minimal, no decoration."
suffix = "No cool tones, no blue, no gray shadows, no dark zones. Warm throughout. No herbs, no garnish, no grapes, no nuts, no fruit."

prompt = f"""{prefix}

Vertical 3:4 composition, tight crop. A small square clear glass ramekin filled with dense solid rendered golden animal fat — rich saturated yellow, firm and waxy like cold European butter, opaque, with visible knife scoop marks on the surface showing dense texture. Satiny waxy sheen.

Behind the ramekin: a thick artisan sourdough bread slice showing beautiful open crumb, resting on warm cream-toned butter parchment paper. A brass butter knife with aged warm patina laid casually beside the ramekin on the parchment.

Surface: warm honey-toned marble or stone that blends into a warm gradient background. A rumpled natural linen cloth partially visible at the edge of frame.

3/4 angle (45° down). The fat ramekin is the hero — bread and knife are supporting elements only. Maximum 3 elements in frame.

Shot on Phase One IQ4 medium format. Shallow depth of field — ramekin tack sharp, bread softly dissolving. Bon Appetit editorial quality.

{suffix}"""

OUT = "/root/.openclaw/workspace/phat-visuals"

for shot in range(1, 7):
    print(f"Shot {shot}...")
    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-v17-raw-{shot}.png"
                with open(raw_path, "wb") as f:
                    f.write(part.inline_data.data)
                img = Image.open(raw_path)
                img = img.resize((768, 1024), Image.LANCZOS)
                final_path = f"{OUT}/slide11-v17-{shot}.png"
                img.save(final_path)
                print(f"  Saved: {final_path}")
                break
        else:
            print(f"  No image in response")
    except Exception as e:
        print(f"  Error: {e}")

print("Done — v17")
