Tested on Fedora 43 with GNOME Shell 49.4. Two layers need to be configured: systemd-logind (the system) and GDM's gsd-power (the greeter), because GDM runs its own GNOME settings daemon that suspends independently.
sudo mkdir -p /etc/systemd/logind.conf.d
sudo tee /etc/systemd/logind.conf.d/lid.conf << 'EOF'