.navds-timeline {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  width: 100%;
  min-width: fit-content;
  align-items: center;
}

.navds-timeline__axislabels {
  position: relative;
  height: 1rem;
  box-sizing: content-box;
  grid-column: 2;
  margin-bottom: var(--ax-spacing-1);
}

.navds-timeline__row-label {
  white-space: nowrap;
  width: auto;
  margin-right: var(--ax-spacing-4);
  grid-column: 1;
  min-height: 1.5rem;
  display: flex;
  align-items: center;
  gap: var(--ax-spacing-2);
}

.navds-timeline__row-label:where(:nth-last-child(2)) {
  align-self: flex-end;
}

.navds-timeline__axislabels-label {
  position: absolute;
  color: var(--ax-text-subtle);
  white-space: nowrap;
}

.navds-timeline__row {
  display: flex;
  background: var(--ax-bg-neutral);
  margin: var(--ax-spacing-4) 0;
  grid-column: 2;
}

.navds-timeline__row--active {
  background: var(--ax-bg-accent-moderateA);
}

.navds-timeline__row:last-of-type {
  margin-bottom: 0;
}

.navds-timeline__row-periods {
  min-height: 1.5rem;
  position: relative;
  width: 100%;
  margin: 0;
}

.navds-timeline__row-periods > li {
  list-style-type: none;
}

.navds-timeline__period:focus-visible {
  z-index: 4;
  outline: 2px solid var(--ax-border-focus);
  outline-offset: 2px;

  && {
    box-shadow: 0 0 0 2px var(--ax-bg-default);
  }
}

.navds-timeline__period {
  height: 100%;
  border-radius: var(--ax-border-radius-full);
  position: absolute;
  padding: 0;
  display: flex;
  align-items: center;
  z-index: 2;
  border: none;
  font-size: 1rem;
}

.navds-timeline__period--inner {
  margin: 0 var(--ax-spacing-2);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  text-align: left;
  display: flex;
  align-items: center;
}

.navds-timeline__period--inner svg {
  flex-shrink: 0;
}

.navds-timeline__period--clickable {
  cursor: pointer;
}

.navds-timeline__period--success {
  background: var(--ax-bg-success-moderate);
  border: solid 1px var(--ax-border-success);
  color: var(--ax-text-success-icon);

  &.navds-timeline__period--clickable:hover {
    background: var(--ax-bg-success-moderate-hover);
  }

  &.navds-timeline__period--clickable.navds-timeline__period--selected {
    background: var(--ax-bg-success-strong-pressed);
    border: none;
    color: var(--ax-text-success-contrast);
  }
}

.navds-timeline__period--warning {
  background: var(--ax-bg-warning-moderate);
  border: solid 1px var(--ax-border-warning);
  color: var(--ax-text-warning-icon);

  &.navds-timeline__period--clickable:hover {
    background: var(--ax-bg-warning-moderate-hover);
  }

  &.navds-timeline__period--clickable.navds-timeline__period--selected {
    background: var(--ax-bg-warning-strong-pressed);
    border: none;
    color: var(--ax-text-warning-contrast);
  }
}

.navds-timeline__period--danger {
  background: var(--ax-bg-danger-moderate);
  border: solid 1px var(--ax-border-danger);
  color: var(--ax-text-danger-icon);

  &.navds-timeline__period--clickable:hover {
    background: var(--ax-bg-danger-moderate-hover);
  }

  &.navds-timeline__period--clickable.navds-timeline__period--selected {
    background: var(--ax-bg-danger-strong-pressed);
    border: none;
    color: var(--ax-text-danger-contrast);
  }
}

.navds-timeline__period--info {
  background: var(--ax-bg-info-moderate);
  border: solid 1px var(--ax-border-info);
  color: var(--ax-text-info-icon);

  &.navds-timeline__period--clickable:hover {
    background: var(--ax-bg-info-moderate-hover);
  }

  &.navds-timeline__period--clickable.navds-timeline__period--selected {
    background: var(--ax-bg-info-strong-pressed);
    border: none;
    color: var(--ax-text-info-contrast);
  }
}

.navds-timeline__period--neutral {
  background: var(--ax-bg-neutral-moderate);
  border: solid 1px var(--ax-border-neutral);
  color: var(--ax-text-neutral-icon);

  &.navds-timeline__period--clickable:hover {
    background: var(--ax-bg-neutral-moderate-hover);
  }

  &.navds-timeline__period--clickable.navds-timeline__period--selected {
    background: var(--ax-bg-neutral-strong-pressed);
    border: none;
    color: var(--ax-text-neutral-contrast);
  }
}

.navds-timeline__period--connected-both {
  border-radius: 0;
}

