#!/usr/bin/env python3

import subprocess
import sys

def create_olevia_brandbook():
    """Create OLEVIA brand book cover with updated headline"""
    
    # Image dimensions (matching original proportions)
    width = 1200
    height = 800
    
    # Colors
    bg_start = "#D4AC0D"  # Golden amber start
    bg_end = "#B7950B"    # Golden amber end
    text_color = "white"
    border_color = "white"
    
    # Create base image with gradient background
    cmd = [
        'convert',
        '-size', f'{width}x{height}',
        f'gradient:{bg_start}-{bg_end}',
        '/tmp/base.png'
    ]
    subprocess.run(cmd, check=True)
    
    # Add "BRAND BOOK" text at top
    cmd = [
        'convert', '/tmp/base.png',
        '-font', 'DejaVu-Sans',
        '-pointsize', '24',
        '-fill', text_color,
        '-gravity', 'North',
        '-annotate', '+0+40', 'BRAND BOOK',
        '/tmp/with_brandbook.png'
    ]
    subprocess.run(cmd, check=True)
    
    # Add OLEVIA logo with border
    # First create the logo box
    cmd = [
        'convert', '/tmp/with_brandbook.png',
        '-stroke', border_color,
        '-strokewidth', '4',
        '-fill', 'none',
        '-draw', f'roundrectangle {width//2-180},{height//2-120} {width//2+180},{height//2-60} 20,20',
        '/tmp/with_logo_border.png'
    ]
    subprocess.run(cmd, check=True)
    
    # Add OLEVIA text inside the border
    cmd = [
        'convert', '/tmp/with_logo_border.png',
        '-font', 'DejaVu-Sans-Bold',
        '-pointsize', '48',
        '-fill', text_color,
        '-gravity', 'Center',
        '-annotate', '+0-90', 'OLEVIA',
        '/tmp/with_logo.png'
    ]
    subprocess.run(cmd, check=True)
    
    # Add main headline "The Age of 'close-enough' is Over"
    cmd = [
        'convert', '/tmp/with_logo.png',
        '-font', 'DejaVu-Serif',
        '-pointsize', '56',
        '-fill', text_color,
        '-gravity', 'Center',
        '-annotate', '+0+20', "The Age of 'close-enough'",
        '/tmp/with_headline1.png'
    ]
    subprocess.run(cmd, check=True)
    
    # Add "is Over" on next line
    cmd = [
        'convert', '/tmp/with_headline1.png',
        '-font', 'DejaVu-Serif',
        '-pointsize', '56',
        '-fill', text_color,
        '-gravity', 'Center',
        '-annotate', '+0+80', 'is Over',
        '/tmp/with_headline.png'
    ]
    subprocess.run(cmd, check=True)
    
    # Add subtext
    subtext = "The first dairy-identical plant butter that performs exactly"
    cmd = [
        'convert', '/tmp/with_headline.png',
        '-font', 'DejaVu-Sans',
        '-pointsize', '20',
        '-fill', text_color,
        '-gravity', 'Center',
        '-annotate', '+0+140', subtext,
        '/tmp/with_subtext1.png'
    ]
    subprocess.run(cmd, check=True)
    
    # Add second line of subtext
    subtext2 = "like dairy butter in taste, texture, and performance"
    cmd = [
        'convert', '/tmp/with_subtext1.png',
        '-font', 'DejaVu-Sans',
        '-pointsize', '20',
        '-fill', text_color,
        '-gravity', 'Center',
        '-annotate', '+0+165', subtext2,
        '/root/.openclaw/workspace/olevia-brandbook-updated.png'
    ]
    subprocess.run(cmd, check=True)
    
    # Clean up temp files
    import os
    temp_files = [
        '/tmp/base.png',
        '/tmp/with_brandbook.png', 
        '/tmp/with_logo_border.png',
        '/tmp/with_logo.png',
        '/tmp/with_headline1.png',
        '/tmp/with_headline.png',
        '/tmp/with_subtext1.png'
    ]
    
    for temp_file in temp_files:
        try:
            os.remove(temp_file)
        except:
            pass
    
    print("✅ OLEVIA brand book cover updated successfully!")
    print("📁 Saved to: /root/.openclaw/workspace/olevia-brandbook-updated.png")

if __name__ == "__main__":
    create_olevia_brandbook()