Camera Position/FoV focused on object in world with Viewport Scale & Size in mind!

So I got a math issue, I have a cube in my scene that I want a static camera to focus on.
The cube should always be fully visible, no matter what viewport Size or scale it starts off with.

I have the Viewport Size/Scale and I also have the cubes Origin, Extent and VectorLength values,
but I can’t for the life of me figure out the formula. (trying to change camera Z-Axis or potentially FoV)

It’s for Mobiles & iPads so the goal is to handle square viewports of iPads and horizontal ones from mobiles!
Example sizes range from 2049x1536 to as small as 1280x720 with a lot of variations in between.

Also, the Constrain Aspect Ratio is set to false, as I don’t want to have black borders, and thus here we are!

The above screenshot is what I’ve got right now, and it’s not really doing much… Just hoping it gives someone an idea of what to put together here

Been given one hint on Unreal Slacker discord:

Would be nice if a math-genius would appear haha!