//
// Copyright IBM Corp. 2023, 2023
//
// This source code is licensed under the Apache-2.0 license found in the
// LICENSE file in the root directory of this source tree.
//

// Standard imports.
@import '../../global/styles/project-settings';

@mixin keyword-closed-defaults {
  height: rem(20px);
  padding-top: 0;
  // stylelint-disable-next-line carbon/layout-token-use
  padding-right: rem(3px);
  border-width: rem(1px);
  border-style: solid;
  border-radius: $spacing-04;
  white-space: nowrap;

  &:hover {
    cursor: pointer;
  }

  // The "up" chevron
  svg {
    // stylelint-disable-next-line carbon/layout-token-use
    margin: rem(1px) 0 0 0;
    vertical-align: text-top;
  }
}
@mixin keyword-open-defaults {
  @include keyword-closed-defaults();

  // The "up" chevron, flipped
  svg {
    transform: rotate(180deg);
  }
}
@mixin body-defaults {
  @include carbon--type-style('body-long-01');

  display: block;
  padding: $spacing-03 $spacing-04;
  border-left-width: rem(1.25px);
  border-left-style: solid;
  margin: $spacing-02 0;
  // Novice to pro does not always use Carbon defaults/tokens
  // stylelint-disable-next-line carbon/motion-duration-use, carbon/motion-easing-use
  animation: fade 600ms;
}

// Other Carbon settings.
// TODO: @import 'carbon-components/scss/globals/grid/grid'; if needed

// NonLinearReading uses the following Carbon components:
// TODO: @import(s) of Carbon component styles used by NonLinearReading

// NonLinearReading uses the following Carbon for IBM Products components:
// TODO: @import(s) of IBM Products component styles used by NonLinearReading

// Define all component styles in a mixin which is then exported using
// the Carbon import-once mechanism.
@mixin non-linear-reading {
  // The block part of our conventional BEM class names (blockClass__E--M).
  $block-class: #{$pkg-prefix}--non-linear-reading;

  @keyframes fade {
    0% {
      opacity: 0;
    }

    15% {
      opacity: 0;
    }

    100% {
      opacity: 1;
    }
  }

  .#{$block-class}__light {
    .#{$block-class}__keyword {
      &-closed {
        @include keyword-closed-defaults();

        border-color: $interactive-03;
        background-color: transparent;
        color: $interactive-03;

        &:hover {
          background-color: $interactive-03;
          color: $inverse-01;
        }
      }

      &-open {
        @include keyword-open-defaults();

        border-color: $interactive-03;
        background-color: $interactive-03;
        color: $inverse-01;

        &:hover {
          background-color: transparent;
          color: $interactive-03;
        }
      }
    }

    .#{$block-class}__body {
      @include body-defaults();

      border-left-color: $text-01;
    }
  }

  .#{$block-class}__dark {
    .#{$block-class}__keyword {
      &-closed {
        @include carbon--theme($carbon--theme--g100, true);
        @include keyword-closed-defaults();

        border-color: $icon-03;
        background-color: transparent;
        color: $text-01;

        &:hover {
          background-color: $icon-03;
          color: $inverse-01;
        }
      }

      &-open {
        @include carbon--theme($carbon--theme--g100, true);
        @include keyword-open-defaults();

        border-color: $icon-03;
        background-color: $icon-03;
        color: $inverse-01;

        &:hover {
          background-color: transparent;
          color: $text-01;
        }
      }
    }

    .#{$block-class}__body {
      @include carbon--theme($carbon--theme--g100, true);
      @include body-defaults();

      border-left-color: $text-01;
      color: $text-01;

      // override default link color to compensate for a gradient background.
      a {
        color: $link-01;
      }
    }
  }
}

@include exports('non-linear-reading') {
  @include non-linear-reading;
}
