TempSpectator Datapack (MC 1.21.8)
===================================
This datapack puts a player into Spectator mode when they die, for a configurable amount of time.
When the timer reaches 0, the player is teleported to their bed/respawn anchor (if set) or to a
configurable fallback spawn, and their previous gamemode is restored. A bossbar and actionbar
countdown show the remaining time while Spectator-locked.

--------------------------------------------------------------------------------
Install
--------------------------------------------------------------------------------
1) Copy the ZIP into:  <world>/datapacks/
2) Start/load the world and run:  /reload

Enabled packs:        /datapack list enabled
Available packs:      /datapack list available

--------------------------------------------------------------------------------
Commands
--------------------------------------------------------------------------------
Set lockout duration (seconds)
  /scoreboard players set #cfgSeconds md_config 60

Set spawn to your current position (used if no bed/anchor is found):
  /function tempspec:config/set_fallback_here

Clear spawn:
  /function tempspec:config/clear_fallback

Show debug info about what respawn format the player has:
  /function tempspec:debug/where_will_i_respawn