The ephemeral secret which is derived from Bob's public ratchet key is not used to encryt the message. Instead, that ephemeral secret is passed through
HKDF together with
Root key to derive
Chain Key and to update the
Root Key. The Root Key is derived from
Chain Key, new Root Key = HKDF(Root Key, ephemeral_secret)
Then the Chain Key is passed through
HKDF to derive the
Message Key and to update the Chain Key.
Message Key = HMAC-SHA256(Chain Key, 0x01)
Chain Key = HMAC-SHA256(Chain Key, 0x02)
This Message Key is used to encrypt the message. Even if Bob is offline, Alice can still send the second message by deriving a Message Key from an updated Chain Key.
Once Bob sends a reply with a new public ratchet key, Alice will again derive a Chain Key from a new Root Key (see step 1) and repeat the process. X3DH is never reinitialised again.