-- lx-bundle:true

--- Small visual design used by the basic LiqubePage proof
-- @module plugins.lppreview.design

local style = require("core.style")

local design = {
	typography = {
		font_size = 16,
		line_height_scale = 1.2,
		heading_scales = { 2, 1.7, 1.5, 1.35, 1.2, 1.1 },
	},
	document = {
		minimum_content_width = 80,
		padding_horizontal = 32,
		padding_vertical = 14,
	},
	paragraphs = {
		gap = 14,
	},
	headings = {
		gap_above = { 18, 14, 12, 10, 9, 8 },
		separator_width = 1,
		separator_opacity = { 0.45, 0.22 },
	},
	lists = {
		indent = 22,
	},
	horizontal_rules = {
		width = 1,
		opacity = 0.34,
	},
	-- Shared painter reads these values before checking individual rows
	code_spans = {
		padding_vertical = 0,
	},
	links = {
		underline_width = 1,
		underline_offset = 2,
	},
}

--- Return the live document background
-- @return table color
function design.get_document_background_color()
	return style.background
end

--- Return the live document text color
-- @param syntax_type string|nil optional live color role
-- @return table color
function design.get_text_color(syntax_type)
	local syntax_style = syntax_type and style.syntax and style.syntax[syntax_type]

	if type(syntax_style) == "table" and (syntax_style.fg or syntax_style.bg) then
		return syntax_style.fg or style.text
	end

	return syntax_style or style.text
end

--- Return the live link color reserved for later inline support
-- @return table color
function design.get_link_color()
	return style.accent or style.text
end

--- Return the horizontal separator color
-- @return table color
function design.get_horizontal_rule_color()
	return style.transparent(style.text, design.horizontal_rules.opacity)
end

--- Return the scaled horizontal separator width
-- @return number width
function design.get_horizontal_rule_width()
	return math.max(1, design.horizontal_rules.width * (SCALE or 1))
end

--- Return whether one heading level draws a separator
-- @param level number heading level
-- @return boolean enabled
function design.is_heading_separator_enabled(level)
	return design.headings.separator_opacity[level] ~= nil
end

--- Return one heading separator color
-- @param level number heading level
-- @return table color
function design.get_heading_separator_color(level)
	return style.transparent(style.text, design.headings.separator_opacity[level] or 0)
end

--- Return the scaled heading separator width
-- @return number width
function design.get_heading_separator_width()
	return math.max(1, design.headings.separator_width * (SCALE or 1))
end

return design
