-- Gruvbox Light Theme for Lumacs
-- Defined in Lua using the theme API

local theme = editor:create_and_register_theme("gruvbox-light")

-- Gruvbox Light color palette
local bg0 = lumacs.Color(251, 241, 199)     -- background
local bg1 = lumacs.Color(235, 219, 178)     -- background soft
local bg2 = lumacs.Color(213, 196, 161)     -- background hard
-- local bg3 = lumacs.Color(189, 174, 147)     -- background harder (not explicitly used)
local fg0 = lumacs.Color(40, 40, 40)        -- foreground
local fg1 = lumacs.Color(60, 56, 54)        -- foreground
local fg2 = lumacs.Color(80, 73, 69)        -- foreground
local fg3 = lumacs.Color(102, 92, 84)       -- foreground
local fg4 = lumacs.Color(124, 111, 100)     -- gray

local red    = lumacs.Color(157, 0, 6)         -- red
local green  = lumacs.Color(121, 116, 14)    -- green
local yellow = lumacs.Color(181, 118, 20)   -- yellow
local blue   = lumacs.Color(7, 102, 120)      -- blue
local purple = lumacs.Color(143, 63, 113)   -- purple
local aqua   = lumacs.Color(66, 123, 88)      -- aqua
local orange = lumacs.Color(175, 58, 3)     -- orange

-- Set face attributes
local normal_attrs = lumacs.FaceAttributes()
normal_attrs.foreground = fg0
normal_attrs.background = bg0
theme:set_face("normal", normal_attrs)

local keyword_attrs = lumacs.FaceAttributes()
keyword_attrs.foreground = red
keyword_attrs.background = bg0
keyword_attrs.weight = lumacs.FontWeight.Bold
theme:set_face("font-lock-keyword-face", keyword_attrs)

local string_attrs = lumacs.FaceAttributes()
string_attrs.foreground = green
string_attrs.background = bg0
theme:set_face("font-lock-string-face", string_attrs)

local comment_attrs = lumacs.FaceAttributes()
comment_attrs.foreground = fg4
comment_attrs.background = bg0
comment_attrs.slant = lumacs.FontSlant.Italic
theme:set_face("font-lock-comment-face", comment_attrs)

local function_attrs = lumacs.FaceAttributes()
function_attrs.foreground = yellow
function_attrs.background = bg0
theme:set_face("font-lock-function-name-face", function_attrs)

local type_attrs = lumacs.FaceAttributes()
type_attrs.foreground = purple
type_attrs.background = bg0
theme:set_face("font-lock-type-face", type_attrs)

local number_attrs = lumacs.FaceAttributes()
number_attrs.foreground = orange
number_attrs.background = bg0
theme:set_face("font-lock-constant-face", number_attrs)

local constant_attrs = lumacs.FaceAttributes()
constant_attrs.foreground = aqua
constant_attrs.background = bg0
theme:set_face("font-lock-builtin-face", constant_attrs) -- Mapping to builtin for consistency

local error_attrs = lumacs.FaceAttributes()
error_attrs.foreground = red
error_attrs.background = bg1
error_attrs.weight = lumacs.FontWeight.Bold
theme:set_face("error", error_attrs)

local selection_attrs = lumacs.FaceAttributes()
selection_attrs.foreground = fg0
selection_attrs.background = bg2
theme:set_face("region", selection_attrs)

local cursor_attrs = lumacs.FaceAttributes()
cursor_attrs.foreground = bg0
cursor_attrs.background = fg0
theme:set_face("cursor", cursor_attrs)

local statusline_attrs = lumacs.FaceAttributes()
statusline_attrs.foreground = fg1
statusline_attrs.background = bg1
theme:set_face("mode-line", statusline_attrs)

local statusline_inactive_attrs = lumacs.FaceAttributes()
statusline_inactive_attrs.foreground = fg3
statusline_inactive_attrs.background = bg1
theme:set_face("mode-line-inactive", statusline_inactive_attrs)

local line_number_attrs = lumacs.FaceAttributes()
line_number_attrs.foreground = fg4
line_number_attrs.background = bg0
theme:set_face("line-number", line_number_attrs)

local minibuffer_prompt_attrs = lumacs.FaceAttributes()
minibuffer_prompt_attrs.foreground = blue
minibuffer_prompt_attrs.background = bg0
minibuffer_prompt_attrs.weight = lumacs.FontWeight.Bold
theme:set_face("minibuffer-prompt", minibuffer_prompt_attrs)

print(string.format("Theme '%s' loaded.", theme:name()))
