@use '../../theme/styles' as theme;

.wr-splitter {
  display: flex;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  user-select: none;
  font-family: var(--wr-font-family-base);

  &--horizontal {
    flex-direction: row;
  }

  &--vertical {
    flex-direction: column;
  }

  &__pane {
    flex-grow: 0;
    flex-shrink: 0;
    min-width: 0;
    min-height: 0;
    overflow: auto;
  }

  &__divider {
    flex: 0 0 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--wr-color-light);
    outline: 0;
    transition: background var(--wr-transition-base);

    // Coarse pointers: expand the 4px gutter to a 44px tap area.
    @include theme.touch-target($positioned: true);

    &:hover,
    &:focus-visible {
      background: var(--wr-color-primary);
    }

    &:focus-visible {
      @include theme.focus-ring;
    }
  }

  &--horizontal &__divider {
    width: 4px;
    cursor: ew-resize;
  }

  &--vertical &__divider {
    height: 4px;
    cursor: ns-resize;
  }

  &__handle {
    background: var(--wr-color-white);
    border: 1px solid var(--wr-color-light);
    box-shadow: var(--wr-shadow-sm);
    display: inline-block;
    flex: 0 0 auto;
  }

  &--horizontal &__handle {
    width: 0.875rem;
    height: 2rem;
    @include theme.smooth-br(var(--wr-control-radius-sm));
  }

  &--vertical &__handle {
    width: 2rem;
    height: 0.875rem;
    @include theme.smooth-br(var(--wr-control-radius-sm));
  }

  &--disabled &__divider {
    cursor: not-allowed;

    &:hover {
      background: var(--wr-color-light);
    }
  }
}
