@use 'sass:math';

// Typographic scale settings
$ms-ratio: math.div(16, 14) !default;
$sp-unit-ratio: 0.5 !default;

// Baseline grid settings
$sp-unit: 1rem * $sp-unit-ratio !default;

$font-sizes: (
  display: 5,
  display-mobile: 4,
  h1: 2.5,
  h1-mobile: 2,
  h2: 2.5,
  h2-mobile: 2,
  h3: 1.5,
  h3-mobile: 1.5,
  h4: 1.5,
  h4-mobile: 1.5,
  default: 1,
  small: 0.875,
  x-small: 0.75,
) !default;

$line-heights: (
  display: 11 * $sp-unit,
  display-mobile: 9 * $sp-unit,
  h1: 6 * $sp-unit,
  h1-mobile: 5 * $sp-unit,
  h2: 6 * $sp-unit,
  h2-mobile: 5 * $sp-unit,
  h3: 4 * $sp-unit,
  h3-mobile: 4 * $sp-unit,
  h4: 4 * $sp-unit,
  h4-mobile: 4 * $sp-unit,
  default-text: 3 * $sp-unit,
  small: 2.5 * $sp-unit,
  x-small: 2 * $sp-unit,
) !default;

// baseline nudges for type scale ratio of (16/14)^2
$nudges: (
  display: 0.35rem,
  display-mobile: 0.25rem,
  h1-large: 0.55rem,
  h1-mobile: 0.55rem,
  h1: 0.55rem,
  h2: 0.55rem,
  h2-mobile: 0.55rem,
  h3: 0.45rem,
  h3-mobile: 0.45rem,
  h4-large: 0.45rem,
  h4: 0.45rem,
  h4-mobile: 0.45rem,
  h5: 0.375rem,
  h6: 0.375em,
  h6-large: 0.375rem,
  p: 0.375rem,
  p-ubuntumono: 0.45rem,
  small: 0.05rem,
  x-small: 0.25rem,
) !default;

// Correct baseline drift due to browser rounding. (Visible in text > 1000 lines)
// It is applied only to padding-top.
// DEPRECATED, will be removed in 4.0
$browser-rounding-compensations: (
  h1: 0,
  h2: 0,
  h3: 0,
  h4: 0,
  h5: 0,
  h6: 0,
  p: 0,
  small-largescreen: 0,
  small: 0,
) !default;

// Main spacing variables. spv stands spacing-vertical; sph stands for spacing-horizontal.

$spv--x-small: $sp-unit * 0.5 !default;
$spv--small: $sp-unit !default;
$spv--medium: $sp-unit * 1.5 !default;
$spv--large: $sp-unit * 2;
$spv--x-large: $sp-unit * 3 !default;
$spv--strip-shallow: $sp-unit * 3 !default;
$spv--strip-regular: $sp-unit * 8 !default;
$spv--strip-deep: $sp-unit * 16 !default;

$sph--x-small: $sp-unit * 0.5 !default; // to be used in place of an inline space between characters/words
$sph--small: $sp-unit !default;
$sph--large: $sp-unit * 2 !default;
$sph--x-large: $sp-unit * 3 !default;

// Space after text elements
$sp-after: (
  display: $spv--x-large,
  display-mobile: $spv--x-large,
  h1: $spv--x-large,
  h1-mobile: $spv--x-large,
  h2: $spv--x-large,
  h2-mobile: $spv--x-large,
  h3: $spv--x-large,
  h3-mobile: $spv--x-large,
  h4: $spv--x-large,
  h4-mobile: $spv--x-large,
  p: $spv--x-large,
  p-small-caps: $spv--large,
  p-dense: $spv--large,
  default-text: $sp-unit,
  small: $spv--large,
  small--dense: $spv--large,
  x-small: $spv--large,
) !default;

// commonly occuring calculations available as variables
$spv-nudge: map-get($nudges, p) !default; // top: nudge; bottom: unit - nudge; result: height = exact multiple of base unit
$spv-nudge-compensation: $sp-unit - $spv-nudge !default;

// form input spacing variables
$input-margin-bottom: $sp-unit * 4 - $spv-nudge * 2;
$input-border-thickness: 1.5px;
$input-vertical-padding: calc($spv-nudge - $input-border-thickness);

// tick element variables
$form-tick-box-size: 1rem;
$form-tick-height: 0.375rem;
$form-tick-offset-top: 0.1875rem;
$form-tick-box-nudge: 0.15rem; // to nudge the tick box a bit below baseline (to correctly align with default text size)
$form-radio-inner-circle-diameter: 0.375rem;
$form-radio-circle-offset: 0.5 * ($form-tick-box-size - $form-radio-inner-circle-diameter);

$text-max-width: 40em !default;

$icon-sizes: (
  small: $sp-unit * 1.5,
  default: $sp-unit * 2,
  heading-icon--x-small: $sp-unit * 3,
  heading-icon--small: $sp-unit * 4,
  heading-icon: $sp-unit * 5,
  thumb: $sp-unit * 6,
  thumb--large: $sp-unit * 12,
) !default;

$default-icon-size: map-get($icon-sizes, default);

$table-cell-vertical-padding: $spv--small;

// generic units
$sp-xx-small: $sp-unit * 0.25 !default;
$sp-x-small: $sp-unit * 0.5 !default;
$sp-small: $sp-unit !default;
$sp-medium: $sp-unit * 2 !default;
$sp-large: $sp-unit * 3 !default;
$sp-x-large: $sp-unit * 4 !default;
$sp-xx-large: $sp-unit * 5 !default;
$sp-xxx-large: $sp-unit * 6 !default;
$sp-xxxx-large: $sp-unit * 8 !default;
$sp-xxxxx-large: $sp-unit * 12 !default; // anythng this large should be expressed as a sum of constituent heights. This is not currently used AFAIK  , consider removing for 3.0
