@use 'sass:meta';
@use '../../scss/variables' as *;

.note-detail-wrapper {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  padding-top: 0;
  background-color: var(--background-color);
}

.note-detail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row;
  justify-content: center;
  transition: all 0.3s ease-in-out;

  div[data-contents] {
    padding-bottom: 20px;
  }
}

.note-detail-preview {
  overflow: auto;
}

.note-detail-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  flex: 1;

  .logo {
    width: 140px;
    height: 140px;
    opacity: 0.2;

    path {
      fill: var(--foreground-color);
    }
  }

  @media only screen and (max-width: $single-column) {
    display: none; // prevents flicker when closing note
  }
}

.note-detail-textarea,
.note-detail-markdown {
  width: 100%;
  height: 100%;
  border: 0;
  line-height: 1.5em;
  font-size: 16px;
  color: var(--primary-color);
  background: var(--background-color);
  resize: none;
  -webkit-tap-highlight-color: transparent;
  word-break: normal;
  overflow-wrap: anywhere;

  &:focus {
    outline: none;
  }
}

.note-detail-textarea {
  min-height: 100%;
  cursor: text;

  div,
  span {
    cursor: inherit;
  }

  .checkbox {
    cursor: pointer;
  }
}

body[data-theme='light'] .note-detail-markdown {
  @include meta.load-css(
    '../../node_modules/highlight.js/scss/base16/solarized-light'
  );
}

body[data-theme='dark'] .note-detail-markdown {
  @include meta.load-css(
    '../../node_modules/highlight.js/scss/base16/solarized-dark'
  );
}

.note-detail-markdown {
  overflow: visible;
  -webkit-overflow-scrolling: touch;

  p {
    margin: 0 0 1.5em;
    unicode-bidi: plaintext;
  }

  ul p {
    margin: 0;
  }

  a {
    cursor: pointer;
    overflow-wrap: break-word;
    word-wrap: break-word;
  }

  img {
    max-width: 100%;
    height: auto;
  }

  h1,
  h2,
  h3,
  h4,
  h5,
  h6 {
    line-height: 1.15;
  }

  h1 {
    font-weight: $light;
  }

  h5,
  h6 {
    text-transform: uppercase;
  }

  hr {
    border: 0;
    border-top: 1px solid var(--secondary-color);
  }

  blockquote {
    font-style: italic;
    border-left: 4px solid var(--secondary-color);
    margin-left: 0;
    padding-left: 1em;
  }

  $ul-padding-left: 1.4em;

  ul {
    padding-left: $ul-padding-left;
  }

  // Remove unneeded margin on root-level tasklist items
  & > ul > .task-list-item {
    margin-left: -#{$ul-padding-left};
  }

  .task-list-item {
    // It's good to have immediate CSS feedback on click since
    // there will be a slight delay until the checkbox actually toggles
    &:active {
      input {
        transform: scale(0.9);
      }
    }

    input {
      position: relative;
      bottom: 0.0625em;
      margin-right: 4px;
      height: 1em;
      vertical-align: middle;
    }
  }

  pre {
    border: 1px solid var(--tertiary-color);
    padding: 1em;
    border-radius: $border-radius;
    font-size: 85%;
  }

  p > code {
    background-color: var(--secondary-color);
    border-radius: 2px;
    padding: 3px;
  }

  table {
    border-collapse: collapse;
    border-spacing: 0;
    display: block;
    width: 100%;

    tr:nth-child(2n) {
      background-color: var(--secondary-color);
    }

    th,
    td {
      border: 1px solid var(--tertiary-color);
      padding: 6px 13px;
    }

    th {
      font-weight: 600;
    }
  }

  kbd {
    display: inline-block;
    padding: 3px 4px;
    line-height: 100%;
    color: #444d56;
    vertical-align: middle;
    background-color: #fafbfc;
    border: solid 1px #c6cbd1;
    border-bottom-color: #959da5;
    border-radius: 3px;
    box-shadow: inset 0 0 0 #959da5;
  }
}

.monaco-editor.monaco-editor .detected-link {
  text-underline-position: initial;
}
