//
// Copyright IBM Corp. 2016, 2018
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

@import 'vars';
@import 'deprecate';
@import 'functions';

/// @access public
/// @deprecated (For v10) Use `$carbon--font-families`
/// @group typography
/// @returns font-family types
$font-family-mono: 'ibm-plex-mono', 'Menlo', 'DejaVu Sans Mono', 'Bitstream Vera Sans Mono', Courier, monospace !default;
/// @deprecated (For v10) Use `$carbon--font-families`
$font-family-sans-serif: 'ibm-plex-sans', Helvetica Neue, Arial, sans-serif !default;
/// @deprecated (For v10) Use `$carbon--font-families`
$font-family-serif: 'ibm-plex-serif', 'Georgia', Times, serif !default;
/// @deprecated (For v10) Use Plex fonts
$font-family-helvetica: 'IBM Helvetica', Helvetica Neue, HelveticaNeue, Helvetica, sans-serif !default;

/// @access public
/// @group typography
/// @returns 16px font size
/// @deprecated (For v10) Superseded by `$carbon--base-font-size`
$base-font-size: 16px !default; // Default, Use with em() and rem() functions

/// @access public
/// @deprecated (For v10) Superseded by `$carbon--base-font-size`
/// @type Map
/// @group typography
/// @returns different type sizes in rem
$typescale-map: (
  'giga': 4.75rem,
  'mega': 3.375rem,
  'alpha': 2.25rem,
  'beta': 1.75rem,
  'gamma': 1.25rem,
  'delta': 1.125rem,
  'epsilon': 1rem,
  'zeta': 0.875rem,
  'omega': 0.75rem,
  'caption': 0.75rem,
  'legal': 0.6875rem,
  'p': 1rem,
);

/// @access public
/// @deprecated (For v10) Use `@include carbon--type-scale()`
/// @group typography
/// @param {String} $size - value of type size
/// @returns type size in rem from typescale-map
@mixin typescale($size) {
  @include deprecate(
    '`@include typescale()` has been removed. ' + 'Use `@include carbon--type-scale()` instead.',
    feature-flag-enabled('breaking-changes-x'),
    true
  ) {
    @if map-has-key($typescale-map, $size) {
      font-size: map-get($typescale-map, $size);
    } @else {
      @warn 'This is not a step of the Carbon Type Scale!';
    }
  }
}

/// @access public
/// @param {Value} $px - value of type in pixels
/// @returns type size converted to rem
/// @example - rem(48px);
/// @deprecated (For v10) Use `carbon--rem()`
@function rem($px) {
  @return ($px / $base-font-size) * 1rem;
}

/// @access public
/// @param {Value} $px - value of type in pixels
/// @returns type size converted to em
/// @example - em(48px);
/// @deprecated (For v10) Use `carbon--em()`
@function em($px) {
  @return ($px / $base-font-size) * 1em;
}

/// @access public
/// @returns helvetica font family
/// @group typography
/// @example - @include helvetica;
/// @deprecated (For v10) Use Plex fonts
@mixin helvetica {
  @include deprecate(
    '`@include helvetica` has been removed. ' + 'Use `@include carbon--font-family()` instead.',
    feature-flag-enabled('breaking-changes-x'),
    true
  ) {
    font-family: $font-family-helvetica;
  }
}

/// @access public
/// @deprecated (For v10) Use `@include carbon--font-family()`
/// @returns uses sans-serif font type if $css--plex is true, else uses helvetica
/// @group typography
/// @example - @include font-family;
@mixin font-family {
  @include deprecate(
    '`@include font-family` has been removed. ' + 'Use `@include carbon--font-family()` instead.',
    feature-flag-enabled('breaking-changes-x'),
    true
  ) {
    @if global-variable-exists('css--plex') and $css--plex == true {
      font-family: $font-family-sans-serif;
    } @else {
      font-family: $font-family-helvetica;
    }
  }
}

/// There are two line heights to choose from. One for headings and one for body text
/// @access public
/// @param {String} $el - 'heading' or 'body'
/// @example @include line-height('heading');
/// @deprecated (For v10) Use `@include carbon--type-style()`
@mixin line-height($el) {
  @include deprecate(
    '`@include line-height()` has been removed. ' + 'Use `@include carbon--type-style()` instead.',
    feature-flag-enabled('breaking-changes-x'),
    true
  ) {
    @if $el == 'heading' {
      line-height: 1.25;
    } @else if $el == 'body' {
      line-height: 1.5;
    } @else {
      @warn 'Invalid argument used for @mixin line-height($el) . Please use 'heading' or 'body'.';
    }
  }
}

/// @access public
/// @require bold-text Only applied to bold weight text
/// @deprecated (For v10) The new type styles doesn't use this
@mixin font-smoothing {
  @include deprecate('`@include font-smoothing` has been removed.', feature-flag-enabled('breaking-changes-x'), true) {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
}

/// @access public
/// @deprecated (For v10) The new type styles doesn't use this
@mixin letter-spacing {
  @include deprecate('`@include letter-spacing` has been removed.', feature-flag-enabled('breaking-changes-x'), true) {
    letter-spacing: 0;
  }
}

/// @access public
/// @type Map
/// @returns mapped out pixel equivalent in rem
/// @deprecated (For v10) Superseded by `$carbon--type-scale`
$font-size-map: (
  '76': 4.75rem,
  '54': 3.375rem,
  '36': 2.25rem,
  '28': 1.75rem,
  '20': 1.25rem,
  '18': 1.125rem,
  '16': 1rem,
  '14': 0.875rem,
  '12': 0.75rem,
  '11': 0.6875rem,
);

/// @access public
/// @deprecated (For v10) Use `@include carbon--type-scale()`
/// @param {String} $size value from $font-size-map
/// @returns font size in rem from $font-size-map
/// @require $font-size-map
/// @example @include font-size('76');
@mixin font-size($size) {
  @include deprecate(
    '`@include font-size()` has been removed. ' + 'Use `@include carbon--type-scale()` instead.',
    feature-flag-enabled('breaking-changes-x'),
    true
  ) {
    @if map-has-key($font-size-map, $size) {
      font-size: map-get($font-size-map, $size);
    } @else {
      @warn 'This is not a step of the Carbon Type Scale! Valid sizes are 11, 12, 14, 16, 18, 20, 28, 36, 54, and 76';
    }
  }
}

// 🔬 Experimental
@import '../../globals/scss/vendor/@carbon/elements/scss/type/styles';

/// @access public
/// @returns different type styles per token.
/// @see $tokens Map in src/globals/scss/vendor/@carbon/type/scss/_styles.scss
/// @param {String} $name - the name of the token to get the styles for
/// @param {Boolean} $fluid [false] - specify whether to include fluid styles
/// @example -  @include type-style('body-short-01');
@mixin type-style($name, $fluid: false) {
  @include carbon--type-style($name, $fluid);
}
