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

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

/// Output all o-footer styles including a navigation matrix, and two themes.
///
/// @param {string} $opts [('themes': ('light', 'dark'), 'margin': 40px, 'matrix': true)] - a map of footer options. Keys include 'themes', a list of themes to support including "dark" and "light"; 'margin', a length to customise the footer's top margin; and 'matrix', a boolean value whether to support a complex footer with large navigation structure.
@mixin oFooter(
	$opts: (
		'themes': (
			'light',
			'dark',
		),
		'margin': null,
		'matrix': true,
	)
) {
	@include oPrivateFoundation();

	$margin: map-get($opts, 'margin');
	$margin: if($margin, $margin, (2 * $_o-footer-spacing-unit));
	$matrix: map-get($opts, 'matrix');
	$themes: map-get($opts, 'themes');
	$themes: if($themes, $themes, ());

	//Surface layouts for o-grid JavaScript helper https://github.com/Financial-Times/o-grid#getcurrentlayout
	@include oPrivateGridSurfaceCurrentLayout();

	.o-footer {
		@include oPrivateTypographySans(0);
		margin-top: $margin;
		line-height: $_o-footer-spacing-unit;

		a {
			border-bottom: 0;
			text-decoration: none;
		}
	}

	.o-footer__container {
		@include oPrivateGridContainer();
		/* hack to stop the margins collapsing */
		padding-top: 0.1px;
	}

	.o-footer__row {
		margin-top: $_o-footer-spacing-unit;
	}

	.o-footer__legal-links {
		padding-left: 0px;

		a {
			display: inline-block;
		}

		li {
			@include oPrivateTypographySans(-1);
			list-style: none;
			display: inline-block;

			&:before {
				content: '\2022';
				padding-left: oPrivateSpacingByName('s1');
				padding-right: oPrivateSpacingByName('s1');
			}
			&:first-child:before {
				content: '';
				padding: 0;
			}
		}
	}

	.o-footer__copyright {
		margin-top: $_o-footer-spacing-unit;
		margin-bottom: $_o-footer-spacing-unit;

		a {
			text-decoration: underline;
		}
	}

	.o-footer__brand {
		padding-top: oPrivateSpacingByName('s4');
		padding-bottom: oPrivateSpacingByName('s4');
	}

	.o-footer__brand-logo {
		@include _oFooterBrandImage('brand-nikkei-tagline', 200);
		height: 20px;
		background-repeat: no-repeat;
		background-position: right;
	}

	@media print {
		.o-footer {
			display: none;
		}
	}

	@if $matrix {
		@include _oFooterMatrix($themes);
	}

	// Include the themes
	@each $theme in $themes {
		@include _oFooterTheme($theme);
	}

	.o-footer-visually-hidden {
		@include oPrivateNormaliseVisuallyHidden();
	}
}

@if $o-footer-is-silent == false {
	@include oFooter();
	$o-footer-is-silent: true !global;
}
