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

@use 'sass:string';
@use 'sass:map';

/// Font family fallbacks for: IBM Plex Mono, IBM Plex Sans, IBM Plex Sans
/// Condensed, IBM Plex Sans Hebrew, and IBM Plex Serif
/// @type Map
/// @access public
/// @group @carbon/type
$font-families: (
  'mono':
    string.unquote(
      "'IBM Plex Mono', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', monospace"
    ),
  'sans':
    string.unquote(
      "'IBM Plex Sans', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'sans-condensed':
    string.unquote(
      "'IBM Plex Sans Condensed', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'sans-arabic':
    string.unquote(
      "'IBM Plex Sans Arabic', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'sans-devanagari':
    string.unquote(
      "'IBM Plex Sans Devanagari', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'sans-hebrew':
    string.unquote(
      "'IBM Plex Sans Hebrew', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'sans-jp':
    string.unquote(
      "'IBM Plex Sans JP', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'sans-kr':
    string.unquote(
      "'IBM Plex Sans KR', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'sans-thai-looped':
    string.unquote(
      "'IBM Plex Sans Thai Looped', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'sans-thai':
    string.unquote(
      "'IBM Plex Sans Thai', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', sans-serif"
    ),
  'serif':
    string.unquote(
      "'IBM Plex Serif', system-ui, -apple-system, BlinkMacSystemFont, '.SFNSText-Regular', serif"
    ),
) !default;

/// Get the font-family for an IBM Plex font
/// @param {String} $name
/// @return {String}
/// @access public
/// @group @carbon/type
@function font-family($name) {
  @return map.get($font-families, $name);
}

/// Include the `font-family` definition for the given name in your selector
/// @param {String} $name
/// @access public
/// @group @carbon/type
@mixin font-family($name) {
  font-family: font-family($name);
}

/// Suggested font weights to be used in product
/// @type Map
/// @access public
/// @group @carbon/type
$font-weights: (
  'light': 300,
  'regular': 400,
  'semibold': 600,
) !default;

/// Retrieve the font-weight value for a given name
/// @param {String} $weight
/// @return {Number}
/// @access public
/// @group @carbon/type
@function font-weight($weight) {
  @return map.get($font-weights, $weight);
}

/// Set the `font-weight` property with the value for a given name
/// @param {String} $weight
/// @access public
/// @group @carbon/type
@mixin font-weight($weight) {
  font-weight: font-weight($weight);
}
