I know that when a light ray refracts towards the normal, it means that it's perpendicular. But what is it refracting towards the normal with respect to?

With respect to the direction of the original path in the original medium.

Now clarification: IT does not always bend towards the normal. That is only true if it is going from a medium of lessor index of refraction to a medium of higher index. If the opposite is the case, then it bends away from the normal.