How to get Mouse 3D position 1f above the ground on uneven terrain

I’m making 3D Diablo style game. I want the cursor to be 1f above the ground on the global Y-axis. It’s easy to get the point where mouse is touching the ground but I want mouse to be above it (crosshair will be exactly where the mouse is). I’m not sure how to get it right. I’m new to programming and Unity, so maybe there’s an easier way to do it, but so far, this is the code I have:

private Vector3 GetMousePosition()
{
   ray = mainCamera.ScreenPointToRay(Input.mousePosition);
    
   if (Physics.Raycast(ray, out hitInfo, Mathf.Infinity))
   {
       Vector3 hitPoint = hitInfo.point;
    
       float t = (hitPoint.y + 1f - ray.origin.y) / ray.direction.y;
       Vector3 pointAbove = ray.origin + t * ray.direction;
    
       return pointAbove;
   }
}

Code works fine on flat surfaces. Pointer is in air exactly 1f above the ground but it is not working on uneven terrain. I think it gets the height of a hitInfo and then calculate on which point on ray the height will be 1f higher but on slope terrain its not working. It should find a point on ray where distance to the ground (not hitInfo.y) is equal to 1f.