#!/usr/bin/env python3
"""Generate fully-expanded Flow production sheets (TRACK2+..) from compact shot
data. Every prompt is complete — set, action, camera, full style/no-lettering
sentence — so nothing is ever abbreviated at paste time."""
from pathlib import Path

STYLE = ("1980s hand-drawn cel animation, thick ink outlines, painterly gouache "
         "backgrounds, film grain. No text, no captions, no watermark; all signs, "
         "posters and record sleeves are blank or abstract designs with no lettering.")

SETS = {
 "sea": "The record store flooded into an open ocean at night, wooden record racks bobbing like rafts on rolling waves, neon glow on the black water, spray and foam.",
 "lava": "The record store as a volcanic cavern, floor of glowing molten orange vinyl, record crates floating like obsidian rafts, melted records dripping from shelves like stalactites, ember flecks in the air.",
 "space": "The record store torn open to deep space, shelving units drifting in zero gravity trailing debris fields of floating records, Earth tiny below, purple and teal nebula light.",
 "grid": "Inside a computerized hi-fi system rendered as a neon wireframe world, glowing cyan and magenta grid floor like a giant equalizer, circuit-board skyscrapers, records as glowing light-discs, black sky with waveform aurora.",
 "runout": "A surreal endless landscape inside a record's run-out groove, black glossy vinyl canyons with concentric ridge walls curving to the horizon, dust motes the size of boulders, single spotlight sun.",
 "altar": "The record store bathed in glossy black liquid vinyl dripping upward, a sacred glowing turntable altar where the listening booth once stood.",
 "store": "Inside the cluttered record store at night, neon glow, checkerboard floor.",
 "store_day": "Inside the cluttered record store in the daytime, warm light, checkerboard floor.",
}

# (sheet, id, set, chars, tier, action+camera text)
S = []
def shot(sheet, sid, st, chars, tier, text): S.append((sheet, sid, st, chars, tier, text))

T2, T3, T4, T5, T6, T7, SH, X = "TRACK2", "TRACK3", "TRACK4", "TRACK5", "TRACK6", "TRACK7", "SHIFTS", "EXTRAS"

# ---- TRACK 2 — SIDE A / SEA ----
shot(T2,"t2s1_action","sea",["Dez"],"fast","The checkerboard floor liquefies into dark water beneath Dez's feet; he scrambles frantically up onto a floating wooden record rack as the water rises fast. Medium-wide tracking shot.")
shot(T2,"t2s1_death","sea",["Dez"],"fast","Dez slips off the floating rack and sinks under the dark water with a comic glug, one hand and a stream of bubbles the last thing visible. The clip ends held on the calm water surface. Static wide shot.")
shot(T2,"t2s2_action","sea",["Dez"],"fast","Dez leaps from one bobbing record rack to another, timing each jump to the peak of the rolling waves, arms windmilling. Tracking wide shot moving with him.")
shot(T2,"t2s2_death","sea",["Dez"],"fast","Dez mistimes a jump and lands on the edge of a floating rack, which tips over in a slow theatrical topple and dumps him into the sea with a splash. The clip ends held on the overturned rack. Static wide shot.")
shot(T2,"t2s3_death","sea",["Dez"],"fast","A huge shark whose dorsal fin is a black vinyl record with a red label swallows Dez whole in one lunge, then surfaces and burps out his silver headphones. The clip ends held on the floating headphones. Static medium shot.")
shot(T2,"t2s4_action","sea",["Dez"],"fast","The whole ocean begins spinning like a turntable platter around a distant vortex as a skyscraper-sized chrome tonearm swings down from the sky; Dez rides the circular current on a floating crate and leaps clear as the giant needle plows past. Wide dramatic shot.")
shot(T2,"t2s4_alt","sea",["Dez"],"qual","NEEDLE-DROP ALT: Dez leaps onto the giant chrome tonearm itself and surfs down its arm as the ocean spins beneath him, music-powered confidence, arms out. Sweeping heroic tracking shot.")
shot(T2,"t2s4_death","sea",["Dez"],"fast","Dez is caught in the spinning current and sucked down the vortex at the ocean's center like water draining from a tub, spinning as he goes, one arm up. The clip ends held on the swirling drain. High angle wide shot.")
shot(T2,"t2s5_action","sea",["Dez"],"fast","Dez surfs a large open gatefold record sleeve down the face of a rolling wave toward a distant doorway, crouched low, spray flying. Tracking shot alongside him.")
shot(T2,"t2s5_death","sea",["Dez"],"fast","Dez wipes out mid-surf, tumbling head over heels through the foam, and washes up in a heap inside a wooden crate. The clip ends held on him upside down in the crate, one shoe floating past. Static wide shot.")

