// Objects :: Crop

// Crop map
$fabric-crops: (
  '2\\:1': (
    2: 1,
  ),
  '4\\:3': (
    4: 3,
  ),
  'full-hd': (
    16: 9,
  ),
) !default;

// Crop content blocks
.o-crop {
  position: relative;
  display: block;
  overflow: hidden;
}

.o-crop__content {
  @include absolute(top 0 left 0);
  max-width: none;
}

// Crop variants
@each $crop-name, $crop-value in $fabric-crops {
  @each $antecedent, $consequent in $crop-value {
    @if (type-of($antecedent) != number) {
      @error "`#{$antecedent}` needs to be a number.";
    }

    @if (type-of($consequent) != number) {
      @error "`#{$consequent}` needs to be a number.";
    }

    .o-crop--#{$crop-name}:before {
      padding-bottom: ($consequent/$antecedent) * 100%;
    }
  }
}

// Fill modifier
.o-crop--fill {
  > .o-crop__content {
    min-height: 100%;
    min-width: 100%;
  }
}
