.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(--a-spacing-1);
}

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

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

.navds-timeline__axislabels-label {
  position: absolute;
  color: var(--ac-timeline-axislabel-text, var(--a-text-subtle));
  white-space: nowrap;
}

.navds-timeline__row {
  display: flex;
  background: var(--ac-timeline-row-bg, var(--a-surface-subtle));
  margin: var(--a-spacing-4) 0;
  grid-column: 2;
}

.navds-timeline__row--active {
  background: var(--ac-timeline-row-active-bg, var(--a-surface-selected));
}

.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__row-periods:focus {
  outline: none;
}

.navds-timeline__period {
  height: 100%;
  border-radius: var(--a-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(--a-spacing-1);
  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(--ac-timeline-period-success-bg, var(--a-surface-success-subtle));
  box-shadow: inset 0 0 0 1px var(--ac-timeline-period-success-border, var(--a-border-success));
}

.navds-timeline__period--success.navds-timeline__period--clickable:hover {
  background: var(--a-surface-success-subtle-hover);
  background: var(--ac-timeline-period-success-bg-hover, var(--a-surface-success-subtle-hover));
}

.navds-timeline__period--warning {
  background: var(--ac-timeline-period-warning-bg, var(--a-surface-warning-subtle));
  box-shadow: inset 0 0 0 1px var(--ac-timeline-period-warning-border, var(--a-border-warning));
}

.navds-timeline__period--warning.navds-timeline__period--clickable:hover {
  background: var(--ac-timeline-period-warning-bg-hover, var(--a-surface-warning-subtle-hover));
}

.navds-timeline__period--danger {
  background: var(--ac-timeline-period-danger-bg, var(--a-surface-danger-subtle));
  box-shadow: inset 0 0 0 1px var(--ac-timeline-period-danger-border, var(--a-border-danger));
}

.navds-timeline__period--danger.navds-timeline__period--clickable:hover {
  background: var(--ac-timeline-period-danger-bg-hover, var(--a-surface-danger-subtle-hover));
}

.navds-timeline__period--info {
  background: var(--ac-timeline-period-info-bg, var(--a-surface-info-subtle));
  box-shadow: inset 0 0 0 1px var(--ac-timeline-period-info-border, var(--a-border-info));
}

.navds-timeline__period--info.navds-timeline__period--clickable:hover {
  background: var(--ac-timeline-period-info-bg-hover, var(--a-surface-info-subtle-hover));
}

.navds-timeline__period--neutral {
  background: var(--ac-timeline-period-neutral-bg, var(--a-bg-subtle));
  box-shadow: inset 0 0 0 1px var(--ac-timeline-period-neutral-border, var(--a-border-default));
}

.navds-timeline__period--neutral.navds-timeline__period--clickable:hover {
  background: var(--ac-timeline-period-neutral-bg-hover, var(--a-gray-200));
}

.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__period--selected {
  box-shadow: inset 0 0 0 2px var(--ac-timeline-period-selected-border, var(--a-border-action-selected));
  z-index: 3;
}

.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(--a-surface-default);
  box-shadow:
    inset 0 0 0 1px var(--ac-timeline-pin-bg, var(--a-surface-danger)),
    0 0 0 4px var(--ac-timeline-pin-bg, var(--a-surface-danger)),
    0 0 0 5px var(--a-surface-default);
  z-index: 2;
  border-radius: var(--a-border-radius-full);
  padding: var(--a-spacing-1);
  position: relative;
}

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

.navds-timeline__pin-button:focus-visible {
  box-shadow:
    inset 0 0 0 1px var(--ac-timeline-pin-bg, var(--a-surface-danger)),
    0 0 0 3px var(--ac-timeline-pin-bg, var(--a-surface-danger)),
    0 0 0 4px var(--a-surface-default),
    0 0 0 6px var(--a-border-focus);
  outline: none;
}

.navds-timeline__pin-button:hover {
  box-shadow:
    inset 0 0 0 1px var(--ac-timeline-pin-bg-hover, var(--a-surface-danger-hover)),
    0 0 0 4px var(--ac-timeline-pin-bg-hover, var(--a-surface-danger-hover)),
    0 0 0 5px var(--a-surface-default);
}

.navds-timeline__pin-button:hover:focus-visible {
  box-shadow:
    inset 0 0 0 1px var(--ac-timeline-pin-bg-hover, var(--a-surface-danger-hover)),
    0 0 0 3px var(--ac-timeline-pin-bg-hover, var(--a-surface-danger-hover)),
    0 0 0 4px var(--a-surface-default),
    0 0 0 6px var(--a-border-focus);
}

