// Dependencies.
@import 'init';

// Tabs
//
// Markup:
// {{> "tabs"}}
// {{> "tabs--secondary"}}
//
// Style guide: components.navigation.tabs

// Tabs (primary)
//
// Markup: tabs.hbs
//
// Style guide: components.navigation.tabs.primary

.tabs,
%tabs {
  @include clearfix;
  @include margin(1 0);
  background-color: color(tabs-bg);
  text-indent: 0;
  padding: 0;
  list-style: none;
  white-space: nowrap;
  border: 1px solid color(tabs-border);

  @media print {
    display: none;
  }
}

.tabs__tab,
%tabs__tab {
  margin: 0;
  float: left;
  width: 100%;

  @include respond-to('small') {
    width: auto;
  }

  @include rtl() {
    float: right;
  }
}

%tabs__tab-link-common {
  @include line-height(1);
  display: inline-block;
  text-decoration: none;
}

.tabs__tab-link,
%tabs__tab-link {
  @extend %tabs__tab-link-common;
  @include padding(.75 1);
  width: 100%;

  @include respond-to('small') {
    width: auto;
  }

  &:focus,
  &:hover {
    background-color: color(tabs-bg-hover);
  }
}

.tabs__tab-link.is-active,
%tabs__tab-link-is-active {
  position: relative;
  text-decoration: none;
  font-weight: weight(bold);
  background-color: color(tabs-bg-hover);

  &:before {
    content: '';
    width: 3px;
    height: 100%;
    border-left: 3px solid color(tabs-border);
    border-bottom: 0;
    bottom: 0;
    left: -3px;
    position: absolute;

    @include respond-to('small') {
      border-bottom: 3px solid;
      border-left: 0;
      width: 100%;
      height: 3px;
      bottom: 0;
      left: 0;
    }
  }
}

// Secondary tabs
//
// Markup: tabs--secondary.hbs
//
// Style guide: components.navigation.tabs.secondary

.tabs--secondary,
%tabs--secondary {
  @extend %tabs;
  @include font-size(s);
  background-image: none;
  border: 0;
}

.tabs +,
%tabs + {
  .tabs--secondary,
  %tabs--secondary {
    // Collapse bottom margin of .tabs.
    margin-top: -1rem;
  }
}

.tabs--secondary__tab,
%tabs--secondary__tab {
  @include margin(.5 3px);
  float: left;

  @include rtl() {
    float: right;
  }
}

.tabs--secondary__tab-link,
%tabs--secondary__tab-link {
  @extend %tabs__tab-link-common;
  @include padding(8px 18px);
  @include border-radius(20px);
  background-color: color(tabs-secondary-bg);

  &:focus,
  &:hover {
    background-color: color(tabs-secondary-bg-hover);
  }

  &:active {
    @extend %tabs--secondary__tab-link-is-active;
  }
}

.tabs--secondary__tab-link.is-active,
%tabs--secondary__tab-link-is-active {
  background-color: color(tabs-secondary-bg);
  font-weight: weight(bold);
}
