$header-item-height: 60px;
$item-height: 50px;
$details-cell-width: 320px;
$timeline-cell-width: 180px;
$border-style: 1px solid $border-gray-normal;
$roadmap-gradient-dark-gray: rgba(0, 0, 0, 0.15);
$roadmap-gradient-gray: rgba(255, 255, 255, 0.001);
$scroll-top-gradient: linear-gradient(to bottom, $roadmap-gradient-dark-gray 0%, $roadmap-gradient-gray 100%);
$scroll-bottom-gradient: linear-gradient(to bottom, $roadmap-gradient-gray 0%, $roadmap-gradient-dark-gray 100%);
$column-right-gradient: linear-gradient(to right, $roadmap-gradient-dark-gray 0%, $roadmap-gradient-gray 100%);

@keyframes colorTransitionDetailsCell {
  from {
    background-color: $blue-100;
  }

  to {
    background-color: $white-light;
  }
}

@mixin roadmap-scroll-mixin {
  height: $grid-size;
  width: $details-cell-width;
  pointer-events: none;
}

html.group-epics-roadmap-html {
  height: 100%;
  // We need to reset this just for Roadmap page
  overflow-y: initial;
}

.with-performance-bar {
  .group-epics-roadmap-body {
    $header-size: $performance-bar-height + $header-height;
    height: calc(100% - #{$header-size});
  }
}

.group-epics-roadmap-body {
  height: calc(100% - #{$header-height});

  .page-with-contextual-sidebar {
    height: 100%;
  }

  .group-epics-roadmap {
    // This size is total of breadcrumb height and computed height of
    // filters container (70px)
    $header-size: $breadcrumb-min-height + 70px;
    height: calc(100% - #{$header-size});
  }

  .group-epics-roadmap-wrapper,
  .group-epics-roadmap .content {
    height: 100%;
  }
}

.epics-details-filters {
  .btn-group {
    .dropdown-toggle {
      border-top-right-radius: 0;
      border-bottom-right-radius: 0;
    }

    .btn-sort-direction {
      border-left: 0;

      &:hover {
        border-color: $gray-darkest;
      }
    }

    @include media-breakpoint-down(xs) {
      display: flex;

      .dropdown-menu-sort {
        // This is a hack to fix dropdown alignment in small screens
        // where Bootstrap applies inline `transform: translate3d(...)`
        // and since our dropdown button has sort direction button
        // present, alignment needs to compensate for that space
        // without which it appears shifted towards left.
        //
        // One more approach is to override `transform` using `!important`
        // but that too involves using magic number
        margin-left: 27px;
      }
    }
  }
}

.epics-roadmap-filters {
  .epics-details-filters {
    .btn-roadmap-preset {
      padding: 7px $gl-btn-padding;
    }
  }
}

.group-epics-roadmap-wrapper {
  padding-bottom: 0;
}

.breadcrumbs.group-epics-roadmap {
  border-bottom: $border-style;

  .breadcrumbs-container {
    border-bottom: 0;
  }
}

.roadmap-container {
  overflow: hidden;
  height: 100%;

  &.overflow-reset {
    overflow: initial;
  }
}

.roadmap-shell {
  position: relative;
  height: 100%;
  width: 100%;
  overflow-x: auto;

  .skeleton-loader {
    position: absolute;
    top: $header-item-height;
    width: $details-cell-width;
    height: 100%;
    padding-top: $gl-padding-top;
    padding-left: $gl-padding;
    z-index: 4;

    &::after {
      height: 100%;
    }
  }

  &.prevent-vertical-scroll {
    overflow-y: hidden;
  }
}

.roadmap-timeline-section .timeline-header-blank::after,
.epics-list-section .epic-details-cell::after,
.skeleton-loader::after {
  content: '';
  position: absolute;
  top: 0;
  right: -$grid-size;
  width: $grid-size;
  pointer-events: none;
  background: $column-right-gradient;
}

.roadmap-timeline-section {
  position: sticky;
  position: -webkit-sticky;
  top: 0;
  z-index: 20;

  .timeline-header-blank,
  .timeline-header-item {
    box-sizing: border-box;
    float: left;
    height: $header-item-height;
    border-bottom: $border-style;
    background-color: $white-light;
  }

  .timeline-header-blank {
    position: sticky;
    position: -webkit-sticky;
    top: 0;
    left: 0;
    width: $details-cell-width;
    z-index: 2;

    &::after {
      height: $header-item-height;
    }
  }

  .timeline-header-item {
    width: $timeline-cell-width;

    &:last-of-type .item-label {
      border-right: 0;
    }

    .item-label,
    .item-sublabel .sublabel-value {
      color: $gray-600;
      font-weight: 400;

      &.label-dark {
        color: $gray-900;
      }

      &.label-bold {
        font-weight: 600;
      }
    }

    .item-label {
      padding: $gl-padding-8 $gl-padding;
      border-right: $border-style;
      border-bottom: $border-style;
    }

    .item-sublabel {
      position: relative;
      display: flex;

      .sublabel-value {
        flex-grow: 1;
        flex-basis: 0;
        text-align: center;
        font-size: $code-font-size;
        line-height: 1.5;
        padding: 2px 0;
      }
    }

    .current-day-indicator-header {
      bottom: 0;
      height: $gl-vert-padding;
      width: $gl-vert-padding;
      background-color: $red-500;
      border-radius: 50%;
      transform: translateX(-2px);
    }
  }

  &.scroll-top-shadow .timeline-header-blank::before {
    @include roadmap-scroll-mixin;
    content: '';
    position: absolute;
    left: 0;
    bottom: -$grid-size;
    border-top: 1px solid $white-light;
    background: $scroll-top-gradient;
  }
}

.epics-list-section {
  height: calc(100% - 60px);

  .epics-list-item {
    &:hover {
      .epic-details-cell,
      .epic-timeline-cell {
        background-color: $gray-100;
      }
    }

    &.epics-list-item-empty {
      height: 100%;

      &:hover {
        .epic-details-cell,
        .epic-timeline-cell {
          background-color: $white-light;
        }
      }

      .epic-details-cell,
      .epic-details-cell::after,
      .epic-timeline-cell {
        height: 100%;
      }
    }

    &.newly-added-epic {
      .epic-details-cell {
        animation: colorTransitionDetailsCell 3s;
      }
    }

    .epic-details-cell,
    .epic-timeline-cell {
      box-sizing: border-box;
      float: left;
      height: $item-height;
      border-bottom: $border-style;
    }

    .epic-details-cell {
      position: sticky;
      position: -webkit-sticky;
      left: 0;
      width: $details-cell-width;
      padding: $gl-padding-8 $gl-padding;
      font-size: $code-font-size;
      background-color: $white-light;
      z-index: 10;

      &::after {
        height: $item-height;
      }

      .epic-title,
      .epic-group-timeframe {
        will-change: contents;
      }

      .epic-title {
        display: table;
        table-layout: fixed;
        width: 100%;

        .epic-url {
          display: table-cell;
          color: $gray-900;
          font-weight: 600;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
      }

      .epic-group-timeframe {
        color: $gray-700;
        width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
      }

      .epic-group:hover {
        cursor: pointer;
      }
    }

    .epic-timeline-cell {
      position: relative;
      width: $timeline-cell-width;
      background-color: transparent;
      border-right: $border-style;

      .current-day-indicator {
        top: -1px;
        width: 2px;
        height: calc(100% + 1px);
        background-color: $red-500;
        pointer-events: none;
      }

      .timeline-bar-wrapper {
        position: relative;
      }

      .timeline-bar {
        position: absolute;
        top: 12px;
        height: 24px;
        background-color: $blue-500;
        border-radius: $border-radius-default;
        opacity: 0.75;
        will-change: width, left;
        z-index: 5;

        &:hover {
          opacity: 1;
        }

        &.start-date-undefined {
          background: linear-gradient(to right, $roadmap-gradient-gray 0%, $blue-200 50%, $blue-500 100%);
        }

        &.end-date-undefined {
          background: linear-gradient(to right, $blue-500 0%, $blue-200 50%, $roadmap-gradient-gray 100%);
        }
      }

      &:last-child {
        border-right: 0;
      }
    }
  }

  .scroll-bottom-shadow {
    @include roadmap-scroll-mixin;
    position: fixed;
    bottom: 0;
    background: $scroll-bottom-gradient;
    z-index: 2;
  }
}