.navds-timeline__period--connected-right {
  border-bottom-right-radius: 0;
  border-top-right-radius: 0;
}

.navds-timeline__period--connected-left {
  border-bottom-left-radius: 0;
  border-top-left-radius: 0;
}

.navds-timeline__pin-wrapper {
  position: absolute;
  grid-column: 2;
  top: 0;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column-reverse;
  isolation: isolate;

  --navdsc-timeline-pin-size: 0.9rem;
}

.navds-timeline__pin-button {
  border: none;
  cursor: pointer;
  background: var(--ax-bg-default);
  box-shadow: inset 0 0 0 4px var(--ax-bg-danger-strong);
  z-index: 2;
  border-radius: var(--ax-border-radius-full);
  padding: var(--ax-spacing-2);
  position: relative;

  &::before {
    content: "";
    inset: 0;
    position: absolute;
    width: 25px;
    height: 25px;
    border-radius: var(--ax-border-radius-full);
    left: calc(-12.5px + 3.5px);
    top: calc(-12.5px + 3.5px);
  }

  &:hover {
    box-shadow: inset 0 0 0 4px var(--ax-bg-danger-strong-hover);
  }

  &:focus-visible {
    box-shadow:
      inset 0 0 0 4px var(--ax-border-danger-strong),
      0 0 0 2px var(--ax-bg-default);
    outline: 2px solid var(--ax-border-focus);
    outline-offset: 2px;
  }
}

.navds-timeline__pin-wrapper::before {
  content: "";
  top: var(--navdsc-timeline-pin-size);
  height: calc(100% - var(--navdsc-timeline-pin-size) * 2);
  width: 1px;
  margin: 0 auto;
  background: var(--ax-border-strong);
}

.navds-timeline__zoom {
  margin-top: var(--ax-spacing-6);
  float: right;
  display: flex;
  list-style-type: none;
}

.navds-timeline__zoom-button {
  all: unset;
  cursor: pointer;
  padding: 6px 9px 6px 8px;
  border: 1px solid var(--ax-border-default);
  border-width: 1px 0 1px 1px;
  background: var(--ax-bg-default);
}

.navds-timeline__zoom li:first-child .navds-timeline__zoom-button {
  border-radius: var(--ax-border-radius-medium) 0 0 var(--ax-border-radius-medium);
}

.navds-timeline__zoom li:last-child .navds-timeline__zoom-button {
  border-width: 1px;
  border-radius: 0 var(--ax-border-radius-medium) var(--ax-border-radius-medium) 0;
}

.navds-timeline__zoom li:only-child .navds-timeline__zoom-button {
  border-radius: var(--ax-border-radius-medium);
}

.navds-timeline__zoom-button:not([aria-pressed="true"]):hover {
  background: var(--ax-bg-neutral-moderate-hoverA);
}

.navds-timeline__zoom-button[aria-pressed="true"] {
  background: var(--ax-bg-neutral-strong-pressed);
  border-color: var(--ax-bg-neutral-strong-pressed);
  color: var(--ax-text-neutral-contrast);
}

.navds-timeline__zoom li:focus-within {
  z-index: 5;
}

.navds-timeline__zoom-button:focus-visible {
  box-shadow:
    0 0 0 1px var(--ax-bg-default),
    0 0 0 3px var(--ax-border-focus);
  border-width: 1px;
}

.navds-timeline__zoom li:not(:last-child) .navds-timeline__zoom-button:focus-visible {
  margin-right: 2px;
  padding-right: 6px;
}

/**
* Timeline Popover
*/

.navds-timeline__popover {
  z-index: 5;
  background-color: var(--ax-bg-raised);
  box-shadow: var(--ax-shadow-dialog);
  border: 1px solid;
  border-color: var(--ax-border-subtleA);
  border-radius: var(--ax-border-radius-large);
  padding: var(--ax-spacing-4) var(--ax-spacing-5);
}

@media (forced-colors: active) {
  .navds-timeline__period:focus {
    outline: 2px solid highlight;
    outline-offset: 2px;
  }

  .navds-timeline__period--success,
  .navds-timeline__period--warning,
  .navds-timeline__period--info,
  .navds-timeline__period--neutral,
  .navds-timeline__period--danger {
    forced-color-adjust: none;
  }

  .navds-timeline__row {
    border: 1px solid transparent;
  }

  .navds-timeline__pin-wrapper::before {
    border: 1px solid transparent;
  }

  .navds-timeline__pin-button {
    outline: 4px solid transparent;
  }

  .navds-timeline__pin-button:focus,
  .navds-timeline__pin-button:focus-visible {
    outline: 4px solid highlight;
    outline-offset: 2px;
    box-shadow: none;
  }
}
