How Does Stamp Duty Work in NSW?

Couple reviewing a property contract and working out costs

How stamp duty works in NSW, how it is calculated, when it is payable, and where first home buyers may get a discount or exemption.