# ---- TRACK 3 — HOT WAX ----
shot(T3,"t3s1_action","lava",["Dez"],"fast","Dez hops across floating record crates like stepping stones over the molten orange vinyl, each crate beginning to sink one beat after he lands, forcing constant rhythm. Tracking wide shot.")
shot(T3,"t3s1_death","lava",["Dez"],"fast","Dez's crate sinks too soon and he slowly descends into the molten orange vinyl with dignity, giving a solemn thumbs-up as he disappears. The clip ends held on the thumbs-up sinking below the surface. Static medium shot.")
shot(T3,"t3s2_action","lava",["Dez"],"fast","A huge glob of molten wax drips from a melted-record stalactite above; Dez sidesteps at the last instant as it splats where he stood. Static medium-wide shot, low angle.")
shot(T3,"t3s2_death","lava",["Dez"],"fast","The molten glob lands square on Dez and flattens him; the wax cools instantly into a fresh seven-inch record standing upright with his startled face as the center label. The clip ends held on the record. Static medium shot.")
shot(T3,"t3s3_action","lava",["Dez"],"fast","Gatefold album sleeves peel off the cavern walls and flap through the air like leathery pterodactyls dive-bombing Dez; he ducks the first and swats the second away with a wooden crate lid. Dynamic medium shot.")
shot(T3,"t3s3_death","lava",["Dez"],"fast","A flapping gatefold sleeve snatches Dez by the shoulders and carries him off screaming toward the cavern ceiling; a single black record floats gently down like a dropped feather. The clip ends held on the empty frame with the record settling. Static wide shot.")
shot(T3,"t3s4_action","lava",["Dez"],"fast","Geysers of molten wax erupt one after another down the cavern corridor as Dez sprints toward camera, dodging left and right, everything collapsing behind him. Low tracking shot facing him.")
shot(T3,"t3s4_alt","lava",["Dez"],"qual","NEEDLE-DROP ALT: Dez rides the top of an erupting wax geyser upward like an elevator, cool and composed with arms crossed, stepping off at a high ledge. Rising crane shot following him up.")
shot(T3,"t3s4_death","lava",["Dez"],"fast","A geyser erupts directly under Dez and launches him high into the darkness with a trailing scream; a beat later small embers drift down. The clip ends held on the empty corridor. Static wide shot.")

# ---- TRACK 4 — B-SIDE / SPACE ----
shot(T4,"t4s1_action","space",["Dez"],"fast","The roof tears away and everything goes weightless; Dez grabs the end of a drifting shelving unit at the last second as records float up around him like bubbles. Wide dramatic shot.")
shot(T4,"t4s1_death","space",["Dez"],"fast","Dez misses his grab and drifts slowly backward into the starfield, getting smaller and smaller, waving politely the entire time. The clip ends held on him as a tiny distant speck still waving. Static wide shot.")
shot(T4,"t4s2_action","space",["Dez"],"fast","Dez kicks off a drifting record rack and glides weightless through space to catch the next rack, momentum only, legs trailing. Tracking shot alongside.")
shot(T4,"t4s2_death","space",["Dez"],"fast","Dez misjudges his push and tumbles away head over heels in slow weightless spins, resigned expression on each rotation. The clip ends held mid-tumble. Static medium shot.")
shot(T4,"t4s3_action","space",["Dez"],"fast","A field of tumbling vinyl records streams past like asteroids; Dez weaves between them while clinging to a drifting crate, ducking as big ones whistle past. Tracking wide shot.")
shot(T4,"t4s3_death","space",["Dez"],"fast","A massive thick old shellac record slams into Dez with a comic starburst impact, leaving him flattened against its surface like a bug on a windshield as it tumbles away. The clip ends held on the tumbling record. Static wide shot.")
shot(T4,"t4s4_action","space",["Dez"],"fast","A spindle-shaped black hole drags the whole debris field into a spiral; Dez kicks off a drifting amplifier at the exact right moment and slingshots around the singularity in a tight arc. Sweeping orbital shot.")
shot(T4,"t4s4_death","space",["Dez"],"fast","Dez is caught by the singularity and stretched impossibly long and thin, spiraling into the black hole like a strand of liquorice, deadpan expression. The clip ends held on the black hole with one shoe orbiting it. Static wide shot.")
shot(T4,"t4s5_action","space",["Dez"],"fast","Dez surfs a glowing red-hot record through fiery atmospheric re-entry, crouched low, flames streaming past him, city lights far below. Tracking shot alongside.")
shot(T4,"t4s5_death","space",["Dez"],"fast","Dez comes in too steep and slams into the record store's checkerboard floor leaving a smoking crater; after a beat his hand rises from the crater holding the record, unharmed. The clip ends held on the raised hand. Static wide shot.")

