Why blue leaves the beam first
Scattering is not a gentle gradient — it grows with the fourth power, so small differences in wavelength become large differences in colour.
Because scattering scales with 1/λ⁴, cutting the wavelength from 700 nm to 450 nm multiplies scattering by about 5.5, and violet near 400 nm scatters roughly nine times more than red. Each kilometre of air removes a little more short-wavelength light from the direct beam than long-wavelength light.
Over a short midday path the loss is barely visible. Over the sunset path, about 38 times longer, the losses compound: the sun's disc slides from white to yellow, then orange, then a deep red just before it touches the horizon.
The sky around the setting sun shows the same gradient in space instead of time — red nearest the sun, then orange, then the still-blue higher sky, where the light reaching your eye has travelled a much shorter path.