//
// 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.
//

$font-path: 'https://unpkg.com/carbon-components@latest/src/globals/fonts' !default;

@import './vendor/@carbon/elements/scss/import-once/import-once';
@import 'deprecate';
@import 'helper-mixins';
@import './vendor/@carbon/elements/scss/type/font-face/mono';
@import './vendor/@carbon/elements/scss/type/font-face/sans';

/// @deprecated (For v10) Superseded by `@include carbon--font-face-sans()`, `@include carbon--font-face-mono()`, etc.
/// @access private
/// @group global-font-face
@mixin check-default-font-path {
  @if (str-index($font-path, 'https://unpkg.com/') == 1) {
    @warn 'The default font path (#{$font-path}) should be used only for demonstration/evaluation purposes. For production applications, please host fonts in your own CDN and change `$font-path` accordingly.';
    @content;
  } @else {
    @content;
  }
}

/// Helvetica Neue font face declarations
/// @access public
/// @deprecated (For v10) Use `@include carbon--font-face-sans()`, `@include carbon--font-face-mono()`, etc.
/// @group global-font-face
@mixin helvetica-font-face {
  // Default font directory, `!default` flag allows user override.
  // (font files are configured to be served as static assets from server.js)
  @include deprecate(
    'Usage of Helvetica font in `carbon-components` has been deprecated.'
  ) {
    @include check-default-font-path {
      @font-face {
        font-family: 'IBM Helvetica';
        font-style: normal;
        font-weight: 300;
        src: url('#{$font-path}/helvetica-neue-light.woff2') format('woff2'),
          url('#{$font-path}/helvetica-neue-light.woff') format('woff');
      }

      @font-face {
        font-family: 'IBM Helvetica';
        font-style: italic;
        font-weight: 300;
        src: url('#{$font-path}/helvetica-neue-light-italic.woff2')
            format('woff2'),
          url('#{$font-path}/helvetica-neue-light-italic.woff') format('woff');
      }

      @font-face {
        font-family: 'IBM Helvetica';
        font-style: normal;
        font-weight: 400;
        src: url('#{$font-path}/helvetica-neue-roman.woff2') format('woff2'),
          url('#{$font-path}/helvetica-neue-roman.woff') format('woff');
      }

      @font-face {
        font-family: 'IBM Helvetica';
        font-style: italic;
        font-weight: 400;
        src: url('#{$font-path}/helvetica-neue-roman-italic.woff2')
            format('woff2'),
          url('#{$font-path}/helvetica-neue-roman-italic.woff') format('woff');
      }

      @font-face {
        font-family: 'IBM Helvetica';
        font-style: normal;
        font-weight: 700;
        src: url('#{$font-path}/helvetica-neue-bold.woff2') format('woff2'),
          url('#{$font-path}/helvetica-neue-bold.woff') format('woff');
      }

      @font-face {
        font-family: 'IBM Helvetica';
        font-style: italic;
        font-weight: 700;
        src: url('#{$font-path}/helvetica-neue-bold-italic.woff2')
            format('woff2'),
          url('#{$font-path}/helvetica-neue-bold-italic.woff') format('woff');
      }
    }
  }
}

@include exports('css--font-face') {
  @if not variable-exists('css--font-face') or $css--font-face == true {
    @if variable-exists('css--plex') and $css--plex == true {
      @include carbon--font-face-mono();
      @include carbon--font-face-sans();
    } @else {
      @include helvetica-font-face;
    }
  }
}
