/*----------------------------------*\
  #COLORS
\*----------------------------------*/


@function palette($color_name, $tone: 'base', $category: 'colors') {
  
  
  // @return map-get(map-get(map-get($palettes, colors), $palette), $tone);

  @return map-get-deep($palettes, $category, $color_name, $tone);
}

@function to-string($value) {
  @return inspect($value);
}

@function convert-color-map($map-old, $map-new, $overwrite: true) {
  $case: "lower-case";
  // Iterate through each value of the new map
  @each $key, $new-value in $map-new {
    // Check if that value already exists on the old map
    @if type-of($new-value) == map and type-of($key) != color and map-has-key($map-old, $key) {
      // There is an existing key
      $old-value: map-get($map-old, $key);
      @if type-of($new-value) == map and type-of($old-value) == map {
        // If both are maps, recurse regardless of $overwrite
        $merged-value: convert-color-map($old-value, $new-value);
        $stringified-key: to-string($key);
        $new-key: call("to-" + $case, $stringified-key);
        $map-old: map-merge(map-remove($map-old, $key), (
          quote($new-key): $merged-value
        ));

      }@else{
        // Otherwise check $overwrite
        @if $overwrite{
          $stringified-key: to-string($key);
          $new-key: call("to-" + $case, $stringified-key);
          $map-old: map-merge(map-remove($map-old, $key), (
            quote($new-key): $new-value
          ));
        }
      }
    }@else{
      // There is no existing key so add
      $stringified-key: to-string($key);
      $new-key: call("to-" + $case, $stringified-key);

      $map-old: map-merge(map-remove($map-old, $key), (
        quote($new-key): $new-value
      ));
    }
  }
  @return $map-old;
}



$palettes: (
  colors: (
    red: (
      light: #f5e6e6,
      base: #9d0606,
      dark: #310202
    ),
    orange: (
      base: #d25600
    ),
    yellow: (
      light: #f9f0d2,
      base: #ddae25
    ),
    green: (
      light: #e3f2d3,
      lighter: #7b9e02,
      base:    #007330
    ),
    teal: (
      base: #09929d
    ),
    blue: (
      lightest: #E4F4FF,
      lighter: #b0dfff,
      light:   #42b1ff,
      base:    #0092f8,
      dark:    #005c9c,
      darker:  #003051
    ),
    navy: (
      base: #132f8e
    ),
    royal-blue: (
      lighter: #9dbacf, // Nested menu link
      light: #5c6585, // Nested menu border
      base: #474f68, // Nested menu background
      dark: #3f465f,
      darker: #344059, // Nested menu header
      darkest: #262e3f // Nested menu header hover
    ),
    violet: (
      base: #3c3376
    ),
    pink: (
      lighter: #ff69b4,
      base: #a30776
    ),
    gray: (
      lightest-hover: #edebe9, // Menu Header Hover
      lightest-active: #e4e1de, // Menu Header Active, Active state should always be slightly lighter than border
      
      lightest: #f3f3f3, // Menu Header Background
      lighter:    #dcd8d4, // Menu Header Border
      light:  #d3cec9,
      base:     #97a0a5,
      dark:     #6a7980,
      darker:   #4d575b,
      darkest:  #2a3032
    ),
    black: (
      base: #000
    ),
    white: (
     base: #fff
    )
  ),
    
  social: (
    facebook: (
      base: #3b5998
    ),
    twitter: (
      base: #55acee
    ),
    linkedin: (
      base: #0077b5
    ),
    email: (
      base: #0092f8
    )
  )
);



$json-colors: convert-color-map($palettes, $palettes);
$json-colors: jsonexport('colors.sass.json', $json-colors);
