$color-grayscale-light: rgb(186 190 197);
$color-tan: rgb(188 139 82);
$color-bleu-de-france-dark: rgb(45 112 180);
$color-bleu-de-france-light: rgb(108 163 218);
$color-green: rgb(124 181 24);
$color-princeton-orange-on-white: rgb(231 117 0);
$color-tan-lighter: rgb(219 193 163);
$color-grayscale-dark: rgb(130 138 151);
$color-grayscale: rgb(149 156 167);
$color-white: rgb(255 255 255);
$color-grayscale-lighter: rgb(245 245 245);
$color-grayscale-warm-lighter: rgb(250 249 245);
$color-yellow: rgb(255 186 10);
$color-bleu-de-france: rgb(44 110 175);
$color-tan-dark: rgb(158 113 61);
$color-bleu-de-france-darker: rgb(35 87 139);
$color-bleu-de-france-lighter: rgb(149 189 228);
$color-red: rgb(201 40 19);
$color-grayscale-darker: rgb(65 70 78);
$color-rich-black: rgb(0 17 35);
$color-tan-light: rgb(202 163 119);
$color-tan-darker: rgb(121 87 47);
$color-princeton-orange-on-black: rgb(245 128 37);
$font-size-large-min: 1.125em;
$font-size-base-max: 1.125em;
$font-size-x-large: 36px;
$font-size-xxx-large: 64px;
$font-size-xx-large: 48px;
$font-size-x-large-max: 1.777em;
$font-size-xxx-large-max: 3.157em;
$font-size-large: 24px;
$font-size-xx-large-max: 2.369em;
$font-size-large-max: 1.333em;
$font-size-x-small: 11px;
$font-size-base-min: 1em;
$font-size-small: 13px;
$font-size-x-large-min: 1.266em;
$font-size-xxx-large-min: 1.602em;
$font-size-xx-large-min: 1.424em;
$font-size-base: 16px;
$font-family-heading: "franklin-gothic-urw", helvetica, arial, sans-serif;
$font-family-text: "franklin-gothic-urw", helvetica, arial, sans-serif;
$font-weight-bold: 700;
$font-weight-semi-bold: 600;
$font-weight-regular: 400;
$font-weight-light: 300;
$opacity-disabled: 0.5;
$height-header: 55px;
$height-footer: 64px;
$tappable-square: 44px;
$duration-quickly: 0.08s;
$duration-slowly: 0.5s;
$z-index-modal: 9999;
$z-index-sticky: 100;
$media-query-medium: (min-width: 600px);
$media-query-large: (min-width: 900px);
$media-query-x-large: (min-width: 1200px);
$media-query-xx-large: (min-width: 1800px);
$media-query-xxx-large: (min-width: 2300px);
$box-shadow-small: 0 0 0 1px rgb(92 106 196 / 10%);
$box-shadow-small-inset: inset 0 0 0 1px rgb(0 0 0 / 5%);
$box-shadow-selected: 0 0 0 1px #e77500;
$letter-spacing-x-large: 2px;
$letter-spacing-large: 1px;
$letter-spacing-base: 0;
$letter-spacing-small: -0.5px;
$letter-spacing-x-small: -1px;
$border-radius-default: 3px;
$border-radius-circle: 50%;
$space-xx-large: 128px;
$space-x-large: 64px;
$space-large: 48px;
$space-base: 24px;
$space-small: 16px;
$space-x-small: 8px;
$space-xx-small: 4px;
$line-height-base: 1.6;
$line-height-small: 1.3;
$line-height-heading: 1.5;

/* GLOBAL MIXINS
--------------------------------------------- */

/* AUTO SCALING FOR TYPE WITH MIN/MAX SIZES

  @param {Number}  $responsive  - Viewport-based size
  @param {Number}  $min         - Minimum font size (px)
  @param {Number}  $max         - Maximum font size (px) (optional)

  @param {Number}  $fallback    - Fallback for viewport-based units (optional)

  @example SCSS - 5vw size, 35px min & 150px max size + 50px fallback:

  @include responsive-font(5vw, 35px, 150px, 50px);
*/
@mixin responsive-font($responsive, $min, $max: false, $fallback: false) {
  $responsive-unitless: strip-unit($responsive);
  $dimension: if(unit($responsive) == "vh", "height", "width");
  $min-breakpoint: calc($min / $responsive-unitless * 100);

  @media (max-#{$dimension}: #{$min-breakpoint}) {
    font-size: $min;
  }

  @if $max {
    $max-breakpoint: calc($max / $responsive-unitless * 100);

    @media (min-#{$dimension}: #{$max-breakpoint}) {
      font-size: $max;
    }
  }

  @if $fallback {
    font-size: $fallback;
  }

  font-size: $responsive;
}

