  We establish precise upper-tail asymptotics and large deviation principles
for the rightmost eigenvalue $\lambda_1$ of Wigner matrices with sub-Gaussian
entries. In contrast to the case of heavier tails, where deviations of
$\lambda_1$ are due to the appearance of a few large entries, and the sharp
sub-Gaussian case that is governed by the collective deviation of entries in a
delocalized rank-one pattern, we show that the general sub-Gaussian case is
determined by a mixture of localized and delocalized effects.
  Our key result is a finite-$N$ approximation for the upper tail of
$\lambda_1$ by an optimization problem involving \emph{restricted annealed free
energies} for a spherical spin glass model. This new type of argument allows us
to derive full large deviation principles when the log-Laplace transform of the
entries' distribution $\mu$ has bounded second derivative, whereas previous
results required much more restrictive assumptions, namely sharp
sub-Gaussianity and symmetry, or only covered certain ranges of deviations.
  We show that the sharp sub-Gaussian condition characterizes measures $\mu$
for which the rate function coincides with that of the Gaussian Orthogonal
Ensemble (GOE). When $\mu$ is not sharp sub-Gaussian, at a certain distance
from the bulk of the spectrum there is a transition from the GOE rate function
to a non-universal rate function depending on $\mu$, and this transition
coincides with the onset of a localization phenomenon for the associated
eigenvector.
