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

$ease-out-quad: cubic-bezier(0.25, 0.46, 0.45, 0.94);

* {
  padding: 0;
  -GtkToolButton-icon-spacing: 4;
  -GtkTextView-error-underline-color: $error_color;

  -GtkButton-child-displacement-x: 0;
  -GtkButton-child-displacement-y: 0;

  -GtkCheckButton-indicator-size: 18;
  -GtkCheckMenuItem-indicator-size: 18;

  // The size for scrollbars. The slider is 2px smaller, but we keep it
  // up so that the whole area is sensitive to button presses for the
  // slider. The stepper button is larger in both directions, the slider
  // only in the width

  -GtkScrolledWindow-scrollbar-spacing: 0;
  -GtkScrolledWindow-scrollbars-within-bevel: 0;

  -GtkScrolled-window-overlay-scrolling: FALSE;

  -GtkToolItemGroup-expander-size: 11;
  -GtkExpander-expander-size: 16;
  -GtkTreeView-expander-size: 11;

  -GtkTreeView-horizontal-separator: 4;

  -GtkWidget-text-handle-width: 20;
  -GtkWidget-text-handle-height: 20;

  -GtkDialog-button-spacing: 4;
  -GtkDialog-action-area-border: 0;

  -GtkStatusbar-shadow-type: none;

  outline-width: 0px;
}


/***************
 * Base States *
 ***************/

.background {
  color: w_color(text);
  background-color: w_color(normal);

  &:backdrop {
    text-shadow: none;
    -gtk-icon-shadow: none;
    color: backdrop(w_color(text));
    background-color: backdrop(w_color(normal));
  }
}

/*
   These wildcard seems unavoidable, need to investigate.
   Wildcards are bad and troublesome, use them with care,
   or better, just don't.
   Everytime a wildcard is used a kitten dies, painfully.
*/

*:disabled {
  -gtk-icon-effect: dim;
}

.gtkstyle-fallback {
  background-color: w_color(normal);
  color: w_color(text);
  &:hover {
    background-color: lighten(w_color(normal), 10%);
    color: w_color(text);
  }
  &:active {
    background-color: darken(w_color(normal), 10%);
    color: w_color(text);
  }
  &:disabled {
    background-color: insensitive(w_color(normal));
    color: insensitive(w_color(text));
  }
  &:selected {
    background-color: s_color(normal);
    color: s_color(text);
  }
}

%view,
.view {
  color: v_color(text);
  background-color: v_color(normal);

  &:backdrop {
    color: backdrop(v_color(text));
    background-color: backdrop(v_color(normal));
  }
  
  &:disabled {
    color: insensitive(v_color(text));
  }

  &:selected {
    &:focus, & {
    border-radius: $r;
    @extend %selected_items;
    }
  }
}

.view,
textview {
  text {
    @extend %view;

    selection { &:focus, & { @extend %selected_items; }}
  }
}

textview border {
  background-color: v_color(normal);
  background-image: image($border_color); // HACK: the border node just draws background so,
  background-repeat: no-repeat;                        // using a background-image to draw the border

  &:backdrop { background-color: backdrop(v_color(normal)); }

  &.bottom {
    background-size: 100% 1px;
    background-position: top;
  }

  &.top {
    background-size: 100% 1px;
    background-position: bottom;
  }

  &.left {
    background-size: 1px 100%;
    background-position: right;
  }

  &.right {
    background-size: 1px 100%;
    background-position: left;
  }
}

.rubberband,
rubberband {
  border: 1px solid s_color(normal);
  background-color: transparentize(s_color(normal),0.8);
  &:backdrop {
    border-color: backdrop(s_color(normal));
    background-color: backdrop(transparentize(s_color(normal),0.8));
  }
}

flowbox {
  rubberband { @extend rubberband; }

  flowboxchild {
    padding: 3px;
    border-radius: $r;

    &:selected {
      @extend %selected_items;

      outline-offset: 0px;
    }
  }
}

label {
  &.separator {
    color: w_color(text);
    @extend .dim-label;
    &:backdrop { color: backdrop(w_color(text)); }
  }

  selection {
    background-color: s_color(normal);
    color: s_color(text)
  }
  &:disabled {
    color: insensitive(w_color(text));
    selection { @extend %selected_items:disabled; }

    &:backdrop { color: backdrop(insensitive(w_color(text))); }
  }
  &:backdrop {
    color:backdrop(w_color(text));

    selction {@extend %selected_items:backdrop;}
  }
}

.dim-label {
  opacity: 0.5;
  text-shadow: none;
}

assistant {
  .sidebar {
    background-color: v_color(text);
    border-top: 1px solid $border_color;

    &:backdrop {
      background-color: backdrop(v_color(text));
      border-color: backdrop($border_color);
    }
  }
  &.csd .sidebar { border-top-style: none; }
  .sidebar label {
    padding: 6px 12px;
  }
  .sidebar label.highlight {
    background-color: mix(v_color(normal), v_color(text), 80%);
  }
}

%osd, 
.osd {
  color: w_color(text);
  border: 1px solid $border_color;
  background-color: transparentize(w_color(normal),0.2);
  background-clip: padding-box;
  box-shadow: none;
  text-shadow: none;
  -gtk-icon-shadow: none;
  &:backdrop {
    color: backdrop(w_color(text));
    background-color: backdrop(transparentize(w_color(normal),0.2));
    -gtk-icon-shadow: none;
  }
}

%selected_items {
  background-color: s_color(normal);
  color: s_color(text);
  &:hover {
    background-color: s_color(hover);
    color: w_color(text);
  }
  &:backdrop {
    background-color: backdrop(s_color(backdrop));
    color: backdrop(v_color(normal));
  }
}

%selected_items {
  background-color: s_color(normal);
  border-radius: 0px;

  @at-root %nobg_selected_items, & {
    color: s_color(text);

    &:disabled { color: insensitive(s_color(text)); }

    &:backdrop {
      color: backdrop(s_color(text));

      &:disabled { color: backdrop(insensitive(s_color(text))); }
    }
  }
}
