.ui.feed {

  .requests-event-item {
    box-sizing: border-box;

    &.selected, &:target {
      & > .requests-event-container:not(.reply) > .requests-event-inner-container > .event {
        box-shadow: 0 0 0 2px @primaryColor;
      }

      & > .requests-event-container.reply {
        box-shadow: 0 0 0 2px @primaryColor;
        border-radius: @defaultBorderRadius;
        z-index: 1000;
      }
    }
  }

  .requests-event-container {
    position: relative;
    padding: @defaultPadding 0;

    &:not(.reply)::before {
      position: absolute;
      top: 0;
      bottom: 0;
      left: 4.5em;
      display: block;
      width: 2px;
      content: "";
      background-color: @borderColor;

      @media screen and (max-width: @largestMobileScreen) {
        left: .9rem;
      }
    }

    &:first-child {
      padding-top: 0;
    }

    &.reply {
      padding: (@eventPadding / 2) @eventPadding;

      &:hover {
        background-color: @whiteHover;
      }

      .requests-avatar-container {
        margin-top: 0;
      }

      .content {
        margin: 0;
      }

      .event {
        background: none;
      }
    }

    .timeline-comment-editor-container {
      padding: @eventPadding;
      padding-top: 0;
    }
  }

  .requests-avatar-container {
    padding-right: 0.5em;
    margin-top: 1rem;
    position: relative;

    @media screen and (max-width: @largestMobileScreen) {
      margin-top: 0;
    }

    img {
      max-height: 40px;
      width: auto;
    }

    &.has-line::before {
      content: "";
      position: absolute;
      display: block;
      top: 0;
      bottom: 0;
      // Half the width of the avatar minus the width of the line
      left: calc(1em - 2px);
      width: 2px;
      background-color: @borderColor;
      // Full height of the comment + the margin of the next comment
      height: calc(100% + 1rem);


      @media screen and (max-width: @largestMobileScreen) {
        & {
          display: none;
        }
      }
    }

    &.has-line.line-fade::before {
      background: linear-gradient(to top, #f9f9f9, @borderColor);
    }
  }

  .requests-reply-top-divider {
    margin-bottom: 0;
    border-bottom: none !important;
  }

  .requests-reply-container {
    padding-top: 0.5rem;
    background-color: #f9f9f9;

    .ui.message.warning {
      margin: 0.5rem;
    }
  }

  .requests-comment-fake-reply {
    display: flex;
    align-items: center;
    padding: @eventPadding;
    padding-top: 0;

    .requests-avatar-container {
      margin-top: 0;
    }

    .requests-comment-fake-reply-input {
      width: 100%;

      input:disabled {
        // This is overriden to `opacity: 1 !important` in the Invenio Theme so we need a clearer visual effect
        opacity: 0.45 !important;
      }
    }
  }

  .requests-event-inner-container {
    display: flex;
    width: 100%;

    @media screen and (max-width: @largestMobileScreen) {
      &:not(.thread){
        display: block;
      }
    }

    &.thread {
      margin-left: 3.75em;
      align-items: center;
      @media screen and (max-width: @largestMobileScreen) {
        margin-left: 0.60em;
      }
    }
  }

  .event {
    min-width: 0;
    width: 100%;
    flex: 1;
    border: @defaultBorder;
    border-radius: @defaultBorderRadius;
    background-color: @white;
    position: relative;

    @media screen and (max-width: @largestMobileScreen) {
      margin-top: .5rem;
    }

    .collapsible-comment {
      display: block;
      position: relative;

      .collapsible-comment-inner {
        display: block;
        overflow-y: hidden;
        overflow-x: auto;
        transition: max-height 300ms ease;
        max-height: @collapsibleHeight;
      }

      &.expanded .collapsible-comment-inner {
        max-height: none;
      }

      &.overflowing,
      &.expanded {
        margin-bottom: 50px;
      }

      &.overflowing::after {
        position: absolute;
        bottom: 0px;
        height: @collapsibleHeight;
        width: 100%;
        content: "";
        background: linear-gradient(transparent, var(--collapsible-color, @white));
      }

      &.expanded::after {
        display: none;
      }

      .show-more {
        position: absolute;
        bottom: -50px;
        left: 50%;
        right: 50%;
        transform: translate(-50%, -50%);
        width: 100px;
        z-index: 1000;
      }
    }

    .text {
      width: auto;

      &.extra blockquote {
        margin-left: 0.5rem;
        padding-left: 0.75rem;
        color: @mutedTextColor;

        & > blockquote {
          margin-left: 0;
        }
      }
    }

    .button.requests-reply-expand {
      margin-left: @eventPadding;
    }

    &.requests-action-event {
      border: 0;
      display: flex;
      align-items: center;

      .label{
        margin-right: 0.5 * @defaultMargin;
      }
    }

    .requests-event-container {
      --collapsible-color: #f9f9f9;

      &:hover {
        --collapsible-color: #f2f2f2;
      }
    }

    &.requests-reply-event {
      border: none;
      padding: 0;
      margin-left: 0.5rem;
    }

    p.requests-event-body-deleted {
      font-style: italic;
      color: @mutedTextColor;
    }

    &:not(.requests-reply-event) > .placeholder {
      margin: 1rem;
    }

    &.requests-reply-event > .placeholder {
      &, &::before, & .line, & .line::after{
        background-color: #f9f9f9;
      }
    }
  }

  .requests-action-event-icon {
    position: relative;
    padding: 1rem 0;

    .icon {
      background-color: @white;
    }
  }

  .requests-comment-fake-reply {
    display: flex;
    align-items: center;

    .requests-avatar-container {
      margin-top: 0;
    }
  }

  .requests-reply-count {
    background-color: @primaryColor;
    color: white;
    padding: 2px 4px;
    border-radius: @defaultBorderRadius;
    font-weight: normal;
    // Default font Helvetica has non-standard metrics so doesn't look middle-aligned on Firefox
    font-family: sans-serif;
    font-size: 0.75rem;
  }

  .requests-reply-caret {
    margin-left: 2px !important;
    // The button styles add a right margin when the `right` class is added, despite that just being
    // part of the icon name.
    margin-right: 0 !important;
  }

  .requests-reply-load-more {
    // Padding + width of avatar + padding on right-side of avatar + margin on left-side of main content
    margin-left: calc(@eventPadding + 28px + 1em + 0.5rem);
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    position: relative;
    color: @linkColor;
    font-weight: normal;

    &::before {
      content: "";
      position: absolute;
      display: block;
      top: 0;
      bottom: 0;
      // Margin on left-side of main content, padding on right-side of avatar, half width of line
      left: calc(-1rem - 1em);
      width: 2px;
      background: linear-gradient(to bottom, #f9f9f9, @borderColor);
      // Full height of the comment + the margin of the next comment
      height: calc(100% + 1rem);
    }

    @media screen and (max-width: @largestMobileScreen) {
      & {
        margin: 0.5rem @eventPadding;
        &::before {
          display: none;
        }
      }
    }
  }
}

/* First element after LoadMore component */
.ui.feed.after-load-more .requests-event-item:first-child .requests-event-container:not(.reply) {
  padding-top: 3em;
  &::before {
    background: linear-gradient(180deg, transparent 0, @borderColor 75%) !important;
  }
}

/* Last element before LoadMore component */
.ui.feed.before-load-more .requests-event-item:last-child .requests-event-container:not(.reply) {
  padding-bottom: 3em;
  &::before {
    background: linear-gradient(0deg, transparent 0, @borderColor 75%) !important;
  }
}

.requests-pagination-load-more {
  cursor: pointer;
}

.ui.feed {
  // override SUI defaults  to bypass immediate parent rule for feed
  .event > .content .user {
    display: inline-block;
    font-weight: @userFontWeight;
    margin-right: @userDistance;
    vertical-align: baseline;
  }

  .event > .content .user img {
    margin: @userImageMargin;
    width: @userImageWidth;
    height: @userImageHeight;
    vertical-align: @userImageVerticalAlign;
  }

  .event > .content {
    margin: @eventPadding;
  }

  /*--------------
     Inline Date
  ---------------*/

  /* Date inside Summary */

  .event > .content .summary > .date {
    display: @summaryDateDisplay;
    float: @summaryDateFloat;
    font-weight: @summaryDateFontWeight;
    font-size: @summaryDateFontSize;
    font-style: @summaryDateFontStyle;
    margin: @summaryDateMargin;
    padding: @summaryDatePadding;
    color: @summaryDateColor;
  }

  /*--------------
    Extra Summary
  ---------------*/

  .event > .content .extra {
    margin: @extraMargin;
    background: @extraBackground;
    padding: @extraPadding;
    color: @extraColor;
  }

  /* Images */

  .event > .content .extra.images img {
    display: inline-block;
    margin: @extraImageMargin;
    width: @extraImageWidth;
  }

  /* Text */

  .event > .content .extra.text {
    padding: @extraTextPadding;
    border-left: @extraTextPointer;
    font-size: @extraTextFontSize;
    line-height: @extraTextLineHeight;

  }

  /* User uploaded images within text */
  .event > .content .extra.text img {
    max-width: 100%;
    height: auto;
  }

  /*--------------
        Meta
  ---------------*/

  .event > .content .meta {
    display: @metadataDisplay;
    font-size: @metadataFontSize;
    margin: @metadataMargin;
    background: @metadataBackground;
    border: @metadataBorder;
    border-radius: @metadataBorderRadius;
    box-shadow: @metadataBoxShadow;
    padding: @metadataPadding;
    color: @metadataColor;
  }

  .event > .content .meta > * {
    position: relative;
    margin-left: @metadataElementSpacing;
  }

  .event > .content .meta > *:after {
    content: @metadataDivider;
    color: @metadataDividerColor;
    top: 0;
    left: @metadataDividerOffset;
    opacity: 1;
    position: absolute;
    vertical-align: top;
  }

  .event > .content .meta .like {
    color: @likeColor;
    transition: @likeTransition;
  }

  .event > .content .meta .like:hover .icon {
    color: @likeHoverColor;
  }

  .event > .content .meta .active.like .icon {
    color: @likeActiveColor;
  }

  /* First element */

  .event > .content .meta > :first-child {
    margin-left: 0em;
  }

  .event > .content .meta > :first-child::after {
    display: none;
  }

  /* Action */

  .event > .content .meta a,
  .event > .content .meta > .icon {
    cursor: @metadataActionCursor;
    opacity: @metadataActionOpacity;
    color: @metadataActionColor;
    transition: @metadataActionTransition;
  }

  .event > .content .meta a:hover,
  .event > .content .meta a:hover .icon,
  .event > .content .meta > .icon:hover {
    color: @metadataActionHoverColor;
  }
}

.ui.popup.requests-event-body-popup {
  padding: 0;
  border: none;

  .ui.button {
    margin: 0;
  }
}

.requests-placeholder-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  margin-right: 0.75rem;
  position: relative;
  z-index: 9999;
}

.requests-placeholder-event-icon {
  width: 24px;
  height: 21px;
  z-index: 9999;
}

.requests-placeholder-avatar-icon {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin-right: 5px;
}

.requests-placeholder-summary-line {
  width: 150px;
}
