$devices: (tablet: 541px, desktop: 1025px) !default;

@mixin media($type) {
    @if $type == "print" {
        @media only print and (min-width: 0) {
            @content;
        }
    }
    @else {
        @media (min-width: map-get($devices, $type)) {
            @content;
        }
    }
}

@function smallest-device-pixel() {
    $smallest: 100000000;

    @each $device, $pixels in $devices {
        @if $pixels < $smallest and $device != "print" {
            $smallest: $pixels;
        }
    }

    @return $smallest - 1;
}

@mixin mobile {
    @media (max-width: #{smallest-device-pixel()}) {
        @content;
    }
}
