Hinge on one side. Piano hinges on the parts that fold. Math to calculate the correct angles. Didn't seem like voodoo to me.
This is the one that really looks like magic. https://www.youtube.com/watch?v=10y28PD73vk
This is the one that really looks like magic. https://www.youtube.com/watch?v=10y28PD73vk