Well, I don't see a problem with putting the trim over the foam. If this were structural, you would already know not to frame with foam between members. The load of the nails or trim screws in the trim will not cause problems with the foam. The area of the trim boards will speread the load sufficiently as to not crush the foam.
As for twisting of the trim? The foam board will not offer as much rigidity behind the trim. Just the same, a trim board on top of a trim board, is likely to be affected by the bottom board and may pop loose from the twist of the board underneath. You will be fine with the foam, caulk the trim well on the sides and top. I personally am not so picky about the bottoms, because I feel that water needs to escape somewhere. It wouldn't hurt to caulk the foam to the window all the way around.
I'm sure that there are other opinions on the caulking and on your original question. I'm interested in them also.
Tom in KY, just one soldier in the raging war against perplexion.