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

$dark-icon-themes: "theme_dark", "theme_solarizedDark", "theme_nord";

$font-family-sans-serif: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
$font-size-base: 14px;
$text-color: #212529;
$muted-text-color: #6c747c;
$border-color: #ced4dc;
$border-color-dark: #ddd;
$border-radius: 3px;
$focus-outline-color: #1252a3;

$brand-primary: #175ddc;

$background-color: #ffffff;
$background-offset-color: #f0f0f0;

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

$success-color-light: #017e45;
$success-color-dark: #8db89b;

$error-color-light: #c83522;
$error-color-dark: #ee9792;

$themes: (
  light: (
    textColor: $text-color,
    mutedTextColor: $muted-text-color,
    backgroundColor: $background-color,
    backgroundOffsetColor: $background-offset-color,
    primaryColor: $brand-primary,
    buttonPrimaryColor: $brand-primary,
    textContrast: $background-color,
    inputBorderColor: darken($border-color-dark, 2.75%),
    inputBackgroundColor: #ffffff,
    borderColor: $border-color,
    focusOutlineColor: $focus-outline-color,
    successColor: $success-color-light,
    errorColor: $error-color-light,
  ),
  dark: (
    textColor: #ffffff,
    mutedTextColor: #bac0ce,
    backgroundColor: #2f343d,
    backgroundOffsetColor: darken(#2f343d, 2.75%),
    buttonPrimaryColor: #6f9df1,
    primaryColor: #6f9df1,
    textContrast: #2f343d,
    inputBorderColor: #4c525f,
    inputBackgroundColor: #2f343d,
    borderColor: #4c525f,
    focusOutlineColor: lighten($focus-outline-color, 25%),
    successColor: $success-color-dark,
    errorColor: $error-color-dark,
  ),
  nord: (
    textColor: $nord5,
    mutedTextColor: $nord4,
    backgroundColor: $nord1,
    backgroundOffsetColor: darken($nord1, 2.75%),
    buttonPrimaryColor: $nord8,
    primaryColor: $nord9,
    textContrast: $nord2,
    inputBorderColor: $nord0,
    inputBackgroundColor: $nord2,
    borderColor: $nord0,
    focusOutlineColor: lighten($focus-outline-color, 25%),
    successColor: $success-color-dark,
  ),
  solarizedDark: (
    textColor: $solarizedDarkBase2,
    // Muted uses main text color to avoid contrast issues
    mutedTextColor: $solarizedDarkBase2,
    backgroundColor: $solarizedDarkBase03,
    backgroundOffsetColor: darken($solarizedDarkBase03, 2.75%),
    buttonPrimaryColor: $solarizedDarkCyan,
    primaryColor: $solarizedDarkGreen,
    textContrast: $solarizedDarkBase02,
    inputBorderColor: rgba($solarizedDarkBase2, 0.2),
    inputBackgroundColor: $solarizedDarkBase01,
    borderColor: $solarizedDarkBase2,
    focusOutlineColor: lighten($focus-outline-color, 15%),
    successColor: $success-color-dark,
  ),
);

@mixin themify($themes: $themes) {
  @each $theme, $map in $themes {
    .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);
}
