@import './palette.scss';
@import './consts.scss';
@import './mixins.scss';

/*
  priority order:
  1. customStyles
  2. default font values
*/

$paragraphFontSize: 16px;
$paragraphFontSizeMobile: 14px;
$quoteFontSize: 18px;
$quoteLineHeight: 26px;
$minHeight: 1.5;

$ricos-font-family: var(--ricos-font-family, unset);
$ricos-default-font-family: Helvetica Neue, Helvetica, Arial;
$ricos-settings-font-family: var(--ricos-settings-text-font-family, $ricos-default-font-family);
$ricos-native-font-family: var(--ricos-native-text-font-family, $ricos-font-family);

$font-sizes: (
  'p': unset,
  'quote': $quoteFontSize,
  'link': unset,
  'hashtag': unset,
  'button': unset,
  'h1': $headerOneSize,
  'h2': $headerTwoSize,
  'h3': $headerThreeSize,
  'h4': $headerFourSize,
  'h5': $headerFiveSize,
  'h6': $headerSixSize,
);

$font-sizes-mobile: (
  'p': unset,
  'quote': $quoteFontSize,
  'link': unset,
  'hashtag': unset,
  'button': unset,
  'h1': $headerOneMobileSize,
  'h2': $headerTwoMobileSize,
  'h3': $headerThreeMobileSize,
  'h4': $headerFourMobileSize,
  'h5': $headerFiveMobileSize,
  'h6': $headerSixMobileSize,
);

$text-heights: (
  'p': unset,
  'quote': $quoteLineHeight,
  'link': unset,
  'hashtag': unset,
  'button': unset,
  'h1': $headerOneHeight,
  'h2': $headerTwoHeight,
  'h3': $headerThreeHeight,
  'h4': $minHeight,
  'h5': $minHeight,
  'h6': $minHeight,
);

$min-heights: (
  'p': unset,
  'quote': unset,
  'link': unset,
  'hashtag': unset,
  'button': unset,
  'h1': $headerOneHeight,
  'h2': $headerTwoHeight,
  'h3': $headerThreeHeight,
  'h4': unset,
  'h5': unset,
  'h6': unset,
);

$text-decorations: (
  'p': unset,
  'quote': unset,
  'link': none,
  'hashtag': none,
  'button': unset,
  'h1': unset,
  'h2': unset,
  'h3': unset,
  'h4': unset,
  'h5': unset,
  'h6': unset,
);

@mixin ricosTypography($name, $isViewer) {
  font-family: var(--ricos-custom-#{$name}-font-family, unset);
  font-size: var(--ricos-custom-#{$name}-font-size, map-get($font-sizes, $name));
  font-style: var(--ricos-custom-#{$name}-font-style, if($name == 'quote', normal, unset));
  font-weight: var(--ricos-custom-#{$name}-font-weight, unset);
  text-decoration: var(--ricos-custom-#{$name}-text-decoration, map-get($text-decorations, $name));
  line-height: var(--ricos-custom-#{$name}-line-height, map-get($text-heights, $name));
  min-height: var(--ricos-custom-#{$name}-min-height, map-get($min-heights, $name));
  @if $name == 'p' {
    color: $ricos-p-color;
    @if $isViewer {
      @at-root #{'& > span > span, span > a span'} {
        background-color: $ricos-p-background-color;
      }
    } @else {
      @at-root #{'& > *'} {
        background-color: $ricos-p-background-color;
      }
    }
  }
  @include container-max-width {
    font-size: var(--ricos-custom-#{$name}-font-size, map-get($font-sizes-mobile, $name));
  }
}

%regularText {
  font-family: $ricos-font-family;
}

.fontElementMap {
  @extend %regularText;
}

:global {
  %glob_regularText {
    font-family: $ricos-font-family;
  }

  .glob_fontElementMap {
    @extend %glob_regularText;
  }
}
