You get shield only if your base gets at least 30% damaged and the attacker drops more then 1/3 of your TH level's max troop space. The space is calculated based on max that defenders TH lvl can have including heroes and more. No more shield if just the Th is sniped and you will lose more resources as TH will hold significantly more resources after update.
after every 3 hours of cumulative play time since your last shield, you get kicked out for 6 minutes and after that you can play in small increments before being kicked out again till you get a shield or one of exceptions happen.
this is simplistic version. Stickies explain in detail very well actually. Hope it's going to help you read stickies better.

