local addOnName, namespace = ...

namespace.WildThingsUI.settings = {
    -- Brand (colors.css --accent / --accent-dim / --on-accent + alpha variants)
    ACCENT = {r = 0x25/255, g = 0xF7/255, b = 0x37/255, a = 1},
    ACCENT_DIM = {r = 0x1F/255, g = 0x70/255, b = 0x13/255, a = 1},
    ON_ACCENT = {r = 0x05/255, g = 0x27/255, b = 0x10/255, a = 1},
    ACCENT_A08 = {r = 37/255, g = 247/255, b = 55/255, a = 0.08},
    ACCENT_A13 = {r = 37/255, g = 247/255, b = 55/255, a = 0.13},
    ACCENT_A20 = {r = 37/255, g = 247/255, b = 55/255, a = 0.2},
    ACCENT_A70 = {r = 37/255, g = 247/255, b = 55/255, a = 0.7},
    WT_WHITE = {r = 0xF5/255, g = 0xFC/255, b = 0xFF/255, a = 1},

    -- Surfaces (green-tinted near-black ladder)
    BG = {r = 0x0A/255, g = 0x0E/255, b = 0x0B/255, a = 1},
    SURFACE_1 = {r = 0x10/255, g = 0x15/255, b = 0x11/255, a = 1},
    SURFACE_2 = {r = 0x15/255, g = 0x1C/255, b = 0x17/255, a = 1},
    SURFACE_3 = {r = 0x1B/255, g = 0x24/255, b = 0x1D/255, a = 1},
    PANEL_BG = {r = 10/255, g = 14/255, b = 11/255, a = 0.97},
    BTN_BG = {r = 16/255, g = 24/255, b = 19/255, a = 0.6},
    BTN_BG_HOVER = {r = 16/255, g = 24/255, b = 19/255, a = 0.65},
    INPUT_BG = {r = 5/255, g = 8/255, b = 6/255, a = 0.5},
    DD_BG = {r = 19/255, g = 29/255, b = 22/255, a = 0.9},

    -- Borders — white + alpha (adapts to any tint)
    BORDER = {r = 1, g = 1, b = 1, a = 0.05},
    BORDER_STRONG = {r = 1, g = 1, b = 1, a = 0.2},
    BORDER_HOVER = {r = 1, g = 1, b = 1, a = 0.3},
    BORDER_BTN = {r = 1, g = 1, b = 1, a = 0.3},
    BORDER_BTN_HOVER = {r = 1, g = 1, b = 1, a = 0.45},
    WHITE_A08 = {r = 1, g = 1, b = 1, a = 0.08}, -- IconButton's borderless hover/active wash (Phase 10)
    STRIP_BG = {r = 0, g = 0, b = 0, a = 0.18}, -- Shell titlebar/sidebar/statusbar strip color (Phase 11)

    -- Text — white + alpha
    TEXT = {r = 1, g = 1, b = 1, a = 0.92},
    TEXT_DIM = {r = 1, g = 1, b = 1, a = 0.53},
    TEXT_SECTION = {r = 1, g = 1, b = 1, a = 0.41},
    TEXT_DISABLED = {r = 1, g = 1, b = 1, a = 0.3},
    TEXT_BTN = {r = 1, g = 1, b = 1, a = 0.55},
    TEXT_BTN_HOVER = {r = 1, g = 1, b = 1, a = 0.7},

    -- Rows (alternating overlays)
    ROW_ODD = {r = 0, g = 0, b = 0, a = 0.1},
    ROW_EVEN = {r = 0, g = 0, b = 0, a = 0.2},
    ROW_HOVER = {r = 1, g = 1, b = 1, a = 0.06},

    -- State overlays (mirror accent alpha variants)
    HOVER_OVERLAY = {r = 37/255, g = 247/255, b = 55/255, a = 0.13},
    SELECTED_OVERLAY = {r = 37/255, g = 247/255, b = 55/255, a = 0.2},

