//////////////////////////////
// Toolkit Settings
//////////////////////////////
$Toolkit-Settings: (
  'clearfix extend': false,
  'color stack amounts': 25% 50% 75% 85% 90%,
  'tint shade amounts': 75% 50% 25%,
  'tint color': #fff,
  'shade color': #000,
  'color scale steps': 6,
  'ligature extend': false,
  'font face weight': normal,
  'font face style': normal,
  'font face inline woff': false,
  'icon font extend': false,
  'icon font speak': false,
  'fade in duration': 1s,
  'fade in loading class': '.wf-loading',
  'fade in extend': false,
  'intrinsic ratio': 16/9,
  'intrinsic ratio width': 100%,
  'intrinsic ratio elements': '> *',
  'intrinsic ratio position': top,
  'intrinsic ratio extend': false,
  'nested context contexts': 100%,
  'nested context position': left,
  'triangle color': #000,
  'triangle height': 1em,
  'triangle width': 1em,
  'triangle angle': 0,
  'parallax perspective': 1,
  'parallax element': 'body',
  'parallax ios': true,
  'parallax distance': 0,
  'vertical midpoint': 50%,
  'vertical extend': false,
  'horizontal midpoint': 0%,
  'horizontal fixed midpoint': 50%,
  'horizontal fixed': false,
  'horizontal extend': false,
  'absolute center vertical midpoint': 50%,
  'absolute center horizontal midpoint': 0%,
  'absolute center fixed horizontal midpoint': 50%,
  'absolute center fixed': false,
  'absolute center extend': false,
  'underline background': #fff,
  'underline color': #00e,
  'underline clear descenders': true,
  'underline distance': 1,
  'underline width': 2,
  'underline extend': false,
  'art pixel size': 1px,
  'art color': black,
  'art border radius': 0%
);

//////////////////////////////
// New Settings module
//////////////////////////////
// Global
$GlobalSettings: $Toolkit-Settings !default;
// User
$UserSettings: () !default;

//////////////////////////////
// User Setting Exists
//////////////////////////////
@function user-setting-exists($setting) {
  @if map-has-key($UserSettings, $setting) {
    @return true;
  }
  @else {
    @return false;
  }
}

@function user-setting-exists-multiple($settings...) {
  $Return: ();
  @each $setting in $settings {
    $Return: map-merge($Return, ($setting: user-setting-exists($setting)));
  }
  @return $Return;
}

// Toolkit Version
@function toolkit-has($setting) {
  @return user-setting-exists($setting);
}

//////////////////////////////
// Setting Get
//////////////////////////////
@function setting-get($setting) {
  @if user-setting-exists($setting) {
    @return map-get($UserSettings, $setting);
  }
  @else {
    @return map-get($GlobalSettings, $setting);
  }
}

@function setting-get-multiple($settings...) {
  $values: ();
  @each $setting in $settings {
    $values: map-merge($values, ($setting: setting-get($setting)));
  }
  @return $values;
}

// Toolkit Version
@function toolkit-get($setting) {
  @return setting-get($setting);
}


//////////////////////////////
// Settings Set
//////////////////////////////
@function setting-set($setting, $value) {
  $UserSettings: map-merge($UserSettings, ($setting: $value)) !global;
  @return true;
}

@function setting-set-multiple($settings) {
  $UserSettings: map-merge($UserSettings, $settings) !global;
  @return true;
}

@mixin setting-set($setting, $value) {
  $setting-setter: setting-set($setting, $value) !global;
}

@mixin setting-change($setting, $value) {
  @include setting-set($setting, $value);
}

@mixin setting-set-multiple($settings) {
  $setting-setter: setting-set-multiple($settings) !global;
}

@mixin setting-change-multiple($settings) {
  @include setting-set-multiple($settings);
}

// Toolkit Version
@function toolkit-set($setting, $value) {
  @return setting-set($setting, $value);
}

@mixin toolkit-change($setting, $value) {
  @include setting-set($setting, $value);
}

@mixin toolkit-set($setting, $value) {
  @include setting-set($setting, $value);
}

//////////////////////////////
// Remove Setting
//////////////////////////////
@function setting-clear($setting) {
  $Return: ();

  @each $Key, $Value in $UserSettings {
    $Return: if($setting == $Key, $Return, map-merge($Return, ($Key: $Value)));
  }

  $UserSettings: $Return !global;
  @return true;
}

@function setting-clear-multiple($settings...) {
  @each $setting in $settings {
    $clear-the-settings: setting-clear($setting);
  }
  @return true;
}

@function setting-reset() {
  $UserSettings: () !global;
  @return true;
}

@mixin setting-clear($setting) {
  $setting-clearer: setting-clear($setting);
}

@mixin setting-clear-multiple($settings...) {
  $setting-clearer: setting-clear-multiple($settings);
}

@mixin setting-reset() {
  $setting-clearer: setting-reset();
}

// Toolkit Version
@function toolkit-reset($setting) {
  @return setting-clear($setting);
}

@mixin toolkit-reset($setting) {
  @include setting-clear($setting);
}

//////////////////////////////
// Setting Pick
//////////////////////////////
@function setting-pick($setting, $input) {
  @return if($input != null, $input, setting-get($setting));
}

@function setting-pick-multiple($settings) {
  $Return: ();
  @each $setting, $input in $settings {
    $Return: map-merge($Return, ($setting: setting-pick($input, $setting)));
  }

  @return $Return;
}