// generic drawing of more complex things

// ripple effect animations

@keyframes ripple_effect {
  to { background-size: 1000% 1000%; }
}

@keyframes header_ripple_effect {
  from {
    background-image: radial-gradient(circle farthest-corner at center,
                                      $primary_color 0%,
                                      transparent 0%);
  }

  to {
    background-image: radial-gradient(circle farthest-corner at center,
                                      $primary_color 100%,
                                      transparent 0%);
  }
}


@mixin entry($t, $fc: $primary_color) {
//
// entry
//
// $t: entry type
// $fc: focus color
//

  @if $t == normal {
    transition: $longer_transition, $shadow_transition;
    border-image: radial-gradient(circle closest-corner at center calc(100% - 1px),
                                    $track_color 100%,
                                    transparent 0%)
                                    0 0 2 / 0 0 2px;;
    box-shadow: $shadow_0;
    background-color: if($fc == $primary_color, $base_color, $fc);
    color: if($fc == $primary_color, $fg_color, $inverse_fg_color);
    
    &:backdrop { color: backdrop($fg_color); }
  }

  @if $t == focus {
    border-image: radial-gradient(circle closest-corner at center calc(100% - 1px),
                                    $accent_color 100%,
                                    transparent 0%)
                                    0 0 2 / 0 0 2px;
    box-shadow: $shadow_2;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: $accent_color
  }

  @if $t == disabled {
    box-shadow: $shadow_0;
    background-color: rgba($alt_base_color, 0.5);
    color: rgba($disabled_fg_color, 0.85);
    
    &:backdrop { color: rgba(backdrop($disabled_fg_color), 0.85); }
  }

  @if $t == flat-normal {
    transition: $longer_transition;
    border-image: radial-gradient(circle closest-corner at center calc(100% - 1px),
                                  $fc 0%,
                                  transparent 0%)
                                  0 0 0 / 0 0 0px;
    box-shadow: inset 0 -1px if($fc == $primary_color, $track_color, $fc);
    background-color: transparent;
    color: $fg_color;
  }

  @if $t == flat-focus {
    border-image: radial-gradient(circle closest-corner at center calc(100% - 1px),
                                  $fc 100%,
                                  transparent 0%)
                                  0 0 2 / 0 0 2px;
    box-shadow: inset 0 -1px if($fc == $primary_color, $track_color, $fc);
  }

  @if $t == flat-disabled {
    box-shadow: inset 0 -1px $divider_color;
    background-color: transparent;
    color: $disabled_fg_color;
  }
}


@mixin button($t, $c: $lighter_bg_color) {
//
// button
//
// $t: button type
// $c: base color
//

  @if $t == normal {
    transition: $longer_transition,
                $shadow_transition;
    box-shadow: $shadow_1, inset 0 0 0 9999px transparent;
    background-color: $c;
    color: $button_fg_color;
    
    &:backdrop { color: backdrop($button_fg_color); }
  }

  @if $t == hover {
    box-shadow: $shadow_2, inset 0 0 0 9999px transparent;
    color: $fg_color;
  }

  @if $t == active {
    transition: $longer_transition;
    box-shadow: $shadow_2, inset 0 0 0 9999px $semi_fill_color;
    color: $fg_color;
  }

  @if $t == disabled {
    box-shadow: none;
    background-color: $divider_color;
    color: if($c == $lighter_bg_color, $disabled_secondary_fg_color, $disabled_fg_color);
  }

  @if $t == checked {
    background-color: $accent_color;
    color: $inverse_fg_color;
    &:backdrop { 
      background-color: backdrop($accent_color);
      color: backdrop($inverse_fg_color); 
    }
  }

  @if $t == checked-disabled {
    background-color: rgba($accent_color, $lower_opacity);
    color: rgba($accent_color, $disabled_opacity);
    
    &:backdrop { 
      opacity: 0.5;
    }
  }

  @if $t == flat-normal {
    transition: $longer_transition;
    box-shadow: inset 0 0 0 9999px transparent;
    background-color: transparent;
    color: $secondary_fg_color;
  }

  @if $t == flat-hover {
    box-shadow: inset 0 0 0 9999px $semi_fill_color;
    color: $fg_color;
  }

  @if $t == flat-active {
    transition: $longer_transition;
    box-shadow: inset 0 0 0 9999px $semi_fill_color;
    color: $fg_color;
  }

  @if $t == flat-disabled {
    box-shadow: none;
    background-color: transparent;
    color: if($c == $lighter_bg_color, $disabled_secondary_fg_color, $disabled_fg_color);
  }

  @if $t == flat-checked {
    background-color: $track_color;
    color: $fg_color;
  }

  @if $t == flat-checked-disabled {
    background-color: $divider_color;
    color: $disabled_fg_color;
  }
}


@mixin overshoot($p) {
//
// overshoot
//
// $p: position
//
// possible $p values:
// top, bottom, right, left
//

  $_position: center $p;

  @if ($p == left) or ($p == right) {
    $_position: $p center;
  }

  background-image: -gtk-gradient(radial,
                                  $_position, 0,
                                  $_position, 0.75,
                                  to(rgba($alt_primary_color, $lower_opacity)),
                                  to(transparent));

  background-repeat: no-repeat;
  background-position: $_position;

  background-color: transparent; // reset some properties to be sure to not inherit them somehow
  border: none;                  //
  box-shadow: none;              //
}


@mixin undershoot($p) {
//
// undershoot
//
// $p: position
//
// possible $p values:
// top, bottom, right, left
//

  $_undershoot_color_dark: $track_color;
  $_undershoot_color_light: rgba($base_color, $lower_opacity);

  $_gradient_dir: left;
  $_dash_bg_size: 12px 1px;
  $_gradient_repeat: repeat-x;
  $_bg_pos: left $p;

  @if ($p == left) or ($p == right) {
    $_gradient_dir: top;
    $_dash_bg_size: 1px 12px;
    $_gradient_repeat: repeat-y;
    $_bg_pos: $p top;
  }

  background-color: transparent; // shouldn't be needed, but better to be sure

  background-image: none;

  padding-#{$p}: 1px;
  background-size: $_dash_bg_size;
  background-repeat: $_gradient_repeat;
  background-origin: content-box;
  background-position: $_bg_pos;
}
