// When color definition differs for dark and light variant,
// it gets @if ed depending on $variant

@function gtkalpha($c, $a) {
  @return unquote("alpha(#{$c}, #{$a})");
}

@function scale-alpha($c, $a) {
  @return scale-color($c, $alpha: percentage(-1 + $a));
}

@import 'color-palette';

// based border and highlight values:
// https://material.google.com/style/icons.html#icons-product-icons

// Foreground colors
$light_contrast_color: scale-alpha($black, 0.8);
$dark_contrast_color: $white;

$fg_color: if($variant == 'light', $light_contrast_color, $dark_contrast_color);
$secondary_fg_color: scale-alpha($fg_color, $enabled_opacity);
$tertiary_fg_color: scale-alpha($fg_color, $hint_opacity);

$inversed_fg_color: $dark_contrast_color;
$secondary_inversed_fg_color: scale-alpha($inversed_fg_color, $enabled_opacity);
$tertiary_inversed_fg_color: scale-alpha($inversed_fg_color, $hint_opacity);

$topbar_fg_color: if($light == 'true', $fg_color, $inversed_fg_color);
$secondary_topbar_fg_color: if($light == 'true', $secondary_fg_color, $secondary_inversed_fg_color);
$tertiary_topbar_fg_color: if($light == 'true', $tertiary_fg_color, $tertiary_inversed_fg_color);

$disabled_fg_color: scale-alpha($fg_color, $disabled_opacity);
$disabled_secondary_fg_color: scale-alpha($secondary_fg_color, $disabled_opacity);
$disabled_tertiary_fg_color: scale-alpha($tertiary_fg_color, $disabled_opacity);

$disabled_inversed_fg_color: scale-alpha($inversed_fg_color, $disabled_opacity);
$disabled_secondary_inversed_fg_color: scale-alpha($secondary_inversed_fg_color, $disabled_opacity);
$disabled_tertiary_inversed_fg_color: scale-alpha($tertiary_inversed_fg_color, $disabled_opacity);

$disabled_topbar_fg_color: if($light == 'true', $disabled_fg_color, $disabled_inversed_fg_color);
$disabled_secondary_topbar_fg_color: if($light == 'true', $disabled_secondary_fg_color, $disabled_secondary_inversed_fg_color);
$disabled_tertiary_topbar_fg_color: if($light == 'true', $disabled_tertiary_fg_color, $disabled_tertiary_inversed_fg_color);

// Background colors
$bg_color: if($variant == 'light', $grey-100, $blue-grey-700);
$base_color: if($variant == 'light', $white, $blue-grey-600);
$alt_base_color: mix($base_color, $bg_color, 50%);
$lighter_bg_color: if($variant == 'light', $grey-50, $blue-grey-500);
$darker_bg_color: if($variant == 'light', $grey-200, $blue-grey-900);
$headerbar_color: if($variant == 'light', if($light == 'true', $grey-300, $blue-grey-700), $blue-grey-800);
$secondary_titlebar_color: if($light == 'true', $grey-400, $blue-grey-800);
$topbar_color: if($light == 'true', $grey-400, $blue-grey-900);

$primary_color: $blue-400;
$alt_primary_color: $light-blue-A200;
$accent_color: $pink-A200;

// Misc colors
$track_color: gtkalpha(currentColor, $lower_opacity);
$semi_track_color: gtkalpha(currentColor, $lower_opacity / 2);
$row_track_color: gtkalpha(currentColor, 0.05);
$borders_color: if($variant == 'light', scale-alpha($black, 0.1), scale-alpha($black, 0.2));
$highlight_color: if($variant == 'light', scale-alpha($white, 0.4), scale-alpha($white, 0.1));
$secondary_highlight_color: scale-alpha($white, 0.2);
$topbar_highlight_color: if($light == 'true', $highlight_color, $secondary_highlight_color);
$topbar_indicator_color: if($light == 'true', $primary_color, currentColor);

$placeholder_text_color: mix($fg_color, $base_color, percentage($hint_opacity));

$link_color: $primary_color;
$link_visited_color: $purple-A200;

$warning_color: $orange-A700;
$error_color: $deep-orange-A700;
$success_color: $green-A700;

$suggested_color: $accent_color;
$destructive_color: $red-A200;

$info_bg_color: $green-400;
$question_bg_color: $blue-400;
$warning_bg_color: $orange-400;
$error_bg_color: $red-400;
