How does the F-35's roll posts work, and how does its engine turn down 90 degrees?
The purpose of the roll posts is to let the pilot have some control authority in hover and stabilization, along with controlling aircraft attitude. Basically, the Rolls Royce Lift System used in the VTOL F-35 has three components connected by drive shaft (along with the engine):


The LiftFan at the front
Three-bearing swivel module (3BSM), which turns the nozzle through 95$^\circ$, and
Two Roll posts on either side of the fuselage.




F-35 Liftfan system; image from nationstates.net

Basically, some bypass air is directed towards the (individually adjustable) roll post ducts to ensure stability during hover, which is done by the onboard computer. In this image, you can see the roll post doors opening on outboard sides of the MLG doors.



F-35 roll post doors opening; image from nationstates.net

The 3-Bearing Swivel Module (3BSM) has three segments driven by two actuators (the first one drives the first segment, while the second one drives the second segment directly and the third one through an angle gearbox). The three segments are cut at an angle, so that when transferring from forward flight to hover, the central segment ends up with its longer edge at the top (so that their sections with maximum length are on the same side), thus 'summing' the bearing offset angles to give a 95$^\circ$ deflection of the jetpipe nozzle in the downward direction.

From codeonemagazone:


  The three-bearing swivel nozzle, 3BSN, design uses three segments of the engine exhaust duct cut on an angle and joined by two airtight circular bearings. External motors drive geared teeth in these segments to rotate them to create the deflected thrust. The forward and aft segments always stay aligned with one another in the rotational axis. The center segment rotates through 180 degrees relative to them. The third bearing is on the back of the engine aft of the turbine stage and provides the ability to swivel the nozzle thrust axis in yaw at any pitch angle.




Three bearing swivel module, from codeonemagazine