You should be fine as long as you also install a box extension. It looks like you will probably need to cut your recess a little bigger in your paneling.
NEC 314.20:
Flush-Mounted Installations. Installations within or behind a surface
of concrete, tile, gypsum, plaster, or other noncombustible material,
including boxes employing a flush-type cover or faceplate, shall be
made so that the front edge of the box, plaster ring, extension ring,
or listed extender will not be set back of the finished surface more
than 6 mm (1∕4 in.).
Installations within a surface of wood or other combustible surface
material, boxes, plaster rings, extension rings, or listed extenders
shall extend to the finished surface or project therefrom.
So if your wall material is one of the non-combustible ones listed, you can have the box be up to 1/4" recessed. But the wood requires the box to be flush and you can use an extension to make it so.
And you are right, it wouldn't be any less safe than the current setup, but the current setup is unsafe and not up to code. If there is a bad connection in that box and things start to heat up in there, you want something fire-rated in between the heat source and the wood paneling.
In addition to the above, you will also need to follow the instructions provided with your light fixture. If the instruction say don't do this, then you shouldn't do it.