@use "sass:math";
@use "sass:string";

/**
  Sizes built with golden ratio (1.618) with the interval of 5.
  Font Size Calculator: https://gist.github.com/VJAI/f4240f0353bf992d967f52f74844d963

  const base = 19;
  const ratio = 1.618;
  const interval = 5;

  function size(point) {
    const s = base * Math.pow(ratio, point/interval);
    return [s, `${(s / base).toFixed(3)} rem`];
  }

  for (let i = -20; i < 20; i++) {
    console.log(size(i));
  }

  0.146[20] 0.161[19] 0.177[18] 0.195[17] 0.214[16] 0.236[15] 0.260[14] 0.286[13] 0.315[12] 0.347[11]
  0.382[10] 0.421[09] 0.463[08] 0.510[07] 0.561[06] 0.618[05] 0.680[04] 0.749[03] 0.825[02] 0.908[01]
  1.000[00] 1.101[01] 1.212[02] 1.335[03] 1.470[04] 1.618[05] 1.781[06] 1.961[07] 2.160[08] 2.378[09]
  2.618[10] 2.882[11] 3.174[12] 3.494[13] 3.847[14] 4.236[15] 4.664[16] 5.135[17] 5.654[18] 6.225[19]
 */

$ratio: 1.618;
$interval: 5;

@function size($point, $negative: false, $unit: 'rem') {
  $val: math.div(math.round(math.pow($ratio, math.div($point, $interval)) * 1000), 1000);

  @if $negative {
    $val: -1 * $val;
  }

  @return string.unquote($val + $unit);
}