-- Nord Theme for Lumacs
-- Defined in Lua using the theme API

local theme = editor:create_and_register_theme("nord")

-- Nord color palette
local nord0 = lumacs.Color(46, 52, 64)      -- Polar Night - darkest
local nord1 = lumacs.Color(59, 66, 82)      -- Polar Night
local nord2 = lumacs.Color(67, 76, 94)      -- Polar Night  
local nord3 = lumacs.Color(76, 86, 106)     -- Polar Night - lightest
local nord4 = lumacs.Color(216, 222, 233)   -- Snow Storm - dark
local nord5 = lumacs.Color(229, 233, 240)   -- Snow Storm
local nord6 = lumacs.Color(236, 239, 244)   -- Snow Storm - lightest
local nord7 = lumacs.Color(143, 188, 187)   -- Frost - cyan
local nord8 = lumacs.Color(136, 192, 208)   -- Frost - light blue
local nord9 = lumacs.Color(129, 161, 193)   -- Frost - blue
local nord10 = lumacs.Color(94, 129, 172)   -- Frost - dark blue
local nord11 = lumacs.Color(191, 97, 106)   -- Aurora - red
local nord12 = lumacs.Color(208, 135, 112)  -- Aurora - orange
local nord13 = lumacs.Color(235, 203, 139)  -- Aurora - yellow
local nord14 = lumacs.Color(163, 190, 140)  -- Aurora - green
local nord15 = lumacs.Color(180, 142, 173)  -- Aurora - purple

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

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

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

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

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

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

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

local constant_attrs = lumacs.FaceAttributes()
constant_attrs.foreground = nord13
constant_attrs.background = nord0
theme:set_face("font-lock-constant-face", constant_attrs)

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

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

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

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

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

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

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

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