@charset 'UTF-8';

////
/// Flavor SCSS Mixins Media
/// @group mixins-media
/// @author blackmirror1980
////

/// Media query mixin
///
/// @todo refactor this mixin
/// @todo write documentation
/// @access public
@mixin media($args...) {
  $media-type: 'only screen';
  $media-type-key: 'media-type';
  $args: keywords($args);
  $expr: '';

  @if map-has-key($args, $media-type-key) {
    $media-type: map-get($args, $media-type-key);
    $args: map-remove($args, $media-type-key);
  }

  $expr: "#{$media-type}";

  @each $key, $value in $args {
    @if $value {
      $expr: "#{$expr} and (#{$key}: #{$value})";
    }
  }

  @media #{$expr} {
    @content;
  }
}
