Capital Gains

Hello,

 

When I sell my California primary residence, how do I calculate capital gains for the State of California and the federal government?

Also, where can I obtain a list or the criteria relative to what expenses are deductible for lowering capital gains?

 

Thx