// ------------------------------------
// Posts

.Post {
  padding: var(--post-padding) var(--post-padding) var(--post-padding) 0;
  transition: 0.2s box-shadow, top 0.2s, opacity 0.2s;
  position: relative;
  top: 0;
  border-radius: var(--border-radius);
  .clearfix();

  &.editing {
    top: 5px;
    opacity: 0.5;
  }
}

.Post-header {
  margin-bottom: 15px;

  &, a, .Button--text.Button--link {
    color: var(--muted-color);
  }
  > ul {
    list-style-type: none;
    padding: 0;
    margin: 0;

    > li {
      display: inline;
      margin-right: 10px;
    }
  }

  .UserCard {
    position: absolute;
    top: 0;
    left: 0;
    z-index: var(--zindex-dropdown);
    transition: opacity 0.2s, transform 0.2s;
    transform: scale(0.95);
    transform-origin: left top;
    opacity: 0;

    &.in {
      transform: scale(1);
      opacity: 1;
    }
  }

  .Avatar {
    .Avatar--size(32px);
    vertical-align: middle;
    margin-right: 5px;
  }
}
.PostUser {
  margin: 0;
  display: inline;
  font-weight: normal;
  position: relative;

  .PostUser-name {
    display: inline;
  }
  .PostUser-name, .PostUser-name a {
    color: var(--heading-color);
    font-weight: bold;
    font-size: 14px;
  }

  .UserOnline {
    margin-right: 5px;

    & .icon {
      font-size: 12px;
    }
    & .fa-circle {
      color: var(--online-user-circle-color);
    }
  }
}
.PostUser-badges {
  text-align: right;
  white-space: nowrap;
  pointer-events: none;
}

.Post-body {
  font-size: 14px;
  line-height: 1.7;
  position: relative;
  overflow: auto;
  overflow-wrap: break-word;

  p, ul, ol, blockquote {
    margin-bottom: 1em;
  }
  a {
    border-bottom: 1px solid var(--control-bg);
    font-weight: 600;

    &:hover, &:focus, &:active {
      text-decoration: none;
      border-color: var(--link-color);
    }
  }
  blockquote {
    font-size: inherit;
    border: 0;
    background: var(--control-bg);
    color: var(--control-color);
    border-radius: var(--border-radius);
    padding: 8px 15px;
    border-top: 2px dotted var(--body-bg);
    border-bottom: 2px dotted var(--body-bg);
    margin: 1em 0;
  }
  // Inline code
  code {
    font-family: source-code-pro, Monaco, Consolas, "Courier New", monospace;
    padding: 5px;
    background: var(--code-bg);
    color: var(--code-color);
    line-height: 1.3;
    font-size: 90%;
    border-radius: 4px
  }
  // Code blocks
  pre {
    border: 0;
    padding: 0;
    background: var(--code-bg);
    color: var(--code-color);
    font-size: 90%;
    border-radius: var(--border-radius);
    overflow-wrap: normal;

    code {
      padding: 1em;
      background: none;
      color: inherit;
      line-height: inherit;
      font-size: 100%;
      border-radius: 0;
      display: block;
      overflow-x: auto;
      // Backwards compatibility for browsers that don't support `max()`
      max-height: 50vh;
      max-height: ~"max(50vh, 250px)";
    }
  }
  h1, h2, h3, h4, h5, h6 {
    margin-top: 1em;
    margin-bottom: 16px;
    font-weight: bold;
  }
  h1 {
    font-size: 225%;
  }
  h2 {
    font-size: 175%;
  }
  h3 {
    font-size: 150%;
  }
  h4 {
    font-size: 125%;
  }
  h5, h6 {
    font-size: 100%;
  }
  h6 {
    color: var(--muted-more-color);
  }
  img, iframe {
    max-width: 100%;
  }
}
.Post-body, .Post-preview {
  > *:first-child {
    margin-top: 0 !important;
  }
}

.Post--renderFailed {
  background-color: var(--control-danger-bg);
}

