/**
/// Pulls a name out of the $colors array by key and throws a warning
/// if the specified color name does not exist
/// @param  {String} $name A color name inside that is inside $colors
/// @return {String}       The matching color or null
*/
@function color($name) {
  @if map-has-key($colors, $name) {
    @return map-get($colors, $name);
  }

  @warn "Unknown `#{$name}` in $colors.";
  @return null;
}

@function safeColor($name) {
  @if map-has-key($safeColors, $name) {
    @return map-get($safeColors, $name);
  }

  @warn "Unknown `#{$name}` in $safeColors.";
  @return null;
}

/**
/// Prefixes a given string with the $projectPrefix and a category prefix out
/// of $categoryPrefixes by the key $category
/// @param  {String} $category A category name in $categoryPrefixes
/// @param  {String} $selector The selector that gets prefixed
/// @return {String}           The prefixed selector
*/
@function prefix($category, $selector) {
    @if map-has-key($categoryPrefixes, $category) {
      @return #{$projectPrefix}-#{map-get($categoryPrefixes, $category)}-#{$selector};
    }

    @return #{$projectPrefix}-#{$selector};
}

@function utility($selector) {
    @return prefix('utility', $selector);
}

@function atom($selector) {
    @return prefix('atom', $selector);
}

@function molecule($selector) {
    @return prefix('molecule', $selector);
}

@function organism($selector) {
  @return prefix('organism', $selector);
}

@function template($selector) {
  @return prefix('template', $selector);
}

/**
/// Pulls a name out of the $shadows array by key and throws a warning
/// if the specified shadow name does not exist
/// @param  {String} $name A shadow name inside that is inside $shadows
/// @return {String}       The matching shadow or null
*/
@function shadows($name) {
  @if map-has-key($shadows, $name) {
    @return map-get($shadows, $name);
  }

  @warn "Unknown `#{$name}` in $colors.";
  @return null;
}
