@use 'sass:math';

$shadow---offset: 2px !default;
$shadow---elevations: (
  (0, 0),
  (4, 8),
  (8, 16),
  (16, 16),
  (24, 24),
) !default;

@mixin shadow($elevation, $border: false, $horizontal: false, $reverse: false) {
  $offset: if($reverse, -$shadow---offset, $shadow---offset);
  $x: if($horizontal, $offset, 0);
  $y: if($horizontal, 0, $offset);
  $blur: nth(nth($shadow---elevations, $elevation), 1) * 1px;
  $opacity: math.div(nth(nth($shadow---elevations, $elevation), 2), 100);
  $base-shadow: $x $y $blur gc(shadow, $opacity);

  @if ($border == false) {
    box-shadow: $base-shadow;
  } @else {
    box-shadow: $base-shadow, inset 0 0 0 1px gc(border);
  }
}
