@import '@financial-times/o-colors/main';

@import 'src/scss/variables';
@import 'src/scss/mixins';

/// Outputs all o-normalise styles.
/// @param {list} $opts - A map of which normalise styles and helper classes to output.
/// @example Output all o-normalise styles.
///     @include oNormalise();
/// @example Output all o-normalise styles, without css class helpers such as `o-normalise-visually-hidden`.
///     @include oNormalise($opts: (
///     	'elements': ('forms', 'images', 'text', 'links'),
///     	'body': ('font-smoothing', 'focus', 'reduce-motion')
///     ));
/// @access public
@mixin oNormalise($opts: (
	'elements': ('forms', 'images', 'text', 'links'),
	'body': ('font-smoothing', 'focus', 'reduce-motion'),
	'helpers': ('clearfix', 'visually-hidden')
)) {
	// The elements to normalise.
	$elements: map-get($opts, 'elements');
	$links: index($elements, 'links');
	$text: index($elements, 'text');
	$images: index($elements, 'images');
	$forms: index($elements, 'forms');

	// The body features to normalise.
	$body: map-get($opts, 'body');
	$font-smoothing: index($body, 'font-smoothing');
	$focus: index($body, 'focus');
	$reduce-motion: index($body, 'reduce-motion');

	// The normalise classes to output.
	$helpers: map-get($opts, 'helpers');
	$clearfix: index($helpers, 'clearfix');
	$visually-hidden: index($helpers, 'visually-hidden');

	@if($body) {
		@include _oNormaliseBody($font-smoothing, false, $focus, $reduce-motion);
	}

	@if($links) {
		@include _oNormaliseLinks();
	}

	@if($text) {
		@include _oNormaliseText();
	}

	@if($forms) {
		@include _oNormaliseForms();
	}

	@if($clearfix) {
		.o-normalise-clearfix {
			@include oNormaliseClearfix;
		}
	}

	@if($visually-hidden) {
		.o-normalise-visually-hidden {
			@include oNormaliseVisuallyHidden;
		}
	}
}

@if ($o-normalise-is-silent == false) {
	// Output all normalising styles
	@include oNormalise();

	// Set to silent again to avoid being output twice
	$o-normalise-is-silent: true !global;
}
