  So far, most of the literature on (quantum) contextuality and the
Kochen-Specker theorem seems either to concern particular examples of
contextuality, or be considered as quantum logic. Here, we develop a general
formalism for contextuality scenarios based on the combinatorics of hypergraphs
which significantly refines a similar recent approach by Cabello, Severini and
Winter (CSW). In contrast to CSW, we explicitly include the normalization of
probabilities, which gives us a much finer control over the various sets of
probabilistic models like classical, quantum and generalized probabilistic. In
particular, our framework specializes to (quantum) nonlocality in the case of
Bell scenarios, which arise very naturally from a certain product of
contextuality scenarios due to Foulis and Randall. In the spirit of CSW, we
find close relationships to several graph invariants. The recently proposed
Local Orthogonality principle turns out to be a special case of a general
principle for contextuality scenarios related to the Shannon capacity of
graphs. Our results imply that it is strictly dominated by a low level of the
Navascu\'es-Pironio-Ac\'in hierarchy of semidefinite programs, which we also
apply to contextuality scenarios.
  We derive a wealth of results in our framework, many of these relating to
quantum and supraquantum contextuality and nonlocality, and state numerous open
problems. For example, we show that the set of quantum models on a
contextuality scenario can in general not be characterized in terms of a graph
invariant.
  In terms of graph theory, our main result is this: there exist two graphs
$G_1$ and $G_2$ with the properties \begin{align*} \alpha(G_1) &= \Theta(G_1),
& \alpha(G_2) &= \vartheta(G_2), \\[6pt] \Theta(G_1\boxtimes G_2) & >
\Theta(G_1)\cdot \Theta(G_2),& \Theta(G_1 + G_2) & > \Theta(G_1) + \Theta(G_2).
\end{align*}
