#!/usr/bin/env python3
from PIL import Image, ImageDraw, ImageFont
import os

W, H = 1080, 1350
BG = (26, 26, 46)        # #1a1a2e
TXT = (255, 255, 255)    # white
ORANGE = (249, 115, 22)  # #f97316
MUTED = (200, 200, 210)

def font(sz, bold=False):
    for p in ["/usr/share/fonts/truetype/poppins/Poppins-Bold.ttf",
              "/usr/share/fonts/truetype/poppins/Poppins-SemiBold.ttf",
              "/usr/share/fonts/truetype/poppins/Poppins-Regular.ttf",
              "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",
              "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf"]:
        if os.path.exists(p):
            try:
                return ImageFont.truetype(p, sz)
            except Exception:
                continue
    return ImageFont.load_default()

img = Image.new("RGB", (W, H), BG)
d = ImageDraw.Draw(img)

# Safe zone
SZ = 65
# Header
d.text((SZ, SZ), "DAS BENGKEL INDONESIA", font=font(34, True), fill=ORANGE)
d.text((W-SZ, SZ), "OTOMOTIF", font=font(30, True), fill=TXT, anchor="ra")

# Accent line under header
d.line([(SZ, SZ+70), (W-SZ, SZ+70)], fill=ORANGE, width=4)

# Title (big, bold)
title = "HONDA VTEC:\nCARA KERJA &\nMASALAH UMUM"
d.multiline_text((SZ, 260), title, font=font(96, True), fill=TXT, spacing=20)

# Subtitle
d.text((SZ, 760), "VTEC itu bukan sekadar jargon.", font=font(40), fill=ORANGE)
d.text((SZ, 820), "Ini teknologi yang bikin Honda beda.", font=font(40), fill=ORANGE)

# Body points
y = 950
points = [
    ("2 profil cam dalam 1 camshaft", "Bikin irit di rpm rendah, garang di rpm tinggi"),
    ("Solenoid + tekanan oli", "Kunci rahasia \"tendangan\" di rpm tinggi"),
    ("Rawat oli & komponen VTEC", "Biar tetap teriak, bukan cuma bikin pusing"),
]
for t, s in points:
    d.text((SZ, y), "\u2713  " + t, font=font(42, True), fill=TXT)
    d.text((SZ+45, y+60), s, font=font(30), fill=MUTED)
    y += 160

# Footer
d.line([(SZ, H-140), (W-SZ, H-140)], fill=(70,70,100), width=3)
d.text((SZ, H-120), "www.dasindonesia.com", font=font(30, True), fill=ORANGE)
d.text((W-SZ, H-120), "#EngineOverhaul", font=font(30, True), fill=TXT, anchor="ra")

img.save("das_fb_20260816_vtec.png")
print("saved das_fb_20260816_vtec.png")
