@import '../../global/variables';
@import '../../global/mixins/exports';

@include exports('ray-radio-pill') {
  .#{$ray-class-prefix}radio-pill__wrapper {
    width: 100%;
    display: flex;
  }

  .#{$ray-class-prefix}radio-pill {
    display: flex;
    flex-grow: 1;
    flex-basis: 0;
    text-align: center;
    align-items: center;
    min-width: 0;

    &:not(:first-child) {
      margin-left: -$ray-border-width;

      [dir='rtl'] & {
        margin-left: 0;
        margin-right: -$ray-border-width;
      }
    }

    &:first-child {
      .#{$ray-class-prefix}radio-pill__label {
        border-bottom-left-radius: $ray-border-radius;
        border-top-left-radius: $ray-border-radius;

        [dir='rtl'] & {
          border-bottom-left-radius: 0;
          border-top-left-radius: 0;
          border-bottom-right-radius: $ray-border-radius;
          border-top-right-radius: $ray-border-radius;
        }
      }
    }

    &:last-child {
      .#{$ray-class-prefix}radio-pill__label {
        border-bottom-right-radius: $ray-border-radius;
        border-top-right-radius: $ray-border-radius;

        [dir='rtl'] & {
          border-bottom-right-radius: 0;
          border-top-right-radius: 0;
          border-bottom-left-radius: $ray-border-radius;
          border-top-left-radius: $ray-border-radius;
        }
      }
    }
  }

  .#{$ray-class-prefix}radio-pill__input {
    appearance: none;
    width: 0;
    height: 0;
    opacity: 0;
    // This is needed to remove spacing on inputs in iOS Safari
    position: absolute;
    z-index: -99999;

    &:checked + .#{$ray-class-prefix}radio-pill__label {
      border: 1px solid $ray-color-blue-50;
      background-color: $ray-color-blue-03;
      color: $ray-color-blue-50;
      z-index: 1;
    }

    &:not(:checked) {
      &:hover + .#{$ray-class-prefix}radio-pill__label {
        color: $ray-color-blue-50;
        border: 1px solid $ray-color-blue-50;
        background-color: $ray-color-white;
        z-index: 1;
      }
    }

    &:focus {
      & + .#{$ray-class-prefix}radio-pill__label {
        box-shadow: $ray-box-shadow-focus-state;
        z-index: 2;
      }
    }
  }

  .#{$ray-class-prefix}radio-pill__label {
    cursor: pointer;
    color: $ray-color-black;
    background-color: $ray-color-white;
    flex-grow: 1;
    padding: $ray-radio-pill-v-spacing-compact $ray-radio-pill-h-spacing-compact;
    border: $ray-border-width solid $ray-color-gray-31;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;

    @media (min-width: map-get($ray-layout-grid-breakpoints, tablet)) {
      padding: $ray-radio-pill-v-spacing $ray-radio-pill-h-spacing;
    }
  }
}
