@use 'sass:string';
@use 'global/common' as global;

// @see https://github.com/twbs/bootstrap/blob/main/scss/_functions.scss
@function _material-symbols-str-replace($string, $search, $replace: '') {
  $index: string.index($string, $search);

  @if $index {
    $replaced: _material-symbols-str-replace(string.slice($string, $index + string.length($search)), $search, $replace);

    @return string.slice($string, 1, $index - 1) + $replace + $replaced;
  }

  @return $string;
}

@mixin _material-symbols-font($font-family) {
  $class-name: string.to-lower-case($font-family);
  $class-name: _material-symbols-str-replace($class-name, ' ', '-');
  $font-file: global.$acms-font + $class-name;

  @debug $font-file;

  @font-face {
    font-family: $font-family;
    font-style: normal;
    font-weight: 100 700;
    src: url('#{$font-file}.woff2') format('woff2');
    font-display: block;
  }

  .#{$class-name} {
    display: inline-block;
    font-family: $font-family;
    font-size: inherit;
    font-style: normal;
    font-weight: normal;
    font-feature-settings: 'liga'; // Support for IE
    line-height: 1;
    text-transform: none;
    letter-spacing: normal;
    word-wrap: normal;
    white-space: nowrap;
    vertical-align: middle;
    direction: ltr;
    -webkit-font-smoothing: antialiased; // Support for all WebKit browsers
    -moz-osx-font-smoothing: grayscale; // Support for Firefox
    text-rendering: optimizelegibility; // Support for Safari and Chrome
  }
}

@include _material-symbols-font('Material Symbols Outlined');
