@use "lib/viewport";

.archetype-private_message {
  --pm-padding: 1.25em;

  .topic-post {
    @include viewport.from(sm) {
      margin-bottom: 0.5em;
    }

    @include viewport.until(sm) {
      article {
        border-top: none;
      }
    }

    &:last-child {
      margin-bottom: 1.5em;
    }
  }

  .regular.contents {
    border-radius: var(--d-border-radius);
    border: 1px solid var(--content-border-color);
    padding-left: var(--pm-padding);
    margin-left: calc(var(--pm-padding) * -1);

    @include viewport.until(sm) {
      margin-left: 0;
      padding: 1.5em 1em 0;
    }
  }

  .topic-avatar,
  .topic-body {
    border: none;
  }

  @include viewport.until(sm) {
    .topic-avatar {
      margin-bottom: -1em; // intentional overlap
    }
  }

  .topic-body {
    @include viewport.until(sm) {
      .topic-body {
        flex: 1 1 auto;
      }
    }

    .cooked {
      box-sizing: border-box;
      margin-top: 0.25em;
      padding-right: calc(var(--topic-body-width-padding) * 2);

      @include viewport.until(sm) {
        padding: 0;
        margin: 0;
      }
    }
  }

  .post-menu-area {
    margin: 0.5em 0 var(--topic-body-width-padding);

    @include viewport.from(sm) {
      padding-right: var(--topic-body-width-padding);
    }
  }

  .who-liked {
    box-sizing: border-box;
    padding-right: var(--topic-body-width-padding);
  }

  .post-notice {
    box-sizing: border-box;
    border-radius: var(--d-border-radius);
    background-color: var(--tertiary-very-low);
    border-color: var(--tertiary-very-low);
    margin-bottom: 1em;
    padding: var(--pm-padding) 1em;
    width: 100%;
    max-width: calc(
      var(--topic-body-width) + var(--topic-body-width-padding) * 2 +
        var(--topic-avatar-width) - 1.65em
    );

    @include viewport.from(sm) {
      margin-left: 1.65em;
      padding-inline: 2em;
    }

    &.old {
      border: 1px solid var(--content-border-color);

      @include viewport.until(sm) {
        padding-top: var(--pm-padding);
      }
    }
  }

  .topic-map {
    border: none;
    padding-block: var(--pm-padding);
    display: grid;
    grid-template-areas: "contents additional" "pm-map pm-map";
    grid-template-columns: 1fr auto;
    border-radius: var(--d-border-radius);

    @include viewport.from(sm) {
      padding-left: calc(
        48px - var(--pm-padding)
      ); // 48px is the width of the avatar
    }

    section {
      border: none;
      background: var(--primary-very-low);
      padding-inline: var(--pm-padding);

      &:first-of-type {
        border-radius: var(--d-border-radius) var(--d-border-radius) 0 0;
      }

      &:last-of-type {
        border-radius: 0 0 var(--d-border-radius) var(--d-border-radius);
      }
    }

    .map {
      padding-top: var(--pm-padding);
    }

    &__contents,
    &__additional-contents {
      padding-top: var(--pm-padding);
    }

    &__contents {
      grid-area: contents;
    }

    &__additional-contents {
      grid-area: additional;
    }

    &__private-message-map {
      grid-area: pm-map;
      padding: 0.5em var(--pm-padding) var(--pm-padding);
    }

    .participants {
      margin-bottom: 1.5em;

      .user {
        border: none;
        background: var(--primary-low);
        padding: 2px 4px;
        border-radius: var(--d-border-radius);
      }
    }
  }

  .map:first-of-type .buttons .btn {
    border: none;
    border-radius: var(--d-border-radius);
  }

  .embedded-posts {
    border: none;

    .topic-body {
      overflow: visible;
      width: 100%;
    }

    .topic-avatar {
      padding-left: 0;
    }

    .collapse-down,
    .collapse-up {
      display: none;
    }

    &.bottom {
      margin-bottom: 0;
      margin-right: calc(var(--topic-body-width-padding) * 2);
    }

    &.top {
      .cooked {
        border: 1px solid var(--content-border-color);
        border-radius: var(--d-border-radius);
        margin-left: calc(var(--pm-padding) * -1);
        padding-left: 2.15em;
      }

      .row {
        .topic-body,
        .topic-avatar {
          border: none;
        }
      }
    }
  }

  .timeline-replies {
    display: flex;
    align-items: baseline;
    margin-right: 0.15em;
  }

  // special post type colors
  .current-user-post {
    .regular.contents {
      background: var(--tertiary-very-low);
      border-color: var(--tertiary-very-low);
    }

    .embedded-posts {
      .topic-body .cooked {
        background: transparent;
      }
    }
  }

  .moderator {
    .topic-body.highlighted {
      .regular.contents {
        animation: none;
      }
    }

    .regular.contents {
      background: var(--highlight-low);
      border-color: var(--highlight-low);

      .cooked {
        background: transparent;
      }
    }
  }

  .whisper {
    .topic-body .regular.contents {
      background: transparent;
      border: 2px dashed var(--primary-low);
    }

    &.current-user-post .topic-body .regular.contents {
      border: 2px dashed var(--tertiary-low);
    }
  }

  .deleted {
    .topic-body .regular.contents {
      background: var(--danger-low);
      border-color: transparent;

      .cooked {
        background: transparent;
      }
    }

    &.whisper {
      .topic-body .regular.contents {
        border-color: var(--danger-low-mid);
      }
    }
  }
}
