  In the context of CAT(0) cubical groups, we develop an analogue of the theory
of curve complexes and subsurface projections. The role of the subsurfaces is
played by a collection of convex subcomplexes called a \emph{factor system},
and the role of the curve graph is played by the \emph{contact graph}. There
are a number of close parallels between the contact graph and the curve graph,
including hyperbolicity, acylindricity of the action, the existence of
hierarchy paths, and a Masur--Minsky-style distance formula.
  We then define a \emph{hierarchically hyperbolic space}; the class of such
spaces includes a wide class of cubical groups (including all virtually compact
special groups) as well as mapping class groups and Teichm\"{u}ller space with
any of the standard metrics. We deduce a number of results about these spaces,
all of which are new for cubical or mapping class groups, and most of which are
new for both. We show that the quasi-Lipschitz image from a ball in a nilpotent
Lie group into a hierarchically hyperbolic space lies close to a product of
hierarchy geodesics. We also prove a rank theorem for hierarchically hyperbolic
spaces; this generalizes results of Behrstock--Minsky, Eskin--Masur--Rafi,
Hamenst\"{a}dt, and Kleiner. We finally prove that each hierarchically
hyperbolic group admits an acylindrical action on a hyperbolic space. This
acylindricity result is new for cubical groups, in which case the hyperbolic
space admitting the action is the contact graph; in the case of the mapping
class group, this provides a new proof of a theorem of Bowditch.
