//
// Copyright 2017 Google Inc. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//

@import "@material/animation/functions";
@import "@material/typography/mixins";
@import "@material/ripple/common";
@import "@material/ripple/mixins";
@import "./mixins";
@import "../mixins";

$mdc-tab-with-text-height: 48px;
$mdc-tab-with-icon-and-text-height: 72px;

@mixin mdc-tabs-icon-tab-content {
  display: block;
  margin: 0 auto;
}

// postcss-bem-linter: define tab

.mdc-tab {
  @include mdc-typography(button);
  @include mdc-tab-ink-color(text-secondary-on-background);
  @include mdc-ripple-surface;
  @include mdc-states;
  @include mdc-ripple-radius-bounded;

  display: table-cell;
  position: relative;
  box-sizing: border-box;
  min-width: 160px;
  min-height: $mdc-tab-with-text-height;
  padding: 0 24px;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  overflow: hidden;
  vertical-align: middle;

  &:hover {
    @include mdc-tab-ink-color(text-primary-on-background);
  }

  &:focus {
    outline: none;
  }

  // TODO: Replace with breakpoint variable
  @media screen and (max-width: 600px) {
    min-width: 72px;
    padding: 0 12px;
  }

  &__icon {
    @include mdc-tabs-icon-tab-content;

    width: 24px;
    height: 24px;

    // postcss-bem-linter: ignore
    .mdc-tab-bar--icons-with-text & {
      margin-top: 4px;
    }
  }

  &__icon-text {
    @include mdc-tabs-icon-tab-content;
  }

  // postcss-bem-linter: ignore
  &__icon + &__icon-text {
    padding-top: 6px;
  }
}

.mdc-tab--active {
  @include mdc-tab-ink-color(text-primary-on-background);

  &::before {
    bottom: 0;
  }
}

.mdc-tab__indicator {
  @include mdc-tab-bar-indicator-mixin_;

  left: 2px;
  width: calc(100% - 4px);
}

// stylelint-disable plugin/selector-bem-pattern, selector-max-specificity
.mdc-tab-bar:not(.mdc-tab-bar-upgraded) {
  .mdc-tab--active,
  .mdc-tab:hover,
  .mdc-tab:active {
    .mdc-tab__indicator {
      visibility: visible;
    }
  }

  .mdc-tab:not(.mdc-tab--active):hover .mdc-tab__indicator {
    opacity: .38;
  }

  .mdc-tab--active,
  .mdc-tab:not(.mdc-tab--active):active .mdc-tab__indicator {
    opacity: .87;
  }
}
// stylelint-enable plugin/selector-bem-pattern, selector-max-specificity

// postcss-bem-linter: end
