/**********************
 * Window Decorations *
 *********************/
 window {
  // lamefun trick to get rounded borders regardless of CSD use
  border-width: 0px;

  // this needs to be transparent
  // see bug #722563
  $_wm_border: if($variant=='light', transparentize(black, 0.77), transparentize(black, 0.25));
  $_wm_border_backdrop: if($variant=='light', transparentize(black, 0.82), transparentize(black, 0.25));
  $_window_radius: 1px;
  $_menu_radius: 1px;

  &.csd {
    box-shadow: 0 3px 9px 1px transparentize(black, 0.5),
                0 0 0 1px $_wm_border; //doing borders with box-shadow
    margin: 0px;
    border-radius: $_window_radius $_window_radius 0 0;
    &:backdrop {
      // the transparent shadow here is to enforce that the shadow extents don't
      // change when we go to backdrop, to prevent jumping windows.
      // The biggest shadow should be in the same order then in the active state
      // or the jumping will happen during the transition.
      box-shadow: 0 3px 9px 1px transparent,
                  0 2px 6px 2px transparentize(black, 0.8),
                  0 0 0 1px $_wm_border_backdrop;
      transition: $backdrop_transition;
    }

    &.popup {
      border-radius: $_menu_radius;
      box-shadow: 0 1px 2px transparentize(black, 0.8),
                  0 0 0 1px transparentize($_wm_border, 0.1);
    }

    &.dialog.message {
      box-shadow: 0 1px 2px transparentize(black, 0.8),
                  0 0 0 1px transparentize($_wm_border, 0.1);
    }
  }

  &.solid-csd {
    margin: 0;
    padding: 4px;
    border: solid 1px $borders_color;
    border-radius: 0;
    box-shadow: inset 0 0 0 4px $borders_color, inset 0 0 0 3px $headerbar_color, inset 0 1px transparentize($fg_color, 0.93);

    &:backdrop { box-shadow: inset 0 0 0 4px $borders_color, inset 0 0 0 3px $backdrop_bg_color, inset 0 1px transparentize($fg_color, 0.93); }
  }

  &.maximized,
  &.fullscreen { border-radius: 0; box-shadow: none; }

  &.tiled,
  &.tiled-top,
  &.tiled-left,
  &.tiled-right,
  &.tiled-bottom {
   border-radius: 0;
   box-shadow: 0 0 0 1px $_wm_border,
               0 0 0 20px transparent; //transparent control workaround -- #3670
    &:backdrop { 
      box-shadow: 0 0 0 1px $_wm_border_backdrop,
                  0 0 0 20px transparent; // #3670
    }
  }

  &.popup { box-shadow: none; }

  // server-side decorations as used by mutter
  &.ssd { box-shadow: 0 0 0 1px $_wm_border; } //just doing borders, wm draws actual shadows

}

// Window Close button
windowcontrols button {
  &.close, &.maximize, &.minimize {
    min-width: 20px;
    min-height: 20px;
    margin: 0;
    padding: 0 1px;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 16px 16px;

    &, &:hover, &:focus, &:active, &:backdrop, &:backdrop:hover {
      background-color: transparent;
      border: none;
      box-shadow: none;
      color: transparent;
    }

  }
  
  &.close {
    background-image: -gtk-scaled(url("../assets/close.png"),url("../assets/close@2.png"));
    &:hover,&:active {
      background-image: -gtk-scaled(url("../assets/close_prelight.png"),url("../assets/close_prelight@2.png"));
    }
  }
  &.maximize {
    background-image: -gtk-scaled(url("../assets/maximize.png"),url("../assets/maximize@2.png"));
    &:hover,&:active {
      background-image: -gtk-scaled(url("../assets/maximize_prelight.png"),url("../assets/maximize_prelight@2.png"));
    }
  }
  &.minimize {
    background-image: -gtk-scaled(url("../assets/min.png"),url("../assets/min@2.png"));
    &:hover,&:active {
      background-image: -gtk-scaled(url("../assets/min_prelight.png"),url("../assets/min_prelight@2.png"));
    }
  }

  .selection-mode & {
    @extend %button.flat.suggested-action;

    @extend %nobg_selected_items;
  }

  &:backdrop { 
    -gtk-icon-shadow: none; 
    background-image: -gtk-scaled(url("../assets/close_unfocused.png"),url("../assets/close_unfocused@2.png"));
  }
}


headerbar.selection-mode button.titlebutton,
.titlebar.selection-mode button.titlebutton {
  @include _button_text_shadow(white, $selected_bg_color);

  &:backdrop { -gtk-icon-shadow: none; }
}


// catch all extend :)

%selected_items {
  background-color: $selected_bg_color;

  @at-root %nobg_selected_items, & {
    color: $selected_fg_color;
    font-weight: normal;
    //&:hover{background-color: transparent;}
    @if $variant == 'light' { outline-color: transparentize($selected_fg_color, 0.7); }

    &:disabled { color: mix($selected_fg_color, $selected_bg_color, 50%); }

    &:backdrop {
      color: $backdrop_selected_fg_color;

      &:disabled { color: mix($backdrop_selected_fg_color, $selected_bg_color, 30%); }
    }
  }
}

.monospace { font-family: Monospace; }
