Just as a reference – I do not use WordPress, but I am almost certain this functionality is in it somewhere. To answer at the heart of your question though using other means…
You can absolutely do this using CSS/jQuery/PHP. Here is a link to get you started on a tutorial. There is also a number of other tutorials for this with simple google searches.
As for darkening the background, you should be able to do that using CSS/jQuery for the on-click/open events.
For a specific wordpress solution, I believe this might be what you are looking for but to be frank, I have very little experience with WP so can’t confirm it is correct.
Best of luck!