// generic drawing of more complex things

@use "../../theme";
@use "../../theme-color";

@mixin entry($t, $fc: theme-color.$primary) {
//
// entry
//
// $t: entry type
// $fc: focus color
//

  @if $t == normal {
    transition-duration: theme.$state-duration;
    background-color: if($fc == theme-color.$primary, theme-color.entry-fill(theme-color.$on-surface), theme-color.entry-fill(theme-color.$on-dark));
    border-color: transparent;
    box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.stroke(theme-color.$on-surface), $fc);
  }

  @if $t == focus {
    border-color: transparent;
    box-shadow: inset 0 -2px $fc;
  }

  @if $t == hover {
    box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.$on-surface, $fc);
  }

  @if $t == insensitive {
    color: theme-color.disabled(theme-color.$on-surface);
    border-color: transparent;
    box-shadow: inset 0 -1px if($fc == theme-color.$primary, theme-color.disabled-stroke(theme-color.$on-surface), $fc);
  }
}


@mixin button($t, $c: theme-color.$surface-z8, $tc: theme-color.$on-surface) {
//
// button
//
// $t: button type
// $c: base color
// $tc: text color
//

  @if $t == normal {
    color: $tc;
    background-color: $c;
    border-color: transparent;
    box-shadow: theme.$shadow-z2;
    text-shadow: none;
    icon-shadow: none;
    transition-duration: theme.$state-duration;
  }

  @if $t == focus {
    color: $tc;
    background-color: theme-color.focus-overlay($tc, $on: $c);
    text-shadow: none;
    icon-shadow: none;
    box-shadow: theme.$shadow-z4;
  }

  @if $t == hover {
    color: $tc;
    background-color: theme-color.hover-overlay($tc, $on: $c);
    border-color: transparent;
    box-shadow: theme.$shadow-z4;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == active {
    color: $tc;
    background-color: theme-color.pressed-overlay($tc, $on: $c);
    border-color: transparent;
    box-shadow: theme.$shadow-z8;
    text-shadow: none;
    icon-shadow: none;
    transition-duration: theme.$ripple-duration;
  }

  @if $t == insensitive {
    color: if($tc == theme-color.$on-surface, theme-color.disabled(theme-color.$on-surface), $tc);
    background-color: if($c == theme-color.$surface-z8, theme-color.fill(theme-color.$on-surface), $c);
    border-color: transparent;
    box-shadow: theme.$shadow-z0;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-normal {
    color: if($tc != theme-color.$on-dark, theme-color.$primary, theme-color.hint(theme-color.$on-dark));
    background-color: transparent;
    border-color: transparent;
    box-shadow: theme.$shadow-z0;
    text-shadow: none;
    icon-shadow: none;
    transition-duration: theme.$state-duration;
  }

  @if $t == flat-focus {
    color: if($tc != theme-color.$on-dark, theme-color.$primary, theme-color.hint(theme-color.$on-dark));
    background-color: theme-color.focus-overlay(if($tc != theme-color.$on-dark, theme-color.$primary, theme-color.$on-dark));
    text-shadow: none;
    icon-shadow: none;
    box-shadow: theme.$shadow-z0;
  }

  @if $t == flat-hover {
    color: if($tc != theme-color.$on-dark, theme-color.$primary, theme-color.hint(theme-color.$on-dark));
    background-color: theme-color.hover-overlay(if($tc != theme-color.$on-dark, theme-color.$primary, theme-color.$on-dark));
    border-color: transparent;
    box-shadow: theme.$shadow-z0;
    text-shadow: none;
    icon-shadow: none;
  }

  @if $t == flat-active {
    color: if($tc != theme-color.$on-dark, theme-color.$primary, theme-color.hint(theme-color.$on-dark));
    background-color: theme-color.pressed-overlay(if($tc != theme-color.$on-dark, theme-color.$primary, theme-color.$on-dark));
    border-color: transparent;
    box-shadow: theme.$shadow-z0;
    text-shadow: none;
    icon-shadow: none;
    transition-duration: theme.$ripple-duration;
  }

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