@mixin generateNthHeading($n, $scale) {
	>h#{$n} {
		font-size: calc(var(--ifm-h#{$n}-font-size) * $scale);
		margin-top: calc( var(--ifm-heading-vertical-rhythm-top) * var(--ifm-leading) * $scale);
		margin-bottom: calc( var(--ifm-heading-vertical-rhythm-bottom) * var(--ifm-leading) * $scale);
	}
}

@mixin generateHeadings($scale) {
	@for $i from 1 to 6 {
		@include generateNthHeading($i, $scale); 
	}
}

@mixin generateSizeMode($id, $headingScale, $textScale, $codeScale: $textScale)
{
	.sizeMode-#{$id} :global(.theme-doc-markdown) {
		@include generateHeadings($headingScale);

		>ul, >ol {
			font-size: calc($textScale * 100%);
			margin-bottom: calc( var(--ifm-list-margin) * $textScale );
		}
		>p, >span, >blockquote>p {
			font-size: calc($textScale * 100%);
			margin-bottom: calc( var(--ifm-paragraph-margin-bottom) * $textScale );
		}

		>table {
			font-size: calc($textScale * 100%);
		}


		>details[data-collapsed] {
			font-size: calc($textScale * 100%);
			padding: calc(var(--ifm-alert-padding-vertical) * $textScale) calc(var(--ifm-alert-padding-horizontal) * $textScale);
		}

		:global(.tabs__item) {
			padding: calc(var(--ifm-tabs-padding-vertical) * $textScale) calc(var(--ifm-tabs-padding-horizontal) * $textScale);
		}

		>:global(.tabs-container) {
			font-size: calc($textScale * 100%);
		}

		>:global(.theme-admonition) {
			font-size: calc($textScale * 100%);
			&>div:first-child {
				font-size: calc(var(--ifm-h4-font-size) * $textScale);
			}
		}

		// Special case for empty lines in lists
		li>p {
			font-size: 100%;
			margin-bottom: 0;
		}

		:global(.theme-code-block) {

			font-size: calc(16px * $codeScale);
			>div, pre {
				font-size: inherit;
			}

			pre {
				// Use only 1/3 of the line height difference
				// It shouldn't be affected as much for better readability
				line-height: calc(
					var(--ifm-pre-line-height) -
					var(--ifm-pre-line-height) * (1.0 - $codeScale) / 3.0
				);
			}

		}
	}
}

$minHeadingSize: 0.8;
$maxHeadingSize: 1.1;

$minTextSize: 0.6;
$maxTextSize: 1.0;

@function linearScaleAt($scaleLevel, $min, $max) {
	@return $min + ($max - $min) * (calc($scaleLevel / 5));
}

@function linearTextScaleAt($scaleLevel) {
	@return linearScaleAt($scaleLevel, $minTextSize, $maxTextSize);
}

@function linearHeadingScaleAt($scaleLevel) {
	@return linearScaleAt($scaleLevel, $minHeadingSize, $maxHeadingSize);
}

@include generateSizeMode(1, linearHeadingScaleAt(1), linearTextScaleAt(1));
@include generateSizeMode(2, linearHeadingScaleAt(2), linearTextScaleAt(2));
@include generateSizeMode(3, linearHeadingScaleAt(3), linearTextScaleAt(3));
@include generateSizeMode(4, linearHeadingScaleAt(4), linearTextScaleAt(4));
@include generateSizeMode(5, linearHeadingScaleAt(5), linearTextScaleAt(5));