    -- Semantic
    OK = {r = 0x25/255, g = 0xF7/255, b = 0x37/255, a = 1},
    DANGER = {r = 0xFF/255, g = 0x52/255, b = 0x62/255, a = 1},
    WARN = {r = 0xFF/255, g = 0xB8/255, b = 0x4D/255, a = 1},
    INFO = {r = 0x5B/255, g = 0xC8/255, b = 0xF0/255, a = 1},
    DIRTY_AMBER = {r = 0xF0/255, g = 0xB4/255, b = 0x28/255, a = 1},
    NEUTRAL = {r = 0x8A/255, g = 0x8F/255, b = 0x8C/255, a = 1},
    DANGER_A13 = {r = 255/255, g = 82/255, b = 98/255, a = 0.13},
    DANGER_A70 = {r = 255/255, g = 82/255, b = 98/255, a = 0.7},
    -- Role-badge tints for the Raid night bottom section's Tank/Ranged columns
    -- (DESIGN-NOTES §5). Same .13 alpha as DANGER_A13/ACCENT_A13, which already back the
    -- Melee/Heal badges -- these two complete the set rather than introducing a new scale.
    INFO_A13 = {r = 91/255, g = 200/255, b = 240/255, a = 0.13},
    WARN_A13 = {r = 255/255, g = 184/255, b = 77/255, a = 0.13},
    -- Phase 57 (SUMDESIGN-05) -- the no-portal banner's border (0.35) and
    -- fill (0.10) alphas. Same base RGB as WARN_A13 (255,184,77) and the same
    -- {BASE}_A{alpha*100} naming convention ACCENT_A08/A13/A20/A70 and
    -- DANGER_A13/A70 already use. WARN_A13 itself stays untouched -- it
    -- backs the Raid Night role badges and must not drift.
    WARN_A35 = {r = 255/255, g = 184/255, b = 77/255, a = 0.35},
    WARN_A10 = {r = 255/255, g = 184/255, b = 77/255, a = 0.10},

    -- Toggle
    TG_OFF = {r = 68/255, g = 68/255, b = 68/255, a = 0.65},
    TG_KNOB_OFF = {r = 1, g = 1, b = 1, a = 0.5},
    TG_ON = {r = 37/255, g = 247/255, b = 55/255, a = 0.75},

