-- Solarized Dark Theme for Lumacs
-- Defined in Lua using the theme API

local theme = editor:create_and_register_theme("solarized-dark")

-- Solarized Dark color palette
local base03 = lumacs.Color(0, 43, 54)      -- background
local base02 = lumacs.Color(7, 54, 66)      -- background highlights
local base01 = lumacs.Color(88, 110, 117)   -- comments / secondary content
local base0  = lumacs.Color(101, 123, 131)  -- body text / default code / primary content
local base1  = lumacs.Color(147, 161, 161)   -- optional emphasized content
-- local base2  = lumacs.Color(238, 232, 213)   -- background highlights (not used in dark theme)
-- local base3  = lumacs.Color(253, 246, 227)   -- background (not used in dark theme)

local yellow  = lumacs.Color(181, 137, 0)    -- constants
local orange  = lumacs.Color(203, 75, 22)    -- regex, numbers
local red     = lumacs.Color(220, 50, 47)       -- keywords
local magenta = lumacs.Color(211, 54, 130)  -- strings
local violet  = lumacs.Color(108, 113, 196)  -- functions
local blue    = lumacs.Color(38, 139, 210)     -- variables
local cyan    = lumacs.Color(42, 161, 152)     -- special
local green   = lumacs.Color(133, 153, 0)     -- types

-- Set face attributes using the modern face system
local normal_attrs = lumacs.FaceAttributes()
normal_attrs.foreground = base0
normal_attrs.background = base03
theme:set_face("normal", normal_attrs)

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

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

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

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

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

local number_attrs = lumacs.FaceAttributes()
number_attrs.foreground = orange
number_attrs.background = base03
theme:set_face("font-lock-constant-face", number_attrs) -- Number is mapped to constant face

local constant_attrs = lumacs.FaceAttributes()
constant_attrs.foreground = yellow
constant_attrs.background = base03
theme:set_face("font-lock-builtin-face", constant_attrs) -- Assuming constants might be builtin

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

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

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

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

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

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

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

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