Stack Semantics of Type Theory