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

.timelineSelection {
  --thread-label-column-width: 150px;
  --vertical-scrollbar-reserved-width: 15px;
  --content-width: calc(
    100vw - var(--thread-label-column-width) -
      var(--vertical-scrollbar-reserved-width)
  );
  --grippy-range-background-color: #aaa;
  --grippy-range-border-color: white;
  --grippy-range-hover-background-color: #888;
  --selection-outbound-opacity: 0.1;

  position: relative;
  display: flex;
  width: var(--content-width);
  flex: 1;
  flex-direction: column;
  margin-left: var(--thread-label-column-width);
  -moz-user-focus: ignore;
}

.timelineSelectionHoverLine {
  position: absolute;
  z-index: 1;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgb(0 0 0 / 0.4);
  pointer-events: none;
}

.timelineSelectionOverlayTime {
  position: absolute;
  z-index: 1;
  padding: 3.25px 8px;
  border-radius: 0 4px 4px 0;
  margin-left: 1px;
  background-color: rgb(153 153 153);
  color: #fff;
}

.timelineSelectionOverlay {
  position: absolute;
  z-index: 2;
  display: flex;
  overflow: hidden;
  flex-flow: row nowrap;
  padding-left: 5px;
  margin-left: -5px;
  inset: 0;
  pointer-events: none;
}

.timelineSelectionDimmerBefore,
.timelineSelectionDimmerAfter {
  flex-shrink: 0;
  background: rgb(12 12 13 / var(--selection-outbound-opacity));
  forced-color-adjust: none;
}

.timelineSelectionDimmerAfter {
  flex: 1;
}

.timelineSelectionOverlayWrapper {
  display: flex;
  flex-flow: column nowrap;
}

.timelineSelectionGrippy {
  display: flex;
  height: 20px;
  flex-flow: row nowrap;
  pointer-events: auto;
}

.timelineSelectionGrippyRangeStart,
.timelineSelectionGrippyRangeEnd {
  position: relative;
  z-index: 3;
  width: 0;
  padding: 3px;
  border: 1px solid var(--grippy-range-border-color);
  border-radius: 5px;
  margin: 0 -4px;
  background: var(--grippy-range-background-color);
  cursor: ew-resize;
}

/* The :not() selectors are to handle the edge case where the mouse is pressed
 * on a grippy, then the pointer is moved down (above the first track) but not
 * moved horizontally.
 * In that case, because selectionDeltas are 0, the draggingStart/draggingEnd
 * classes are not set, and the grippy is not hovered, so it would be light
 * grey until the mouse is moved horizontally. */
.timelineSelectionGrippyRangeStart:hover,
.draggingStart > .timelineSelectionGrippyRangeStart,
:not(.draggingStart, .draggingEnd)
  > .timelineSelectionGrippyRangeStart.dragging,
.timelineSelectionGrippyRangeEnd:hover,
.draggingEnd > .timelineSelectionGrippyRangeEnd,
:not(.draggingStart, .draggingEnd) > .timelineSelectionGrippyRangeEnd.dragging {
  background: var(--grippy-range-hover-background-color);
}

.timelineSelectionGrippyMoveRange {
  flex: 1;
  cursor: grab;
}

.timelineSelectionGrippyMoveRange.dragging {
  cursor: grabbing;
}

.timelineSelectionOverlayInner {
  display: flex;
  min-width: 0;
  min-height: 0;
  flex: 1;
  align-items: center;
  justify-content: center;
}

.timelineSelectionOverlayRange {
  position: absolute;
  top: 20px;
  padding: 4px 8px;
  border-radius: 0 0 4px 4px;
  background-color: var(--blue-50);
  box-shadow: 0 2px 2px rgb(0 0 0 / 0.2);
  color: #fff;
  opacity: 1;
  pointer-events: none;
  transition: opacity 200ms;
}

.timelineSelectionOverlayRange.hidden {
  opacity: 0;
}

.timelineSelectionOverlayZoomButton {
  position: relative;
  width: 30px;
  height: 30px;
  box-sizing: border-box;
  border: 1px solid rgb(0 0 0 / 0.2);
  border-radius: 100%;
  margin: -15px;
  background-color: rgb(255 255 255 / 0.6);
  opacity: 0.5;
  pointer-events: auto;
  transition: opacity 200ms ease-in-out;
  will-change: opacity;
}

.timelineSelectionOverlayZoomButton::before {
  position: absolute;
  display: grid;
  content: url(../../../res/img/svg/zoom-icon.svg);
  inset: 0;
  place-content: center;
}

.timelineSelectionOverlayZoomButton.hidden {
  opacity: 0 !important;
  pointer-events: none;
  transition: unset;
}

.timelineSelectionOverlayZoomButton:hover {
  background-color: rgb(255 255 255 / 0.9);
}

.timelineSelectionOverlayZoomButton:active,
.timelineSelection:hover .timelineSelectionOverlayZoomButton {
  opacity: 1;
}

.timelineSelectionOverlayZoomButton:active:hover {
  background-color: rgb(160 160 160 / 0.6);
}

@media (forced-colors: active) {
  .timelineSelectionOverlayTime {
    background-color: CanvasText;
    color: Canvas;
  }

  .timelineSelectionHoverLine {
    background-color: CanvasText;
  }

  .timelineSelection {
    --grippy-range-background-color: ButtonText;
    --grippy-range-border-color: ButtonBorder;
    --grippy-range-hover-background-color: SelectedItem;
    --selection-outbound-opacity: 0.6;
  }

  .timelineSelectionDimmerBefore {
    border-inline-end: 1px solid CanvasText;
  }

  .timelineSelectionDimmerAfter {
    border-inline-start: 1px solid CanvasText;
  }

  .timelineSelectionOverlayZoomButton {
    border-color: ButtonText;
    background-color: ButtonFace;
    opacity: 1;
  }

  .timelineSelectionOverlayZoomButton::before {
    filter: url(#--button-icon-color);
  }

  .timelineSelectionOverlayZoomButton:hover {
    border-color: SelectedItem;
    background-color: SelectedItemText;
  }

  .timelineSelectionOverlayZoomButton:hover::before {
    filter: url(#--button-icon-hover-color);
  }

  .timelineSelectionOverlayZoomButton:active:hover {
    border-color: ButtonText;
    background-color: ButtonFace;
  }

  .timelineSelectionOverlayZoomButton:hover:active::before {
    filter: url(#--button-icon-active-color);
  }
}
