LLM foundations for engineers: what tokens and context windows really cost, how sampling shapes an answer, and why a prompt succeeds twice, then fails.