/**
 * Font settings
 */
$font-settings:
(
    copy-normal:
    (
        font-family: (Arial, Helvetica, sans-serif),
        font-style: normal,
        font-weight: normal,
        letter-spacing: 0
    ),
    copy-bold:
    (
        font-family: (Arial, Helvetica, sans-serif),
        font-style: normal,
        font-weight: normal,
        letter-spacing: 0
    ),
    headline:
    (
        font-family: (Arial, Helvetica, sans-serif),
        font-style: normal,
        font-weight: normal,
        letter-spacing: 0
    ),
    headline-medium:
    (
        font-family: (Arial, Helvetica, sans-serif),
        font-style: normal,
        font-weight: normal,
        letter-spacing: 0
    )
);


/**
 * Text settings
 */
$text-settings:
(
    base:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 18px,
            line-height: 1.4
        ),
        phablet:
        (
            font-size: 17px
        )
    ),

    h1:
    (
        all:
        (
            font-settings: headline,
            font-size: 45px,
            line-height: 1.3
        ),
        tablet:
        (
            font-size: 35px
        ),
        phablet:
        (
            font-size: 26px
        )
    ),

    h2:
    (
        all:
        (
            font-settings: headline,
            font-size: 38px,
            line-height: 1.3
        ),
        tablet:
        (
            font-size: 32px
        ),
        phablet:
        (
            font-size: 23px
        )
    ),

    h3:
    (
        all:
        (
            font-settings: headline,
            font-size: 30px,
            line-height: 1.3
        ),
        tablet:
        (
            font-size: 28px
        ),
        phablet:
        (
            font-size: 23px
        )
    ),

    h4:
    (
        all:
        (
            font-settings: headline,
            font-size: 26px,
            line-height: 1.3
        ),
        tablet:
        (
            font-size: 23px
        ),
        phablet:
        (
            font-size: 21px
        )
    ),

    h4-medium:
    (
        all:
        (
            font-settings: headline-medium,
            font-size: 24px,
            line-height: 1.3
        ),
        tablet:
        (
            font-size: 23px
        ),
        phablet:
        (
            font-size: 21px
        )
    ),

    h5:
    (
        all:
        (
            font-settings: headline,
            font-size: 24px,
            line-height: 1.3
        ),
        tablet:
        (
            font-size: 23px
        ),
        phablet:
        (
            font-size: 17px
        )
    ),

    h6:
    (
        all:
        (
            font-settings: headline,
            font-size: 22px,
            line-height: 1.3
        ),
        tablet:
        (
            font-size: 20px
        )
    ),

    t1:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 45px
        )
    ),

    t2:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 24px,
        ),
        tablet:
        (
            font-size: 23px
        ),
        phablet:
        (
            font-size: 19px
        )
    ),

    t3:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 20px
        ),
        phablet:
        (
            font-size: 16px
        ),
        mobile:
        (
            font-size: 13px
        )
    ),

    t4:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 18px,
            line-height: 1.5
        )
    ),

    t5:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 18px
        ),
        phablet:
        (
            font-size: 15px
        ),
        mobile:
        (
            font-size: 15px
        )
    ),

    t6:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 16px
        ),
        phablet:
        (
            font-size: 15px
        ),
        mobile:
        (
            font-size: 15px
        )
    ),

    t7:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 14px
        )
    ),

    t8:
    (
        all:
        (
            font-settings: copy-normal,
            font-size: 13px
        )
    ),

    t9:
    (
        all:
        (
            font-settings: copy-bold,
            font-size: 16px
        ),
        phablet:
        (
            font-size: 14px
        ),
        mobile:
        (
            font-size: 14px
        )
    )
);


/**
 * Embedds all necessary css properties to use the font $name in the
 * current css class.
 *
 * @see $font-settings
 * @param $name
 * @param $ignore
 */
@mixin use-font($name, $ignore: none) {
    @if (not map-has-key($font-settings, $name)) {
        @debug 'use-font : invalid font setting #{$name}';
    }
    $settings: map-get($font-settings, $name);
    @include map-as-properties($settings, $ignore: $ignore);
}


/**
 * Embedds all necessary css properties to use the text setting $name in the
 * current css class. This may include breakpoints.
 *
 * @see $text-settings
 * @param $name
 */
@mixin use-text($name) {
    @if (not map-has-key($text-settings, $name)) {
        @debug 'use-text : invalid text setting #{$name}';
    }
    $settings: map-get($text-settings, $name);
    $all-settings: map-get($settings, all);

    @if (map-has-key($all-settings, font-settings)) {
        @include use-font(map-get($all-settings, font-settings));
    }
    @include map-as-properties($all-settings, '', font-settings spacing-settings);

    @each $breakpoint-name, $breakpoint in $breakpoint-settings {
        @if (map-has-key($settings, $breakpoint-name)) {
            @include use-breakpoint($breakpoint-name, below) {
                @include map-as-properties(map-get($settings, $breakpoint-name), '', font-settings spacing-settings);
            }
        }
    }
    @each $breakpoint-name, $properties in $settings {
        @if (str-slice($breakpoint-name, 0, 6) == 'custom') {
            @include use-breakpoint($breakpoint-name, below, $properties) {
                @include map-as-properties(map-get($settings, $breakpoint-name), $ignore: (min-width, max-width));
            }
        }
    }
}
