{{- /*
  Build the complete SCSS variables dict passed to toCSS as hugo:vars.
  Two categories:
    - Internal: theme config (base URL, logo, loading image) — highest priority
    - Appearance: defaults + derived + user config ([params.appearance])
  Reference: assets/scss/_variables.scss
  Note: Color values must use hex format (e.g. "#ff0000"), CSS named colors (e.g. "red") are not supported
  because Hugo's isTypedCSSValue only recognizes hex colors, CSS functions, and CSS units.
*/ -}}

{{- /* Internal — theme config (not user-overridable) */ -}}
{{- $logo := resources.Get "images/fixit.svg" | minify -}}
{{- $loading := resources.Get "images/loading.svg" | minify -}}
{{- $internal := dict
  "base_url" (relURL "")
  "logo_img" $logo.RelPermalink
  "loading_img" $loading.RelPermalink
-}}

{{- /* Appearance — defaults + derived + user overrides */ -}}
{{- $overrides := dict -}}
{{- range $key, $value := .Site.Params.appearance | default dict -}}
  {{- if $value -}}
    {{- $overrides = $overrides | merge (dict $key $value) -}}
  {{- end -}}
{{- end -}}
{{- $appearance := dict
  "global_font_family" "system-ui, -apple-system, BlinkMacSystemFont, PingFang SC, Microsoft YaHei UI, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, Helvetica, Arial, sans-serif"
  "global_font_size" "16px"
  "global_font_weight" "400"
  "global_line_height" "1.5rem"
  "global_border_radius" "6px"
  "global_background_color" "#ffffff"
  "global_background_color_dark" "#1f252d"
  "global_font_color" "#1f2328"
  "global_font_color_dark" "#b3bdcb"
  "global_font_secondary_color" "#8b949e"
  "global_font_secondary_color_dark" "#7d8792"
  "global_link_color" "#161209"
  "global_link_color_dark" "#b3bdcb"
  "global_link_hover_color" "#2983bb"
  "global_link_hover_color_dark" "#fff"
  "global_border_color" "#d7dee4"
  "global_border_color_dark" "#383f47"
  "scrollbar_color" "#a6a6a6"
  "scrollbar_hover_color" "#7d7d7d"
  "selection_color" "rgba(53, 166, 247, 0.25)"
  "selection_color_dark" "rgba(50, 112, 194, 0.4)"
  "header_background_color" "#f6f8fa"
  "header_background_color_dark" "#151b23"
  "header_title_font_size" "1.375rem"
  "menu_active_color_dark" "#fff"
  "menu_border_color" "#3c3c3c1f"
  "menu_border_color_dark" "#5454547a"
  "search_background_color" "#e9eaed"
  "search_background_color_dark" "#202833"
  "tag_cloud_start_dark" "#909092"
  "toc_title_font_size" "1rem"
  "toc_content_font_size" "0.875rem"
  "collection_title_font_size" "1rem"
  "collection_list_font_size" "0.875rem"
  "related_title_font_size" "1rem"
  "related_list_font_size" "0.875rem"
  "single_link_color" "#2376b7"
  "single_link_color_dark" "#1781b5"
  "single_link_hover_color" "#ea517f"
  "single_link_hover_color_dark" "#cc5595"
  "table_background_color" "#f9fbfe"
  "table_background_color_dark" "#26303a"
  "table_thead_color" "#e3ebf4"
  "table_thead_color_dark" "#3a4653"
  "table_border_color" "#d4dee8"
  "table_border_color_dark" "#4b5867"
  "blockquote_color" "#697681"
  "blockquote_color_dark" "#9ba3aa"
  "reward_color" "#ff6347"
  "reward_color_dark" "#ff4d2e"
  "reward_img_width" "180px"
  "pagination_link_color" "#bfbfbf"
  "pagination_link_hover_color" "#000"
  "pagination_link_hover_color_dark" "#fff"
  "code_color" "#26323d"
  "code_color_dark" "#c5d1dc"
  "code_font_family" "Source Code Pro, Menlo, Consolas, Monaco, monospace"
  "code_header_color" "#70808f"
  "code_header_color_dark" "#99a7b5"
  "code_header_background_color" "#dde6ef"
  "code_header_background_color_dark" "#161f28"
  "code_background_color" "#f3f7fb"
  "code_background_color_dark" "#2a333d"
  "code_error_color" "#dc3545"
  "code_highlight_color" "#fff2b8"
  "code_highlight_color_dark" "rgba(191, 144, 32, 0.28)"
  "code_font_size" "0.875em"
  "code_block_font_size" "0.875rem"
  "github_corner_color" "#ffffff"
  "github_corner_color_dark" "#000000"
-}}
{{- /* Derived — computed from base defaults */ -}}
{{- $derived := dict
  "header_title_font_family" (index $appearance "global_font_family")
  "menu_active_color" (index $appearance "global_link_color")
  "tag_cloud_start" (index $appearance "global_font_color_dark")
  "tag_cloud_end" (index $appearance "global_font_color")
  "tag_cloud_end_dark" (index $appearance "global_font_color_dark")
  "pagination_link_color_dark" (index $appearance "global_font_color_dark")
  "github_corner_fill" (index $appearance "header_background_color_dark")
  "github_corner_fill_dark" (index $appearance "header_background_color")
-}}

{{- $appearance = $overrides | merge $derived | merge $appearance -}}

{{- /* Merge: appearance + internal */ -}}
{{- $scssVars := dict "internal" $internal | merge $appearance -}}

{{- return $scssVars -}}
