@use '../../scss/variables' as *;

@keyframes announce-note-update {
  0% {
    padding-left: 8px;
  }

  50% {
    padding-left: 16px;
  }

  100% {
    padding-left: 8px;
  }
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.note-list {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow: hidden;
  background: inherit;
  background-color: var(--background-color);

  .comfy .note-list-item-excerpt {
    white-space: nowrap;
  }

  .condensed {
    .note-list-item {
      min-height: 43px;
    }

    .note-list-item-status {
      align-items: center;
      padding-bottom: 3px;
      padding-top: 0;
    }

    .note-list-item-text {
      padding-bottom: 0;
      padding-top: 0;
    }

    .note-list-item-excerpt {
      display: none;
    }
  }

  .expanded .note-list-item-excerpt {
    white-space: normal;
    max-height: 63px;
  }

  &.is-empty {
    align-items: center;
    justify-content: center;
    height: 100vh;
  }

  .note-list-item .search-match {
    background-color: transparent;
    color: var(--accent-color);
    padding-left: 0;
    padding-right: 0;
    border-radius: 0;
  }
}

.note-list-placeholder {
  font-size: 1.5em;
  text-align: center;

  .no-notes-icon svg {
    width: 48px;
    height: 48px;
    margin-bottom: 8px;
    color: var(--secondary-accent-color);
  }

  .no-notes-message {
    font-size: 16px;
    color: var(--foreground-color);
  }

  button {
    color: var(--accent-color);
    display: block;
    font-size: 14px;
    margin-top: 8px;
  }
}

.note-list-items {
  flex: 1 1 auto;
  overflow: hidden;
  -webkit-overflow-scrolling: touch;

  div:focus {
    outline: none;
  }
}

.note-list-empty-trash {
  flex: none;
  padding: 10px 20px;
  border-top: 1px solid var(--secondary-color);
  text-align: center;
}

.note-list-header {
  width: 100%;
  height: 28px;
  font-size: 14px;
  font-weight: 500;
  line-height: normal;
  color: var(--foreground-color);
  padding: 5px 16px;
}

.note-list-item {
  cursor: pointer;
  display: flex;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  font-family: 'Simplenote Tasks', $sans, sans-serif;
  min-height: 64px;

  .note-list-item-content {
    display: flex;
    width: 100%;
  }

  .note-list-item-status {
    display: flex;
    padding: 12px 0 0;
    width: 28px;
    flex-shrink: 0;
  }

  .note-list-item-pinner {
    color: transparent;
    height: 16px;
    width: 16px;
    margin: 0 auto;

    svg {
      vertical-align: top;
    }
  }

  .note-list-item-text {
    flex: 1 1 auto;
    overflow: hidden;
    padding: 9px 0;
    border-bottom: 1px solid var(--secondary-color);
  }

  .note-list-item-title,
  .note-list-item-excerpt {
    white-space: nowrap;
    text-align: left;
    text-overflow: ellipsis;
    overflow: hidden;
  }

  .note-list-item-excerpt {
    color: var(--foreground-color);
  }

  &:not(.note-list-item-pinned):hover .note-list-item-pinner {
    color: var(--foreground-color);
  }

  &:not(.note-list-item-selected) {
    &:hover {
      background: var(--alternative-highlight-color);
    }
  }

  &.note-recently-updated {
    animation: announce-note-update 0.4s ease-in-out;
    animation-iteration-count: 3;
  }

  .note-list-item-status-right {
    display: flex;
    padding: 9px 6px 0 0; // we want 10px total to the right side, but the icon has 4px padding already
    border-bottom: 1px solid var(--secondary-color);
  }

  .note-list-item-pending-changes,
  .note-list-item-published-icon {
    padding: 0 4px;
    color: var(--foreground-color);

    & svg {
      height: 16px;
      width: 16px;
    }
  }

  .note-list-item-pending-changes {
    & svg {
      animation: 2s spin infinite linear;
    }

    &.is-offline svg {
      animation: none;
      fill: var(--tertiary-color);
    }
  }

  .note-list-item-title {
    display: flex;
    justify-content: space-between;
    font-size: 16px;
    font-weight: 500;
    color: var(--primary-color);

    & span {
      text-overflow: ellipsis;
      overflow: hidden;
    }
  }

  &.note-list-item-pinned:not(.note-list-item-selected) {
    .note-list-item-pinner {
      color: var(--accent-color);
    }
  }

  &.note-list-item-selected {
    background: var(--highlight-color);

    .note-list-item-excerpt {
      color: var(--primary-color);
    }

    .note-list-item-pending-changes,
    .note-list-item-published-icon {
      color: var(--primary-color);
    }

    &.note-list-item-pinned .note-list-item-pinner {
      color: var(--primary-color);
    }
  }
}
