//
// 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 'css--plex-core';
@import 'helper-mixins';
@import 'feature-flags';
@import './vendor/@carbon/elements/scss/type/font-face/mono';
@import './vendor/@carbon/elements/scss/type/font-face/sans';

/// @access public
/// @deprecated (For v10) Use `@include carbon--font-face-sans()`, `@include carbon--font-face-mono()`, etc.
@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 global-variable-exists('css--font-face') or $css--font-face == true {
    @if global-variable-exists('css--plex') and $css--plex == true {
      @if feature-flag-enabled('components-x') {
        @include carbon--font-face-mono();
        @include carbon--font-face-sans();
      } @else {
        @include plex-font-face;
      }
    } @else {
      @include helvetica-font-face;
    }
  }
}
