// 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) {
//
// entry
//
// $t: entry type
// $fc: focus color
//

  @if $t == normal {
    caret-color: $text-secondary;
    color: $text-secondary;
    background-color: if($variant == 'light', $base, on(dark, divider));
    margin: 2px 6px 6px;
    border: 2px solid transparent;
    box-shadow: 0 3px 3px rgba(black, 0.24), 0 5px 8px rgba(black, 0.05);
  }

  @if $t == focus {
    color: $text;
    box-shadow: 0 3px 3px rgba(black, 0.20), 0 5px 8px rgba(black, 0.08);
    border: 2px solid $primary;
  }

  @if $t == hover {
    box-shadow: 0 3px 3px rgba(black, 0.20), 0 5px 8px rgba(black, 0.12);
  }

  @if $t == insensitive {
    color: on(dark, secondary);
  }
}

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

  @if $t == normal {
    caret-color: rgba(black, 0.75);
    color: rgba(black, 0.75);
    background-color: rgba(white, 0.75);
    border-color: transparent;
    box-shadow: none;
  }

  @if $t == focus {
    color: rgba(black, 0.85);
    border-color: transparent;
    background-color: rgba(white, 0.95);
    border: none;
    box-shadow: none;
  }

  @if $t == hover {
    color: rgba(black, 0.75);
    background-color: rgba(white, 0.85);
    box-shadow: none;
  }

  @if $t == insensitive {
    color: rgba(black, 0.35);
    box-shadow: none;
  }
}

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

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

  @if $t == focus {
    color: $primary;
    text-shadow: none;
    icon-shadow: none;
    box-shadow: none !important;
    outline: none !important;

    &:active {
      color: white;
    }
  }

  @if $t == hover {
    color: $tc;
    background-color: rgba($tc, 0.12);
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == active {
    color: $tc;
    background-color: rgba($tc, 0.24);
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == checked {
    color: on(dark);
    background-color: $primary;
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == insensitive {
    color: if($tc == $text, $text-secondary-disabled, $tc);
    background-color: if($c == $base, $secondary-fill, $c);
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-normal {
    color: if($tc != on(dark), $text-secondary, on(dark, secondary));
    background-color: transparent;
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-focus {
    color: if($tc != on(dark), $text, on(dark));
    text-shadow: none;
    icon-shadow: none;
    box-shadow: none !important;
    outline: none !important;
  }

  @if $t == flat-hover {
    color: if($tc != on(dark), $text, on(dark));
    background-color: if($tc != on(dark), $secondary-fill, on(dark, divider));
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-active {
    color: if($tc != on(dark), $text, on(dark));
    background-color: if($tc != on(dark), $track, on(dark, track));
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-checked {
    color: if($tc != on(dark), $text, on(dark));
    background-color: if($tc != on(dark), $track, $primary);
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-insensitive {
    color: if($tc != on(dark), $text-secondary-disabled, on(dark, secondary-disabled));
    background-color: transparent;
    border-color: transparent;
    box-shadow: none;
    text-shadow: none;
    icon-shadow: none;
  }
}
