/*
 * Markdown editor: GitHub's comment editor, written once for every place Forgejo renders its own
 * markdown editor: a bordered box whose toolbar carries the Write/Preview tabs, and a plain
 * attachment line instead of a dashed drop area. To style another editor, add its container to
 * the list. The release form keeps Forgejo's drop area and only takes the editor.
 */
:is(
    .page-content.repository.view.issue.github-conversation .comment.form,
    .page-content.repository.new.issue.github-issue-new,
    .review-box-panel,
    .comment-code-cloud,
    .page-content.repository.new.release
  )
  .combo-markdown-editor {
  border: 1px solid var(--color-light-border);
  border-radius: var(--border-radius);
  background: var(--color-body);
  & markdown-toolbar {
    background: var(--color-box-header);
    border-bottom: 1px solid var(--color-light-border);
  }
  & .markdown-toolbar-button {
    color: var(--color-text-light-1);
    width: 28px;
    height: 28px;
    padding: 6px;
    border: 0;
    background: transparent;
  }
  & textarea {
    background: var(--color-body);
    font-size: 14px;
    border: 1px solid var(--color-light-border);
    border-radius: var(--border-radius);
    box-shadow: none;
  }
  overflow: visible;

  & markdown-toolbar {
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    min-height: 38px;
    padding: 0 8px 0 0;
    gap: 8px;

    & .markdown-toolbar-group {
      flex: 0 0 auto;
    }
    & .switch {
      border: 0;
      background: transparent;
      border-radius: 0;
      margin: 0 auto -1px 0;
      min-height: 38px;
    }
    /* Forgejo overlaps neighbouring switch items with negative margins and paints the first one. */
    & .switch .item {
      height: 38px;
      min-height: 38px;
      margin: 0 !important;
      padding: 8px 16px !important;
      border: 1px solid transparent;
      border-radius: 0;
      background: transparent !important;
      box-shadow: none;
      outline: 0;
      color: var(--color-text-light-1);
      font-size: 14px;
      line-height: 21px;
      font-weight: 400;
    }
    & .switch .item:not(.active):hover {
      color: var(--color-text);
    }
    & .switch .item.active {
      border-right-color: var(--color-light-border);
      border-left-color: var(--color-light-border);
      border-bottom-color: var(--color-body);
      background: var(--color-body) !important;
      color: var(--color-text);
    }
    /* The editor's own border already draws the first tab's left edge. */
    & .switch .item.active:first-child {
      border-left-color: transparent;
      border-top-left-radius: var(--border-radius);
    }
    & .switch .item:focus-visible {
      outline: 2px solid var(--github-fgColor-accent);
      outline-offset: -2px;
    }
    & .switch .item.active::before,
    & .switch .item.active::after {
      display: none;
    }
  }
  & > .ui.tab.markup {
    background: var(--color-body);
    padding: 16px;
    min-height: 136px;
    font-size: 14px;
    line-height: 21px;
  }
  & textarea {
    margin: 8px;
    width: calc(100% - 16px);
    height: auto;
    min-height: 123px;
    max-height: calc(35lh + 18px);
    field-sizing: content;
    line-height: 21px;
    font-family: var(--fonts-proportional);
    padding: 8px;
  }
}
:is(
    .page-content.repository.view.issue.github-conversation .comment.form,
    .page-content.repository.new.issue.github-issue-new,
    .review-box-panel,
    .comment-code-cloud
  )
  .ui.dropzone {
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  & .dz-message {
    margin: 0;
    text-align: left;
  }
  & .dz-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    min-height: 32px;
    font-size: 12px;
    line-height: 18px;
    font-weight: 400;
    color: var(--color-text-light-1);
    background: transparent;
    border: 0;
    box-shadow: none;
  }
  border: 0 !important;
  & .dz-button {
    color: var(--color-text-light-1) !important;
  }
}

/* GitHub's attach control leads with a paperclip; Dropzone renders the button, so draw it in CSS. */
.page-content.repository.view.issue.github-conversation .comment.form .ui.dropzone .dz-button::before {
  content: "";
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  background-color: currentcolor;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M12.212 3.02a1.753 1.753 0 0 0-2.478.003l-5.83 5.83a3 3 0 0 0-.88 2.127c0 .795.315 1.551.88 2.116.567.567 1.333.89 2.126.89.79 0 1.548-.321 2.116-.89l5.48-5.48a.75.75 0 0 1 1.061 1.06l-5.48 5.48a4.5 4.5 0 0 1-3.177 1.33c-1.2 0-2.345-.487-3.187-1.33a4.48 4.48 0 0 1-1.32-3.177c0-1.195.475-2.341 1.32-3.186l5.83-5.83a3.25 3.25 0 0 1 5.553 2.297c0 .863-.343 1.691-.953 2.301L7.439 12.39c-.375.377-.884.59-1.416.593a2 2 0 0 1-1.412-.593 1.99 1.99 0 0 1 0-2.828l5.48-5.48a.75.75 0 0 1 1.042.018.75.75 0 0 1 .018 1.042l-5.48 5.48a.49.49 0 0 0 0 .707.5.5 0 0 0 .352.154.5.5 0 0 0 .356-.154l5.833-5.827a1.755 1.755 0 0 0 0-2.481Z'/%3E%3C/svg%3E")
    center / 16px no-repeat;
}
