@mixin normal_buttons($bg, $fg, $br) {
  padding: 4px 8px;
  border-style: solid;
  border-width: 1px;
  border-radius: $button_radius;
  color: $fg;
  border-color: gtkshade($br, 0.6);
  border-top-color: gtkshade($br, 0.9);
  border-left-color: gtkshade($br, 0.85);
  border-right-color: gtkshade($br, 0.85);
  background-color: $bg;
  background-image: linear-gradient(to bottom, gtkshade($bg, 1.15), $bg, gtkshade($bg, 1.05));

  @if $variant != 'dark' {
    box-shadow: inset 0 1px 0 0 gtkalpha($light_shadow, 0.7);
  }
  @else {
    box-shadow: inset 0 2px 3px 0 gtkalpha($light_shadow, 0.15);
  }
  -gtk-outline-radius: $button_radius;

  &:hover {
    border-color: gtkshade($br, 0.5);
    border-top-color: gtkshade($br, 0.85);
    border-left-color: gtkshade($br, 0.75);
    border-right-color: gtkshade($br, 0.75);
    color: $fg;
    background-color: gtkshade($bg, 1.1);
    @if $variant != 'dark' {
      box-shadow: inset 0 -9px 4px 0 gtkalpha($light_shadow, 0.8), inset 0 1px 0 0 gtkalpha($light_shadow, 0.7), inset 0 8px 4px 0 gtkalpha($light_shadow, 0.4);
    }
    @else {
      box-shadow: inset 0 -9px 4px 0 gtkalpha($light_shadow, 0.2), inset 0 1px 0 0 gtkalpha($light_shadow, 0.2), inset 0 8px 4px 0 gtkalpha($light_shadow, 0.2);
    }
  }

  &:active, &:checked {
    border-color: gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.65);
    border-top-color: gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.3);
    border-left-color: gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.5);
    border-right-color: gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.5);
    background-color: gtkshade($bg, 0.5);
    background-image: linear-gradient(to bottom, gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.9), gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.85), gtkmix($bg, $selected_bg_color, 0.3));
    box-shadow: inset 0 1px 0 0 gtkalpha($light_shadow, 0.3);

    &:disabled {
      color: gtkmix($fg, $unfocused_disabled_fg_color, 0.1);
    }
  }
  
  // just like in original solaris
  &:active {
    color: $selected_fg_color;
  }

  &:disabled {
    color: gtkmix($fg, $unfocused_disabled_fg_color, 0.5);
  }

  &:backdrop {
    color: $fg;
  }
}

@mixin flat_buttons($bg, $fg, $br)
{
  border-color: transparent;
  border-radius: $button_radius;
  color: $fg;
  background-color: transparent;
  background-image: none;
  box-shadow: none;

  &:hover {
    border-color: gtkshade($br, 0.6);
    border-top-color: gtkshade($br, 0.9);
    border-left-color: gtkshade($br, 0.85);
    border-right-color: gtkshade($br, 0.85);
    background-color: $bg;
    background-image: linear-gradient(to bottom, gtkshade($bg, 1.1), $bg, gtkshade($bg, 1.05));
    box-shadow: inset 0 1px 0 0 gtkalpha($light_shadow, 0.7);
    color: $fg;
  }

  &:active, &:checked {
    border-color: gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.65);
    border-top-color: gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.3);
    border-left-color: gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.5);
    border-right-color: gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.5);
    background-color: gtkshade($bg, 0.5);
    background-image: linear-gradient(to bottom, gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.9), gtkshade(gtkmix($bg, $selected_bg_color, 0.3), 0.85), gtkmix($bg, $selected_bg_color, 0.3));
    box-shadow: inset 0 1px 0 0 gtkalpha($light_shadow, 0.3);
  }

  &:disabled {
    border-color: transparent;
    color: gtkalpha($fg, 0.8);
    background-color: transparent;
    
    &:backdrop {
      border-color: transparent;
      color: gtkalpha($fg, 0.7);
      background-color: transparent;
    }
  }

  &:backdrop {
    color: $fg;
  }
}

@mixin button() {
  button {
    @include normal_buttons($bg_color, $fg_color, $borders);
    
    &.flat {
      @include flat_buttons($bg_color, $fg_color, $borders);
    }
  }
}
