$grid-columns: 12;

$sm: 48rem;
$md: 62rem;
$lg: 75rem;

.grid {
  display: flex;
  flex-direction: column;
  flex-flow: row wrap;
  > [class*="column-"] {
    display: block;
    padding: 1rem;
  }
}

@for $i from 1 through $grid-columns {
  .column-xs-#{$i} {
    flex-basis: $i / $grid-columns * 100%;
    max-width: $i / $grid-columns * 100%;
  }
}

@media (min-width: $sm) {
  @for $i from 1 through $grid-columns {
    .column-sm-#{$i} {
      flex-basis: $i / $grid-columns * 100%;
      max-width: $i / $grid-columns * 100%;
    }
  }
}

@media (min-width: $md) {
  @for $i from 1 through $grid-columns {
    .column-md-#{$i} {
      flex-basis: $i / $grid-columns * 100%;
      max-width: $i / $grid-columns * 100%;
    }
  }
}

@media (min-width: $lg) {
  @for $i from 1 through $grid-columns {
    .column-lg-#{$i} {
      flex-basis: $i / $grid-columns * 100%;
      max-width: $i / $grid-columns * 100%;
    }
  }
}

@supports (display: grid) {
  .grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: auto;
    > [class*="column-"] {
      margin: 0;
      max-width: 100%;
    }
  }

  @for $i from 1 through $grid-columns {
    .column-xs-#{$i} {
      grid-column-start: span #{$i};
      grid-column-end: span #{$i};
    }
  }

  @media(min-width: $sm) {
    @for $i from 1 through $grid-columns {
      .column-sm-#{$i} {
        grid-column-start: span #{$i};
        grid-column-end: span #{$i};
      }
    }
  }

  @media(min-width: $md) {
    @for $i from 1 through $grid-columns {
      .column-md-#{$i} {
        grid-column-start: span #{$i};
        grid-column-end: span #{$i};
      }
    }
  }

  @media(min-width: $lg) {
    @for $i from 1 through $grid-columns {
      .column-lg-#{$i} {
        grid-column-start: span #{$i};
        grid-column-end: span #{$i};
      }
    }
  }
}