// Timeline
//================================================== //
// See also: /sass/controls/_processindicator.scss

.timeline {
  min-height: 44px;
  position: relative;

  // vertical line
  &::before {
    border-left: 1px dashed $timeline-line-color;
    bottom: 60px;
    content: '';
    left: 1.125em;
    position: absolute;
    top: 0;
    width: 3px;
    height: var(--timeline-height, calc(80% + 12px));
  }

  .indicator {
    border: 2px solid $timeline-indicator-color;

    &.processing {
      border: 2px solid $timeline-indicator-processing-color;
    }

    &.complete {
      background-color: $timeline-indicator-complete-color;
      border: 2px solid $timeline-indicator-complete-color;
    }
  }
}

.timeline-block {
  margin-bottom: $input-field-bottom-margin;
  position: relative;

  // micro-clearfix
  &::after {
    clear: both;
    content: '';
    display: table;
  }

  &:last-child {
    margin-bottom: 0;
  }

  .date {
    margin-left: 5em;

    > * {
      vertical-align: middle;
    }

    > span {
      @include font-size(12);

      line-height: 1.5rem;
    }

    > .icon {
      height: 18px;
      margin-right: 2px;
      width: 18px;
    }
  }

  .indicator-container {
    float: left;
    position: relative;
    text-align: center;
    width: 2.5em;

    > * {
      vertical-align: middle;
    }

    // line behind the indicator
    &::before {
      background-color: transparent;
      border-bottom: 1px dashed $timeline-line-color;
      content: '';
      display: inline-block;
      height: 0;
      left: 1.5em;
      position: absolute;
      top: 0.7em;
      width: 100%;
    }
  }

  .content {
    margin-left: 5em;

    .heading {
      color: $timeline-header-color;
    }

    > *:last-child {
      margin-bottom: 0;
    }

    .summary-form:last-child {
      .field:last-child {
        margin-bottom: 0;
      }
    }
  }
}

@mixin mobile-timeline() {
  .card .timeline,
  .widget .timeline {
    &::before {
      bottom: 60px;
    }
  }

  .timeline-block {
    &:nth-last-child(2)::before {
      visibility: hidden;
    }

    .date,
    .indicator-container,
    .content {
      float: left;
    }

    .date {
      margin-left: 0;
      width: 11em;
    }

    .indicator-container {
      margin-left: 0;
    }

    .content,
    .date {
      margin-left: 5em;
      float: none;
    }

    .date {
      width: auto;
    }
  }
}

@media (min-width: $breakpoint-phone-to-tablet) {
  @include mobile-timeline();
}

.card .timeline,
.widget .timeline {
  margin-left: 20px;
  margin-top: 20px;
}

.column {
  &.one-third {
    .card .timeline,
    .widget .timeline {
      &::before {
        bottom: 60px;
      }

      .timeline-block {
        &:nth-last-child(2)::before {
          visibility: hidden;
        }

        .indicator-container {
          margin-left: 0;
        }

        .content,
        .date {
          margin-left: 5em;
          float: none;
        }

        .date {
          width: auto;
          top: 85%;
        }
      }
    }
  }
}

// RTL Styles
html[dir='rtl'] {
  .timeline {
    // vertical line
    &::before {
      border-left: 0;
      border-right: 1px dashed $timeline-line-color;
      left: auto;
      right: 1.125em;
    }
  }

  .timeline-block {
    &:nth-last-child(2) {
      &::before {
        right: 1em;
      }
    }

    .date {
      margin-left: inherit;
      margin-right: 5em;

      > .icon {
        margin-left: 2px;
      }
    }

    &:has(.summary-form) .date {
      margin-right: 5em;
    }

    .indicator-container {
      float: right;

      &::before {
        left: auto;
        right: 1.5em;
      }
    }

    .content {
      margin-left: inherit;
      margin-right: 5em;
    }
  }

  .card .timeline .timeline-block .date,
  .widget .timeline .timeline-block .date {
    margin-right: 2.5em;

    .icon {
      margin-right: inherit;
    }
  }

  .column.one-third .widget .timeline .timeline-block .date {
    margin-left: auto;
  }

  @media (min-width: $breakpoint-phone-to-tablet) {
    .timeline {
      &::before {
        left: auto;
      }
    }

    .timeline-block {
      .date {
        margin-left: inherit;
        margin-right: 5em;
      }

      .indicator-container {
        margin-left: inherit;
      }

      .content {
        margin-left: inherit;
      }
    }
  }
}
