// =========================================================================================================================
// Spice - Web fonts
// ------------------------------------------------------

@charset "utf-8";
@import "variables";
@import "utils";

/// Add selected Google web fonts and assign them to selectors with this mixin and
/// eliminate the need to reference an external stylesheet. Arguments allow you to select
/// the font you wish to add, the selectors to assign and optional weight of the font.
/// 	<br /><br />
/// **Currently available fonts:**
/// - open-sans
/// - open-sans-condensed
/// - roboto
/// - roboto-slab
/// - leckerli-one
/// - quicksand
/// - oswald
/// - source-sans
/// - lobster
/// - arvo
/// - pacifico
/// - grand-hotel
/// - satisfy
/// - damion
/// @name googleFont
/// @group fonts
/// @param {String} font [] The name of the google font to include e.g. 'open-sans'
/// @param {Array} elements [false] List of elements to extend with the font-family
/// @param {Integer/String} weight [false] optional weight of the fonts e.g. 300 | 400 | 700 | Bold | Normal
/// @example scss - Include
///  @include googleFont('quicksand',h1 h2 h3 h4 h5 h6,400);
///  @include googleFont('roboto-slab',body textarea button);
/// @example css - Output
///  @font-face {
///    font-family: "Quicksand";
///    font-style: normal;
///    font-weight: 300;
///    src: local(Quicksand Light), local(Quicksand-Light), url(http://fonts.gstatic.com/s/quicksand/v5/qhfoJiLu10kFjChCCTvGlOgdm0LZdjqr5-oayXSOefg.woff2) format("woff2");
///    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
///  }
///  @font-face {
///    font-family: "Quicksand";
///    font-style: normal;
///    font-weight: 400;
///    src: local(Quicksand Regular), local(Quicksand-Regular), url(http://fonts.gstatic.com/s/quicksand/v5/sKd0EMYPAh5PYCRKSryvW1tXRa8TVwTICgirnJhmVJw.woff2) format("woff2");
///    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
///  }
///  @font-face {
///    font-family: "Quicksand";
///    font-style: normal;
///    font-weight: 700;
///    src: local(Quicksand Bold), local(Quicksand-Bold), url(http://fonts.gstatic.com/s/quicksand/v5/32nyIRHyCu6iqEka_hbKsugdm0LZdjqr5-oayXSOefg.woff2) format("woff2");
///    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
///  }
///  .quicksand, h1, h2, h3, h4, h5, h6 {
///    font-family: "Quicksand", arial, sans-serif;
///    font-weight: 400;
///  }
///  
///  @font-face {
///    font-family: Roboto Slab;
///    font-style: normal;
///    font-weight: 300;
///    src: local(Roboto Slab Light), local(RobotoSlab-Light), url(http://themes.googleusercontent.com/static/fonts/robotoslab/v3/dazS1PrQQuCxC3iOAJFEJR_xHqYgAV9Bl_ZQbYUxnQU.woff) format("woff2");
///    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
///  }
///  @font-face {
///    font-family: Roboto Slab;
///    font-style: normal;
///    font-weight: 400;
///    src: local(Roboto Slab Regular), local(RobotoSlab-Regular), url(http://themes.googleusercontent.com/static/fonts/robotoslab/v3/y7lebkjgREBJK96VQi37ZobN6UDyHWBl620a-IRfuBk.woff) format("woff2");
///    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
///  }
///  @font-face {
///    font-family: Roboto Slab;
///    font-style: normal;
///    font-weight: 700;
///    src: local(Roboto Slab Bold), local(RobotoSlab-Bold), url(http://themes.googleusercontent.com/static/fonts/robotoslab/v3/dazS1PrQQuCxC3iOAJFEJTqR_3kx9_hJXbbyU8S6IN0.woff) format("woff2");
///    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
///  }
///  .roboto-slab, body, textarea, button {
///    font-family: Roboto Slab, arial, sans-serif;
///  }

@mixin googleFont($font,$elements:false,$weight:false){

	$font : to-lower-case($font);
	$thisFont : map-get($googleFonts,$font);
	
	@if $thisFont{

		$weights  : map-get($thisFont,weights);
		$family   : map-get($thisFont,font-family);
		@each $weight in $weights {

			$key : nth($weight,1);
			$val : nth($weight,2);
			$loc1 : map-get($val,localone);
			$loc2 : map-get($val,localtwo);
			$url  : map-get($val,url);

			@font-face {
			  font-family: #{$family};
			  font-style: normal;
			  font-weight: $key;
			  src: local(#{$loc1}), local(#{$loc2}), #{$url} format('woff2');
			  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
			}
		}

		.#{$font}{
			font-family: (#{$family}), arial, sans-serif;

			@if $weight{
				font-weight: $weight;
			}

			@if $font == "open-sans-condensed"{

				letter-spacing: 0.1em;
				text-transform: uppercase;
			}
		}



		@if $elements {

			@each $element in $elements {
				#{$element}{
					@extend .#{$font};
				}
			}
		}
	}
	@else {
		@error "#{$font} is Currently not supported or invalid - please see documentation for a list of available google fonts"
	}	
}
