:root {
  --segment-active-color: var(--segment-active-text-color);
  --segment-border-top: 1px solid var(--segment-color);
  --segment-border-bottom: 1px solid var(--segment-color);
  --segment-border: 0 solid var(--segment-color);
  --segment-border-radius: 4px;
}

/*~
  name: Segment
  category: Segment
  markup: |
    <div class="segment" style="width: 280px; margin: 0 auto;">
      <div class="segment__item">
        <input type="radio" class="segment__input" name="segment-a" checked>
        <div class="segment__button">One</div>
      </div>
      <div class="segment__item">
        <input type="radio" class="segment__input" name="segment-a">
        <div class="segment__button">Two</div>
      </div>
      <div class="segment__item">
        <input type="radio" class="segment__input" name="segment-a">
        <div class="segment__button">Three</div>
      </div>
    </div>
*/

.segment {
  @apply(--reset-font);
  display: inline-flex;
  align-items: stretch;
  align-content: stretch;
  flex-wrap: nowrap;
  margin: 0;
  padding: 0;
  border: none;
}

.segment__item {
  @apply(--reset-font);
  border-radius: 0;
  width: 100%;
  padding: 0;
  margin: 0;
  @apply(--hide-input-parent);
  overflow: hidden;
  box-sizing: border-box;
  display: block;
  background-color: transparent;
  border: none;
}

.segment__input {
  @apply(--hide-input);
}

.segment__button {
  @apply(--reset-font);
  border-radius: 0;
  background-color: transparent;
  color: var(--segment-color);
  border: 1px solid var(--segment-color);
  border-top-width: 1px;
  border-bottom-width: 1px;
  border-right-width: 1px;
  border-left-width: 0;
  font-weight: var(--font-weight);
  padding: 0;
  font-size: 13px;
  height: 29px;
  line-height: 29px;
  width: 100%;
  transition: background-color 0.2s linear, color 0.2s linear;
  box-sizing: border-box;
  text-align: center;
}

.segment__item:disabled {
  @apply(--disabled);
}

.segment__button:hover {
  transition: none;
}

.segment__button:focus {
  outline: 0;
}

:active + .segment__button {
  background-color: var(--segment-active-background-color);
  border: var(--segment-border);
  border-top: var(--segment-border-top);
  border-bottom: var(--segment-border-bottom);
  border-right: 1px solid var(--segment-color);
  font-size: 13px;
  width: 100%;
  transition: none;
}

:checked + .segment__button {
  background-color: var(--segment-color);
  color: var(--segment-active-color);
  transition: none;
}

.segment__item:first-child > .segment__button {
  border-left-width: 1px;
  border-radius: var(--segment-border-radius) 0 0 var(--segment-border-radius);
}

.segment__item:last-child > .segment__button {
  border-right-width: 1px;
  border-radius: 0 var(--segment-border-radius) var(--segment-border-radius) 0;
}

/*~
  name: Material Segment
  category: Segment
  markup: |
    <div class="segment segment--material" style="width: 280px; margin: 0 auto;">
      <div class="segment__item segment--material__item">
        <input type="radio" class="segment__input segment--material__input" name="segment-b" checked>
        <div class="segment__button segment--material__button">One</div>
      </div>
      <div class="segment__item segment--material__item">
        <input type="radio" class="segment__input segment--material__input" name="segment-b">
        <div class="segment__button segment--material__button">Two</div>
      </div>
      <div class="segment__item segment--material__item">
        <input type="radio" class="segment__input segment--material__input" name="segment-b">
        <div class="segment__button segment--material__button">Three</div>
      </div>
    </div>
*/

.segment--material {
  border-radius: 2px;
  overflow: hidden;
  box-shadow: 0 0 2px 0 rgba(0, 0, 0, 0.12), 0 2px 2px 0 rgba(0, 0, 0, 0.24);
}

.segment--material__button {
  @apply(--material-font);
  font-size: 14px;
  height: 32px;
  line-height: 32px;
  border-width: 0;
  color: var(--material-segment-text-color);
  border-radius: 0;
  background-color: var(--material-segment-background-color);
}

:active + .segment--material__button {
  background-color: var(--material-segment-background-color);
  border-radius: 0;
  border-width: 0;
  font-size: 14px;
  transition: none;
  color: var(--material-segment-text-color);
}

:checked + .segment--material__button {
  background-color: var(--material-segment-active-background-color);
  color: var(--material-segment-active-text-color);
  border-radius: 0;
  border-width: 0;
}

.segment--material__item:first-child > .segment--material__button,
.segment--material__item:last-child > .segment--material__button {
  border-radius: 0;
  border-width: 0;
}

