-- HDG_HT_W_StyleAffinity.lua  (B3 inline row)
-- "Your style: Alliance 376/383 (98%)  ·  Horde 358/370 (97%)  ·  ..."
-- Single horizontal text row; lives in the hero band between DecoratorTitle
-- and TrophyShelf. Mirrors v2.37 HouseTab styleLabel exactly.

local _, privateDB = ...
privateDB.HDG_HT = privateDB.HDG_HT or {}
privateDB.HDG_HT.Widgets = privateDB.HDG_HT.Widgets or {}
local W = { id = "styleAffinity", title = "Your Style" }
privateDB.HDG_HT.Widgets.StyleAffinity = W

function W.Create(parent, _)
    local self = {}
    local Theme = privateDB.HDG_HT.Theme
    local scheme = Theme.GetCurrentScheme()

    self.row = parent:CreateFontString(nil, "OVERLAY", "GameFontNormal")
    self.row:SetPoint("TOPLEFT", parent, "TOPLEFT", 2, -2)
    self.row:SetPoint("RIGHT", parent, "RIGHT", -2, 0)
    self.row:SetJustifyH("LEFT")
    self.row:SetWordWrap(false)
    self.row:SetTextColor(scheme.text.r, scheme.text.g, scheme.text.b)
    Theme.ApplyFont(self.row, scheme, "small")

    function self:Refresh(snap)
        local top = (snap and snap.topStyles) or {}
        if #top == 0 then self.row:SetText(""); return end

        local cAccent, cText, cDim = Theme.C_Accent(), Theme.C_Text(), Theme.C_Dim()
        local parts = {}
        for i = 1, math.min(5, #top) do
            local s = top[i]
            local pct = math.floor((s.pct or 0) + 0.5)
            parts[#parts + 1] = string.format(
                "%s%s|r %s%d/%d|r %s(%d%%)|r",
                cAccent, tostring(s.name or "?"),
                cText, s.collected or 0, s.total or 0,
                cDim, pct)
        end
        self.row:SetText(cDim .. "Your style:|r  " .. table.concat(parts, "  " .. cDim .. "-|r  "))
    end

    function self:Resize(_, _) end
    return self
end

return W
