// Need to define the raw colors somewhere!
// stylelint-disable color-no-hex, no-indistinguishable-colors, function-max-empty-lines, value-list-max-empty-lines
$theme-color-palette-data: (

  // This shold not be necessary
  error: (
    50: #fff1f0, //m-red, 50
    500: #c31032 //m-red, 800
  ),

  link: (
    500: #1976D2, //m-blue, 700
  ),

  m-red: (
    50: #FFEBEE,
    100: #FFCDD2,
    200: #EF9A9A,
    300: #E57373,
    400: #EF5350,
    500: #F44336,
    600: #E53935,
    700: #D32F2F,
    800: #C62828,
    900: #B71C1C,
    A100: #ff8a80,
    A200: #ff5252,
    A400: #ff1744,
    A700: #d50000
  ),

  m-pink: (
    50: #FCE4EC,
    100: #F8BBD0,
    200: #F48FB1,
    300: #F06292,
    400: #EC407A,
    500: #E91E63,
    600: #D81B60,
    700: #C2185B,
    800: #AD1457,
    900: #880E4F,
    A100: #ff80ab,
    A200: #ff4081,
    A400: #f50057,
    A700: #c51162
  ),

  m-purple: (
    50: #F3E5F5,
    100: #E1BEE7,
    200: #CE93D8,
    300: #BA68C8,
    400: #AB47BC,
    500: #9C27B0,
    600: #8E24AA,
    700: #7B1FA2,
    800: #6A1B9A,
    900: #4A148C,
    A100: #ea80fc,
    A200: #e040fb,
    A400: #d500f9,
    A700: #aa00ff
  ),

  m-deep-purple: (
    50: #EDE7F6,
    100: #D1C4E9,
    200: #B39DDB,
    300: #9575CD,
    400: #7E57C2,
    500: #673AB7,
    600: #5E35B1,
    700: #512DA8,
    800: #4527A0,
    900: #311B92,
    A100: #b388ff,
    A200: #7c4dff,
    A400: #651fff,
    A700: #6200ea
  ),

  m-indigo: (
    50: #E8EAF6,
    100: #C5CAE9,
    200: #9FA8DA,
    300: #7986CB,
    400: #5C6BC0,
    500: #3F51B5,
    600: #3949AB,
    700: #303F9F,
    800: #283593,
    900: #1A237E,
    A100: #8c9eff,
    A200: #536dfe,
    A400: #3d5afe,
    A700: #304ffe
  ),

  m-blue: (
    50: #E3F2FD,
    100: #BBDEFB,
    200: #90CAF9,
    300: #64B5F6,
    400: #42A5F5,
    500: #2196F3,
    600: #1E88E5,
    700: #1976D2,
    800: #1565C0,
    900: #0D47A1,
    A100: #82b1ff,
    A200: #448aff,
    A400: #2979ff,
    A700: #2962ff
  ),

  m-light-blue: (
    50: #E1F5FE,
    100: #B3E5FC,
    200: #81D4FA,
    300: #4FC3F7,
    400: #29B6F6,
    500: #03A9F4,
    600: #039BE5,
    700: #0288D1,
    800: #0277BD,
    900: #01579B,
    A100: #80d8ff,
    A200: #40c4ff,
    A400: #00b0ff,
    A700: #0091ea
  ),

  m-cyan: (
    50: #E0F7FA,
    100: #B2EBF2,
    200: #80DEEA,
    300: #4DD0E1,
    400: #26C6DA,
    500: #00BCD4,
    600: #00ACC1,
    700: #0097A7,
    800: #00838F,
    900: #006064,
    A100: #84ffff,
    A200: #18ffff,
    A400: #00e5ff,
    A700: #00b8d4
  ),

  m-teal: (
    50: #E0F2F1,
    100: #B2DFDB,
    200: #80CBC4,
    300: #4DB6AC,
    400: #26A69A,
    500: #009688,
    600: #00897B,
    700: #00796B,
    800: #00695C,
    900: #004D40,
    A100: #a7ffeb,
    A200: #64ffda,
    A400: #1de9b6,
    A700: #00bfa5
  ),

  m-green: (
    50: #E8F5E9,
    100: #C8E6C9,
    200: #A5D6A7,
    300: #81C784,
    400: #66BB6A,
    500: #4CAF50,
    600: #43A047,
    700: #388E3C,
    800: #2E7D32,
    900: #1B5E20,
    A100: #b9f6ca,
    A200: #69f0ae,
    A400: #00e676,
    A700: #00c853
  ),

  m-light-green: (
    50: #F1F8E9,
    100: #DCEDC8,
    200: #C5E1A5,
    300: #AED581,
    400: #9CCC65,
    500: #8BC34A,
    600: #7CB342,
    700: #689F38,
    800: #558B2F,
    900: #33691E,
    A100: #ccff90,
    A200: #b2ff59,
    A400: #76ff03,
    A700: #64dd17
  ),

  m-lime: (
    50: #F9FBE7,
    100: #F0F4C3,
    200: #E6EE9C,
    300: #DCE775,
    400: #D4E157,
    500: #CDDC39,
    600: #C0CA33,
    700: #AFB42B,
    800: #9E9D24,
    900: #827717,
    A100: #f4ff81,
    A200: #eeff41,
    A400: #c6ff00,
    A700: #aeea00
  ),

  m-yellow: (
    50: #FFFDE7,
    100: #FFF9C4,
    200: #FFF59D,
    300: #FFF176,
    400: #FFEE58,
    500: #FFEB3B,
    600: #FDD835,
    700: #FBC02D,
    800: #F9A825,
    900: #F57F17,
    A100: #ffff8d,
    A200: #ffff00,
    A400: #ffea00,
    A700: #ffd600
  ),

  m-amber: (
    50: #FFF8E1,
    100: #FFECB3,
    200: #FFE082,
    300: #FFD54F,
    400: #FFCA28,
    500: #FFC107,
    600: #FFB300,
    700: #FFA000,
    800: #FF8F00,
    900: #FF6F00,
    A100: #ffe57f,
    A200: #ffd740,
    A400: #ffc400,
    A700: #ffab00
  ),

  m-orange: (
    50: #FFF3E0,
    100: #FFE0B2,
    200: #FFCC80,
    300: #FFB74D,
    400: #FFA726,
    500: #FF9800,
    600: #FB8C00,
    700: #F57C00,
    800: #EF6C00,
    900: #E65100,
    A100: #ffd180,
    A200: #ffab40,
    A400: #ff9100,
    A700: #ff6d00
  ),

  m-deep-orange: (
    50: #FBE9E7,
    100: #FFCCBC,
    200: #FFAB91,
    300: #FF8A65,
    400: #FF7043,
    500: #FF5722,
    600: #F4511E,
    700: #E64A19,
    800: #D84315,
    900: #BF360C,
    A100: #ff9e80,
    A200: #ff6e40,
    A400: #ff3d00,
    A700: #dd2c00
  ),

  m-brown: (
    50: #EFEBE9,
    100: #D7CCC8,
    200: #BCAAA4,
    300: #A1887F,
    400: #8D6E63,
    500: #795548,
    600: #6D4C41,
    700: #5D4037,
    800: #4E342E,
    900: #3E2723
  ),

  m-grey: (
    50: #FAFAFA,
    100: #F5F5F5,
    200: #EEEEEE,
    300: #E0E0E0,
    400: #BDBDBD,
    500: #9E9E9E,
    600: #757575,
    700: #616161,
    800: #424242,
    900: #212121
  ),

  m-blue-grey: (
    50: #ECEFF1,
    100: #CFD8DC,
    200: #B0BEC5,
    300: #90A4AE,
    400: #78909C,
    500: #607D8B,
    600: #546E7A,
    700: #455A64,
    800: #37474F,
    900: #263238
  ),

  black: (
    500: #000000
  ),

  white: (
    500: #FFFFFF
  ),
);


/// Returns the color value for a given color name and group.
///
/// @param {String} $hue - The color's hue.
/// @param {String} $value - The darkness/lightness of the color. Defaults to base.
/// @param {Color} $for-background - The background color on which this color will
/// appear. Applies a multiply filter to ensure appropriate contrast.
/// @return {Color} The color value.

@function theme-color($hue, $value: 500, $for-background: null) {
  $fetched-color: map-get(map-get($theme-color-palette-data, $hue), $value);

  @if map-has-key($theme-color-palette-data, $fetched-color) {
    $fetched-color: map-get(map-get($theme-color-palette-data, $fetched-color), $value);
  }

  @if $for-background != null {
    $fetched-color: color-multiply($fetched-color, $for-background);
  }

  @if type-of($fetched-color) == color {
    @return $fetched-color;
  } @else {
    @error 'Color `#{$hue} - #{$value}` not found. Available colors: #{available-names($theme-color-palette-data)}';
  }
}


/// 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: #ffffff;
  }

  @return $foreground * $background / 255;
}

// stylelint-enable color-no-hex, no-indistinguishable-colors, function-max-empty-lines, value-list-max-empty-lines
