#!/bin/bash
# IMPOSSIBLE-GEO - Cloudflare Worker batch generator
# 6 images: CGA palette + impossible geometry structures
# Usage: ./cf-batch-impossible-geo.sh [steps]
# Requires: CF_IMG_API_KEY env var

set -e

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
CF_GEN="$SCRIPT_DIR/../../shared/scripts/cf-generate-wp.sh"
OUTPUT_DIR="$SCRIPT_DIR/../renders/$(date +%Y%m%d)"
STEPS="${1:-8}"
PREFIX="geo"

mkdir -p "$OUTPUT_DIR"

echo "IMPOSSIBLE-GEO - CF Worker Batch"
echo "Output: $OUTPUT_DIR"
echo "Steps:  $STEPS"
echo ""

run() {
    local label="$1"
    local prompt="$2"
    echo "[$label]"
    bash "$CF_GEN" "$prompt" "$OUTPUT_DIR" "${PREFIX}_${label}" "$STEPS"
    echo ""
}

run "penrose" "A Penrose triangle rendered in CGA graphics aesthetic, cyan magenta white black palette. Impossible geometry, the three beams connect in a loop that defies three-dimensional space. Mathematical precision, clean geometric lines, retro computing aesthetic. Pure void background, minimal atmospheric composition. The impossible structure floats in empty black space. 1920x1080 widescreen, CGA masterpiece."

run "escher_stairs" "Escher-style impossible staircase rendered in CGA graphics aesthetic, white cyan black palette. Staircases loop back on themselves in an endless circuit, figures absent, pure architectural form. Isometric perspective, mathematical precision, retro computing aesthetic. Clean geometric lines, tiled floor pattern. 1920x1080 widescreen, CGA masterpiece."

run "tesseract" "A tesseract hypercube projection rendered in CGA graphics aesthetic, cyan magenta white black palette. Four-dimensional cube unfolding in three-dimensional space, nested cubes connected by edges, dimensional depth suggested by line weight. Mathematical precision, pure geometric form. Void background. 1920x1080 widescreen, CGA masterpiece."

run "klein_bottle" "A Klein bottle rendered in CGA graphics aesthetic, magenta white black palette. The surface passes through itself with no inside or outside boundary, smooth continuous topology. Mathematical precision, clean wireframe lines, retro computing aesthetic. Pure void, minimal composition, the impossible surface as pure form. 1920x1080 widescreen, CGA masterpiece."

run "mobius" "A Mobius strip rendered in CGA graphics aesthetic, cyan white black palette. Single-sided surface with one boundary edge, half-twist clearly visible, smooth geometric form. Mathematical precision, retro computing aesthetic, clean geometric lines. Pure void background, the strip as pure mathematical object. 1920x1080 widescreen, CGA masterpiece."

run "fractal_cathedral" "A fractal cathedral rendered in CGA graphics aesthetic, cyan magenta white black palette. Gothic spires that recursively contain smaller versions of themselves, self-similar architecture at every scale. Mathematical precision, retro computing aesthetic, clean geometric lines. Deep black void, the impossible architecture as pure form. 1920x1080 widescreen, CGA masterpiece."

echo "Batch complete. Images in: $OUTPUT_DIR"
