How exactly does long term cap gains tax work when diluted with regular income in the same year?

Hi everyone,

 

My scenario's objective is simple: pay zero income tax.

 

The mechanics: we know that taxable income in tax year 2025 below (Single Filers: Taxable income up to $48,350) will pay $0 in long term cap gains tax. However if one has $30k of deductions (mortgage interest plus property taxes) I postulate that such use case will permit to take an additional $30k distribution out of a 401k since it will be negated by the deductions so taxable income is still kept at bay for the $0 tax LT cap gains goal.

 

However how would that work out in terms of income tax on the $30k? Which bucket of income (1) or (2) will the deductions apply to? The taxable income will still be less than $48,350/year but it's made up by two different income sources. Please enlighten me!