/* The conversation of an issue or pull request as templates/repo/issue/view.tmpl renders it, marked
   github-conversation: the header, timeline, comments and sidebar. These rules were part of the theme stylesheets; they
   load right after the theme, before the component and page stylesheets. */

.page-content.repository.view.issue.github-conversation {
  & > .ui.container {
    width: calc(100% - 64px) !important;
    max-width: 1232px !important;
    margin: 24px auto !important;
  }
  & .issue-title-header {
    margin: 0 0 24px;
    padding: 0;
  }
  & .issue-title {
    align-items: flex-start;
    gap: 16px;
  }
  & .issue-title h1 {
    margin: 0;
    font-size: 32px;
    line-height: 40px;
    font-weight: 400;
  }
  & .issue-title h1 .index {
    color: var(--color-text-light-1);
    font-weight: 300;
  }
  & .issue-title-meta {
    margin-top: 12px;
    min-height: 32px;
  }
  &.github-issue-conversation .issue-title-meta .time-desc {
    display: none;
  }
  & .issue-state-label {
    height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    line-height: 20px;
    border-radius: 20px !important;
  }
  & .issue-content {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 288px;
    gap: 32px;
  }
  & .issue-content img.ui.avatar {
    border-radius: 50%;
  }
  & .issue-content-left {
    min-width: 0;
    width: auto;
  }
  & .issue-content-right {
    &.ui.segment {
      width: auto;
      padding: 0;
      margin: 0;
      border: 0;
      box-shadow: none;
      min-width: 0;
      font-size: 12px;
    }
    & .divider {
      margin: 16px 0;
      border-color: color-mix(in srgb, var(--color-light-border) 70%, transparent);
      width: 100%;
    }
    & strong {
      font-size: 12px;
      font-weight: 600;
      color: var(--color-text-light-1);
    }
    & .ui.list {
      margin: 0;
      padding: 0;
    }
    & .ui.avatar {
      width: 20px;
      height: 20px;
    }
    /* The sidebar's values; the pickers' triggers and menus are the theme's issue_picker. */
    & :is(.ui.form, .no-select, p, .text):not(:where(.ui.dropdown > *, .ui.dropdown > .menu *)) {
      font-size: 12px;
      line-height: 18px;
      color: var(--color-text-light-1);
    }
    & > .ui.labels {
      margin: 0;
    }
    & .ui.button {
      min-height: 28px;
      font-size: 12px;
      line-height: 20px;
    }
    & .assignees .item {
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 0;
    }
    /* A reviewer's row: the name, then small muted actions and the review state. */
    & .assignees .item .sidebar-item-link {
      font-weight: 600;
    }
    & .assignees .item :is(.show-modal, .re-request-review) {
      display: grid;
      place-items: center;
      width: 16px;
      height: 16px;
      color: var(--color-text-light-1);
      &:hover {
        color: var(--github-fgColor-accent);
      }
    }
    & .assignees .item svg {
      width: 16px;
      height: 16px;
    }
    & .watching .ui.button {
      height: 28px;
      padding: 3px 8px;
    }

    & [data-modal="#sidebar-delete-issue"] {
      color: var(--color-red);
    }

    & .timetrack > div > .ui.button {
      display: inline-flex;
      align-items: center;
      justify-content: flex-start;
      gap: 8px;
      height: 28px;
      min-height: 28px;
      padding: 3px 8px;
    }
    & :is(.timetrack > div, .single-button-form) > .ui.button > svg {
      margin: 0 !important;
      flex: 0 0 16px;
    }
    & > .single-button-form {
      margin: 0;
    }
    & .single-button-form > .ui.button,
    & > .ui.show-modal.button {
      border: 0;
      background: transparent;
      box-shadow: none;
      justify-content: flex-start;
      margin: 0 !important;
      font-weight: 400;
      display: flex;
      align-items: center;
      gap: 8px;
      height: 28px;
      min-height: 28px;
      padding: 4px 0;
      & > svg {
        width: 16px;
        height: 16px;
        margin: 0 !important;
      }
      &:hover {
        color: var(--github-fgColor-accent);
      }
    }
    & .reference > .ui {
      align-items: center;
      gap: 8px;
    }
    & .reference .ui.button {
      flex: 0 0 28px;
      width: 28px;
      height: 28px;
      min-height: 28px;
      padding: 6px !important;
      border: 0;
      background: transparent;
      box-shadow: none;
    }
    & .ui.action.input:has(> .selection.dropdown > .text > .text) {
      height: auto;
      align-items: stretch;
      & > .ui.selection.dropdown {
        height: auto;
        min-height: 50px;
        padding: 6px 32px 6px 12px;
        & > .text {
          display: block;
          line-height: 18px;
          white-space: nowrap;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        & > .text > .text {
          line-height: 18px;
          overflow: hidden;
          text-overflow: ellipsis;
        }
        & > .dropdown.icon {
          top: 50%;
          transform: translateY(-50%);
          padding-top: 0;
        }
      }
      & > .ui.button {
        height: auto;
      }
    }
    & #deadline-loader {
      margin-top: 8px;
    }
    & .issue-due-form {
      height: 28px;
      & input {
        min-width: 0;
        height: 28px;
        padding: 3px 8px;
        font-size: 12px;
        background: var(--color-body);
        box-shadow: none;
      }
      & .ui.button {
        width: 28px;
        height: 28px;
        min-height: 28px;
        padding: 5px;
      }
    }
  }

  & .issue-content-left > .ui.timeline {
    margin-left: 0;
    padding-left: 0;
  }
  /* The timeline line runs 16px inside the comment boxes, where the other entries start, on phones too, as on GitHub;
     the theme puts both on the edge of Forgejo's own phone layout. */
  & .ui.timeline {
    --timeline-line-start: 16px;
  }
  & .ui.timeline > .timeline-item:not(.comment) {
    --timeline-entry-start: 16px;
  }
  /* Comment boxes start at the timeline's edge; the timeline line runs behind them. */
  & .ui.timeline > .timeline-item.comment {
    --timeline-entry-start: 0px;

    & > .content {
      margin-left: 0;
    }
  }
  & .timeline-item.comment > .timeline-avatar {
    display: none;
  }
  & .comment-header .inline-timeline-avatar {
    display: inline-flex !important;
    margin-right: 8px;
  }
  & .comment-header .inline-timeline-avatar img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
  }
  & .comment .comment-container {
    position: relative;
    background: var(--color-body);
    border-color: var(--conversation-border, var(--color-light-border));
  }
  & .comment .comment-header {
    min-height: 38px;
    padding: 4px 4px 4px 8px;
    background: var(--color-box-header);
    border-color: var(--color-light-border);
    font-size: 14px;
    line-height: 20px;
  }
  & .comment .comment-header-left {
    min-width: 0;
  }
  & .comment-header-left {
    & > .text {
      font-size: 14px;
      font-weight: 400;
      line-height: 20px;
    }
    & a:has(relative-time) {
      text-decoration: none !important;
    }
  }
  /* The issue's "opened … by <author>" sentence comes from Forgejo's translation, so its author link has no classes. */
  & .comment.first .comment-header-left > .text > a:not(.author, :has(relative-time)) {
    color: var(--color-text);
    font-weight: 600;
  }
  & .comment-header .role-label {
    border: 1px solid var(--color-light-border);
    border-radius: 20px;
    padding: 0 6px;
    font-size: 12px;
  }
  & .comment .comment-body {
    padding: 16px;

    & .markup {
      font-size: 14px;
      line-height: 21px;
    }
    & .markup h2 {
      font-size: 24px;
    }
    & .markup h3 {
      font-size: 20px;
    }
    & .markup pre {
      padding: 16px;
      font-size: 12px;
      line-height: 18px;
    }
  }
  /* GitHub's issue view: the comment boxes span the timeline, and the line runs 20px inside them, where the events
     start. */
  &.github-issue-conversation {
    & .ui.timeline {
      --timeline-line-start: 20px;
    }
    & .comment-list .timeline-item.event {
      --timeline-entry-start: 20px;
      margin-block: 0;
      padding-left: 24px;
    }
    & .comment.first {
      padding-bottom: 0;
    }
    /* 16px more above the first event, inside it, so the line runs on through the space. */
    & .comment.first ~ .timeline-item.event:nth-child(1 of .timeline-item.event) {
      padding-top: 29px;
    }
  }
  & .comment-editor-heading {
    font-size: 16px;
    line-height: 24px;
    font-weight: 600;
    margin: 0 0 8px;
  }
  /* GitHub lines the avatar up with the "Add a comment" heading, not with the editor below it. */
  & .comment.form > .timeline-avatar {
    top: 0 !important;
  }
  /* 16px below GitHub's 2px rule that closes the timeline. */
  & .comment.form {
    z-index: 1;
    margin-top: 16px;
    padding: 0;
    background: var(--color-body);
    & #comment-form {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      gap: 8px;
      border: 0;
      padding: 0;
      background: transparent;
      box-shadow: none;
      & > .field {
        margin: 0;
        min-width: 0;
      }
      & > .field:first-child {
        grid-column: 1 / -1;
      }
      & > .field.footer {
        grid-column: 2;
      }
      & .button {
        height: 32px;
        min-height: 32px;
        padding: 5px 12px;
        font-size: 14px;
        line-height: 20px;
      }
      & #status-button svg {
        color: var(--github-borderColor-done-emphasis);
      }
    }
  }

  &.own-conversation .comment.first {
    & .comment-container {
      --conversation-border: rgb(from var(--github-bgColor-accent-muted) r g b / 0.4);
    }
    & .comment-header {
      background: var(--github-bgColor-accent-muted);
      border-color: var(--conversation-border);
    }
    & .role-label {
      border-color: var(--conversation-border);
    }
  }
  & .conversation-body-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 24px;
  }
  & .comment-container {
    & .conversation-body-actions .ui.dropdown.select-reaction > .menu {
      left: 0 !important;
      right: auto !important;
    }
    /* GitHub's picker: two rows of four 32px buttons, filled column by column. */
    & .ui.dropdown.select-reaction > .menu.reactions-menu.visible {
      display: grid !important;
      grid-template-rows: repeat(2, 40px);
      grid-auto-flow: column;
      grid-auto-columns: 36px;
      width: max-content;
      min-width: 0;
      padding: 0 2px;
      border-radius: var(--border-radius);
      & > .item.reaction {
        display: flex;
        align-items: center;
        justify-content: center;
        float: none;
        width: 32px;
        height: 32px;
        margin: 4px 2px !important;
        padding: 4px !important;
        border-radius: var(--border-radius);
        font-size: 14px;
        line-height: 1;
      }
    }
    &:has(> .reactions .comment-reaction-button) .conversation-body-actions {
      display: none;
    }
  }
  & .comment-header-right {
    gap: 8px;
  }
  & .comment-header .context-dropdown {
    display: grid;
    place-items: center;
    margin: 0;
    padding: 0;
    width: 28px;
    height: 28px;
  }

  @media (max-width: 767.98px) {
    & .comment.form #comment-form {
      grid-template-columns: minmax(0, 1fr);
      & > .field.footer {
        grid-column: 1;
      }
    }

    & > .ui.container {
      width: calc(100% - 32px) !important;
      margin: 16px !important;
    }
    & .issue-title {
      flex-wrap: wrap;
    }
    & .issue-title h1 {
      font-size: 24px;
      line-height: 32px;
    }
    & .issue-content {
      grid-template-columns: minmax(0, 1fr);
    }
    & .issue-content-right.ui.segment {
      border-top: 1px solid var(--color-light-border);
      padding-top: 16px;
    }
    & .comment-header {
      flex-wrap: wrap;
      gap: 4px;
    }
    & .comment-header-left > .text {
      font-size: 12px;
    }
    & .comment .comment-body {
      padding: 12px;
    }
  }
  /* Forgejo forces .text.grey to --color-text-light, which this theme maps to the default text colour. */
  & .comment-header-left > .text.grey {
    color: var(--color-text-light-1) !important;
    & b,
    & b a {
      color: var(--color-text);
    }
  }
  & .comment .markup p {
    line-height: inherit;
  }
  & .comment-list .timeline-item.commits-list .singular-commit {
    min-height: 36px;
    /* A commit's muted 16px icon sits on a page-coloured disc that cuts the timeline line around it. Forgejo's badge
         rule already centres the icon in a round, border-box badge. */
    & > .badge.badge-commit {
      flex: none;
      width: 32px;
      height: 16px !important;
      /* Centred on the timeline line, 15px into the list, with the commit text where it was. */
      margin: 0 7px 0 -30px;
      background: var(--color-body);
      color: var(--color-text-light-1);
      & > svg {
        width: 16px;
        height: 16px;
        padding: 0;
      }
    }
    /* GitHub sets the first commit of a push apart: a taller row and its icon in a filled circle. */
    &:first-child {
      min-height: 64px;
      /* An unfolded body stays right under the title, inside the row's padding. */
      &:has(+ .commit-body:not(.tw-hidden)) {
        min-height: 48px;
        padding-top: 16px;
      }
      & > .badge.badge-commit {
        height: 32px !important;
        border: 2px solid var(--color-body);
        background: var(--github-control-bgColor-rest);
      }
    }
    /* Forgejo's utilities are !important. */
    & > .gt-ellipsis.tw-flex-1 {
      flex: 0 1 auto !important;
    }
    & > .shabox {
      margin-left: auto;
    }
    /* A commit with a body: GitHub's small "…" pill right after the message, not a full button by the hash. */
    & > .ellipsis-button.ui.button {
      flex: none;
      min-width: 0;
      min-height: 0;
      height: 12px;
      margin: 0 0 0 5px;
      padding: 0 5px;
      border: 0;
      border-radius: 1px;
      background: color-mix(in srgb, var(--github-bgColor-neutral-emphasis) 20%, transparent);
      box-shadow: none;
      color: var(--color-text);
      font-size: 12px;
      font-weight: 600;
      line-height: 6px;
      &:hover {
        background: var(--github-control-transparent-bgColor-active);
      }
    }
  }
  /* The unfolded body: muted 12px monospace under the avatar. */
  & .comment-list .timeline-item.commits-list > .commit-body {
    margin: 0 0 8px 9px !important;
    color: var(--color-text-light-1);
    font-size: 12px;
    line-height: 18px;
  }
  & .comment-list .timeline-item.commits-list > .singular-commit:first-child + .commit-body {
    margin-bottom: 16px !important;
  }
  /* Commits listed in the timeline: a plain, muted seven-character hash. */
  & .comment-list .timeline-item.commits-list .shabox .sha.label {
    min-height: 0;
    height: auto;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--color-text-light-1);
    font-size: 12px;
    font-weight: 400;
    line-height: 18px;
    &:hover {
      background: transparent;
      box-shadow: none;
      color: var(--color-primary);
    }
    & .shortsha {
      display: inline-block;
      max-width: 7ch;
      padding: 0;
      overflow: hidden;
      white-space: nowrap;
      vertical-align: bottom;
    }
  }
}