# ---- TRACK 5 — THE GRID ----
shot(T5,"t5s1_action","grid",["Dez"],"fast","The glowing grid floor pulses like equalizer bars, tiles shooting up in columns to the beat; Dez crosses in bursts during the quiet beats, freezing as bars spike around him. Wide isometric-feel shot.")
shot(T5,"t5s1_death","grid",["Dez"],"fast","An equalizer bar erupts under Dez and he bursts into pixels that reassemble mid-air as a crude sad blocky low-resolution version of himself that blinks twice and falls over. The clip ends held on the pixel figure. Static medium shot.")
shot(T5,"t5s2_action","grid",["Dez"],"fast","Faceless neon security figures fling glowing light-discs at Dez; he deflects one with a raised forearm, catches the second, and hurls it back knocking a figure into pixels. Dynamic medium shot.")
shot(T5,"t5s2_alt","grid",["Dez"],"qual","NEEDLE-DROP ALT: Dez duel-wields two glowing records like light-discs and charges the security figures, carving through them in a spin, pixels flying. Heroic tracking shot.")
shot(T5,"t5s2_death","grid",["Dez"],"fast","A light-disc strikes Dez square in the chest; he freezes rigid like a mannequin, tips over stiff as a board and lands with a metallic clang, still frozen. The clip ends held on him rigid on the floor. Static medium shot.")
shot(T5,"t5s3_action","grid",["Dez"],"fast","A crackling wall of static deletion sweeps down the neon corridor erasing everything; Dez sprints toward camera at full panic speed as the wall gains on him. Low tracking shot facing him.")
shot(T5,"t5s3_death","grid",["Dez"],"fast","The deletion wall catches Dez mid-stride and erases him from the feet upward, leaving only a glowing wireframe outline of his running pose that flickers and vanishes. The clip ends held on the empty corridor. Static wide shot.")
shot(T5,"t5s5_action","grid",["Dez"],"fast","Dez escapes on a light-cycle that is unmistakably a turntable with wheels, trailing a ribbon of neon light, and launches off a glowing ramp. Fast tracking shot alongside.")
shot(T5,"t5s5_death","grid",["Dez"],"fast","Dez wipes out on the turntable light-cycle and skids across the grid; he rebounds off the corners of the frame like a bouncing screensaver logo, expression blank, as the clip ends mid-bounce. Static wide shot.")

# ---- TRACK 6 — THE RUN-OUT ----
shot(T6,"t6s1_action","runout",["Dez"],"fast","Deep in the black vinyl canyon a colossal chrome needle plows up the groove behind Dez, throwing a bow-wave of shredded vinyl as he sprints for his life along the curving canyon floor. Wide tracking shot, needle looming.")
shot(T6,"t6s1_alt","runout",["Dez"],"qual","NEEDLE-DROP ALT: Dez leaps backward onto the colossal chrome needle's cartridge and rides it like the prow of a ship as it plows the groove, wind in his quiff, arms spread. Heroic low-angle tracking shot.")
shot(T6,"t6s1_death","runout",["Dez"],"fast","The colossal needle overtakes Dez in a blinding white flash of scratch-static that fills the screen; when it clears the canyon is empty and pristine. The clip ends held on the silent empty groove. Static wide shot.")
shot(T6,"t6s2_action","runout",["Dez"],"fast","Boulders of dust the size of cars tumble down the canyon in a storm; Dez dives into a narrow scratch crevice in the canyon wall at the last moment as boulders crash past. Medium-wide shot.")
shot(T6,"t6s2_death","runout",["Dez"],"fast","A dust boulder buries Dez completely; after a beat he pops his head out of the pile and coughs out a small thick old record with a puff of dust. The clip ends held on his dazed dusty face. Static medium shot.")
shot(T6,"t6s3_action","runout",["Dez"],"fast","The groove walls ripple like sound waves; Dez runs up a moving ripple crest and leaps over the ridge wall into the neighboring groove as the wave collapses behind him. Dynamic tracking shot.")
shot(T6,"t6s3_death","runout",["Dez"],"fast","The ripple collapses early and flings Dez spinning over the ridge wall; he lands in the parallel groove, sits up, and stares at the identical canyon around him in existential defeat. The clip ends held on his blank stare. Static wide shot.")
shot(T6,"t6s4_action","runout",["Dez"],"fast","Dez reaches the vast circular paper label plain at the record's center as thick black vinyl tendrils erupt from the spindle hole ahead; he weaves between grasping tendrils toward the center. Wide dramatic shot.")
shot(T6,"t6s4_death","runout",["Dez"],"fast","A black tendril snares Dez's ankle and drags him across the paper plain and under the label's edge like a monster pulling prey under a rug; the paper settles flat. The clip ends held on the undisturbed label. Static wide shot.")

