What happens if I cast this when I'm at death's door?
You can cast it, and your opponent will go to 0 life, being put at Death's Door and becoming immune to damage for the rest of the turn. You will still remain at 0 life since you can't gain life once you're at death's door.
For purposes of cards that care about the mana cost of spells, what is the mana cost of a spell with X?
If you cast the spell, the mana cost is X. For example, if you cast it for 2 mana, then Immortal Throne would see it as a 2 cost spell. But, if you aren't casting the spell and it's simply in your hand, spellbook, etc., then X is 0 until you actually cast it.