{term_name} empty in nested query loop (posts loop inside terms loop)

Setup:

  • Outer loop: Terms query (custom taxonomy)
  • Inner loop: Posts query (attachment), nested inside each term item, filtered to that term
  • Goal: use the term slug for the lightbox ID

Problem:
{term_slug} works fine in the outer (terms) loop, but returns empty as soon as I place it in the inner (posts) loop. {post_id} works fine there.

Question:
Is there a supported way to pull parent-loop dynamic data from within a nested loop?