// generic drawing of more complex things

// provide font size in pt, with px fallback
@function pt($size: $root-font-size) {
  @return ($size * 0.75 / 1px) + pt;
}

// provide icon size in em, with px fallback
@function em($size: 16px) {
  @return ($size / $root-font-size) + em;
}

// Typography
// based on:
// https://material.io/guidelines/style/typography.html#typography-styles

@mixin font($size) {
  @if $size == display-4 {
    // font-family: $large-font-family;
    font-size: 112px;
    font-weight: 300;
    // line-height: 1;
  }

  @if $size == display-3 {
    // font-family: $large-font-family;
    font-size: 56px;
    font-weight: 400;
    // line-height: 1;
  }

  @if $size == display-2 {
    // font-family: $large-font-family;
    font-size: 45px;
    font-weight: 400;
    // line-height: 48px;
  }

  @if $size == display-1 {
    // font-family: $large-font-family;
    font-size: 34px;
    font-weight: 400;
    // line-height: 40px;
  }

  @if $size == headline {
    font-size: pt(24px);
    font-weight: 400;
    // line-height: 32px;
  }

  @if $size == title {
    font-size: pt(20px);
    font-weight: 500;
    // line-height: 1;
  }

  @if $size == subheading {
    font-size: pt($subheading-size);
    font-weight: 400;
    // line-height: 24px;
  }

  @if $size == body-2 {
    font-size: pt($root-font-size);
    font-weight: 500;
    // line-height: 24px;
  }

  @if $size == body-1 {
    font-size: pt($root-font-size);
    font-weight: 400;
    // line-height: 20px;
  }

  @if $size == caption {
    font-size: pt(12px);
    font-weight: 400;
    // line-height: 1;
  }

  @if $size == button {
    font-size: pt($root-font-size);
    font-weight: 500;
    // line-height: 20px;
  }
}


@mixin entry($t, $fc: $primary_color) {
//
// entry
//
// $t: entry type
// $fc: focus color
//

  @if $t == normal {
    color: $fg_color;
    caret-color: $fg_color;
    background-color: if($variant == 'light', darken($base_color, 2%), darken($base_color, 1%));
    border-radius: $material_radius;
    border: 1px solid $border_color;
    box-shadow: none;
  }

  @if $t == focus {
    border: 1px solid lighten($primary_color, 15%);
    box-shadow: 0 0 0 1px lighten($primary_color, 15%);
  }

  @if $t == hover {
  }

  @if $t == insensitive {
    color: $disabled_fg_color;
    border: 1px solid rgba($border_color, 0.5);
  }
}

@mixin search_entry($t, $fc: $primary_color) {
//
// search_entry
//
// $t: search_entry type
// $fc: focus color
//

  @if $t == normal {
    background-color: rgba(white, 0.12);
    border-radius: $bt_radius;
    border-color: transparent;
    box-shadow: 0 1px 2px rgba(black, 0.35);
  }

  @if $t == focus {
    border-color: transparent;
    background-color: rgba(white, 0.18);
    box-shadow: 2px 3px 5px rgba(black, 0.55);
  }

  @if $t == hover {
    background-color: rgba(white, 0.2);
    box-shadow: 1px 2px 3px rgba(black, 0.35);
  }

  @if $t == insensitive {
    color: $disabled_fg_color;
    box-shadow: none;
  }
}

@mixin button($t, $c: $base_color, $tc: $fg_color) {
//
// button
//
// $t: button type
// $c: base color
// $tc: text color
//

  @if $t == normal {
    color: if($tc == $fg_color, $button_fg_color, $tc);
    background-color: $c;
    border-color: transparent;
    box-shadow: $shadow_1;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == focus {
    color: $tc;
    text-shadow: none;
    icon-shadow: none;
    box-shadow: $shadow_0;
    // box-shadow: inset 0px 0px 0px 2px $divider_color;
  }

  @if $t == hover {
    color: $tc;
    background-color: $c;
    border-color: transparent;
    box-shadow: $shadow_2;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == active {
    color: $tc;
    background-color: mix($tc, $c, percentage($lower_opacity));
    border-color: transparent;
    box-shadow: $shadow_2;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == insensitive {
    color: if($tc == $fg_color, $disabled_secondary_fg_color, $tc);
    background-color: if($c == $base_color, $divider_color, $c);
    border-color: transparent;
    box-shadow: $shadow_0;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-normal {
    color: if($tc != $inverse_fg_color, $secondary_fg_color, $inverse_secondary_fg_color);
    background-color: transparent;
    border-color: transparent;
    box-shadow: $shadow_0;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-focus {
    color: if($tc != $inverse_fg_color, $fg_color, $inverse_fg_color);
    text-shadow: none;
    icon-shadow: none;
    box-shadow: $shadow_0;
    // box-shadow: inset 0px 0px 0px 2px $divider_color;
  }

  @if $t == flat-hover {
    color: if($tc != $inverse_fg_color, $fg_color, $inverse_fg_color);
    background-color: if($tc != $inverse_fg_color, $divider_color, $inverse_divider_color);
    border-color: transparent;
    box-shadow: $shadow_0;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-active {
    color: if($tc != $inverse_fg_color, $fg_color, $inverse_fg_color);
    background-color: if($tc != $inverse_fg_color, $track_color, $inverse_track_color);
    border-color: transparent;
    box-shadow: $shadow_0;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-insensitive {
    color: if($tc != $inverse_fg_color, $disabled_secondary_fg_color, $inverse_disabled_secondary_fg_color);
    background-color: transparent;
    border-color: transparent;
    box-shadow: $shadow_0;
    text-shadow: none;
    icon-shadow: none;
  }
}
