Let's suppose I have a web server X, listening on port N for instance and configured as a Tor hidden service.
How and where is implemented its' hiddenness from public access?
Since you found my comment helpful, I'll just write it as an answer.
The concept is pretty simple. You bind your webserver to your localhost only, so it won't accept connections from outside your computer. Then you configure Tor to connect to this server. Since Tor is installed in your computer, it will be able to connect to your webserver, but others can't. This way, your webserver will only accept connections from inside the Tor network.
For more information, have a look at how to configure a Tor hidden service.
Other relevant links.