```python
def grid_determinant(grid: list[list[int]]) -> int:
    if not all(isinstance(row, list) for row in grid):
        raise ValueError("Argument must be a list of lists.")
    
    n = len(grid)
    if n == 0 or any(len(row) != n for row in grid):
        raise ValueError("Grid must have the same number of rows and columns.")
    
    if n > 3:
        raise ValueError("Grid cannot have more than three rows.")
    
    if not all(isinstance(cell, int) for row in grid for cell in row):
        raise ValueError("All cells must be whole numbers.")
    
    if n == 1:
        return grid[0][0]
    elif n == 2:
        return grid[0][0] * grid[1][1] - grid[0][1] * grid[1][0]
    else:  # n == 3
        det = (grid[0][0] * (grid[1][1] * grid[2][2] - grid[1][2] * grid[2][1])
               - grid[0][1] * (grid[1][0] * grid[2][2] - grid[1][2] * grid[2][0])
               + grid[0][2] * (grid[1][0] * grid[2][1] - grid[1][1] * grid[2][0]))
        return det
```