@mixin titlebar() {
  .titlebar {
    border-bottom: none;
    border-radius: $csd_radius $csd_radius 0px 0px;

    .title {
      padding-left: 12px;
      padding-right: 12px;
      font-weight: bold;
    }

    .subtitle {
      font-size: smaller;
      padding-left: 12px;
      padding-right: 12px;
      color: gtkalpha(currentColor, 0.7);
    }

    .titlebutton {
      &.close, &.maximize, &.minimize, &:not(separator) {
        padding: 7px 14px;
        border: none;
        color: transparent;
        background-color: transparent;
        -gtk-icon-shadow: none;
        
        background-size:  100% 100%;
        background-position: center;
        background-repeat: no-repeat;
        
        &:hover {
          background-color: gtkalpha($fg_color, 0.15);
        }
        
        &:active {
          background-color: gtkalpha($fg_color, 0.3);
        }
      }
      
      &.close {
        background-image: url('assets/close-focused.png');

        &:hover {
          background-color: #ff5252;
          background-image: url('assets/close-focused-active.png');
        }

        &:active {
          background-color: #ff0000;
          background-image: url('assets/close-focused-active.png');
        }

        &:backdrop {
          background-image: url('assets/close-unfocused.png');
          
          &:hover {
            background-color: #ff5252;
            background-image: url('assets/close-focused-active.png');
          }

          &:active {
            background-color: #ff0000;
            background-image: url('assets/close-focused-active.png');
          }
        }
      }

      &.minimize {
        background-image: url('assets/minimize-focused.png');

        &:hover {
          background-image: url('assets/minimize-focused.png');
        }

        &:active {
          background-image: url('assets/minimize-focused.png');
        }

        &:backdrop {
          background-image: url('assets/minimize-unfocused.png');
          
          &:hover {
            background-image: url('assets/minimize-focused.png');
          }

          &:active {
            background-image: url('assets/minimize-focused.png');
          }
        }
      }

      &.maximize {
        background-image: url('assets/maximize-focused.png');

        &:hover {
          background-image: url('assets/maximize-focused.png');
        }

        &:active {
          background-image: url('assets/maximize-focused.png');
        }

        &:backdrop {
          background-image: url('assets/maximize-unfocused.png');
          
          &:hover {
            background-image: url('assets/maximize-focused.png');
          }

          &:active {
            background-image: url('assets/maximize-focused.png');
          }
        }
      }
      
      .maximized &.maximize {
        background-image: url('assets/restore-focused.png');

        &:hover {
          background-image: url('assets/restore-focused.png');
        }

        &:active {
          background-image: url('assets/restore-focused.png');
        }

        &:backdrop {
          background-image: url('assets/restore-unfocused.png');
          
          &:hover {
            background-image: url('assets/restore-focused.png');
          }

          &:active {
            background-image: url('assets/restore-focused.png');
          }
        }
      }
    }

    .tiled &:not(headerbar), .tiled &:backdrop:not(headerbar), .maximized &:not(headerbar), .maximized &:backdrop:not(headerbar) {
      border-radius: 0;
    }
  }

  .titlebar, .titlebar:not(headerbar), headerbar.default-decoration, .csd headerbar.default-decoration, .default-decoration.titlebar:not(headerbar), .csd .default-decoration.titlebar:not(headerbar) {
    min-height: 32px;
    color: $titlebar_fg_color;
    background-color: $titlebar_bg_color;
    border-bottom: 1px solid $borders;
    
    .titlebar { border-bottom: none; }

    &:backdrop {
      background-color: $unfocused_bg_color;
      color: $unfocused_fg_color;
      border-bottom-color: $unfocused_borders;
    }
  }
}
