colorswatch {
  // This widget is made of two boxes one on top of the other, the lower box is colorswatch {} the other one
  // is colorswatch overlay {}, colorswatch has the programmatically set background, so most of the style is
  // applied to the overlay box.

  @include focus-ring($width: 4px, $offset: -2px);

  // base color corners rounding
  // to avoid the artifacts caused by rounded corner anti-aliasing the base color
  // sports a bigger radius.
  // nth-child is needed by the custom color strip.

  &.top {
    border-top-left-radius: $button_radius + 0.5px;
    border-top-right-radius: $button_radius + 0.5px;

    > overlay {
      border-top-left-radius: $button_radius;
      border-top-right-radius: $button_radius;
    }
  }

  &.bottom {
    border-bottom-left-radius: $button_radius + 0.5px;
    border-bottom-right-radius: $button_radius + 0.5px;

    > overlay {
      border-bottom-left-radius: $button_radius;
      border-bottom-right-radius: $button_radius;
    }
  }

  &.left,
  &:first-child:not(.top) {
    border-top-left-radius: $button_radius + 0.5px;
    border-bottom-left-radius: $button_radius + 0.5px;

    > overlay {
      border-top-left-radius: $button_radius;
      border-bottom-left-radius: $button_radius;
    }
  }

  &.right,
  &:last-child:not(.bottom) {
    border-top-right-radius: $button_radius + 0.5px;
    border-bottom-right-radius: $button_radius + 0.5px;

    > overlay {
      border-top-right-radius: $button_radius;
      border-bottom-right-radius: $button_radius;
    }
  }

  @media (prefers-contrast: more) {
    > overlay {
      box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--view-fg-color) 50%, transparent);
    }
  }

  &.dark > overlay {
    color: white;
  }

  &.light > overlay {
    color: RGB(0 0 6 / 75%);

    @media not (prefers-contrast: more) {
      box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--view-fg-color) 10%, transparent);
    }
  }

  &:drop(active) {
    &.light > overlay {
      box-shadow: inset 0 0 0 2px $drop_target_color;
    }

    &.dark > overlay {
      box-shadow: inset 0 0 0 2px $drop_target_color;
    }
  }

  &#add-color-button {
    > overlay {
      @extend %button_basic;

      border-radius: $button_radius 0 0 $button_radius;
    }

    &:only-child > overlay { border-radius: $button_radius; }
  }

  &:disabled {
    filter: Opacity(var(--disabled-opacity));
  }

  &#editor-color-sample {
    border-radius: $button_radius;

    > overlay { border-radius: $button_radius + 0.5px; }
  }
}

plane {
  @include focus-ring($offset: 2px, $outer: true);
}

// colorscale popup
colorchooser .popover.osd { border-radius: $popover_radius; }