@supports not selector(:focus-visible) {
  .navds-timeline__pin-button:focus {
    box-shadow:
      inset 0 0 0 1px var(--ac-timeline-pin-bg, var(--a-surface-danger)),
      0 0 0 3px var(--ac-timeline-pin-bg, var(--a-surface-danger)),
      0 0 0 4px var(--a-surface-default),
      0 0 0 6px var(--a-border-focus);
    outline: none;
  }

  .navds-timeline__pin-button:hover:focus {
    box-shadow:
      inset 0 0 0 1px var(--ac-timeline-pin-bg-hover, var(--a-surface-danger-hover)),
      0 0 0 3px var(--ac-timeline-pin-bg-hover, var(--a-surface-danger-hover)),
      0 0 0 4px var(--a-surface-default),
      0 0 0 6px var(--a-border-focus);
  }
}

.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(--a-surface-inverted);
}

.navds-timeline__zoom {
  margin-top: var(--a-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(--ac-timeline-zoom-border, var(--a-border-default));
  border-width: 1px 0 1px 1px;
  background: var(--ac-timeline-zoom-bg, var(--a-surface-default));
}

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

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

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

.navds-timeline__zoom-button:not([aria-pressed="true"]):hover {
  background: var(--ac-timeline-zoom-bg-hover, var(--a-surface-action-subtle-hover));
}

.navds-timeline__zoom-button[aria-pressed="true"] {
  background: var(--ac-timeline-zoom-selected-bg, var(--a-surface-inverted));
  color: var(--ac-timeline-zoom-selected-text, var(--a-text-on-inverted));
}

.navds-timeline__period:focus-visible {
  outline: none;
  z-index: 4;
  box-shadow: 0 0 0 2px var(--a-border-focus);
}

.navds-timeline__period--selected:focus-visible {
  box-shadow:
    inset 0 0 0 2px var(--ac-timeline-period-selected-border, var(--a-border-action-selected)),
    0 0 0 2px var(--a-border-focus);
  z-index: 3;
}

.navds-timeline__zoom li:focus-within {
  z-index: var(--a-z-index-focus);
}

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

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

@supports not selector(:focus-visible) {
  .navds-timeline__period:focus {
    outline: none;
    z-index: 4;
    box-shadow: 0 0 0 2px var(--a-border-focus);
  }

  .navds-timeline__period--selected:focus {
    box-shadow:
      inset 0 0 0 2px var(--ac-timeline-period-selected-border, var(--a-border-action-selected)),
      0 0 0 2px var(--a-border-focus);
    z-index: 3;
  }

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

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

/**
* Timeline Popover
*/

.navds-timeline__popover {
  z-index: var(--a-z-index-popover);
  background-color: var(--ac-popover-bg, var(--a-surface-default));
  box-shadow: var(--a-shadow-medium);
  border: 1px solid;
  border-color: var(--ac-popover-border, var(--a-border-default));
  border-radius: var(--a-border-radius-large);
  padding: var(--a-spacing-3);
}

.navds-timeline__popover:focus {
  outline: none;
}

.navds-timeline__popover-arrow {
  position: absolute;
  z-index: -1;
  transform: rotate(45deg);
  background-color: var(--ac-popover-bg, var(--a-surface-default));
  border: 1px solid;
  border-color: var(--ac-popover-border, var(--a-border-default));
  width: 1rem;
  height: 1rem;
}

.navds-timeline__popover[data-placement^="top"] > .navds-timeline__popover-arrow {
  border-left-color: transparent;
  border-top-color: transparent;
}

.navds-timeline__popover[data-placement^="bottom"] > .navds-timeline__popover-arrow {
  border-bottom-color: transparent;
  border-right-color: transparent;
}

.navds-timeline__popover[data-placement^="left"] > .navds-timeline__popover-arrow {
  border-left-color: transparent;
  border-bottom-color: transparent;
}

.navds-timeline__popover[data-placement^="right"] > .navds-timeline__popover-arrow {
  border-right-color: transparent;
  border-top-color: transparent;
}

@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;
  }

  .navds-timeline__popover[data-placement^="top"] > .navds-timeline__popover-arrow {
    border-left-color: canvas;
    border-top-color: canvas;
  }

  .navds-timeline__popover[data-placement^="bottom"] > .navds-timeline__popover-arrow {
    border-bottom-color: canvas;
    border-right-color: canvas;
  }

  .navds-timeline__popover[data-placement^="left"] > .navds-timeline__popover-arrow {
    border-left-color: canvas;
    border-bottom-color: canvas;
  }

  .navds-timeline__popover[data-placement^="right"] > .navds-timeline__popover-arrow {
    border-right-color: canvas;
    border-top-color: canvas;
  }
}
