local _, namespace = ...

local WTUI = namespace.WildThingsUI
local Theme = namespace.Theme
local BORDER_STRONG = Theme.BORDER_STRONG

-- namespace:CreateSectionHeader(parent, title)
-- Static, non-interactive display widget: an uppercase dim label followed by a trailing
-- 1px hairline rule that fills the remaining width to the container's right edge.
-- This widget calls into no motion/border/highlight helper of any kind — it is purely
-- static display per 10-RESEARCH.md Area 4.
function namespace:CreateSectionHeader(parent, title)
    local header = CreateFrame("Frame", nil, parent)

    -- Default to filling the parent's width; caller may reposition/resize after creation.
    header:SetPoint("LEFT", parent, "LEFT", 0, 0)
    header:SetPoint("RIGHT", parent, "RIGHT", 0, 0)

    header.label = header:CreateFontString(nil, "ARTWORK")
    header.label:SetFontObject(WildThingsFont13)
    header.label:SetText((title or ""):upper())
    header.label:SetTextColor(Theme.TEXT_SECTION.r, Theme.TEXT_SECTION.g, Theme.TEXT_SECTION.b, Theme.TEXT_SECTION.a)
    header.label:SetPoint("LEFT", header, "LEFT", 0, 0)

    -- Trailing hairline: single 1px texture from the label's right edge to the header's
    -- right edge. Anchoring LEFT/RIGHT points (both vertical-middle anchors) keeps it
    -- vertically centered on the label without a redundant third anchor point.
    header.hairline = header:CreateTexture(nil, "ARTWORK")
    header.hairline:SetHeight(1)
    header.hairline:SetColorTexture(BORDER_STRONG.r, BORDER_STRONG.g, BORDER_STRONG.b, BORDER_STRONG.a)
    header.hairline:SetSnapToPixelGrid(false)
    header.hairline:SetTexelSnappingBias(0)
    header.hairline:SetPoint("LEFT", header.label, "RIGHT", Theme.GAP, 0)
    header.hairline:SetPoint("RIGHT", header, "RIGHT", 0, 0)

    header:SetHeight(header.label:GetStringHeight())

    return header
end
