/**
 *
 * @ai-apps/angular v2.152.0 | _scale.scss
 *
 * Copyright 2014, 2023 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


//
// Copyright IBM Corp. 2018, 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 '../vendor/@carbon/layout/convert';

/// Compute the type size for the given type scale step
/// @param {Number} $step
/// @return {Number} In px
/// @access public
/// @group @carbon/type
@function carbon--get-type-size($step) {
  @if $step == 1 {
    @return 12px;
  }
  // Yn = Yn-1 + {INT[(n-2)/4] + 1} * 2
  @return carbon--get-type-size($step - 1) + (floor(($step - 2) / 4) + 1) * 2;
}

/// Type scale follows a custom formula for determining each step size and supports sizes from 12px to 92px
/// @type Map
/// @access public
/// @group @carbon/type
$carbon--type-scale: ();
@for $i from 1 through 23 {
  $carbon--type-scale: append(
    $carbon--type-scale,
    carbon--rem(carbon--get-type-size($i))
  );
}

/// Get the value of a specific step in the type scale
/// @param {Number} $step
/// @return {Number} In rem
/// @access public
/// @group @carbon/type
@function carbon--type-scale($step) {
  @return nth($carbon--type-scale, $step);
}

/// Set the font-size value of a selector with the value at the given `$step`
/// @param {Number} $step
/// @access public
/// @group @carbon/type
@mixin carbon--type-scale($step) {
  font-size: carbon--type-scale($step);
}

/// Alias of `type-scale` mixin.
/// @param {Number} $step
/// @alias carbon--type-scale
/// @access public
/// @group @carbon/type
@mixin carbon--font-size($step) {
  font-size: carbon--type-scale($step);
}