    -- WoW class colors — keyed by non-localized classFilename (a wholly separate lookup
    -- from Init.lua's numeric-classID -> English-display-name table used for chat-icon gsub)
    CLASS_COLORS = {
        WARRIOR = {r = 0xC6/255, g = 0x9B/255, b = 0x6D/255, a = 1},
        PALADIN = {r = 0xF4/255, g = 0x8C/255, b = 0xBA/255, a = 1},
        HUNTER = {r = 0xAA/255, g = 0xD3/255, b = 0x72/255, a = 1},
        ROGUE = {r = 0xFF/255, g = 0xF4/255, b = 0x68/255, a = 1},
        PRIEST = {r = 1, g = 1, b = 1, a = 1},
        DEATHKNIGHT = {r = 0xC4/255, g = 0x1E/255, b = 0x3A/255, a = 1},
        SHAMAN = {r = 0x00/255, g = 0x70/255, b = 0xDD/255, a = 1},
        MAGE = {r = 0x3F/255, g = 0xC7/255, b = 0xEB/255, a = 1},
        WARLOCK = {r = 0x87/255, g = 0x88/255, b = 0xEE/255, a = 1},
        MONK = {r = 0x00/255, g = 0xFF/255, b = 0x98/255, a = 1},
        DRUID = {r = 0xFF/255, g = 0x7C/255, b = 0x0A/255, a = 1},
        DEMONHUNTER = {r = 0xA3/255, g = 0x30/255, b = 0xC9/255, a = 1},
        EVOKER = {r = 0x33/255, g = 0x93/255, b = 0x7F/255, a = 1},
    },

    -- Radii
    RADIUS_SM = 4,
    RADIUS_MD = 6,
    RADIUS_LG = 8,
    RADIUS_PILL = 999,

    -- Control metrics
    H_BTN = 28,
    H_INPUT = 28,
    H_DROPDOWN = 28,
    TG_W = 40,
    TG_H = 20,
    SIZE_CHECKBOX = 18,
    SIZE_SWATCH = 20,
    H_ROW = 36,
    H_NAV = 30,
    W_SIDEBAR = 180,
    H_TITLEBAR = 48,
    H_STATUSBAR = 26,
    PAD_WINDOW = 12,
    GAP = 8,
    GAP_LG = 16,
    PAD_BTN_X = 12,
    ICON_SM = 14,
    ICON_MD = 16,
    ICON_LG = 20,

    -- Motion (seconds — WoW's SetDuration takes seconds, not ms)
    -- removed dead motion easing token — zero repo consumers; native `SetSmoothing`
    -- accepts only NONE/IN/OUT/IN_OUT presets, never raw bezier control points
    DUR_IN = 0.12,
    DUR_OUT = 0.20,

    -- WTUI-01/WTUI-02 fade-duration seam: same values as DUR_IN/DUR_OUT above (which stay
    -- as-is — they still back CheckButton's checkmark scale-in and Dropdown's chevron
    -- rotation, non-fade consumers). ANIMATION is the dedicated hover/focus-fade section
    -- WTUI-02's UIFrameFadeIn/Out call sites read from.
    ANIMATION = {
        HOVER_IN = 0.12,
        HOVER_OUT = 0.20,
    },

    -- WTUI-01 Window/Shell chrome (distinct near-black tone from the SURFACE_1/2/3 / BG
    -- ladder above — do NOT alias to those; this is its own dedicated gradient/hover set).
    -- Values moved byte-identical from Window.lua/Shell.lua's prior hand-coded literals.
    WINDOW_BG_BOTTOM = {r = 12/255, g = 18/255, b = 10/255, a = 1}, -- dark base (gradient bottom, rest fill)
    WINDOW_BG_HOVER = {r = 16/255, g = 24/255, b = 14/255, a = 1}, -- drag-strip hover lighten
    WINDOW_BORDER = {r = 10/255, g = 42/255, b = 15/255, a = 1}, -- very dark green 1px window outline

    -- WTUI-01 Window.lua exit-cross / resize-triangle chrome-icon greys.
    CHROME_ICON_IDLE = {r = 0.5, g = 0.5, b = 0.5, a = 1},
    CHROME_ICON_HOVER = {r = 0.85, g = 0.85, b = 0.85, a = 1},

    -- WTUI-05 seam: Icon.lua's SetIconState tint dimension (grey idle -> accent hover).
    ICON_TINT_IDLE = {r = 0.7, g = 0.7, b = 0.7, a = 1},
    ICON_TINT_HOVER = {r = 0x25/255, g = 0xF7/255, b = 0x37/255, a = 1}, -- reuses ACCENT green
    ICON_TINT_DISABLED = {r = 0.4, g = 0.4, b = 0.4, a = 1},

    -- DRAGUX-01 slot alpha ramp (rest -> hover -> drag), applied via whole-frame
    -- SetAlpha() (Icon.lua's SetIconState-style discrete states, never AnimationGroups).
    -- SLOT_ALPHA_PRESENT: an occupant confirmed in the raid (in/lead) renders at full
    -- strength so the rest-dim reads as "absent", never as a false signal on a present
    -- player; empty/missing/offline slots keep SLOT_ALPHA_REST.
    SLOT_ALPHA_REST = 0.55,
    SLOT_ALPHA_HOVER = 0.85,
    SLOT_ALPHA_DRAG = 0.95,
    SLOT_ALPHA_PRESENT = 1.0,

    -- DRAGUX-02 central glow driver (UI/GlowDriver.lua) border-pulse parameters
    GLOW_COLOR = {r = 0x25/255, g = 0xF7/255, b = 0x37/255, a = 1}, -- reuses ACCENT green
    GLOW_SPEED = 6, -- radians/sec fed into the driver's sine oscillation
    GLOW_ALPHA_MIN = 0.35,
    GLOW_ALPHA_MAX = 0.95,

    -- DRAGUX-04 fuzzy search: alpha for non-matching grid slots (recede, not recolor)
    SEARCH_RECEDE_ALPHA = 0.4,
}

-- Alias — Private and namespace are the SAME shared table (select(2, ...) everywhere else
-- in the codebase); this is an alias, never a copy. Settings.lua loads before Init.lua per
-- UI/UI.xml, so no load-order hazard.
namespace.Theme = namespace.WildThingsUI.settings

local Theme = namespace.Theme

-- Class color accessor: C_ClassColor (Blizzard, authoritative, never drifts) primary,
-- the CLASS_COLORS table above (transcribed from colors.css) as static fallback, white
-- for an unrecognized key. Keyed by non-localized classFilename ("DEATHKNIGHT"), a table
-- wholly separate from Init.lua's numeric-classID -> English-display-name lookup (used
-- only for chat-icon gsub substitution) — never reuse or extend that other table here.
function Theme.GetClassColor(classFilename)
    local mixin = type(classFilename) == "string"
        and C_ClassColor and C_ClassColor.GetClassColor
        and C_ClassColor.GetClassColor(classFilename)
    if mixin then
        return {r = mixin.r, g = mixin.g, b = mixin.b, a = 1}
    end
    return Theme.CLASS_COLORS[classFilename] or {r = 1, g = 1, b = 1, a = 1}
end

-- Icon stem -> texture path resolution (Phase 10's Icon widget consumes this contract).
Theme.ICON_PATH_FORMAT = "Interface\\Addons\\%s\\Media\\Icons\\Lucide\\%s.png"

function Theme.GetIconPath(stem)
    return string.format(Theme.ICON_PATH_FORMAT, addOnName, stem)
end
