// Typography setter, mixins and classes based on breakpoints
// ==========================================================

// NEW system!
$font-sizes: (
  6: 3.815rem,
  5: 3.052rem,
  4: 2.441rem,
  3: 1.953rem,
  2: 1.563rem,
  1: 1.25rem,
  body: 1rem,
  small: .8rem,
);

@function type-scale($name) {
  @return map-get($font-sizes, $name);
}


// OLD system! To be refactored/removed
$-type-map: () !default;

@mixin type-set($type-name, $breakpoint-name, $type-properties) {
  $type-group: map-get($-type-map, $type-name) or ();
  $type-group: map-merge($type-group, ($breakpoint-name: $type-properties));
  $-type-map: map-merge($-type-map, ($type-name: $type-group)) !global;
}

@mixin typography($type-name, $type-property: null) {
  @if map-has-key($-type-map, $type-name) {
    $type-group: map-get($-type-map, $type-name);
    @each $breakpoint-name, $type-properties in $type-group {
      @include breakpoint($breakpoint-name) {
        @each $property, $value in $type-properties {
          @if not $type-property or $type-property == $property {
            #{$property}: #{$value};
          }
        }
      }
    }
  }
}

@mixin typography-classes($prefix: 'type--') {
  @each $type-name, $type-group in $-type-map {
    .#{$prefix}#{$type-name} {
      @include typography($type-name);
    }
  }
}
