Question about game design ,, I think

I made this post to get some advice,

In games where there is an progression in its story, where the character resolves certain problems, and is progressing through the game.
When is the time to start designing the map, putting some puzzles in place, decide story elements, etc?
I’m working on a project and I’m thinking, once the mechanics are in place and working (almost).
When is the time to start making this design choices ?

Motivation of my question:
The adventure, the design of the world, the puzzles, are tied to the games story. Once the mechanics are finished, I should start to create all this. But I still have not defined all the puzzles, nor all the elements of the story.
In fact, since I only focused on certain mechanics, the project allows me to choose whether I want to make a medieval world or a post-apocalyptic world and science fiction, etc.
Problem is that in this project stage is where I get demotivate and left it to die, I create the mechanics, but now I need to do something with all this, So that it is no longer just a set of working mechanics

And finally, what document is convenient / util to create in order to persist the above mentioned.