-- DR spiral/swipe settings.
-- This just controls the dark swipe overlay on DR cooldowns.

local AC = _G.ArenaCore
if not AC then return end

local DRSpiral = {}
AC.DRSpiralAnimation = DRSpiral

-- Apply spiral animation settings to a DR cooldown frame.
function DRSpiral:ApplySettings(cooldownFrame)
    if not cooldownFrame then return end
    
    -- Grab settings (with sane fallbacks).
    local db = AC.DB and AC.DB.profile and AC.DB.profile.diminishingReturns
    
    -- Defaults if the DB isn't ready yet.
    local enabled = true
    local opacity = 100
    
    -- Pull actual values if available.
    if db and db.spiralAnimation then
        local spiralSettings = db.spiralAnimation
        enabled = spiralSettings.enabled ~= false -- Default: true (enabled)
        opacity = spiralSettings.opacity or 100 -- Default: 100%
    end
    
    -- Apply swipe visibility.
    if enabled then
        local alpha = opacity / 100
        cooldownFrame:SetSwipeColor(0, 0, 0, alpha)
        cooldownFrame:SetDrawSwipe(true)
    else
        cooldownFrame:SetDrawSwipe(false)
    end
end

-- Refresh spiral settings on any visible DR icons.
function DRSpiral:RefreshAllIcons()
    local frames = AC.MasterFrameManager and AC.MasterFrameManager.frames
    if not frames then return end
    
    for i = 1, 3 do
        local frame = frames[i]
        if frame and frame.drIcons then
            for category, drIcon in pairs(frame.drIcons) do
                if drIcon and drIcon.cooldown and drIcon:IsShown() then
                    self:ApplySettings(drIcon.cooldown)
                end
            end
        end
    end
end

-- Initialize (nothing fancy here).
function DRSpiral:Initialize()
end

return DRSpiral
