/*****************************************************************************************  \
 *                                                                                       *
 * General Tabs styles common to all tabs components                                     *
 * Styles specific to each tabs component are in that component's directory              *
 *                                                                                       *
 \  ****************************************************************************************/

.c-tabs {
  @supports (display: grid) {
    @media all and (min-width: 50em) {
      display: grid;
      grid-template-columns: repeat(12, 1fr);
      grid-template-columns: subgrid;
      grid-column-gap: var(--h-padding);
    }
  }
}

.c-tabs__tablist {
  margin-bottom: calc(var(--v-margin) * 1.5);
  white-space: nowrap;
  overflow-x: auto;
  overflow-y: hidden;

  .js-tabs & {
    display: flex;
    justify-content: space-between;
  }

  -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(90deg, #fff 30%, rgba(255, 255, 255, 0)),
    linear-gradient(90deg, rgba(255, 255, 255, 0), #fff 70%) 0 100%,
    radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.25), transparent),
    radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.25), transparent)
    0 100%;
  background-color: #fff;
  background-position: 0 0, 100%, 0 0, 100%;
  background-repeat: no-repeat;
  background-attachment: local, local, scroll, scroll;
  background-size: 20px 100%, 20px 100%, 10px 100%, 10px 100%;

  &::-webkit-scrollbar {
    display: none;
  }

  -ms-overflow-style: none;

  /* Internet Explorer 10+ */
  scrollbar-width: none;

  /* Firefox */

  &:focus,
  &.focus-visible {
    outline: 2px dotted #888;
    outline-offset: 5px;
  }
}

.c-tabs__tab {
  display: inline-block;
  line-height: 1;
  text-align: left;
  position: relative;
  transition: all 0.1s linear;
}

.js-tabs .c-tabs__tablist--dotnav {
  justify-content: center;
}

.c-tabs__tablist--dotnav .c-tabs__tab {
  padding: 0.75rem;
  border-radius: 50%;
  color: #000;
  border: 2px dotted transparent;

  &::before {
    content: '';
    display: block;
    background-color: #000;
    width: 1rem;
    height: 1rem;
    border-radius: 50%;
    transition: background-color 0.1s linear;
  }

  &[aria-selected='true'] {
    color: var(--color--primary);

    &::before {
      background-color: var(--color--primary);
    }
  }

  &:hover {
    &::before {
      background-color: var(--color--primary);
    }
  }

  @media screen and (-ms-high-contrast: active) {
    /* All high contrast styling rules */
    &::before {
      background-color: windowText;
    }

    &[aria-selected='true'] {
      &::before {
        background: highlight;
      }
    }
  }

  &:focus,
  &.focus-visible {
    outline: none;
    border-color: currentColor;
    outline-offset: -4px;
  }

  &:focus:not(:focus-visible) {
    border-color: transparent;
  }

  .js-focus-visible &:focus:not(.focus-visible) {
    border-color: transparent;
  }
}

/* styles for visible labels for the dotnav for voice dictation users */
.c-tabs__tablist--dotnav .c-tabs__tab {
  position: relative;

  .dot-label {
    position: absolute;
    left: 1.25rem;
    transform: translateX(-50%);
    bottom: -2.75rem;
    z-index: 1;
    line-height: 1;
    background-color: var(--color--secondary);
    padding: 0.5em 0.75em;
    border-radius: 4px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s linear;

    &::after {
      /* up arrow */
      content: '';
      position: absolute;
      left: 50%;
      margin-left: -1rem;
      top: -0.5rem;
      width: 0;
      height: 0;
      border-left: 1rem solid transparent;
      border-right: 1rem solid transparent;
      border-bottom: 1rem solid var(--color--secondary);
    }
  }

  &:focus,
  &:hover {
    .dot-label {
      opacity: 1;
    }
  }

  &:focus:not(:focus-visible) {
    .dot-label {
      opacity: 0;
    }
  }

  .js-focus-visible &:focus:not(.focus-visible) {
    .dot-label {
      opacity: 0;
    }
  }
}

.c-tabs__tabpanel {
  margin-bottom: 8rem;

  .js-tabs & {
    margin-bottom: 0;
  }

  &:focus,
  &.focus-visible {
    outline: 2px dotted #888;
    outline-offset: 5px;
  }

  &:focus:not(:focus-visible) {
    outline: none;
    border-color: transparent;
  }

  .js-focus-visible &:focus:not(.focus-visible) {
    outline: none;
    border-color: transparent;
  }
}

.c-tabs__tabpanel__title {
  margin-bottom: 2em;
}

// when the js is enabled, the tabpanels are labelled by their tabs
// you may choose to hide or keep the headings inside of them visible
.js-tabs .c-tabs__tabpanel__title {
  display: none;
}
