$tabs-border-bottom-color: v("border") !default
$tabs-border-bottom-style: solid !default
$tabs-border-bottom-width: 1px !default
$tabs-link-color: v("text") !default
$tabs-link-hover-border-bottom-color: v("text-strong") !default
$tabs-link-hover-color: v("text-strong") !default
$tabs-link-active-border-bottom-color: v("link") !default
$tabs-link-active-color: v("link") !default
$tabs-link-padding: 0.5em 1em !default

$tabs-boxed-link-radius: v("radius") !default
$tabs-boxed-link-hover-background-color: v("background") !default
$tabs-boxed-link-hover-border-bottom-color: v("border") !default

$tabs-boxed-link-active-background-color: v("scheme-main") !default
$tabs-boxed-link-active-border-color: v("border") !default
$tabs-boxed-link-active-border-bottom-color: transparent !default

$tabs-toggle-link-border-color: v("border") !default
$tabs-toggle-link-border-style: solid !default
$tabs-toggle-link-border-width: 1px !default
$tabs-toggle-link-hover-background-color: v("background") !default
$tabs-toggle-link-hover-border-color: v("border-hover") !default
$tabs-toggle-link-radius: v("radius") !default
$tabs-toggle-link-active-background-color: v("link") !default
$tabs-toggle-link-active-border-color: v("link") !default
$tabs-toggle-link-active-color: v("link-invert") !default

+register(tabs-border-bottom-color,$tabs-border-bottom-color, true)
+register(tabs-border-bottom-style,$tabs-border-bottom-style, true)
+register(tabs-border-bottom-width,$tabs-border-bottom-width, true)
+register(tabs-link-color,$tabs-link-color, true)
+register(tabs-link-padding,$tabs-link-padding, true)
+register(tabs-link-hover-border-bottom-color,$tabs-link-hover-border-bottom-color, true)
+register(tabs-link-hover-color,$tabs-link-hover-color, true)
+register(tabs-link-active-border-bottom-color,$tabs-link-active-border-bottom-color, true)
+register(tabs-link-active-color,$tabs-link-active-color, true)
+register(tabs-boxed-link-radius,$tabs-boxed-link-radius, true)
+register(tabs-boxed-link-hover-background-color,$tabs-boxed-link-hover-background-color, true)
+register(tabs-boxed-link-hover-border-bottom-color,$tabs-boxed-link-hover-border-bottom-color, true)
+register(tabs-boxed-link-active-background-color,$tabs-boxed-link-active-background-color, true)
+register(tabs-boxed-link-active-border-color,$tabs-boxed-link-active-border-color, true)
+register(tabs-boxed-link-active-border-bottom-color,$tabs-boxed-link-active-border-bottom-color, true)
+register(tabs-toggle-link-border-color,$tabs-toggle-link-border-color, true)
+register(tabs-toggle-link-border-style,$tabs-toggle-link-border-style, true)
+register(tabs-toggle-link-border-width,$tabs-toggle-link-border-width, true)
+register(tabs-toggle-link-hover-background-color,$tabs-toggle-link-hover-background-color, true)
+register(tabs-toggle-link-hover-border-color,$tabs-toggle-link-hover-border-color, true)
+register(tabs-toggle-link-radius,$tabs-toggle-link-radius, true)
+register(tabs-toggle-link-active-background-color,$tabs-toggle-link-active-background-color, true)
+register(tabs-toggle-link-active-border-color,$tabs-toggle-link-active-border-color, true)
+register(tabs-toggle-link-active-color,$tabs-toggle-link-active-color, true)

