@keyframes eol {
  from { opacity: 0.8 }
  to { opacity: 0.2 }
}

@keyframes flare {
  from{ opacity: 0 }
  to { opacity: 0.5 }
}

.chain {
  transition: margin-top 0.3s ease;
  margin-top: 0;
  display: flex;
  flex-direction: column-reverse;

  &:hover {
    .route:hover {
      .wh-size {
        opacity: 1;
      }

      .wh-state::before {
        opacity: 1;
      }
    }

    .downchain:hover + .route {
      .wh-size {
        opacity: 1;
      }

      .wh-state::before {
        opacity: 1;
      }
    }
  }

  .wh-size {
    position: relative;
    transition: 0.3s ease;
    opacity: 0;
    position: absolute;
    left: -1.5rem;
    bottom: 0;
    text-align: right;
    width: 1.5rem;

    &.s {
      color: var(--color6)
    }

    &::after {
      display: block;
      position: absolute;
      width: 1rem;
      height: 100rem;
      bottom: 29px;
      background: currentColor;
      backface-visibility: hidden;
    }

    &.xxl:after, &.xl:after, &.l:after, &.m:after, &.s:after {
      content: " "
    }

    &.xxl:after {
      left: 0.5rem;
      width: 1.5rem;
    }

    &.xl:after {
      left: 0.75rem;
      width: 1.25rem;
    }

    &.l:after {
      left: 1rem;
      width: 1rem;
    }

    &.m:after {
      left: 1.25rem;
      width: 0.75rem;
    }

    &.s:after {
      left: 1.5rem;
      width: 0.5rem;
    }

    &.half:after {
      color: var(--alert);
    }

    &.crit:after {
      color: var(--error);
    }

    &.lt4:after {
      animation-name: eol;
      animation-duration: 0.75s;
      animation-iteration-count: infinite;
      animation-direction: alternate;
      animation-timing-function: ease-in-out;
    }

    &.lt1:after {
      animation-name: eol;
      animation-duration: 0.25s;
      animation-iteration-count: infinite;
      animation-direction: alternate;
      animation-timing-function: ease-in-out;
    }
  }

  .icon {
    width: 2rem;
    height: 2rem;
  }

  .route {
    display: flex;
    align-items: center;
    transition: margin-top 0.3s ease;
    margin-top: 0;
    position: relative;
    margin: 0 0.5rem;

    &::before {
      content: " ";
      position: absolute;
      right: -0.5rem;
      left: 1rem;
      top: 2px;
      bottom: 3px;
      transition: 0.3s ease;
      opacity: 0;
    }

    &::after {
      content: " ";
      position: absolute;
      right: -0.5rem;
      bottom: 3px;
      left: 1rem;
      height: 1px;
      background: currentColor;
      opacity: 0;
      transition: opacity 0.3s ease;
      z-index: 2;
    }

    &.active::after {
      opacity: 1;
    }

    &.blue::before, &.red::before {
      animation-name: flare;
      animation-iteration-count: infinite;
      animation-direction: alternate;
      animation-timing-function: cubic-bezier(0.5, 0, 0.75, 0);
    }

    &.blue::before {
      background: var(--color6);
      animation-duration: 1s;
    }

    &.red::before {
      background: var(--color3);
      animation-duration: 0.5s;
    }
  }

  .names {
    flex-grow: 1;
    white-space: nowrap;

    .map-name, .sig-id {
      width: 1.5rem;
      text-align: right;
    }

    .hole-type {
      width: 2rem;
      text-align: center;
    }
  }

  .route  {
    .system-name {
      opacity: 0.5;
      position: relative;

      &:after {
        content: attr(data-meta);
        margin-left: 0.5rem;
        color: var(--base1);
        position: absolute;
        left: 100%;
      }
    }

    &.known .system-name {
      opacity: 1;
    }

    .names {
      display: flex;
      gap: 0.5rem;
      padding: 0.5rem 0;
      line-height: 1;
    }
  }

  .downchain {
    padding-left: 1.5rem;
    overflow: hidden;
  }

  .wh-state::after {
    content: " ";
    display: block;
    background: var(--base3);
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    position: absolute;
    z-index: 2;
    top: 0;
    left: 0;
  }
}

.chain.collapse {
  .wh-state svg {
    transform: rotate(-45deg);
  }

  .downchain .chain {
    margin-top: -2rem;
  }
}

