/// Outputs the font size based on the scale, also accepts a font adjustment
/// parameter for when outputting styles for progressively loaded fonts
///
/// @param {Number} $scale number on scale the sizes are based on
/// @param {Number} $progressive-font-adjust multiplier for font-size adjustments
/// when adding styles for progressively loaded font
@mixin _oTypographyFontSize($scale, $progressive-font-adjust: 1) {
	@if type-of($scale) == map {
		@each $breakpoint, $number in $scale {
			@if $breakpoint == 'default' {
				@if type-of($number) == list {
					font-size: _oTypographyFontSizeFromScale(nth($number, 1), $progressive-font-adjust);
				} @else {
					font-size: _oTypographyFontSizeFromScale($number, $progressive-font-adjust);
				}
			} @else {
				@include oGridRespondTo($breakpoint) {
					@if type-of($number) == list {
						font-size: _oTypographyFontSizeFromScale(nth($number, 1), $progressive-font-adjust);
					} @else {
						font-size: _oTypographyFontSizeFromScale($number, $progressive-font-adjust);
					}
				}
			}

		}
	} @else {
		font-size: _oTypographyFontSizeFromScale($scale, $progressive-font-adjust);
	}
}

/// Outputs the the fallback font size only for progressively
/// loaded fonts
///
/// @param {String} $font font to output fallback styles for
/// @param {Number} $scale number on scale the sizes are based on
@mixin _oTypographyProgressiveFontFallbackSize($font, $scale) {
	@if $scale != false and map-has-key($_o-typography-progressive-font-fallbacks, $font) {
		$font-config: map-get($_o-typography-progressive-font-fallbacks, $font);

		.#{$o-typography-loading-prefix}-#{$font} & {
			@include _oTypographyFontSize($scale, map-get($font-config, 'fallback-scale'));
		}
	}
}

/// Outputs the font size and line height based on the scale, also
/// accepts an override line-height to output and a font adjustment
/// parameter for when outputting styles for progressively loaded fonts
///
/// @param {Number} $scale number on scale the sizes are based on
/// @param {Bool | Number} $line-height size to override the line-height property
@mixin oTypographySize($scale, $line-height: false) {
	@if type-of($scale) == map {
		@each $breakpoint, $scale in $scale {
			@if $breakpoint == 'default' {
				@if type-of($scale) == list {
					font-size: _oTypographyFontSizeFromScale(nth($scale, 1));
					line-height: nth($scale, 2);
				} @else {
					font-size: _oTypographyFontSizeFromScale($scale);
					line-height: _oTypographyLineHeightFromScale($scale, $line-height);
				}
			} @else {
				@include oGridRespondTo($breakpoint) {
					@if type-of($scale) == list {
						font-size: _oTypographyFontSizeFromScale(nth($scale, 1));
						line-height: nth($scale, 2);
					} @else {
						font-size: _oTypographyFontSizeFromScale($scale);
						line-height: _oTypographyLineHeightFromScale($scale, $line-height);
					}
				}
			}
		}
	} @else {
		font-size: _oTypographyFontSizeFromScale($scale);
		line-height: _oTypographyLineHeightFromScale($scale, $line-height);
	}
}

/// Outputs the progressive font fallback styles based on
/// font and scale if the font has fallback settings
///
/// @param {String} $font font to output fallback styles for
/// @param {Number} $scale number on scale the size is based on
@mixin oTypographyProgressiveFontFallback($font, $scale) {
	@if $scale != false and map-has-key($_o-typography-progressive-font-fallbacks, $font) {
		$font-config: map-get($_o-typography-progressive-font-fallbacks, $font);

		.#{$o-typography-loading-prefix}-#{$font} & {
			@include _oTypographyFontSize($scale, map-get($font-config, 'fallback-scale'));
			font-family: map-get($font-config, 'fallback');
		}
	}
}

/// Outputs margin-top and/or margin-bottom based on multiples of
/// the baseline unit passed to the mixin
///
/// @param {Bool | Number} $top [false] - multiple of the baseline unit for top margin
/// @param {Bool | Number} $bottom [false] - multiple of the baseline unit for bottom margin
@mixin oTypographyMargin($top: false, $bottom: false) {
	@if $top {
		margin-top: oTypographySpacingSize($top);
	}

	@if $bottom {
		margin-bottom: oTypographySpacingSize($bottom);
	}
}

/// Outputs padding-top and/or padding-bottom based on multiples of
/// the baseline unit passed to the mixin
///
/// @param {Bool | Number} $top [false] - multiple of the baseline unit for top padding
/// @param {Bool | Number} $bottom [false] - multiple of the baseline unit for bottom padding
@mixin oTypographyPadding($top: false, $bottom: false) {
	@if $top {
		padding-top: oTypographySpacingSize($top);
	}

	@if $bottom {
		padding-bottom: oTypographySpacingSize($bottom);
	}
}

/// Outputs font-weight property for the given font
///
/// @param {Bool | String} $font [false] - font-family that is going to be styled bold
@mixin oTypographyBold($font: false) {
	@if $font == 'sans' {
		font-weight: 600;
	} @else {
		font-weight: 700;
	}
}
