//
// Copyright 2017 Google Inc.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions://
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

@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
