Ha! Thanks! 🙂
Yes, welcome to advanced rigging!
This is a very complex problem, if you're into very advanced rigging, you can get yourself a pretty cool set up with constraints...
That said, this would take a while to get to this type of set up.
Why do I say advanced rigging, because you're expected the fold to be opposite from to the end direction, changing half way (when straight).
As you saw, regular Ik cannot do so.
What I could suggest, would be to define a goal for the folding side.
You can set an object to be the goal when the 'elbow' of the chain will aim while folding.
I've attached a video showing how to set it up.
Create your bone chain as usual
Selecting the Ik chain, in the Solver properties you can pick a goal object.
In this example, I'm using two (2) external point helpers, and using Wire parameters, I'm inverting their position Y axis, when one goes in positive Y , the other goes in negative Y, and vice-versa. The wire parameter works with local values. Set Y_Position*-1, this negates the Y position in local space.
One is the master of the other; so we have a Master point and a Slave point.
The Master will be the end of the chain and the slave will be the 'elbow'.
A 3rd point helper will be the top parent of all those, so the set up can be moved in space.
Parent the Ik chain and link to Master.
Parent Master, Slave and the root bone to the 3rd point helper.
Attaching your meshes to bones, you'll see a 180 flip when the Ik switches folding sides, this is normal.
To avoid your meshes to do so, you should use Position constraint and lookAt constraint to the meshes don't flip.
Hopefully the videos are clearer than the text explanation...
I've also included the max scene that you see in the video.
I hope this can help you continue!