@import "~nord/src/sass/nord.scss";

$font-family-sans-serif: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
$font-size-base: 14px;
$text-color: #333333;
$border-color-dark: #ddd;
$border-radius: 3px;

$brand-primary: #175ddc;

$background-color: #f0f0f0;

$solarizedDarkBase0: #839496;
$solarizedDarkBase03: #002b36;
$solarizedDarkBase02: #073642;
$solarizedDarkBase01: #586e75;
$solarizedDarkBase2: #eee8d5;
$solarizedDarkCyan: #2aa198;
$solarizedDarkGreen: #859900;

$themes: (
  light: (
    textColor: $text-color,
    mutedTextColor: #6d757e,
    backgroundColor: $background-color,
    primaryColor: $brand-primary,
    buttonPrimaryColor: $brand-primary,
    textContrast: $background-color,
    inputBorderColor: darken($border-color-dark, 7%),
    inputBackgroundColor: #ffffff,
  ),
  dark: (
    textColor: #ffffff,
    mutedTextColor: #bac0ce,
    backgroundColor: #2f343d,
    buttonPrimaryColor: #6f9df1,
    primaryColor: #6f9df1,
    textContrast: #2f343d,
    inputBorderColor: #4c525f,
    inputBackgroundColor: #2f343d,
  ),
  nord: (
    textColor: $nord5,
    mutedTextColor: $nord4,
    backgroundColor: $nord1,
    buttonPrimaryColor: $nord8,
    primaryColor: $nord9,
    textContrast: $nord2,
    inputBorderColor: $nord0,
    inputBackgroundColor: $nord2,
  ),
  solarizedDark: (
    textColor: $solarizedDarkBase2,
    // Muted uses main text color to avoid contrast issues
    mutedTextColor: $solarizedDarkBase2,
    backgroundColor: $solarizedDarkBase03,
    buttonPrimaryColor: $solarizedDarkCyan,
    primaryColor: $solarizedDarkGreen,
    textContrast: $solarizedDarkBase02,
    inputBorderColor: rgba($solarizedDarkBase2, 0.2),
    inputBackgroundColor: $solarizedDarkBase01,
  ),
);

@mixin themify($themes: $themes) {
  @each $theme, $map in $themes {
    html.theme_#{$theme} & {
      $theme-map: () !global;
      @each $key, $submap in $map {
        $value: map-get(map-get($themes, $theme), "#{$key}");
        $theme-map: map-merge(
          $theme-map,
          (
            $key: $value,
          )
        ) !global;
      }
      @content;
      $theme-map: null !global;
    }
  }
}

@function themed($key) {
  @return map-get($theme-map, $key);
}
