When Camera angle is bigger than 0, it snaps back 180 degrees

Im new to Unity and trying to make my own first person player controller. For now im making the camera look up and down, i have a variable called _xRotation and im rotating the camera on the x axis by (_xRotation - transform.eulerAngles.x) / 15. Whenever the camera angle (not the variable, the actual angle) is bigger than 0 (looks below the horizon), it snaps back about 180 degrees. anybody know any solutions?
Here’s my code:

        private float _xRotation;
        
        void Update()
        {
            _xRotation += Input.GetAxisRaw("Mouse Y") * 5; // 5 is the sensitivity
            _xRotation = Mathf.Clamp(_xRotation, -90f, 90f);
            transform.Rotate((_xRotation - transform.eulerAngles.x) / 15, 0f, 0f, Space.Self);
            // 15 is for smoothing
        }

Nevermind, i figured it out. eulerAngles.x is always positive, while transform.Rotation is not, so i need to use maths to convert eulerAngles.x back to the original format