@import '../../../../../styles/core.scss';

.SearchResults {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0 20px; // using psuedo element below for 20px padding-bottom
  display: flex;
  flex-flow: nowrap column;

  // FF ignores padding-bottom on scrollable containers https://bugzilla.mozilla.org/show_bug.cgi?id=748518
  &:after {
    content: '';
    display: block;
    flex: 0 0 auto;
    height: 20px;
    width: 100%;
  }

  &_empty {
    align-items: center;
    color: get(color 'graphite');
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: center;
    overflow-wrap: anywhere;
    padding: 80px 40px;
    text-align: center;

    :global(.Title) {
      margin-top: 0;
    }
  }

  :global(.icon) {
    color: var(--project-color-primary, get(color 'blue'));
    font-size: 20px;
    height: 20px;
    margin-bottom: 10px;
    width: 20px;
  }

  &-ScrollTo {
    flex: 0 0 auto;
    height: 20px;
  }

  &-Result {
    border-radius: 3px;
    color: get(color 'graphite');
    display: flex;
    cursor: pointer;
    flex-direction: column;
    padding: 9px 10px;
    text-decoration: none;
    transition: background .2s  cubic-bezier(.16,1,.3,1), color .2s  cubic-bezier(.16,1,.3,1);

    &:hover {
      background: get(color 'ivory');
    }

    &:active,
    &:focus {
      background: var(--project-color-primary, get(color 'blue'));
      color: var(--project-color-inverse, #fff);

      :global(.ais-Snippet-highlighted:after) {
        background: var(--project-color-inverse, #fff);
      }

      .SearchResults-Result-Project,
      .SearchResults-Result-Link {
        opacity: .5;
      }
    }

    &:focus {
      outline: none;
    }

    +.SearchResults-Result {
      margin-top: 2px;
    }

    &-Header {
      align-items: center;
      display: flex;

      +.SearchResults-Result-Excerpt :global(.ais-Snippet) {
        margin-top: 5px;
      }
    }

    &-Excerpt:empty {
      display: none;
    }

    // snippet highlight
    :global(.ais-Snippet-highlighted) {
      font-style: normal;
      position: relative;

      &:after {
        background: var(--project-color-primary, get(color 'blue'));
        border-radius: 2px;
        bottom: 0;
        content: '';
        display: block;
        height: 2px;
        left: 0;
        position: absolute;
        right: 0;
        transition: background .2s  cubic-bezier(.16,1,.3,1);
      }
    }

    &-Title {
      align-items: baseline;
      display: flex;
      font-weight: 600;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }

    &-Link {
      font-size: 11px;
      margin-left: 5px;
      margin-right: 5px;
      opacity: .5;
    }

    &-Project {
      font-size: 13px;
      font-weight: 400;
      margin-left: 5px;
      opacity: .5;

      &:before {
        content: 'in ';
        font-weight: normal;
      }
    }

    &-Excerpt {
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }

  // methods
  &-Method {
    border-radius: 3px;
    background: get(color 'shale');
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    height: 15px;
    line-height: 16px;
    margin-right: 5px;
    padding-left: 3px;
    padding-right: 3px;
    text-transform: uppercase;

    &_get {
      background: #6ebc60;
    }

    &_put {
      background: #9a718b;
    }

    &_post {
      background: #2c8fb0;
    }

    &_delete {
      background: #e27a7a;
    }
  }

  footer:last-child {
    // force pagination to bottom
    margin-top: auto;
  }
}
