
-- ============================================================
-- FILE: Map_Config.lua
-- PURPOSE: Pure configuration data table (MapConfig) used by
--   the custom Map/QuestLog UI system. Contains all layout
--   dimensions, color themes, animation durations, and mode
--   keys that the Map, QuestLog, and related panels share.
-- HOW IT WORKS:
--   Defines a single local MapConfig table with constants and
--   one helper function (MapConfig.GetThemeColor). Exports it
--   as Addon.MapConfig for downstream Lua files.
--   Early-exit guard: if MidnightUISettings.General
--   .useBlizzardQuestingInterface == true, returns immediately
--   (entire quest/map system is disabled).
-- DEPENDS ON: nothing
-- EXPORTS: Addon.MapConfig (table)
-- OWNED SAVEDVARIABLES: none
-- EVENTS REGISTERED: none
-- FRAMES CREATED: none
-- GOTCHAS: This file MUST load before QuestLog_Config.lua,
--   QuestLog_Data.lua, QuestLog_Panel.lua, and Map.lua since
--   all of them read Addon.MapConfig at file scope.
--   MAP_THEME_COLORS is the single source of truth for the
--   warm-parchment palette used throughout the quest UI.
-- ============================================================

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 = {
    MODULE_SOURCE = "MapSkin",
    WHITE8X8 = "Interface\\Buttons\\WHITE8x8",
    DEBUG_PROBE_PREFIX = "map_probe",
    QUEST_TAB_ART_PROBE_PREFIX = "map_tab_art",
    QUEST_TAB_ART_CAPTURE_DELAY = 0.18,
    QUEST_TAB_ART_CAPTURE_FOLLOWUP_DELAY = 0.90,
    QUEST_TAB_ART_CHUNK_SIZE = 24,

    HEADER_TOP_HEIGHT = 40,
    HEADER_NAV_HEIGHT = 34,
    CONTROL_BUTTON_SIZE = 28,
    CONTROL_SPACING = 6,
    NAV_HOME_TO_FIRST_GAP = 1,
    FLOOR_DROPDOWN_WIDTH = 220,
    FLOOR_DROPDOWN_MIN_WIDTH = 136,
    FLOOR_DROPDOWN_MAX_WIDTH = 220,
    HEADER_HORIZONTAL_PADDING = 14,
    NAV_MIN_BREADCRUMB_WIDTH = 300,
    CONTROL_RAIL_MAX_WIDTH_FACTOR = 0.46,
    MAP_MAXIMIZED_TOP_INSET = 36,
    MAP_MAXIMIZED_BOTTOM_INSET = 34,
    MAP_DEFAULT_SCREEN_BORDER = 30,
    MAP_MAXIMIZED_SCALE = 0.84,
    MAP_FULLSCREEN_SCALE = 1.00,
    MAP_FULLSCREEN_TOP_INSET = 4,
    MAP_FULLSCREEN_BOTTOM_INSET = 4,
    MAP_FULLSCREEN_SCREEN_BORDER = 4,
    MAP_CONTAINER_SHADOW_SIZE = 24,
    MAP_CONTAINER_SHADOW_ALPHA = 0.55,
    MAP_CONTAINER_SHADOW_CORNER_ALPHA = 0.34,
    MAP_CONTAINER_SHADOW_SOFT_PAD = 42,
    MAP_CONTAINER_SHADOW_SOFT_ALPHA = 0.68,
    MAP_CONTAINER_SHADOW_SOFT_TEXTURE = "Interface\\GLUES\\MODELS\\UI_MainMenu\\BlizzShadow",

    MAP_TRANSITION_FADE_DUR = 0.35,
    SCROLL_PROBE_METHODS = {
        "SetPanTarget",
        "SetZoomTarget",
        "SetNormalizedZoom",
        "PanAndZoomTo",
        "PanAndZoomToNormalized",
        "SetCanvasScale",
        "ScrollToMap",
    },

    ARROW_WIDTH = 12,
    ARROW_HEIGHT = 8,
    ARROW_STROKE_LENGTH = 7,
    ARROW_STROKE_THICKNESS = 2,
    ARROW_STROKE_X_OFFSET = 2,
    ARROW_ROTATION = 0.70,
    FACTION_ICON_ATLAS = "ui-storm-headerorb-level0",
    FACTION_ICON_WIDTH = 18,
    FACTION_ICON_HEIGHT = 21,
    QUEST_LOG_ICON_TEXTURE = "Interface\\GossipFrame\\AvailableQuestIcon",
    QUEST_LOG_PANEL_WIDTH = 380,
    QUEST_LOG_PANEL_INSET = 0,
    QUEST_LOG_SLIDE_DURATION = 0.22,
    QUEST_LOG_PANEL_HEADER_HEIGHT = 72,
    QUEST_LOG_PANEL_CONTENT_INSET = 0,
    QUEST_LOG_PANEL_TAB_HEIGHT = 28,
    QUEST_LOG_PANEL_TAB_WIDTH = 100,
    QUEST_LOG_PANEL_TAB_MIN_WIDTH = 88,
    QUEST_LOG_PANEL_TAB_MAX_WIDTH = 118,
    QUEST_LOG_PANEL_TAB_GAP = 4,
    QUEST_LOG_PANEL_STRATA = "DIALOG",

    QUEST_LIST_CAMPAIGN_HEIGHT      = 62,
    QUEST_LIST_HEADER_HEIGHT        = 28,
    QUEST_LIST_QUEST_ROW_HEIGHT     = 22,
    QUEST_LIST_OBJECTIVE_ROW_HEIGHT = 18,
    QUEST_LIST_HEADER_GAP           = 4,
    QUEST_LIST_QUEST_GAP            = 2,
    QUEST_LIST_OBJECTIVE_GAP        = 1,
    QUEST_LIST_OBJECTIVE_INDENT     = 20,
    QUEST_LIST_CONTENT_PADDING      = 6,

    MAP_THEME_COLORS = {
        accent = { 0.72, 0.62, 0.42 },
        accentMid = { 0.62, 0.52, 0.34 },
        accentDark = { 0.50, 0.40, 0.24 },
        bgHeader = { 0.08, 0.065, 0.04 },
        bgPanel = { 0.055, 0.045, 0.03 },
        bgPanelRaised = { 0.10, 0.08, 0.05 },
        bgPanelAlt = { 0.14, 0.11, 0.07 },
        border = { 0.28, 0.22, 0.14 },
        borderStrong = { 0.38, 0.30, 0.20 },
        textPrimary = { 0.94, 0.89, 0.78 },
        textSecondary = { 0.74, 0.66, 0.52 },
        textMuted = { 0.52, 0.46, 0.34 },
        textDisabled = { 0.38, 0.34, 0.26 },
        ink = { 0.06, 0.05, 0.03 },
    },

    DIAG_LEVEL_RANK = { error = 1, warn = 2, info = 3, debug = 4, trace = 5 },
    QUEST_TAB_MODE_KEYS = { "Quests", "Events", "MapLegend" },
}

function MapConfig.GetThemeColor(key)
    local color = MapConfig.MAP_THEME_COLORS[key]
    if not color then
        return 1, 1, 1
    end
    return color[1], color[2], color[3]
end

Addon.MapConfig = MapConfig
