/* 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/. */

/**
 * This file is a little different. It combines the GlobalTrack and LocalTrack css
 * into one file, as it is mostly shared style.
 */
.timelineTrack {
  padding: 0;
  margin: 0;
}

.timelineTrackLocal {
  --local-track-margin: 15px;

  margin-left: var(--local-track-margin);
}

.timelineTrackRow {
  /* This is the width of the blue left border when a track is selected.
   * This variable will be used every time we need to calculate some width that
   * depends on this value, from the intended perceived width. */
  --selected-left-border-width: 3px;

  display: flex;
  flex-flow: row nowrap;
  background-color: #fff;
}

.timelineTrackRow.selected {
  position: relative;
  padding-left: 0;
  background-color: #edf6ff;
}

/* Showing a blue border on the left side of the track row to indicate that
 * it's selected */
.timelineTrackRow.selected::before {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--selected-left-border-width);
  background: var(--blue-60);
  content: '';
  pointer-events: none;
}

.timelineTrackLocalRow {
  border-left: 1px solid var(--grey-30);
}

.timelineTrackLocalRow.selected {
  /* By removing the left border, it looks like the blue border is on top of it.
   * By using the transparent color instead of removing it altogether, we keep
   * the 1px space. */
  border-left-color: transparent;
}

.timelineTrackLocalRow.selected::before {
  /* We have a left border in local tracks of 1px, moving it left to conceal it. */
  left: -1px;
}

.timelineTrackHidden {
  height: 0;
  pointer-events: none;
}

.timelineTrackLabel {
  --timeline-track-label-width: 150px;

  display: flex;
  width: var(--timeline-track-label-width);
  box-sizing: border-box;
  flex-flow: row nowrap;
  align-items: center;
  border-top: 1px solid var(--grey-30);
  border-right: 1px solid var(--grey-30);
  cursor: default;
}

.timelineTrackNameButton {
  overflow: hidden;

  /* The 8px are used by the box-shadow when the button receives focus */
  width: calc(100% - 8px);
  height: calc(100% - 8px);
  padding: 0 0 0 10px;
  border: none;
  background: none;
  font: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timelineTrackNameButtonAdditionalDetails {
  color: var(--grey-90-a60);
  font-size: 10px;
}

.timelineTrackCloseButton {
  overflow: hidden;
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  padding: 1px;
  border: 0;
  border-radius: 2px;
  background: url(../../../res/img/svg/close-dark.svg) no-repeat center;
  background-origin: content-box;
  background-size: contain;
  color: transparent;
  margin-inline-end: 2px;
  -moz-user-focus: ignore;
}

.timelineTrackCloseButton:hover {
  background-color: rgb(0 0 0 / 0.15);
}

.timelineTrackCloseButton:active:hover {
  background-color: rgb(0 0 0 / 0.3);
}

.timelineTrackLabel:not(:hover) > .timelineTrackCloseButton {
  display: none;
}

.timelineTrackTrack {
  position: relative;
  display: flex;
  flex: 1;
  flex-flow: column nowrap;
  border-top: 1px solid var(--grey-30);
}

.timelineTrackLocalTracks {
  position: relative;
  padding: 0;
  background: var(--grey-20);
  list-style: none;
}

/**
 * Local tracks are indented 15px. This rule adds an inset shadow overlay over the
 * entire local tracks area, including the indented space. This is why it is shifted
 * to the left, and slightly larger than 100%.
 */
.timelineTrackLocalTracks::before {
  position: absolute;

  /* Place it above the Reorderable component, which has a z-index of 2. */
  z-index: 3;
  left: -15px;
  width: calc(100% + 15px);
  height: 100%;
  box-shadow: inset 0 1px 5px rgb(0 0 0 / 0.2);
  content: '';
  pointer-events: none;
}

.timelineTrackLocalLabel {
  /* Calculate the width of the local track label by subtracting the margin and
   * the 1px border from the total track label width. */
  width: calc(
    var(--timeline-track-label-width) - var(--local-track-margin) - 1px
  );
}

@media (forced-colors: active) {
  .timelineTrackRow {
    /* In regular mode, the left border is drawn with a box-shadow which is not visible in HCM,
       and would make the selected track look misaligned.
       Since we're rendering the track with a completely different color, we can avoid setting this
       border, setting it to 0px so the computation made to account for it handle everything fine */
    --selected-left-border-width: 0px;
  }

  .timelineTrackRow.selected .timelineTrackLabel {
    border-color: CanvasText;
    background-color: SelectedItem;
    color: SelectedItemText;
  }

  .timelineTrackRow.selected .timelineTrackLabel button {
    color: inherit;
  }

  .timelineTrackRow:not(.selected):hover .timelineTrackLabel {
    background-color: SelectedItemText;
    color: SelectedItem;
  }

  .timelineTrackRow:not(.selected):hover .timelineTrackLabel button {
    color: inherit;
  }

  /* In regular mode, there's an inset box-shadow, which we don't see in HCM.
     Add a solid border so we do have a separation between a parent and a local track */
  .timelineTrackLocalTracks::before {
    border-top: 1px solid;
  }

  .timelineTrackCloseButton {
    border: 1px solid ButtonText;
    background-color: ButtonFace;
  }

  .timelineTrackCloseButton:hover {
    border-color: SelectedItem;
    background-color: ButtonFace;
  }

  @media (prefers-color-scheme: dark) {
    /* We need to adapt the cross icon in dark mode so it still visible */
    .timelineTrackCloseButton {
      background-image: url(../../../res/img/svg/close-light.svg);
    }
  }
}