.tabs
  @extend %block
  +overflow-touch
  @extend %unselectable
  align-items: stretch
  display: flex
  font-size: v("size-normal")
  justify-content: space-between
  overflow: hidden
  overflow-x: auto
  white-space: nowrap
  a
    align-items: center
    border-bottom-color: v("tabs-border-bottom-color")
    border-bottom-style: v("tabs-border-bottom-style")
    border-bottom-width: v("tabs-border-bottom-width")
    color: v("tabs-link-color")
    display: flex
    justify-content: center
    margin-bottom: calc(-1 * #{v("tabs-border-bottom-width")})
    padding: v("tabs-link-padding")
    vertical-align: top
    &:hover
      border-bottom-color: v("tabs-link-hover-border-bottom-color")
      color: v("tabs-link-hover-color")
  li
    display: block
    &.is-active
      a
        border-bottom-color: v("tabs-link-active-border-bottom-color")
        color: v("tabs-link-active-color")
  ul
    align-items: center
    border-bottom-color: v("tabs-border-bottom-color")
    border-bottom-style: v("tabs-border-bottom-style")
    border-bottom-width: v("tabs-border-bottom-width")
    display: flex
    flex-grow: 1
    flex-shrink: 0
    justify-content: flex-start
    &.is-left
      padding-right: 0.75em
    &.is-center
      flex: none
      justify-content: center
      padding-left: 0.75em
      padding-right: 0.75em
    &.is-right
      justify-content: flex-end
      padding-left: 0.75em
  .icon
    &:first-child
      +ltr-property("margin-right", 0.5em)
    &:last-child
      +ltr-property("margin-left", 0.5em)
  // Alignment
  &.is-centered
    ul
      justify-content: center
  &.is-right
    ul
      justify-content: flex-end
  // Styles
  &.is-boxed
    a
      border: 1px solid transparent
      border-radius: v("tabs-boxed-link-radius") v("tabs-boxed-link-radius") 0 0
      &:hover
        background-color: v("tabs-boxed-link-hover-background-color")
        border-bottom-color: v("tabs-boxed-link-hover-border-bottom-color")
    li
      &.is-active
        a
          background-color: v("tabs-boxed-link-active-background-color")
          border-color: v("tabs-boxed-link-active-border-color")
          border-bottom-color: v("tabs-boxed-link-active-border-bottom-color") !important
  &.is-fullwidth
    li
      flex-grow: 1
      flex-shrink: 0
  &.is-toggle
    a
      border-color: v("tabs-toggle-link-border-color")
      border-style: v("tabs-toggle-link-border-style")
      border-width: v("tabs-toggle-link-border-width")
      margin-bottom: 0
      position: relative
      &:hover
        background-color: v("tabs-toggle-link-hover-background-color")
        border-color: v("tabs-toggle-link-hover-border-color")
        z-index: 2
    li
      & + li
        +ltr-property("margin-left", calc(-1 * #{v("tabs-toggle-link-border-width")}))
      &:first-child a
        +ltr-property("border-top-left-radius", v("tabs-toggle-link-radius"))
        +ltr-property("border-bottom-left-radius", v("tabs-toggle-link-radius"))
      &:last-child a
        +ltr-property("border-bottom-right-radius", v("tabs-toggle-link-radius"))
        +ltr-property("border-top-right-radius", v("tabs-toggle-link-radius"))
      &.is-active
        a
          background-color: v("tabs-toggle-link-active-background-color")
          border-color: v("tabs-toggle-link-active-border-color")
          color: v("tabs-toggle-link-active-color")
          z-index: 1
    ul
      border-bottom: none
    &.is-toggle-rounded
      li
        &:first-child a
          +ltr-property("border-bottom-left-radius", v("radius-rounded"))
          +ltr-property("border-top-left-radius", v("radius-rounded"))
          +ltr-property("padding-left", 1.25em)
        &:last-child a
          +ltr-property("border-bottom-right-radius", v("radius-rounded"))
          +ltr-property("border-top-right-radius", v("radius-rounded"))
          +ltr-property("padding-right", 1.25em)
  // Sizes
  &.is-small
    font-size: v("size-small")
  &.is-medium
    font-size: v("size-medium")
  &.is-large
    font-size: v("size-large")
