/// Convert to color
/// @param {*} $value - value to cast
/// @return {color | null}
@function _sc-to-color($value) {
  @if type-of($value) == "color" {
    @return $value;
  }

  @if type-of($value) != "string" {
    //@warn "Could not cast `#{inspect($value)}` to color.";
    @return null;
  }

  $value-lower: to-lower-case($value);
  $colors: transparent black silver gray white maroon red purple fuchsia green lime olive yellow navy blue teal aqua aliceblue antiquewhite aqua aquamarine azure beige bisque black blanchedalmond blue blueviolet brown burlywood cadetblue chartreuse chocolate coral cornflowerblue cornsilk crimson cyan darkblue darkcyan darkgoldenrod darkgray darkgreen darkgrey darkkhaki darkmagenta darkolivegreen darkorange darkorchid darkred darksalmon darkseagreen darkslateblue darkslategray darkslategrey darkturquoise darkviolet deeppink deepskyblue dimgray dimgrey dodgerblue firebrick floralwhite forestgreen fuchsia gainsboro ghostwhite gold goldenrod gray green greenyellow grey honeydew hotpink indianred indigo ivory khaki lavender lavenderblush lawngreen lemonchiffon lightblue lightcoral lightcyan lightgoldenrodyellow lightgray lightgreen lightgrey lightpink lightsalmon lightseagreen lightskyblue lightslategray lightslategrey lightsteelblue lightyellow lime limegreen linen magenta maroon mediumaquamarine mediumblue mediumorchid mediumpurple mediumseagreen mediumslateblue mediumspringgreen mediumturquoise mediumvioletred midnightblue mintcream mistyrose moccasin navajowhite navy oldlace olive olivedrab orange orangered orchid palegoldenrod palegreen paleturquoise palevioletred papayawhip peachpuff peru pink plum powderblue purple red rosybrown royalblue saddlebrown salmon sandybrown seagreen seashell sienna silver skyblue slateblue slategray slategrey snow springgreen steelblue tan teal thistle tomato turquoise violet wheat white whitesmoke yellow yellowgreen;
  $keywords: ();

  // Filling $keywords with stringified color keywords
  @each $color in $colors {
    $keywords: append($keywords, $color + "");
  }

  // Deal with inherit keyword
  @if $value-lower == "inherit" {
    @return unquote($value);
  }

  // Deal with color keywords
  @if index($keywords, $value-lower) {
    @return nth($colors, index($keywords, $value-lower));
  }

  // Deal with hexadecimal triplets
  @else if str-slice($value-lower, 1, 1) == "#" {
    @return _sc-from-hex($value);
  }

  // Deal with rgb(a) colors
  @else if str-slice($value-lower, 1, 3) == "rgb" {
    @return _sc-from-rgb($value);
  }

  // Deal with hsl(a) colors
  @else if str-slice($value-lower, 1, 3) == "hsl" {
    @return _sc-from-hsl($value);
  }

  // Return value
  @else {
    //@warn "Could not cast `#{inspect($value)}` to color.";
    @return null;
  }
}
