@use "sass:meta";
@use "sass:string";
@use "variables" as *;

/// Get CSS variable with prefix
/// @param {String} $name - CSS variable name (without prefix)
/// @param {*} $fallback - Optional fallback value
/// @return {String} - Complete CSS variable reference
/// @example
///   color: fi-var(global-font-color);
///   background: fi-var(custom-bg, #fff);
@function var($name, $fallback: null) {
  @if $fallback != null {
    @if meta.type-of($fallback) == string {
      @return string.unquote('var(#{$rootPrefix}#{$name}, "#{$fallback}")');
    }
    @return string.unquote("var(#{$rootPrefix}#{$name}, #{$fallback})");
  }

  @return string.unquote("var(#{$rootPrefix}#{$name})");
}