# ---- TRACK 7 — BOSS + endings ----
shot(T7,"t7s1_action","altar",["Dez","The Dead Wax"],"qual","The Dead Wax towers over the turntable altar and slams three massive vinyl tendrils down at Dez in sequence; he dives left, drops flat, and rolls right as each smashes the checkerboard floor. Dramatic wide shot.")
shot(T7,"t7s1_death","altar",["Dez","The Dead Wax"],"qual","The Dead Wax catches Dez between two giant spinning platters and presses them together; they part to reveal a picture disc printed with Dez's startled face, which it flicks away. The clip ends held on the spinning picture disc. Static medium shot.")
shot(T7,"t7s2_action","altar",["Dez","The Dead Wax"],"qual","The Dead Wax's record face spins wildly and conjures rapid-fire phantoms of past hazards around Dez — a vinyl-finned shark, a wax geyser, a light-disc, a chrome needle — each lunging in a one-second flash as he dodges each in turn. Frenetic medium shot.")
shot(T7,"t7s2_death","altar",["Dez","The Dead Wax"],"qual","All four phantom hazards strike Dez at once in an overlapping comic pile-up; the dust clears to show him flattened, sliced, derezzed and scorched simultaneously. The clip ends held on the wreck, the Dead Wax's record face tilting in satisfaction. Static wide shot.")
shot(T7,"t7s3_action","altar",["Dez","The Dead Wax"],"qual","Dez leaps onto the giant spinning platter and runs against its rotation in place, straining toward the glowing tonearm at its edge as the Dead Wax's tendrils close in from all sides; he lunges and grabs the tonearm. Epic slow push-in.")
shot(T7,"t7s3_death","altar",["Dez","The Dead Wax"],"qual","The platter accelerates and flings Dez off; he skids across the floor into a crate of records that collapses on him one crate at a time, with one final crate falling after a long beat. The clip ends held on the pile. Static wide shot.")
shot(T7,"win","altar",["Dez","The Dead Wax"],"qual","Dez lifts the tonearm; the Dead Wax instantly deflates like a punctured balloon, shrinking down into a single ordinary record lying on the turntable; dawn light floods the restored store as Dez, exhausted, sleeves the record, files it in a crate, and sips cold coffee. Slow warm wide shot.")
shot(T7,"stinger","store_day",["Mildred"],"qual","Golden morning light in the quiet store. Mildred the cat pads along the counter to the filing crate, hooks one paw over a plain white record sleeve, slides it out and lets it drop to the floor, then stares directly into camera and slow-blinks. The clip ends held on her stare. Static medium shot.")
shot(T7,"gameover","store",["The Dead Wax"],"fast","The Dead Wax rises slowly behind the counter until it fills the frame, its record face spinning down to a stop as its red spiral eye fixes on camera; it slowly shakes its face left and right. The clip ends held on the stare. Slow push-in.")

