/***************
 * Header bars *
 ***************/
headerbar, .titlebar {
  &, &:backdrop {
    background-image: -gtk-scaled(url("assets/kali-headerbar-logo-#{$variant}.png"),
                                  url("assets/kali-headerbar-logo-#{$variant}@2.png"));
    background-position: 0 -7px;
    background-repeat: no-repeat;
  }

  &:not(.selection-mode),
  &.selection-mode {
    button.titlebutton:not(.appmenu):not(.suggested-action):not(.destructive-action)  {
      color: transparent;
      background-color: gtkmix(gtkshade(gtkcolor(headerbar_bg_color), 1.5), white, 90%);
      background-image: -gtk-scaled(url('assets/titlebutton.png'), url('assets/titlebutton@2.png'));
      background-repeat: no-repeat;
      background-position: center;
      margin: 0;
      margin-left: 8px;
      padding: 0;
      min-width: 18px;
      min-height: 18px;
      border: none;
      box-shadow: inset 0 0 0 1px transparentize(black, if($variant=='light', .8, .1));
      -gtk-icon-shadow: none;
      transition: all .2s;

      & + button.titlebutton { margin-left: 0; }
      &:last-child { margin-right: 8px; }

      &.close {
        background-color: #{"@accent_bg_color"};
        box-shadow: inset 0 0 0 transparent;

        @if $variant == 'light' {
          background-image: -gtk-scaled(url('assets/close-white.png'), url('assets/close-white@2.png'));
        } @else {
          background-image: -gtk-scaled(url('assets/close-black.png'), url('assets/close-black@2.png'));
        }
      }

      &:hover {
        box-shadow: 0 0 0 1px transparentize(black, if($variant=='light', .9, 0));

        &.minimize {
          background-image: -gtk-scaled(url('assets/minimize-#{$variant}.png'), url('assets/minimize-#{$variant}@2.png'));
        }
        &.maximize {
          background-image: -gtk-scaled(url('assets/maximize-#{$variant}.png'), url('assets/maximize-#{$variant}@2.png'));
        }
        &.close {
          @if $variant == 'light' {
            background-image: -gtk-scaled(url('assets/close-black.png'), url('assets/close-black@2.png'));
          } @else {
            background-image: -gtk-scaled(url('assets/close-white.png'), url('assets/close-white@2.png'));
          }
        }
      }

      &:backdrop,
      &:backdrop:hover {
        &.maximize, &.minimize, &.close {
          background-color: gtkmix(gtkcolor(headerbar_backdrop_color), black, if($variant=='light', 85%, .35%));
          background-image: -gtk-scaled(url('assets/titlebutton.png'), url('assets/titlebutton@2.png'));
          box-shadow: inset 0 0 0 1px transparentize(black, if($variant=='light', .9, 0));
        }
      }
    }

    &.default-decoration {
      padding: 0 9px;

      button.titlebutton:not(.appmenu):not(.suggested-action):not(.destructive-action) {
        &, &:last-child {
          margin: 0;
        }
      }
    }
  }
}

/* Remove kali dragon logo from left paned headerbar */
paned headerbar:first-child,
hdyleaflet headerbar:first-child,
headerbar.titlebar headerbar:first-child,
deck leaflet box:first-child headerbar:first-child,
leaflet > headerbar:first-child {
  &, &:backdrop { background-image: none; }
}

/**********************
 * Window Decorations *
 *********************/
/* Fake bottom border radius for old gtk3 apps */
decoration {
  $_border_width: 1px;
  $_top_window_radius: $window_radius+$_border_width;
  $_bottom_window_radius: min($button_radius+$_border_width, 6px);

  border-radius: $_top_window_radius $_top_window_radius $_bottom_window_radius $_bottom_window_radius;
  border: $_border_width solid gtkcolor(view_bg_color);
  border-bottom-width: 2px;

  .maximized &,
  .fullscreen &,
  .tiled &,
  .tiled-top &,
  .tiled-right &,
  .tiled-bottom &,
  .tiled-left &,
  .popup &,
  .ssd &,
  .csd.popup &,
  tooltip.csd &,
  messagedialog.csd & { border-width: 0; }
}

menubar,
.menubar { background-color: $bg_color; }

/***************
 * PHOSH Shell *
 **************/
/* Set a background for the lockscreen */
phosh-lockscreen, .phosh-lockshield,
phog-lockscreen, .phog-lockshield {
  background-image: linear-gradient(rgba(0, 0, 0, 0.4), rgba(0, 0, 0, 0.4)),
  url("file:///usr/share/backgrounds/kali/login.svg");
  background-size: cover;
  background-position: center;
}

phog-lockscreen phog-keypad label {
  background: #081322;
  border-radius: 999px;
  margin: -17px;
}
