At a religious service - stand up and sit down when others do, kneeling is optional. You don't have to sing/pray/recite along if you aren't comfortable, but keep quiet and follow other's lead. If you are not Christian, you don't take Communion (in a Catholic church, you don't unless you're Catholic), although I don't think Communion is common at a funeral. There will be a printed order of service to follow.
For clothing - conservative and sober is pretty standard.
A reception afterwards is very common, typically with food and drink. Take a chance to speak to the bereaved, but don't linger unless you know them very well. If you don't know the family, introduce yourself and how you know the deceased or the family.
You can send the card at any time. It helps a lot to have a personal message (more than just a signature), but you don't have to get fancy. "I'm sorry for your loss, and I'm thinking/praying for your family in this difficult time". If you know the deceased, share a personal memory, or mention what you really liked about them, or how they helped you - these kinds of cards can mean a lot to the recipients, for a long time afterwards.
When talking to the family after the service, again, express your condolences and keep it simple. Avoid anything like "It's for the best" or "I know how you feel" because these things are easy to misinterpret.