// Reset
@mixin reset {
  box-sizing: border-box;
  padding: 0;
  margin: 0;
}

// Used to prevent text selection on an element
@mixin prevent-user-select {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
}

/// Used to hide an element visually, but keeping it accessible for
/// accessibility tools.
@mixin visually-hidden {
  // Need to make sure we override any existing styles.
  position: absolute !important;
  left: 0;
  clip: rect(1px, 1px, 1px, 1px) !important;
  overflow: hidden !important;
  height: 1px !important;
  width: 1px !important;
  padding: 0 !important;
  border: 0 !important;
}

/// To be used on flex items. Resolves some common layout issues, such as
/// text truncation not respecting padding or breaking out of container.
/// https://css-tricks.com/flexbox-truncated-text/
@mixin layout-flex-fix {
  min-width: 0;
  max-width: 100%;
}

/* GLOBAL FUNCTIONS
--------------------------------------------- */

// Create a tint
//
// @param  {Color}  $color to tint
// @param  {Number} $percentage of `$color` in returned color
// @return {Color}
@function tint($color, $percentage) {
  @return mix(white, $color, $percentage);
}

// Create a shade
//
// @param  {Color}  $color to shade
// @param  {Number} $percentage of `$color` in returned color
// @return {Color}
@function shade($color, $percentage) {
  @return mix(black, $color, $percentage);
}

// Calculate color difference
// See https://www.w3.org/TR/AERT/#color-contrast for algorithm
//
// @param  {Color} $color of foreground
// @param  {Color} $color of background
// @return {Boolean}
@function color-difference($foreground, $background) {
  $r: (max(red($foreground), red($background))) - (min(red($foreground), red($background)));
  $g: (max(green($foreground), green($background))) - (min(green($foreground), green($background)));
  $b: (max(blue($foreground), blue($background))) - (min(blue($foreground), blue($background)));
  $sum-rgb: $r + $g + $b;

  @if $sum-rgb < 350 {
    @return "false";
  } @else {
    @return "true";
  }
}

// Set text color based on contrast
//
// @param  {Color}  $color to set
// @param  {Color}  $background color to test
// @param  {Color}  $fallback color to set in case contrast check fails
@function set-text-color($color, $background, $fallback: null) {
  @if $fallback == null {
    $fallback: #000;
  }

  @if color-difference($color, $background) == "false" {
    @return $fallback;
  } @else {
    @return $color;
  }
}

/// Darkens the foreground color by the background color. This is the same as the
/// “multiply” filter in graphics apps.
///
/// @param {Color} $foreground - The color to darken.
/// @param {Color} $background - The background to base darkening on.
/// @return {Color} The modified color.
@function color-multiply($foreground, $background: null) {
  @if $background == null {
    $background: #fff;
  }

  @return $foreground * $background / 255;
}

/// Returns the value in rem for a given pixel value.
/// @param {Number} $value - The pixel value to be converted.
/// @return {Number} The converted value in rem.
@function rem($value) {
  $unit: unit($value);

  @if $unit == "rem" {
    @return $value;
  } @else if $unit == "px" {
    @return $value / $font-size-base * 1rem;
  } @else if $unit == "em" {
    @return $unit / 1em * 1rem;
  } @else {
    @error "Value must be in px, em, or rem.";
  }
}

/// Returns the value in pixels for a given rem value.
/// @param {Number} $value - The rem value to be converted.
/// @return {Number} The converted value in pixels.
@function px($value) {
  $unit: unit($value);

  @if $unit == "px" {
    @return $value;
  } @else if $unit == "em" {
    @return ($value / 1em) * $font-size-base;
  } @else if $unit == "rem" {
    @return ($value / 1rem) * $font-size-base;
  } @else {
    @error "Value must be in rem, em, or px.";
  }
}

/// Returns the list of available names in a given map.
/// @param {Map} $map - The map of data to list the names from.
/// @param {Number} $map - The level of depth to get names from.
/// @return {String} The list of names in the map.
@function available-names($map, $level: 1) {
  @if type-of($map) != "map" {
    @return null;
  }

  $output: "";
  $newline: "\A ";

  @if $level == 1 {
    @each $key, $value in $map {
      $output: $output + "#{$newline}- #{$key} #{available-names($value, $level + 1)}";
    }
  } @else {
    $output: "(";
    $i: 1;

    @each $key, $value in $map {
      $sep: if($i < length($map), ", ", "");
      $output: $output + "#{$key}#{$sep}#{available-names($value, $level + 1)}";
      $i: $i + 1;
    }

    $output: $output + ")";
  }

  @return $output;
}
