The 12-3 btn the switchbox and first ceiling box allows for the incoming feed and both switched legs all traveling in the same wire.
The 12-3 btn the two light boxes allows for the hot feed from box 1 to box 2 on one conductor and the switched leg on the other conductor.
-Use #8 wire for 40 amp circuits. Use a #8 extension cord, and only as long as needed. Avoid extra length whenever possible.
-If the data plate on the motor says 21.5 amps, then use #10 wire and a 30 amp circuit
1. 12-2 from the panel to the ceiling box 1,
2. 12-3 from ceiling box 1 to ceiling box 2,
3. 12-3 from ceiling box 1 to switch box,
Here is where it gets wordy.
I started to write out the wiring scheme, but it is taking too long. PM me your phone number and I'll call you and walk you through it.