
-- ============================================================
-- FILE: QuestLog_Config.lua
-- PURPOSE: Pure configuration data table (QLC) for the custom
--   QuestLog panel. Contains all layout dimensions, bucket
--   colors/labels, difficulty colors, time-sensitive tag IDs,
--   and UI palette colors used by QuestLog_Panel.lua and
--   QuestLog_Data.lua.
-- HOW IT WORKS:
--   Defines QLC table with constants. Two helper methods:
--     QLC.GetThemeColor(key) — delegates to MapConfig colors.
--     QLC.GetBucketColor(key) → r,g,b — reads BUCKET_COLORS.
--   Exports as Addon.QuestLogConfig.
--   Early-exit guard: if useBlizzardQuestingInterface == true,
--   returns immediately (entire quest system disabled).
-- DEPENDS ON: Addon.MapConfig (must load first via Map_Config)
-- EXPORTS: Addon.QuestLogConfig (QLC table)
-- OWNED SAVEDVARIABLES: none
-- EVENTS REGISTERED: none
-- FRAMES CREATED: none
-- GOTCHAS: BUCKET_ORDER = {"now","next","later"} drives the
--   main quest list display order; "turnIn" and "expiring"
--   are conditional buckets (CONDITIONAL_ORDER) prepended
--   when eligible quests exist.
--   TIME_SENSITIVE_TAG_IDs is the authoritative list of WoW
--   questTagID values that trigger the "expiring" bucket.
-- ============================================================

local ADDON_NAME, Addon = ...
if type(ADDON_NAME) ~= "string" or ADDON_NAME == "" then
    ADDON_NAME = "MidnightUI"
end
if type(Addon) ~= "table" then
    Addon = {}
end

do
    -- The user's runtime settings live on MidnightUISettingsPerChar (Bootstrap.lua
    -- aliases MidnightUISettings to it on ADDON_LOADED). At file-load that swap
    -- hasn't happened yet, so check per-char first.
    local function IsBlizzardModeEnabled()
        local perChar = _G.MidnightUISettingsPerChar
        if type(perChar) == "table" and type(perChar.General) == "table"
           and perChar.General.useBlizzardQuestingInterface == true then
            return true
        end
        local s = _G.MidnightUISettings
        if type(s) == "table" and type(s.General) == "table"
           and s.General.useBlizzardQuestingInterface == true then
            return true
        end
        return false
    end
    if IsBlizzardModeEnabled() then
        return
    end
end

local MapConfig = Addon.MapConfig
local function GetMapColor(key)
    if MapConfig and type(MapConfig.GetThemeColor) == "function" then
        return MapConfig.GetThemeColor(key)
    end
    return 1, 1, 1
end

local QLC = {
    WHITE8X8 = "Interface\\Buttons\\WHITE8x8",

    DISPLAY_FONT            = "Fonts\\FRIZQT__.TTF",
    BODY_FONT               = "Fonts\\FRIZQT__.TTF",

    PANEL_WIDTH             = 380,
    PANEL_STRATA            = "DIALOG",
    PANEL_SLIDE_DURATION    = 0.22,
    PANEL_HEADER_HEIGHT     = 72,
    PANEL_SEARCH_HEIGHT     = 0,
    PANEL_ACCENT_WIDTH      = 0,
    PANEL_PAD_X             = 18,

    QUEST_ROW_HEIGHT        = 36,
    QUEST_ROW_GAP           = 6,
    QUEST_ROW_ACCENT_WIDTH  = 0,
    QUEST_ROW_PROGRESS_HEIGHT = 0,
    QUEST_ROW_PAD_LEFT      = 18,
    QUEST_ROW_PAD_RIGHT     = 18,
    QUEST_TITLE_SIZE        = 14,
    STATE_DOT_SIZE          = 6,

    EXPANSION_PADDING       = 14,
    EXPANSION_OBJ_HEIGHT    = 22,
    EXPANSION_OBJ_INDICATOR = 6,
    EXPANSION_ACTION_HEIGHT = 0,
    EXPANSION_FADE_IN       = 0.12,
    EXPANSION_FADE_OUT      = 0.10,

    BUCKET_HEADER_HEIGHT    = 32,
    BUCKET_ACCENT_WIDTH     = 0,

    ZONE_HEADER_HEIGHT      = 22,
    ZONE_DOT_SIZE           = 0,

    CAMPAIGN_CARD_HEIGHT    = 0,
    CAMPAIGN_ACCENT_WIDTH   = 0,
    CAMPAIGN_PROGRESS_HEIGHT = 1,

    FOCUS_HEADER_HEIGHT     = 0,
    FOCUS_ACCENT_WIDTH      = 0,

    EMPTY_STATE_HEIGHT      = 80,

    MAX_VISIBLE_OBJECTIVES  = 6,

    BUCKET_COLORS = {
        now   = { r = 0.98, g = 0.60, b = 0.22, hex = "FA9938" },
        next  = { r = 0.45, g = 0.72, b = 0.92, hex = "73B8EB" },
        later    = { r = 0.58, g = 0.52, b = 0.43, hex = "94856E" },
        turnIn   = { r = 0.34, g = 0.82, b = 0.46, hex = "57D176" },
        expiring = { r = 1.00, g = 0.52, b = 0.20, hex = "FF8533" },
    },
    BUCKET_LABELS = { now = "NOW", next = "NEXT", later = "LATER", turnIn = "TURN IN", expiring = "EXPIRING" },
    BUCKET_ORDER  = { "now", "next", "later" },

    CONDITIONAL_ORDER        = { "turnIn", "expiring" },
    EXPIRING_EXTRACT_THRESHOLD = 7200,

    FOCUS_LABEL = "FOCUS",
    FOCUS_COLOR = { r = 1.00, g = 0.84, b = 0.30 },

    DIFFICULTY_COLORS = {
        trivial    = { r = 0.50, g = 0.50, b = 0.50 },
        standard   = { r = 0.25, g = 0.75, b = 0.25 },
        difficult  = { r = 1.00, g = 0.82, b = 0.00 },
        veryhard   = { r = 1.00, g = 0.50, b = 0.25 },
        impossible = { r = 1.00, g = 0.10, b = 0.10 },
    },

    COMBO_PURPLE = { r = 0.58, g = 0.42, b = 0.78 },
    NEARLY_COMPLETE_THRESHOLD = 0.80,

    TIME_SENSITIVE_TAG_IDS = {
        [109] = true,
        [111] = true,
        [112] = true,
        [113] = true,
        [136] = true,
        [137] = true,
        [141] = true,
        [151] = true,
        [259] = true,
        [266] = true,
        [282] = true,
    },

    COLORS = {
        success       = { r = 0.34, g = 0.82, b = 0.46 },
        warning       = { r = 1.00, g = 0.52, b = 0.20 },
        story         = { r = 1.00, g = 0.84, b = 0.28 },
        progressTrack = { r = 0.20, g = 0.17, b = 0.12, a = 0.20 },
        progressBg    = { r = 0.04, g = 0.03, b = 0.02, a = 0.30 },
    },
}

function QLC.GetThemeColor(key)
    return GetMapColor(key)
end

function QLC.GetBucketColor(bucketKey)
    local c = QLC.BUCKET_COLORS[bucketKey] or QLC.BUCKET_COLORS.later
    return c.r, c.g, c.b
end

Addon.QuestLogConfig = QLC
