Brightness issue on Moto G 2nd gen

A

AC Question

I have a Moto G 2nd generation that is about 2 and a half years old now. The brightness on my device sort of started flickering today around 4 hours ago while it was charging and because it's happened before I didn't pay much attention to it. Now however the screen has slowly gone so dark I can barely see anything at all. When I unlock it it gets bright for a second and then goes back to dark. What could this mean? Is this a hardware or software issue?