@import '../../vendor/carbon-components/scss/globals/scss/vars';
@import 'legend';
@import 'zoom-control';
@import 'scrolling-controls';

$cardPadding: $spacing-05;

.#{$iot-prefix}--map {
  &-card-content.#{$iot-prefix}--card--content--expanded {
    overflow: hidden;
  }
  // container and map canvas
  &__container {
    position: relative;
    // map card should span full width of card
    height: calc(100% + #{$cardPadding});
    width: calc(100% + #{$cardPadding} + #{$cardPadding});
    transform: translateX(-#{$cardPadding});
    transition: width $duration--fast-02 motion(entrance, productive);

    canvas {
      min-height: 100%;
    }
  }

  &-settings {
    opacity: 0;
    left: 100%;
    top: 0;
    position: absolute;
    z-index: 2;
    background: #fff;
    width: 256px;
    height: 100%;
    transform: translateX(0%);
    transition: opacity $duration--fast-02 motion(entrance, productive),
      transform $duration--fast-02 motion(entrance, productive);

    [dir='rtl'] & {
      left: unset;
      right: 100%;
    }
  }

  &-settings-header {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: $spacing-02 $spacing-03 $spacing-02 $spacing-05;

    [dir='rtl'] & {
      padding: $spacing-02 $spacing-05 $spacing-02 $spacing-03;
    }
  }

  &-settings-header__title {
    @include type-style('productive-heading-01');
    margin-right: auto;

    [dir='rtl'] & {
      margin-left: auto;
      margin-right: unset;
    }
  }

  // settings open
  &__container--open {
    width: calc(100% - 256px);
    &-legend.#{$iot-prefix}--map-legend--fullwidth {
      width: calc(100% - 256px);
    }
  }

  &-settings--open {
    opacity: 1;
    transform: translateX(-100%);

    [dir='rtl'] & {
      transform: translateX(100%);
    }
  }

  // Controls
  &-controls {
    transition: bottom $duration--fast-02 motion(entrance, productive);
    display: flex;
    flex-direction: column;
    position: absolute;
    justify-content: space-between;
    z-index: 2;
    right: $spacing-05;
    top: $spacing-05;
    bottom: $spacing-05;

    &--has-increased-margins {
      right: 2rem;
      top: 2rem;
      bottom: 2rem;
      &.#{$iot-prefix}--map-controls--has-fullwidth-legend {
        bottom: 8.5rem;
      }
    }

    &--has-fullwidth-legend {
      bottom: 7.5rem;
      transition: bottom $duration--fast-02 motion(entrance, productive);
    }

    [dir='rtl'] & {
      left: $spacing-05;
      right: unset;

      &--has-increased-margins {
        left: 2rem;
      }
    }
  }

  &-controls__container {
    display: flex;
    flex-direction: column;

    &--has-layers {
      padding-top: 3.5rem;
    }
  }

  &-controls-btn-group {
    display: flex;
    flex-direction: column;
    margin-bottom: $spacing-05;
  }

  &-controls-btn {
    background: #fff;
    @include box-shadow();
  }

  &-controls-btn:not(:last-child) {
    &:not(.iot--btn-icon-selection--selected) {
      border-bottom: 1px solid $ui-03;
    }
  }

  &-controls-layers {
    position: absolute;
    top: 0;
  }

  // Layered controls
  &-controls-layers-trigger {
    background-color: white;
    @include box-shadow();
    margin-bottom: $spacing-05;
    position: absolute;
    right: 0;
    top: 0;
    z-index: 2;

    .#{$iot-prefix}--map-controls-layers--open &:not(:hover)::before,
    .#{$iot-prefix}--map-controls-layers--open &:not(:hover) .#{$prefix}--assistive-text {
      visibility: hidden;
    }

    svg.#{$iot-prefix}--map-controls-layers-trigger__caret {
      fill: $icon-01 !important;
      transform: rotate(45deg);
      bottom: -1px;
      left: -1px;
      position: absolute;
    }
  }

  &-controls-layers-wrapper {
    $size-small-offset: -2rem;
    $size-field-offset: -2.5rem;
    @include box-shadow();
    flex-direction: row-reverse;
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    opacity: 0;
    overflow: hidden;
    transition: opacity $duration--fast-02 motion(entrance, productive),
      transform $duration--fast-02 motion(entrance, productive);

    .#{$iot-prefix}--map-controls-layers--open & {
      opacity: 1;
      overflow: visible;
      max-width: 100vw;
      transform: translateX(#{$size-small-offset});

      .#{$iot-prefix}--card--content--expanded & {
        transform: translateX(#{$size-field-offset});
      }
    }

    [dir='rtl'] & {
      left: 0;
      right: unset;
    }

    [dir='rtl'] .#{$iot-prefix}--map-controls-layers--open & {
      transform: translateX(calc(-1 * #{$size-small-offset}));
      .#{$iot-prefix}--card--content--expanded & {
        transform: translateX(calc(-1 * #{$size-field-offset}));
      }
    }

    [dir='rtl']
      .#{$iot-prefix}--card--content--expanded
      .#{$iot-prefix}--map-controls-layers--open
      & {
      transform: translateX(calc(-1 * #{$size-field-offset}));
    }
  }

  &-controls-layers-btn {
    background-color: white;
    &:not(.iot--btn-icon-selection--selected) {
      border-right: 1px solid $ui-03;
    }

    [dir='rtl'] & {
      &:not(.iot--btn-icon-selection--selected) {
        border-left: 1px solid $ui-03;
        border-right: none;
      }
    }
  }
}
