Implement a solution to manipulate and traverse multidimensional arrays efficiently.
Given a rectangular 2D integer array matrix, return its elements in clockwise spiral order. Traverse the matrix by shrinking its top, bottom, left, and right boundaries after processing each outer layer.
Function: spiral_order(matrix)
Input: A possibly empty list of equal-length integer rows. Output: A one-dimensional list containing every element exactly once.
def spiral_order(matrix):