$width-border: 1px;
$color-border: color(gray, plus3);
$color-bg: color(gray, plus5);
$border: $width-border solid $color-border;

.tabcordion {
  .tabcordion_navlist {
    position: relative;
    margin: 0;
    padding: 0;
    font-size: 0;
  }

  .tabcordion_nav-item {
    margin: 0;
    list-style: none;
    font-size: font-size(-1);
    transition: background 100ms ease,
                color 100ms ease;

    &.is-active {
      .tabcordion_nav-trigger {
        color: color(black);
        font-weight: font-weight(medium);
        cursor: default;
      }
    }

    .tabcordion_nav-trigger {
      padding: ms(-14) ms(-2);
      min-height: 44px;
      border: $border;
      background-color: color(white);
      color: color(primary);
      line-height: normal;
      transition: background 100ms ease,
                  color 100ms ease;
    }
  }

  .tabcordion_panels {
    border: $border;
    border-top: none;
  }

  .tabcordion_panel {
    display: none;
    animation-duration: 500ms;

    &.is-current {
      display: block;
    }
  }
}

.is-tabs {
  .tabcordion_navlist {
    border-bottom: $border;

    .is-active {
      .tabcordion_nav-trigger {
        border-bottom: 3px solid color(primary);
        transition: border-bottom 200ms ease;
      }
    }

    .tabcordion_nav-trigger {
      padding-top: calc(#{ms(-14)} + 3.4px);
      border-bottom: 3px solid $color-bg;
      transition: border-bottom 200ms ease;
    }
  }

  .tabcordion_nav-item {
    display: inline-block;

    &:not(.is-active) {
      &:hover {
        .tabcordion_nav-trigger {
          border-bottom: 3px solid color(primary, lighter);
        }
      }
    }
  }

  .tabcordion_panel {
    animation-name: fade-out;

    &.is-current {
      animation-name: fade-in;
    }
  }
}

@keyframes fade-in {
  0% {
    display: none;
    opacity: 0;
  }

  1% {
    display: block;
    opacity: 0;
  }

  100% {
    display: block;
    opacity: 100%;
  }
}

.is-accordion {
  .tabcordion_nav-item {
    display: block;

    .tabcordion_nav-trigger {
      position: relative;
      display: flex;
      min-height: 44px;
      width: 100%;
      text-align: left;

      &::before {
        position: absolute;
        top: 50%;
        right: 18px;
        width: 3px;
        height: 15px;
        background: color(primary);
        content: '';
        transition: transform 200ms;
        transform: translateY(-50%);
      }

      &::after {
        position: absolute;
        top: 50%;
        right: 12px;
        width: 15px;
        height: 3px;
        background: color(primary);
        content: '';
        transform: translateY(-50%);
      }
    }

    &.is-active {
      .tabcordion_nav-trigger {
        &::before {
          transform: translateY(-50%) rotate(270deg);
        }
      }
    }
  }

  .tabcordion_panels {
    border: 0;
  }

  .tabcordion_panel {
    border: $border;
    border-top: none;
    animation-name: slide-up;

    &.is-current {
      animation-name: slide-down;
      animation-duration: 1000ms;
    }
  }
}

@keyframes slide-down {
  0% {
    display: none;
    overflow: hidden;
    max-height: 0;
  }

  1% {
    display: block;
    overflow: hidden;
    max-height: 0;
  }

  100% {
    display: block;
    max-height: 100vh;
  }
}
