-- HDG_HT_Theme.lua
-- Cockpit-local font sub-theme. The dashboard is denser than the rest of the
-- addon and benefits from tighter, fixed font sizes that don't move with the
-- global font-scale slider. All cockpit widgets call HDG_HT.Theme.ApplyFont
-- instead of HDG.Theme.ApplyFont so the size table here is the single source
-- of truth for dashboard typography.
--
-- The helper still delegates final font/shadow application to
-- HDG.Theme.ApplyFont so font-family selection (user pick) and shadow rules
-- stay centralized — only the *size* is overridden here.

local _, privateDB = ...
privateDB.HDG_HT = privateDB.HDG_HT or {}
local Theme = {}
privateDB.HDG_HT.Theme = Theme

-- Proxy: read-through to the addon-wide Theme for everything we don't
-- explicitly override (GetCurrentScheme, RegisterWidget, C_Accent helpers,
-- ApplyTextShadow, etc.). Files alias `Theme = privateDB.HDG_HT.Theme` and
-- everything else continues to work — only ApplyFont below is replaced.
setmetatable(Theme, { __index = function(_, key)
    local HDG = _G.HousingDecorGuide
    return HDG and HDG.Theme and HDG.Theme[key]
end })

-- Cockpit font sizes by ftype. Tuned for dashboard density. Tweak here, all
-- cockpit text reflows on /reload.
Theme.SIZES = {
    header = 13,   -- card titles, tier ladder
    body   = 11,   -- primary card text, names
    small  = 10,   -- sub-lines, chip text
    xsmall = 9,    -- legend rows, dense numbers
    tiny   = 7,    -- timestamp tags, micro-labels
}

-- Drop-in replacement for HDG.Theme.ApplyFont. Same signature.
--   fs           — fontstring to mutate
--   scheme       — current scheme (used for shadow application only)
--   ftype        — "header" | "body" | "small" | "xsmall" | "tiny"
--   sizeOverride — explicit size; if set, wins over the cockpit table
--
-- We call SetFont directly (not HDG.Theme.ApplyFont) because the canonical
-- helper always adds the user's global fontScale to the size — and the whole
-- point of this sub-theme is to NOT move with that slider. Font-family is
-- still pulled from the user's selection so the dashboard matches the rest
-- of the addon's typeface.
function Theme.ApplyFont(fs, scheme, ftype, sizeOverride)
    if not fs or not fs.SetFont then return end
    local size = sizeOverride or Theme.SIZES[ftype or "body"] or Theme.SIZES.body
    local HDG = _G.HousingDecorGuide
    local fontFile = (HDG and HDG.Colors and HDG.Colors.GetFontFile
                       and HDG.Colors.GetFontFile())
                     or "Fonts\\FRIZQT__.TTF"
    local flags = (scheme and scheme.fonts and scheme.fonts[ftype or "body"]
                    and scheme.fonts[ftype or "body"].flags) or ""
    fs:SetFont(fontFile, size, flags)
    if HDG and HDG.Theme and HDG.Theme.ApplyTextShadow then
        HDG.Theme.ApplyTextShadow(fs, scheme)
    end
end
