/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at <http://mozilla.org/MPL/2.0/>. */

.source-header {
  grid-area: editor-header;
  display: flex;
  width: 100%;
  height: var(--editor-header-height);
  border-bottom: 1px solid var(--theme-splitter-color);
  background-color: var(--theme-toolbar-background);
}

.source-header * {
  user-select: none;
}

.source-header .command-bar {
  flex: initial;
  flex-shrink: 0;
  border-bottom: 0;
  border-inline-start: 1px solid var(--theme-splitter-color);
}

.source-header .toggle-button.start {
  width: var(--cm-gutter-width);
}

.source-tabs {
  flex: auto;
  align-self: flex-start;
  /* Reserve space for the overflow button (even if not visible) */
  padding-inline-end: 28px;
  /* Make sure that overflowing tabs don't show through other elements (see Bug 1855458) */
  max-height: 100%;
  overflow: hidden;
}

.source-tab {
  display: inline-flex;
  align-items: center;
  position: relative;
  min-width: 40px;
  max-width: 100%;
  overflow: hidden;
  padding: 4px 10px;
  cursor: default;
  height: calc(var(--editor-header-height) - 1px);
  font-size: 12px;
  background-color: transparent;
  vertical-align: bottom;

  :root[forced-colors-active] & {
    color: ButtonText;

    &.active {
      color: SelectedItemText;
    }
  }
}

.source-tab::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background-color: var(--tab-line-color, transparent);
  transition:
    transform 250ms var(--animation-curve),
    opacity 250ms var(--animation-curve);
  opacity: 0;
  transform: scaleX(0);
}

.source-tab.active {
  --tab-line-color: var(--tab-line-selected-color);
  color: var(--theme-toolbar-selected-color);
  background-color: var(--theme-toolbar-selected-background);
  border-bottom-color: var(--theme-toolbar-selected-background);
}

.source-tab:not(.active):hover {
  --tab-line-color: var(--tab-line-hover-color);
  background-color: var(--theme-toolbar-hover);

  :root[forced-colors-active] & {
    color: SelectedItem;

    & .source-icon {
      fill: var(--theme-icon-hover-color);
    }
  }
}

.source-tab:hover::before,
.source-tab.active::before {
  opacity: 1;
  transform: scaleX(1);
}

.source-tab .dbg-img.dbg-img-blackBox {
  mask-size: 14px;
}

.source-tab .dbg-img.dbg-img-blackBox.source-icon {
  background-color: #806414;
}

.source-tab .filename {
  display: block;
  white-space: nowrap;
  text-overflow: ellipsis;
  overflow: hidden;
  padding-inline-end: 4px;
}

.source-tab .filename span {
  opacity: 0.7;
  padding-inline-start: 4px;
}

.source-tab .close-btn {
  visibility: hidden;
  margin-inline-end: -6px;
}

.source-tab.active .close-btn {
  color: inherit;
}

.source-tab.active .close-btn,
.source-tab:hover .close-btn {
  visibility: visible;
}

.source-tab.active .source-icon {
  background-color: currentColor;
  fill: currentColor;
}

.source-tab .close-btn:hover {
  color: var(--theme-selection-color);
  background-color: var(--theme-selection-background);
}

:root[forced-colors-active] .source-tab.active .close-btn:hover {
  color: var(--theme-selection-background);
  background-color: var(--theme-selection-color);
}
