@use '../../../../styles/_globals.scss' as *;

:host {
  --note-font-size: 14px;

  display: block;

  :host-context([dir='rtl']) {
    margin-right: unset;
  }
}

.note {
  @include noteStyle;

  overflow: hidden;

  &:hover,
  &.isFocused {
    transform-origin: center center;
    position: relative;
    z-index: 4;
    box-shadow: var(--whiteframe-shadow-3dp);
    //outline: 2px dashed var(--c-accent);
  }

  &.isFocused {
    z-index: 5;
  }

  &.isImg {
    border: 0;
  }
}

.controls {
  position: absolute;
  top: calc(var(--s) * -0.75);
  right: calc(var(--s) * -0.75);

  :host-context([dir='rtl']) & {
    position: absolute;
    right: unset;
    left: calc(var(--s) * -0.75);
  }

  // fixes drag and drop on mobile
  touch-action: none;

  @include mq(xs) {
    opacity: 0;
    transition: var(--transition-standard);

    .note:focus &,
    .note:hover & {
      opacity: 1;
    }
  }
}

.note-img {
  max-width: 100%;
  border-radius: var(--card-border-radius);
  cursor: zoom-in;
}

.content {
  text-align: start;
  font-size: var(--note-font-size);

  inline-markdown ::ng-deep {
    .markdown-wrapper {
      min-height: 40px;
    }

    .markdown-unparsed,
    .markdown-parsed {
      font-size: var(--note-font-size);
      border-radius: var(--card-border-radius);
      box-sizing: border-box;

      background: var(--standard-note-bg);
      color: var(--standard-note-fg);
      border-color: var(--extra-border-color);
    }

    .markdown-unparsed,
    .markdown-parsed > *:first-child {
      padding-right: calc(var(--s) * 1.25);
    }

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

// copied from inline-markdown component
.markdown-preview {
  border: 0;
  padding: var(--s) var(--s2);
  margin: 0;
  width: 100%;
  box-sizing: border-box;
  word-wrap: break-word;
  display: block;
  resize: none;
  min-height: 40px;
  overflow: hidden;
  cursor: text;
}

:host:hover .bottom-controls {
  opacity: 1;

  &.isOver {
    opacity: 0.8;
  }
}

.bottom-controls {
  display: flex;
  align-items: center;
  transition: var(--transition-standard);
  cursor: move;
  border-top: 1px dashed var(--extra-border-color);
  opacity: 0;
  position: relative;

  @include touchOnlyDevice() {
    opacity: 1;
  }

  @include mq(xs) {
    z-index: 1;
    margin-top: -8px;
  }

  &:active {
    cursor: grabbing;
  }

  &.isOver {
    background: inherit;
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
  }

  tag {
    margin: auto;
    pointer-events: none;
    opacity: 1;
  }

  button:first-of-type {
    margin-right: auto;
  }

  button:last-of-type {
    margin-left: auto;
    margin-right: 0;
  }

  .mat-mdc-icon-button {
    height: 36px;
    width: 36px;
    line-height: 36px;
  }
}
