:root {
  --tabs-height: 3rem;
}

.tabs--div-container {
  width: 100%;
  min-height: var(--tabs-height);
  display: flex;
  flex-direction: column;
  white-space: nowrap;
  background-color: inherit;

  &[data-sticky="true"] {
    position: sticky;
    top: 0; 
    z-index: 1;
  }
}

.tabs--container {
  width: 100%;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  border-bottom: solid 1px var(--neutral-100);

  &[data-size="sm"] {
    gap: 0.25rem;
  }

  &[data-disabled="true"] {
    opacity: 0.25;
    pointer-events: none;
  }

  @media screen and (max-width: 576px) {
    position: relative;
    top: unset;
  }
}

.tabs--anchored-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 0;
  overflow-x: auto;
  white-space: nowrap;
  max-width: 100%;
}

.tabs--tab {
  padding: 0.75rem 1rem;
  color: var(--text-action-neutral-secondary);
  text-decoration: none;
  background-color: transparent;
  border: none;
  border-radius: 0;
  cursor: pointer;
  font-size: var(--rem-14);
  font-variation-settings: 'wght' var(--text-medium);
  display: flex;
  flex-direction: row;
  flex: 0;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  text-wrap: nowrap;
  border-bottom: 2px solid transparent;

  &[data-size="sm"] {
    padding: 0.5rem;
    gap: 0.25rem;
    font-size: var(--rem-13);
  }

  &[data-active="true"] {
    color: var(--text-action);
    border-bottom: 2px solid var(--border-action);
  }

  &:not([data-active="true"]):hover {
    color: var(--action-secondary-hover);
  }

  &[data-disabled="true"] {
    color: var(--text-disabled);
    pointer-events: none;
  }

  a {
    text-decoration: none;
  }
}

.tabs--tab-badge {
  min-width: 19px;
  min-height: 19px;
  background-color: var(--icon-action);
  color: white;
  font-size: var(--rem-12);
  font-variation-settings: 'wght' var(--text-semibold);
  padding: 2px 6px;
  border-radius: var(--radius-full);
  line-height: 100%;
  letter-spacing: 0;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tabs--pills-container {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 2px;

  &[data-size="md"] {
    gap: 0;
  }
}

.tabs--pill-tab {
  height: 2rem;
  padding-inline: .75rem;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  text-decoration: none;
  transition: all 0.2s ease-in-out;
  cursor: pointer;
  border-radius: var(--radius-md);
  border: none;
  font-size: var(--rem-14);
  color: var(--text-action-neutral-secondary);
  font-variation-settings: 'wght' var(--text-medium);
  line-height: 100%;
  letter-spacing: 0;

  &:not([data-active="true"]):hover {
    color: var(--text-action-neutral-secondary-hover);
  }

  &[data-size="sm"] {
    gap: .25rem;
    padding-inline: .5rem;
    height: 1.5rem;
    font-size: var(--rem-13);
  }

  &[data-active="true"] {
    color: var(--text-action);
    background-color: var(--surface-success);
  }

  &[data-disabled="true"] {
    color: var(--text-disabled);
    cursor: not-allowed;
  }
}

/* The tabs scroll sideways inside the bar, without a scrollbar: it was a grey strip
   under the tabs. The scroller is a layer inside the bar so that the bar keeps its
   solid background: a sticky bar fading at its edges would show the page scrolling
   under it. The side with more tabs fades out, so the hidden tabs still read as there.
   Browsers without scroll-driven animations get no fade; the tabs still scroll
   (trackpad, shift+wheel, or the wheel over the bar, see tabs_controller.js), and the
   active tab is scrolled into view. */
.tabs--scroller {
  width: 100%;
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: inherit;
  overflow-x: auto;
  scrollbar-width: none;

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

.tabs--anchored-container {
  scrollbar-width: none;

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

@supports (animation-timeline: scroll()) {
  .tabs--scroller {
    --tabs-fade-start: 0px;
    --tabs-fade-end: 0px;
    mask-image: linear-gradient(to right,
      transparent 0, #000 var(--tabs-fade-start),
      #000 calc(100% - var(--tabs-fade-end)), transparent 100%);
    animation: tabs-edge-fade linear both;
    animation-timeline: scroll(self inline);
  }

  @property --tabs-fade-start {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
  }

  @property --tabs-fade-end {
    syntax: "<length>";
    inherits: false;
    initial-value: 0px;
  }

  @keyframes tabs-edge-fade {
    0% { --tabs-fade-start: 0px; --tabs-fade-end: 3rem; }
    10%, 90% { --tabs-fade-start: 3rem; --tabs-fade-end: 3rem; }
    100% { --tabs-fade-start: 3rem; --tabs-fade-end: 0px; }
  }
}