# ---- SHIFTS ----
shot(SH,"sh2_action_thin","store",["Dez"],"fast","Dez reaches for one of two rolls of packing tape on the counter beside a cardboard record mailer; as his hand hovers, the thin roll subtly grows a row of tiny teeth. Static close-up on the counter, tense lighting.")
shot(SH,"sh2_action_thick","store",["Dez"],"fast","Dez reaches for one of two rolls of packing tape on the counter beside a cardboard record mailer; as his hand hovers, the thick roll subtly grows a row of tiny teeth. Static close-up on the counter, tense lighting.")
shot(SH,"sh2_death","store",["Dez"],"fast","The tape roll snaps open into a fanged mimic and swallows Dez's arm to the elbow; he yanks back a skeleton-clean arm, faints, and the mimic waddles back into place on the shelf looking innocent. The clip ends held on the innocent tape roll. Static medium shot.")
shot(SH,"sh3_action","store_day",["Dez"],"fast","Dez weighs a stack of three records on the counter scales, punching numbers on a huge vintage calculator, sweat beading as the numbers spin like a slot machine, the customer's shadow waiting. Slow push-in on his face and the scales.")
shot(SH,"sh3_death_post","store_day",["Dez","The Postman"],"qual","The shop door explodes inward in slow motion and the Postman strides through backlit dust, unslinging his satchel with terrible calm as Dez backs against the shelves clutching a mailer; the Postman produces a single stamped document and everything whites out. The clip ends on white. Cinematic slow motion.")
shot(SH,"sh3_death_acct","store_day",["Dez","The Accountant"],"qual","The Accountant rises vertically through the checkerboard floor beside the counter like a surfacing submarine, adjusts his glasses with one finger, opens his ledger, taps a single line, and Dez folds neatly in half like a closed book and files himself under the counter. The clip ends held on the Accountant sinking back down. Static wide shot.")
shot(SH,"sh4_death","store_day",["Dez","The Boring Guy"],"fast","Time-lapse: the Boring Guy talks on at the counter as light sweeps day to night to day; cobwebs grow over Dez behind the counter, seasons flicker past the window, and Dez is finally a cheerful skeleton in a red flannel shirt still nodding. The clip ends held on the nodding skeleton. Static two-shot.")
shot(SH,"sh5_action","store_day",["Dez","The Name Dropper"],"fast","The Name Dropper leans on the counter holding up a white-sleeved record without looking at it, smirking mid-boast; Dez behind the counter freezes with three thought-bubble-style reaction options flickering on his face: enthusiasm, grunt, counter-flex. Static two-shot.")
shot(SH,"sh5_death","store_day",["Dez","The Name Dropper"],"fast","Time-lapse: the Name Dropper talks endlessly as Dez visibly ages behind the counter — stubble, gray streaks, long beard — while the Name Dropper never changes. The clip ends held on elderly Dez and the still-smirking Name Dropper. Static two-shot.")
shot(SH,"sh5_bonus","store_day",["Dez","The Name Dropper"],"fast","Dez calmly names a rarer record with one raised finger; the Name Dropper's smirk collapses, and he dissolves from the feet upward into embarrassed purple vapor, his sunglasses clattering onto the counter. The clip ends held on the empty jacket settling to the floor. Static medium shot.")
shot(SH,"sh6_action","store",["Dez"],"fast","Dez folds a flat-packed cardboard record mailer in four crisp decisive folds, each fold landing like a drumbeat with a tiny paper flourish, ending with the mailer held up in triumph. Rhythmic close-up on hands and face.")
shot(SH,"sh6_death","store",["Dez"],"fast","On the final fold the cardboard slices Dez's fingertip; operatic slow motion: his face contorts, a single tear rolls, he sinks to his knees clutching the finger as dramatic rim light blazes and dust motes swirl. The clip ends held on his silent scream. Slow push-in.")

# ---- EXTRAS ----
shot(X,"needle_skip","store",[],"fast","The record store scene judders violently sideways twice like a skipping record, images tearing and repeating with horizontal displacement, then snaps to black. One-second transition card. Static shot.")
shot(X,"boringguy_duo","store_day",["The Boring Guy"],"fast","Two identical Boring Guys discover each other across the counter and both begin monologuing simultaneously, pointing gently at nothing, neither listening, both settling in forever. Static two-shot. BONUS GAG.")

HEAD = """# {name} production sheet — paste-ready, fully expanded
Veo 3.1 Fast 16:9 1x unless marked ⭐QUALITY (Veo 3.1 Quality). 2–3 TAKES each,
download EVERYTHING immediately to flow-vids-RSG/. Multi-character shots → Omni
Flash (Veo caps at 3 reference images). Log gens in production/SHOTLOG.csv.

"""

def main():
    out = Path(__file__).resolve().parent.parent / "production" / "flow"
    sheets = {}
    for sheet, sid, st, chars, tier, text in S:
        sheets.setdefault(sheet, []).append((sid, st, chars, tier, text))
    for name, shots in sheets.items():
        md = HEAD.format(name=name)
        for sid, st, chars, tier, text in shots:
            tag = " ⭐QUALITY" if tier == "qual" else ""
            cast = f" [attach: {', '.join(chars)}]" if chars else " [no characters]"
            md += f"## {sid}{tag}{cast}\n{SETS[st]} {text} {STYLE}\n\n"
        (out / f"{name}_SHOTS.md").write_text(md)
        print(f"{name}_SHOTS.md: {len(shots)} shots")

if __name__ == "__main__":
    main()
