:host {
  display: inline-block;
}

// stylelint-disable a11y/media-prefers-reduced-motion
@media screen and (prefers-reduced-motion: reduce) {
  .fw-toggle-card-button,
  .fw-toggle-card-button-tick,
  .fw-toggle-icon-button {
    transition: none;
  }
}

/**
  @prop --fw-toggle-group-button-card-width: width of the card.
  @prop --fw-toggle-group-button-card-height: height of the content.
  @prop --fw-toggle-group-button-card-description-max-height: maximum height for the description text.
  @prop --fw-toggle-group-button-card-description-max-lines: maximum lines that can be displayed for description text.
  @prop --fw-toggle-group-button-icon-button-width: defines the width of the icon toggle button - default is 42px
  @prop --fw-toggle-group-button-icon-button-height: defines the height of the icon toggle button - default is 36px
*/

// Styles for card button
@mixin mixin-fw-toggle-card-button-selected-style {
  background: #e5f2fd; // TODO - get from design team
  border: 1px solid #bbdcfe; // TODO - get from design team
  box-shadow: 0px 1px 4px #ebeff3;
}

.fw-toggle-card-button {
  width: var(--fw-toggle-group-button-card-width, 240px);
  height: var(--fw-toggle-group-button-card-height, 112px);
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  outline: 0;
  padding: 12px;
  border-radius: 8px;
  background: $color-milk;
  border: 1px solid $color-smoke-100;
  box-shadow: inset 0px 1px 2px rgba(24, 50, 71, 0.05);
  transition: background-color 0.3s;
  position: relative;

  .fw-toggle-card-button-header {
    width: 100%;
    pointer-events: none;
    user-select: none;
    line-height: 20px;
    text-align: start;
    color: $text-default;
    font-size: $font-size-16;
    font-weight: $font-weight-600;
    margin-block-end: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: inline-block;
  }

  .fw-toggle-card-button-description {
    width: 100%;
    margin: 0;
    pointer-events: none;
    user-select: none;
    text-align: start;

    color: $text-secondary;
    font-size: $font-size-14;
    font-weight: $font-weight-400;

    word-break: break-word;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    line-height: 16px;
    max-height: var(--fw-toggle-group-button-card-description-max-height, 48px);
    -webkit-line-clamp: var(
      --fw-toggle-group-button-card-description-max-lines,
      3
    );
    -webkit-box-orient: vertical;
  }

  .fw-toggle-card-button-tick {
    width: 20px;
    height: 20px;
    position: absolute;
    inset-block-start: -8px;
    inset-inline-end: -8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    outline: 2px solid $color-milk;
    background-color: $color-azure-800;
    transition: opacity 0.3s;
    opacity: 1;
  }

  &:hover {
    background: $color-smoke-50; // TODO - get from design team
  }

  &:focus {
    border: 1px solid #e5f2fd; // TODO - get from design team
    box-shadow: 0 0 0 1px #e5f2fd; // TODO - get from design team
  }

  &--disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }

  &--selected {
    @include mixin-fw-toggle-card-button-selected-style;
    .fw-toggle-card-button-tick {
      opacity: 1;
    }
  }

  &--selected--checkbox {
    cursor: pointer;
    &:hover {
      @include mixin-fw-toggle-card-button-selected-style;
      .fw-toggle-card-button-tick {
        opacity: 0.5;
      }
    }
    &:active {
      @include mixin-fw-toggle-card-button-selected-style;
      .fw-toggle-card-button-tick {
        opacity: 0.1;
      }
    }
    &:focus {
      @include mixin-fw-toggle-card-button-selected-style;
      .fw-toggle-card-button-tick {
        opacity: 1;
      }
    }
  }

  &--selected--radio {
    cursor: unset;
    pointer-events: none;
    &:hover {
      @include mixin-fw-toggle-card-button-selected-style;
    }
    &:focus {
      @include mixin-fw-toggle-card-button-selected-style;
    }
  }
}
// Styles for card button - end

// Styles for icon toggle button
@mixin mixin-fw-toggle-icon-button-selected-style {
  background: linear-gradient(180deg, #ffffff 2.56%, #f5f7f9 95.75%);
  border: 2px solid #2c5cc5;
  box-shadow: 0px 1px 4px #ebeff3;
}

.fw-toggle-icon-button {
  width: var(--fw-toggle-group-button-icon-button-width, 42px);
  height: var(--fw-toggle-group-button-icon-button-height, 36px);
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: 0;
  padding: 0;
  background: linear-gradient(180deg, #ffffff 2.56%, #f5f7f9 95.75%);
  border: 1px solid #cfd7df;
  border-radius: 4px;
  transition: background-color 0.3s;

  &:hover {
    background: #f5f7f9;
  }

  &:focus {
    @include mixin-fw-toggle-icon-button-selected-style;
  }

  &--disabled {
    cursor: not-allowed;
    opacity: 0.6;
  }

  &--selected {
    @include mixin-fw-toggle-icon-button-selected-style;
  }

  &--selected--checkbox {
    cursor: pointer;
    &:hover {
      background: #f5f7f9;
    }
    &:focus {
      @include mixin-fw-toggle-icon-button-selected-style;
    }
  }

  &--selected--radio {
    cursor: unset;
    pointer-events: none;
    &:hover {
      @include mixin-fw-toggle-icon-button-selected-style;
    }
    &:focus {
      @include mixin-fw-toggle-icon-button-selected-style;
    }
  }
}
// Styles for icon button - end
