@import '@financial-times/math';
@import '@financial-times/o-brand/main';
@import '@financial-times/o-private-foundation/main';
@import '@financial-times/o-forms/main';

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

@import 'src/scss/base';
@import 'src/scss/features/anon';
@import 'src/scss/features/top';
@import 'src/scss/features/search';
@import 'src/scss/features/nav';
@import 'src/scss/features/subnav';
@import 'src/scss/features/megamenu';
@import 'src/scss/features/simple';
@import 'src/scss/features/transparent';
@import 'src/scss/features/sticky';
@import 'src/scss/features/drawer';

/// Output the styles for the header.
/// Can be passed a list of one or more features to output.
/// By default, will output all styles.
///
/// @param {List} $opts [('top', 'subnav', 'search', 'nav', 'anon', 'drawer', 'megamenu', 'sticky', 'simple', 'transparent')]
/// @param {Boolean} $include-base-styles [true]
@mixin oHeader($opts: $_o-header-features, $include-base-styles: true) {
	@include oPrivateFoundation();

	@include oPrivateGridAddLayout(
		$layout-name: 'oHeaderL',
		$layout-width: 1080px,
		$gutter-width: map-get($o-pf-grid-gutters, 'M')
	);

	@include oForms(
		$opts: (
			'elements': (
				'text',
			),
			'features': (
				'suffix',
			),
		)
	);

	@if $include-base-styles == true {
		@include _oHeaderBase;
	}

	@each $feature in $opts {
		// Check the feature exists.
		@if index($_o-header-features, $feature) == null {
			@error "There is no feature '#{$feature}' available in o-header please use one of "
				+ "the following: #{$_o-header-features}";
		}

		// Output feature.
		@if ($feature == 'top' or $feature == 'nav' or $feature == 'drawer') and
			_oHeaderSupports($feature)
		{
			.o-header__drawer-button,
			.o-header__top-button,
			.o-header__nav-button {
				@include oPrivateButtonsContent(
					(
						'type': 'primary',
						'theme': 'mono',
					)
				);
			}

			.o-header__nav-button {
				border-radius: 0;
			}
		}

		@if $feature == 'top' and _oHeaderSupports($feature) {
			@include _oHeaderTop;
		}

		@if $feature == 'anon' and _oHeaderSupports($feature) {
			@include _oHeaderAnon;
		}

		@if $feature == 'subnav' and _oHeaderSupports($feature) {
			@include _oHeaderSubnav;
		}

		@if $feature == 'search' and _oHeaderSupports($feature) {
			@include _oHeaderSearch;
		}

		@if $feature == 'nav' and _oHeaderSupports($feature) {
			@include _oHeaderNav;
		}

		@if $feature == 'drawer' and _oHeaderSupports($feature) {
			@include _oHeaderDrawer;
		}

		@if $feature == 'megamenu' and _oHeaderSupports($feature) {
			@include _oHeaderMegaMenu;
		}

		@if $feature == 'sticky' and _oHeaderSupports($feature) {
			@include _oHeaderSticky;
		}

		@if $feature == 'simple' and _oHeaderSupports($feature) {
			@include _oHeaderSimple;
		}

		@if $feature == 'transparent' and _oHeaderSupports($feature) {
			@include _oHeaderTransparent;
		}
	}
}

@if $o-header-is-silent == false {
	@include oHeader;

	$o-header-is-silent: true !global;
}
