GIF only allows 256 colors per frame, so not really lossless when it comes to photos/video that exceed that limit. I guess there are some hacks around this, but typically they're not used.
The hacks you allude to are based on the fact that GIF also allows you to use:
* Transparency in a frame, which will show the previous frame underneath
* A different color palette per frame
* An infinite frame rate (no delay between two frames), which is also configured per frame
These three points combined allow you to show any video in full 8-bit color via the GIF format.
Unfortunately there's a difference between what GIF allows and what popular browsers allow GIF to do. Specifically all browsers set a minimum frame delay to 10ms == 100fps. This got started in the 90s due to performance concerns in Internet Explorer. Then people kept setting frame delay to 0 in their GIFs but it looked still fine in Internet Explorer. This resulted in a lot of GIFs that would look broken when the browsers would follow the GIF spec. This desire to support broken GIF files is why even in 2020 browsers limit GIF frame delay to 10ms.
Even so, if you only need 25fps for your video, you can get 4*256=1024 colors. Again, these colors can be different from frame to frame.
GIF allows animation and lossless compression.