/* The homepage's Discord section: the raid post, then the member's private
   reply (the spec picker) and a reminder. The message frame is shared with
   the dashboard (../discord.css). */

@layer layout {
  .discord-flow {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
    gap: 24px;
    align-items: start;
    margin-top: 40px;
  }

  /* Steps 2 and 3, stacked beside the raid post and starting level with it. */
  .discord-side {
    display: grid;
    gap: 24px;
    min-width: 0;
  }

  .discord-step {
    display: grid;
    gap: 12px;
    min-width: 0;
    margin: 0;
  }

  .discord-step figcaption {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
  }

  .step-dot {
    display: grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-warm);
    border-radius: 50%;
    background: var(--bg-warm);
    color: var(--accent);
    font-size: 11px;
  }

  .discord-flow {
    position: relative;
  }

  /* Nordrassil's forest (the hero's artwork before the raid scenes), faint
     behind the Discord windows. Like the showcases' art (sections.css) it
     reaches into the sections around it and fades out inside its own box. */
  .discord-section::before {
    position: absolute;
    inset: -80px 0;
    z-index: -2;
    content: "";
    background: url("/assets/art/nordrassil-hero.webp") center 35% / cover no-repeat;
    opacity: 0.32;
    mask-image: radial-gradient(closest-side at 50% 55%, #000 35%, transparent);
    pointer-events: none;
  }

  .discord-section .discord-preview {
    width: 100%;
    max-width: none;
    padding: 20px;
    box-shadow: var(--preview-shadow);
  }

  /* The raid post as a Discord window: the server rail, then the channel with
     its header, the post and the message box. */
  .discord-section .post-preview {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr);
    overflow: hidden;
    padding: 0;
  }

  .discord-servers {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 14px 0;
    background: #1e1f22;
  }

  .discord-servers > i {
    width: 28px;
    height: 2px;
    border-radius: 1px;
    background: #35363c;
  }

  .discord-server {
    position: relative;
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #313338;
    color: #dbdee1;
    font-size: 13px;
    font-weight: 600;
  }

  /* The guild's server, open: a rounded square and Discord's pill at the
     rail's edge. */
  .discord-server.is-active {
    border-radius: 14px;
    background: #4a3826;
    color: var(--accent);
  }

  .discord-server.is-active::before {
    position: absolute;
    left: -12px;
    width: 4px;
    height: 36px;
    border-radius: 0 4px 4px 0;
    content: "";
    background: #f2f3f5;
  }

  .discord-server.is-blue {
    background: linear-gradient(135deg, #3d5a8a, #263452);
  }

  .discord-server.is-red {
    background: linear-gradient(135deg, #8a4a3d, #4a2620);
  }

  .discord-server.is-add {
    color: #23a55a;
    font-size: 20px;
    font-weight: 400;
  }

  .discord-main {
    min-width: 0;
    padding: 18px 20px 16px;
  }

  .discord-topic {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    padding-left: 12px;
    border-left: 1px solid #414348;
    color: #949ba4;
    font-size: 12px;
    font-weight: 400;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .discord-composer {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 10px 14px;
    border-radius: 8px;
    background: #383a40;
    color: #80848e;
    font-size: 13px;
  }

  .discord-composer-plus {
    display: grid;
    place-items: center;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #b5bac1;
    color: #383a40;
    font-size: 17px;
    font-weight: 700;
    line-height: 1;
  }

  .discord-section .discord-message {
    margin-top: 18px;
  }

  .spec-picker-preview .discord-message {
    margin-top: 0;
  }

  .discord-section .discord-message > img {
    width: 38px;
    height: 38px;
  }

  .discord-embed {
    margin-top: 8px;
    padding: 14px 16px 12px;
    border-left: 4px solid var(--accent);
    border-radius: 4px;
    background: #202226;
    font-size: 13px;
    line-height: 1.45;
    color: #dbdee1;
  }

  .discord-embed h3 {
    font-size: 15px;
    font-weight: 700;
  }

  .discord-embed > p {
    margin-top: 6px;
  }

  .post-lines {
    display: grid;
    gap: 3px;
    margin: 10px 0 0;
    padding: 0;
    list-style: none;
  }

  .post-lines li {
    display: flex;
    align-items: center;
    gap: 7px;
  }

  /* The post's own icons, uploaded to Discord as i_ emojis. */
  .discord-section .post-emoji {
    flex: none;
    width: 18px;
    height: 18px;
  }

  .discord-section :is(.post-field-name, .discord-buttons) .post-emoji {
    width: 16px;
    height: 16px;
  }

  .discord-section .post-content {
    margin-top: 2px;
    font-size: 13px;
  }

  .post-mention {
    padding: 0 3px;
    border-radius: 3px;
    background: rgb(88 101 242 / 30%);
    color: #c9cdfb;
  }

  .discord-embed .post-total {
    margin-top: 10px;
  }

  /* Discord sets inline fields three across; the rest take the whole row. The
     post puts four roles two to a row, with an empty field as the third
     (RaidMessage's SPACER). */
  .post-fields {
    display: grid;
    grid-template-columns: repeat(
      auto-fill,
      minmax(max(110px, calc((100% - 28px) / 3)), 1fr)
    );
    gap: 10px 14px;
    margin-top: 8px;
  }

  .post-field.is-wide {
    grid-column: 1 / -1;
  }

  .post-field-name {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    font-weight: 700;
  }

  .post-field ul {
    display: grid;
    gap: 2px;
    margin: 4px 0 0;
    padding: 0;
    list-style: none;
    font-size: 12px;
  }

  /* Each role list ends on a blank line, as the bot ends it (RaidMessage's GAP). */
  .post-field:not(.is-wide) ul {
    margin-bottom: 18px;
  }

  .post-field li {
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 0;
  }

  .post-field li img,
  .post-field p img {
    flex: none;
    border-radius: 3px;
  }

  .discord-section .post-field .post-late {
    margin-left: 1px;
    border-radius: 0;
  }

  :is(.post-classes, .post-status-names) {
    display: flex;
    flex-wrap: wrap;
    gap: 3px 9px;
    margin-top: 4px;
    font-size: 12px;
  }

  .post-status-names {
    gap: 3px 4px;
  }

  :is(.post-classes, .post-status-names) span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
  }

  .post-banner {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 1;
    margin-top: 12px;
    border-radius: 4px;
    object-fit: cover;
  }

  .discord-embed .discord-embed-footer {
    margin-top: 8px;
    padding-top: 0;
    border: 0;
    color: #b5bac1;
    font-weight: 600;
  }

  .discord-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
  }

  .discord-buttons span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 30px;
    padding: 4px 12px;
    border-radius: 4px;
    background: #4e5058;
    color: #fff;
    font-size: 12px;
    font-weight: 500;
  }

  .discord-buttons .is-role {
    background: #5865f2;
  }

  .discord-buttons .is-danger {
    background: #da373c;
  }

  .spec-picker-preview .discord-message-body {
    display: grid;
    gap: 9px;
    min-width: 0;
  }

  .spec-picker-private {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #949ba4;
    font-size: 11px;
  }

  .spec-picker-private .ui-icon {
    width: 14px;
    height: 14px;
  }

  .spec-picker-text {
    color: #dbdee1;
    font-size: 13px;
    line-height: 1.6;
  }

  .spec-picker-text .role-icon {
    display: inline-block;
    margin: 0 4px 0 2px;
    vertical-align: -3px;
  }

  .spec-picker-menu {
    border: 1px solid #1e1f22;
    border-radius: 6px;
    background: #1e1f22;
    font-size: 12px;
  }

  .spec-picker-placeholder {
    display: block;
    padding: 9px 12px;
    border-bottom: 1px solid #2b2d31;
    color: #949ba4;
  }

  .spec-picker-menu ul {
    margin: 0;
    padding: 4px;
    list-style: none;
  }

  .spec-picker-option {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 7px 8px;
    border-radius: 4px;
    color: #dbdee1;
  }

  .spec-picker-option.is-default {
    background: #35373c;
  }

  .spec-picker-option img {
    flex: none;
    width: 20px;
    height: 20px;
    border-radius: 4px;
  }

  .spec-picker-name {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .spec-picker-option small {
    margin-left: auto;
    color: #949ba4;
    font-size: 10px;
    white-space: nowrap;
  }

  .spec-picker-quick {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-self: start;
    padding: 7px 12px;
    border-radius: 4px;
    background: #248046;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
  }

  .spec-picker-quick img {
    flex: none;
    border-radius: 3px;
  }

  .spec-picker-actions {
    margin-top: 0;
  }

  .spec-picker-select {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    background: #1e1f22;
    color: #dbdee1;
    font-size: 12px;
  }

  .spec-picker-select img {
    flex: none;
    border-radius: 4px;
  }

  .spec-picker-select .ui-icon {
    width: 16px;
    height: 16px;
    margin-left: auto;
    color: #b5bac1;
  }

  .spec-picker-confirm {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #3f4147;
    color: #dbdee1;
    font-size: 12px;
    line-height: 1.5;
  }

  .spec-picker-confirm .ui-icon {
    width: 18px;
    height: 18px;
    padding: 2px;
    border-radius: 4px;
    background: #248046;
    color: #fff;
  }

  .reminder-preview .discord-message {
    margin-top: 0;
  }

  .reminder-text {
    display: flex;
    gap: 8px;
    margin-top: 6px;
    color: #dbdee1;
    font-size: 13px;
    line-height: 1.5;
  }

  .reminder-text .post-emoji {
    margin-top: 1px;
  }

  .post-time {
    padding: 0 3px;
    border-radius: 3px;
    background: rgb(255 255 255 / 6%);
  }

  .reminder-link {
    margin-top: 4px;
    padding-left: 24px;
    overflow: hidden;
    color: #00a8fc;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

@layer responsive {
  @media (max-width: 900px) {
    .discord-flow {
      grid-template-columns: minmax(0, 1fr);
      max-width: 620px;
    }

    /* The smaller copy of the artwork, which the hero's srcset gives phones. */
    .discord-section::before {
      background-image: url("/assets/art/nordrassil-hero-960.webp");
    }
  }

  /* A phone's Discord shows the channel alone, and its header has no room for
     the topic. */
  @media (max-width: 640px) {
    .discord-section .post-preview {
      grid-template-columns: minmax(0, 1fr);
    }

    .discord-servers,
    .discord-topic {
      display: none;
    }
  }

  @media (max-width: 520px) {
    .discord-section .discord-preview {
      padding: 14px;
    }

    .discord-section .post-preview {
      padding: 0;
    }

    .discord-main {
      padding: 14px;
    }

    /* Two fields across here, so the third column's spacer would split a
       pair. */
    .post-field.is-spacer {
      display: none;
    }

    .discord-section .discord-message > img {
      width: 28px;
      height: 28px;
    }

    .discord-embed {
      padding: 12px;
    }
  }

  /* The demo keeps the narrow-screen width from the 800px rule; the homepage
     example spans its column. */
  .discord-section .discord-preview {
    width: 100%;
    max-width: none;
  }
}
