/* On-screen Keyboard */

$key_size: 1.2em;
$key_border_radius: $base_border_radius + 4px; // 12px
$key_bg_color: if(variant=='light', $bg_color, darken($bg_color, 1%)); // Yaru: Make keyboard buttons work on both variants
$default_key_bg_color: $key_bg_color; // Yaru: Make keyboard buttons work on both variants
// $default_key_bg_color: if($variant=='light', darken($osd_bg_color, 11%), lighten($osd_bg_color, 2%));


// draw keys using button function
#keyboard { // Yaru change: Make keyboard work on both variants
  background-color: transparentize(if($variant=='light', darken($bg_color, 5%), darken($bg_color, 15%)), 0.1);
  // background-color: $osd_bg_color;
  // box-shadow: inset 0 1px 0 0 $osd_outer_borders_color;

  .page-indicator {
    padding: $base_padding;

    .page-indicator-icon {
      width: 8px;
      height: 8px;
    }
  }
}

// the container for individual keys
.key-container {
  padding: $base_margin;
  spacing: $base_margin;
}

// the keys
.keyboard-key {

  @include fontsize($base_font_size + 5);
  font-weight: bold;
  min-height: $key_size;
  min-width: $key_size;
  border-width: 1px;
  border-style: solid;
  border-radius: $key_border_radius;
  box-shadow: 0 1px 0 0 $shadow_color;

  @include keyboard_key(normal, $key_bg_color, $fg_color); // Yaru change: ↑↑↑

  &:focus { @include keyboard_key(focus, $key_bg_color, $fg_color);} // Yaru change: ↑↑↑
  &:hover { @include keyboard_key(hover, $key_bg_color, $fg_color);} // Yaru change: ↑↑↑
  &:active { @include keyboard_key(active, $key_bg_color, $fg_color); } // Yaru change: ↑↑↑
  &:checked { @include keyboard_key(checked, $key_bg_color, $fg_color); } // Yaru change: ↑↑↑

  &:grayed { //FIXMEy
    background-color: darken($bg_color, 3%);
    color: $fg_color; // Yaru change: ↑↑↑
    border-color: $osd_borders_color;
  }

  // non-character keys
  &.default-key {
    @include keyboard_key(normal, $default_key_bg_color, $fg_color); // Yaru change: ↑↑↑
    &:hover {@include keyboard_key(hover, $default_key_bg_color, $fg_color);} // Yaru change: ↑↑↑
    &:active { @include keyboard_key(active, $default_key_bg_color, $fg_color);} // Yaru change: ↑↑↑
    &:checked { @include keyboard_key(checked, $default_key_bg_color, $fg_color);} // Yaru change: ↑↑↑
    border-radius: $key_border_radius;

    // keys that may be latched: ctrl/alt/shift
    &:latched {
      border-color: lighten($selected_bg_color, 5%);
      background-color: $selected_bg_color;
    }
  }

  // enter key is suggested-action
  &.enter-key { // Yaru: our suggested action color is green
    @include keyboard_key(normal, $suggested_bg_color, $selected_fg_color);
    &:hover { @include keyboard_key(hover, $suggested_bg_color, $selected_fg_color);}
    &:active {@include keyboard_key(active, $suggested_bg_color, $selected_fg_color);}
    &:checked {@include keyboard_key(checked, $suggested_bg_color, $selected_fg_color);}
    border-radius: $key_border_radius;
    color: $osd_fg_color;
  }

  &.shift-key-lowercase {}
  
  // pressed shift has different style
  &.shift-key-uppercase { 
    background-color: if($variant=="light", darken($key_bg_color, 10%), lighten($key_bg_color, 20%)); // Yaru change: ↑↑↑
    color: $fg_color; // Yaru change: ↑↑↑
    &:hover {
      background-color: if($variant=="light", darken($key_bg_color, 13%), lighten($key_bg_color, 25%)); // Yaru change: ↑↑↑
      // color: lighten($osd_bg_color, 5%); // Yaru change: ↑↑↑
    }
  }

  // size of icons on keys
  StIcon { icon-size: 24px; }
}

// long press on a key popup
.keyboard-subkeys { // Yaru: Make keyboard popups work on both variants
  -arrow-border-radius: $base_border_radius*2;
  -arrow-background-color: transparentize(if($variant=='light', darken($bg_color, 5%), darken($bg_color, 8%)), 0.1);
  -arrow-border-width: 1px;
  -arrow-border-color: $borders_color;
  -arrow-base: 20px;
  -arrow-rise: 10px;
  -boxpointer-gap: $base_padding;
  padding: $base_padding;

  .keyboard-key {
    @include keyboard_key(normal, $key_bg_color, $fg_color); // Yaru change: ↑↑↑

    &:focus { @include keyboard_key(focus, $key_bg_color, $fg_color);} // Yaru change: ↑↑↑
    &:hover { @include keyboard_key(hover, $key_bg_color, $fg_color);} // Yaru change: ↑↑↑
    &:active { @include keyboard_key(active, $key_bg_color, $fg_color); } // Yaru change: ↑↑↑
    &:checked { @include keyboard_key(checked, $key_bg_color, $fg_color); } // Yaru change: ↑↑↑

    border-radius:$key_border_radius;
  }
}

// emoji
.emoji-page {
  .keyboard-key {
    background-color: transparent;
    border: none;
    color: initial;
  }
}

.emoji-panel {
  .keyboard-key:latched {
    border-color: lighten($selected_bg_color, 5%);
    background-color: $selected_bg_color;
  }
}

// suggestions
.word-suggestions {
  @include fontsize($base_font_size + 1);
  spacing: 12px;
  min-height: 17pt;
  padding: $base_padding*2;
  color: $fg_color; // Yaru change: ↑↑↑

  // each suggestion
  StButton {
    margin: 0 3px;
    min-width: 32px;
    border-radius: $base_border_radius - 2px;
    padding: 0px $base_padding*3;

    @include keyboard_key(undecorated, $key_bg_color, $fg_color); // Yaru change: ↑↑↑

    &:focus { @include keyboard_key(focus, $key_bg_color, $fg_color);} // Yaru change: ↑↑↑
    &:hover { @include keyboard_key(hover, $key_bg_color, $fg_color);} // Yaru change: ↑↑↑
    &:active { @include keyboard_key(active, $key_bg_color, $fg_color); } // Yaru change: ↑↑↑
    &:checked { @include keyboard_key(checked, $key_bg_color, $fg_color); } // Yaru change: ↑↑↑
  }
}
