#!/usr/bin/env python3
import random
import time
import argparse

EPOCHS = [
    "15th-century early Renaissance Wunderkammer",
    "16th-century high Renaissance Wunderkammer",
    "17th-century Baroque Wunderkammer",
]

CATEGORIES = [
    "Naturalia",
    "Artificialia",
    "Mirabilia",
    "Scientifica",
    "Bestiaria",
    "Marina et Corallia",
    "Organica",
]

BESTIARIA = [
    "a preserved stag beetle with exaggerated mandibles",
    "a coiled serpent with iridescent scales",
    "a taxidermied chameleon frozen mid-transformation",
    "a skeletal bat with elongated finger bones",
    "a dried pufferfish inflated like a spiked globe",
    "a hybrid insect with translucent wings and a segmented body",
    "a scorpion preserved in amber",
    "a malformed frog with duplicated limbs",
    "a sea serpent fragment, fossilized and incomplete",
    "a cluster of moth wings arranged like stained glass",
    "a spider specimen with unusually long legs",
]

MARINA = [
    "a branching red coral resembling frozen flames",
    "a pale seahorse with an exaggerated curled spine",
    "a spiral nautilus shell with pearlescent fractures",
    "a deep-sea fish with oversized eyes and translucent skin",
    "a coral-encrusted bone recovered from the ocean floor",
    "a cluster of barnacles grown into an impossible geometry",
    "a dried starfish with asymmetrical arms",
    "a sea urchin shell with perfect radial symmetry",
]

ORGANICA = [
    "a preserved human heart hardened by alchemical salts",
    "a dried embryo suspended in resin",
    "a fragment of skin marked with unknown symbols",
    "a calcified tumor displayed as a natural marvel",
    "a bundle of nerves arranged like tangled threads",
    "a jawbone with irregular, asymmetrical teeth",
    "a vertebrae chain fused by mineral deposits",
]

NATURALIA = [
    "a lapis lazuli pigment stone from distant mountains",
    "a bezoar stone believed to neutralize poison",
    "a thunderstone mistaken for a fallen star",
    "a fossil shell with mathematically perfect spirals",
    "a toadstone believed to be extracted from a living toad",
    "a mandragora root carved into a human form",
    "a coco de mer sea nut of enormous size",
]

ARTIFICIALIA = [
    "a miniature brass astrolabe with worn engravings",
    "a clockwork automaton fragment with exposed gears",
    "a carved ivory sphere with interlocking layers",
    "a ceremonial dagger with an unusually wide blade",
    "a nautilus shell cup mounted in silver filigree",
    "micro-carvings on a cherry pit with tiny faces",
]

MIRABILIA = [
    "a so-called unicorn horn with spiral striations",
    "a phoenix feather preserved in glass",
    "a giant’s tooth attributed to mythical beings",
    "a lusus naturae stone resembling a human face",
    "a basilisk taxidermy monster stitched from sea creatures",
    "a remora fish said to halt ships",
]

SCIENTIFICA = [
    "a vellum-bound anatomical flap illustration",
    "a glass alembic used for distillation",
    "a convex mirror used for optical experiments",
    "a celestial globe showing distorted constellations",
    "a nocturnal for telling time by the stars",
    "a cabinet of drawers with hidden compartments",
]

MATERIALS = [
    "made of bone and resin",
    "made of horn, coral, and mineral deposits",
    "partially mineralized",
    "organically grown rather than crafted",
    "with uneven, eroded surfaces",
    "with porous, fragile textures",
    "with enamel-like sheen and cracks",
]

CONDITION = [
    "partially restored",
    "cracked and repaired with metal staples",
    "darkened by age and oxidation",
    "unearthed from a forgotten collection",
    "brought by explorers from distant shores",
    "catalogued but never fully understood",
    "sealed for centuries and recently opened",
]

DISPLAY = [
    "isolated specimen",
    "free-floating object",
    "no base, no pedestal",
    "irregular silhouette",
    "non-rectangular form",
    "organic asymmetry",
    "single object, centered",
    "no frame, no border, no panel",
]

STYLE = [
    "pixel art",
    "high contrast",
    "dark neutral background",
    "dramatic chiaroscuro lighting",
]

CATEGORY_OBJECTS = {
    "Bestiaria": BESTIARIA,
    "Marina et Corallia": MARINA,
    "Organica": ORGANICA,
    "Naturalia": NATURALIA,
    "Artificialia": ARTIFICIALIA,
    "Mirabilia": MIRABILIA,
    "Scientifica": SCIENTIFICA,
}

def make_prompt(seed: int):
    r = random.Random(seed)

    epoch = r.choice(EPOCHS)
    category = r.choice(CATEGORIES)
    obj = r.choice(CATEGORY_OBJECTS[category])

    parts = [
        epoch,
        category,
        obj,
        r.choice(MATERIALS),
        r.choice(CONDITION),
        r.choice(DISPLAY),
    ]

    # add 1–2 extra constraints
    parts.extend(r.sample(DISPLAY, k=r.randint(1, 2)))

    return ", ".join(parts + STYLE)

def main():
    ap = argparse.ArgumentParser()
    ap.add_argument("--seed", type=int, default=0, help="optional seed (0 = auto)")
    args = ap.parse_args()

    # Use nanoseconds so multiple calls per second are unique
    seed = args.seed if args.seed != 0 else time.time_ns()
    print(make_prompt(seed))

if __name__ == "__main__":
    main()