.Post--hidden {
  .Post-header, .Post-header a,
  .PostUser .PostUser-name, .PostUser .PostUser-name a {
    color: var(--muted-more-color);
  }
  &:not(.revealContent) {
    .Post-header {
      margin-bottom: 0;
    }
    .Post-body,
    .Post-footer,
    .Post-side > *,
    .PostUser-badges {
      display: none;
    }
  }
  .Post-body,
  .Post-footer,
  .Post-side > *,
  .PostUser-badges {
    opacity: 0.5;
  }
  .Post-header .Button--more {
    .Button--color-auto('muted-more');
  }
}
.Post--loading {
  opacity: 0.5;
}
.PostMeta {
  display: inline;
}
.PostMeta > .Button {
  line-height: 1;
  vertical-align: baseline;
}
.PostMeta .Dropdown-menu {
  width: 420px;
  padding: 10px;
  color: var(--muted-color);

  @media @phone {
    padding: 15px !important;
  }
}
.PostMeta-number {
  color: var(--text-color);
  font-weight: bold;
}
.PostMeta-time, .PostMeta-ip {
  margin-left: 5px;
}
.PostMeta-permalink {
  margin-top: 10px;

  a& {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.PostEdited {
  cursor: default;
}

.EventPost-icon {
  float: left;
}
.EventPost {
  &, a {
    color: var(--muted-color);
  }
  a {
    font-weight: bold;
  }
}
.EventPost-info {
  font-size: 14px;
}

.Post-footer, .Post-actions {
  > ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
  }
  &, a {
    color: var(--muted-color);
  }
  a {
    display: inline-block;

    .icon {
      display: none;
    }
  }
}
.Post-footer {
  display: inline-block;
  height: 0;
  margin-top: 5px;
  margin-bottom: 20px;

  > ul {
    > li {
      margin-bottom: 5px;
    }
  }
  .icon {
    font-size: 14px;
    margin-right: 5px;
  }

  &:empty {
    display: none;
  }
}
.Post-actions {
  margin-top: -5px;
  float: right;
  position: relative;

  transition: opacity 0.2s;

  .EventPost &, .Post--hidden:not(.revealContent) & {
    margin-top: -27px;
    margin-bottom: -15px;
  }

  @media @tablet-up {
    .no-touch & {
      opacity: 0;
    }
  }

  > ul {
    > li {
      margin-right: 0;
      margin-left: -5px;
      display: inline-block;
      vertical-align: top;
    }
  }
  .Post:hover &, .Post:focus-within &, &.openWithin {
    opacity: 1;
  }
}

.PostPreview {
  color: var(--muted-color);
  padding-left: 50px;
  line-height: 1.7em;

  .PostPreview-excerpt {
    word-wrap: break-word;
  }

  &-badge, .Avatar {
    float: left;
    margin-left: -50px;
    .Avatar--size(32px);
  }
  &-badge {
    color: var(--control-color);
  }
  .username {
    color: var(--text-color);
    font-weight: bold;
    margin-right: 5px;
  }
  time {
    margin-right: 5px;
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 600;
  }
}

@media @phone {
  .Post-side {
    .Post-avatar {
      display: none;
    }
  }
  .PostUser-badges {
    position: absolute;
    top: -12px;
    left: 6px;
    width: 32px;

    .Badge {
      .Badge--size(20px);
      margin-left: -13px;
    }
  }
  .EventPost {
    padding-left: 50px;
  }
  .EventPost-icon {
    font-size: 18px;
    margin-left: -30px;
    margin-top: 2px;
  }
}

@media @tablet-up {
  .Post-container {
    display: grid;
    grid-template-columns: var(--avatar-column-width) 1fr;
  }
  .Post-main {
    min-width: 0;
  }
  .CommentPost:not(.Post--hidden), .ReplyPlaceholder {
    min-height: 64px + 40px; // avatar height + padding
  }
  .Post-avatar {
    .Avatar--size(64px);
  }
  .Post-header .Post-avatar {
    display: none;
  }
  .PostUser-badges {
    float: left;
    position: relative;
    margin-left: calc(~"5px - var(--avatar-column-width)");
    margin-top: -3px;
    width: 64px;
  }
  .EventPost-icon {
    text-align: right;
    width: 64px;
    font-size: 22px;
  }
}

.ReplyPlaceholder {
  font-size: 15px;
  cursor: text;
  overflow: hidden;
  margin-top: 50px;
  margin-left: 0;
  padding-left: var(--post-padding);
  border: 2px dashed var(--control-bg);
  color: var(--muted-color);
  border-radius: 10px;
  background-color: transparent;
  display: block;
  appearance: none;
  -webkit-appearance: none;
  text-align: left;
  width: 100%;

  .Post-container {
    display: grid;
    grid-template-columns: var(--avatar-column-width) 1fr;

    @media @phone {
      grid-template-columns: auto 1fr;
      gap: 10px;
    }
  }

  .Post-header {
    margin: 0;
    color: inherit;
  }

  .Post-avatar {
    .Avatar--size(32px);
  }

  .Post-main {
    display: flex;
    align-items: center;
  }
}
@media @tablet-up {
  .ReplyPlaceholder {
    border-color: transparent;
    transition: border-color 0.2s;
    margin-left: calc(0px - var(--post-padding));
    width: calc(100% + var(--post-padding));

    .Post-header {
      position: relative;
    }
    &:hover {
      border-color: var(--control-bg);
    }
    .Post-avatar {
      .Avatar--size(64px);
    }
  }
  .LoadingPost .Post-header {
    position: relative;
  }
}
