// 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
$dark_fg_color: scale-alpha($black, 0.8);
$light_fg_color: $white;

$fg_color: if($variant == 'light', $dark_fg_color, $light_fg_color);
$secondary_fg_color: scale-alpha($fg_color, $secondary_opacity);
$tertiary_fg_color: scale-alpha($fg_color, $tertiary_opacity);

$inverse_fg_color: $light_fg_color;
$secondary_inverse_fg_color: scale-alpha($inverse_fg_color, $secondary_opacity);
$tertiary_inverse_fg_color: scale-alpha($inverse_fg_color, $tertiary_opacity);

$titlebar_fg_color: if($titlebar == 'dark', $inverse_fg_color, $fg_color);
$secondary_titlebar_fg_color: if($titlebar == 'dark', $secondary_inverse_fg_color, $secondary_fg_color);
$tertiary_titlebar_fg_color: if($titlebar == 'dark', $tertiary_inverse_fg_color, $tertiary_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_inverse_fg_color: scale-alpha($inverse_fg_color, $disabled_opacity);
$disabled_secondary_inverse_fg_color: scale-alpha($secondary_inverse_fg_color, $disabled_opacity);
$disabled_tertiary_inverse_fg_color: scale-alpha($tertiary_inverse_fg_color, $disabled_opacity);

$disabled_titlebar_fg_color: if($titlebar == 'dark', $disabled_inverse_fg_color, $disabled_fg_color);
$disabled_secondary_titlebar_fg_color: if($titlebar == 'dark', $disabled_secondary_inverse_fg_color, $disabled_secondary_fg_color);
$disabled_tertiary_titlebar_fg_color: if($titlebar == 'dark', $disabled_tertiary_inverse_fg_color, $disabled_tertiary_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: if($variant == 'light', $grey_50, 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);

$titlebar_bg_color: if($variant == 'light', if($titlebar == 'dark', $blue_grey_700, $grey_300), $blue_grey_800);
$alt_titlebar_bg_color: if($titlebar == 'dark', $blue_grey_800, $grey_400);
$panel_bg_color: if($titlebar == 'dark', $blue_grey_900, $grey_400);

$fill_color: gtkalpha(currentColor, $lower_opacity);
$semi_fill_color: gtkalpha(currentColor, $lower_opacity / 2);
$row_fill_color: gtkalpha(currentColor, 0.05);

// Misc colors
$primary_color: $blue_400;
$alt_primary_color: $light_blue_A200;
$accent_color: $pink_A200;

$link_color: $primary_color;
$visited_link_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;

$border_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));
$alt_highlight_color: scale-alpha($white, 0.2);
$unity_highlight_color: if($titlebar == 'dark', scale-alpha($white, 0.1), scale-alpha($white, 0.2));
$titlebar_highlight_color: if($titlebar == 'dark', $alt_highlight_color, $highlight_color);
$titlebar_indicator_color: if($titlebar == 'dark', currentColor, $primary_color);

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