/* ==========================================================================
   PGDGC Discord mirror.

   Ported from the stylesheet the WordPress plugin inlined on every page — the
   club has been looking at this design for two years, so it is kept rather
   than redesigned. It still inherits from whatever theme it lands in: colours
   come from currentColor, sizes from em, so a feed looks like part of the page
   it sits on. The PGDGC theme tightens a few of these; see the theme's CSS.
   ========================================================================== */

.pgdgc-discord-feed,
.pgdgc-discord-intro,
.pgdgc-discord-image {
  /* Fallbacks first, then the modern equivalents for browsers that have them. */
  --pgdgc-line: rgba(0, 0, 0, .14);
  --pgdgc-fill: rgba(0, 0, 0, .035);
  --pgdgc-soft: rgba(0, 0, 0, .06);
  --pgdgc-line: color-mix(in srgb, currentColor 16%, transparent);
  --pgdgc-fill: color-mix(in srgb, currentColor 4%, transparent);
  --pgdgc-soft: color-mix(in srgb, currentColor 8%, transparent);
  --pgdgc-brand: #5865f2;
}

/* -- Intro --------------------------------------------------------------- */

.pgdgc-discord-intro {
  font-size: .95em;
  line-height: 1.5;
  margin: 0 0 1.5em;
  padding: .85em 1.1em;
  border: 1px solid var(--pgdgc-line);
  border-left: 3px solid var(--pgdgc-brand);
  border-radius: 3px;
  background: var(--pgdgc-fill);
}
.pgdgc-discord-invite { font-weight: 600; }

/* -- Thread -------------------------------------------------------------- */

.pgdgc-discord-feed {
  display: flex;
  flex-direction: column;
  gap: 1.4em;
  margin: 0 0 1.5em;
}

.pgdgc-discord-message {
  display: flex;
  gap: .85em;
  align-items: flex-start;
}

/* A follow-up from the same person within a few minutes: no repeated avatar
   or byline, and pulled tight against the message above it. */
.pgdgc-discord-message--grouped { margin-top: -1em; }

.pgdgc-discord-avatar {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  margin-top: .15em;
  background: var(--pgdgc-soft);
}
.pgdgc-discord-avatar--spacer { background: none; }

.pgdgc-discord-body { flex: 1 1 auto; min-width: 0; }

.pgdgc-discord-byline {
  margin: 0 0 .3em;
  line-height: 1.3;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .5em;
}
.pgdgc-discord-author { font-weight: 700; font-size: .98em; }
.pgdgc-discord-meta { font-size: .8em; opacity: .6; font-weight: 400; }

.pgdgc-discord-badge {
  font-size: .65em;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .18em .45em;
  border-radius: 3px;
  color: #fff;
  background: var(--pgdgc-brand);
  vertical-align: .1em;
}

/* The squared-off top-left corner points back at the avatar, which reads as
   speech without resorting to a literal chat-bubble tail. */
.pgdgc-discord-bubble {
  border: 1px solid var(--pgdgc-line);
  border-radius: 3px 12px 12px 12px;
  background: var(--pgdgc-fill);
  padding: .75em 1em;
  font-size: .96em;
  line-height: 1.55;
  overflow-wrap: break-word;
  transition: background-color .15s ease, border-color .15s ease;
}
.pgdgc-discord-message--grouped .pgdgc-discord-bubble { border-radius: 12px; }
.pgdgc-discord-bubble:hover { background: var(--pgdgc-soft); }
.pgdgc-discord-bubble > :first-child { margin-top: 0; }
.pgdgc-discord-bubble > :last-child { margin-bottom: 0; }
.pgdgc-discord-bubble p { margin: 0 0 .6em; }
.pgdgc-discord-bubble p:last-child { margin-bottom: 0; }

/* -- Bits inside a message ----------------------------------------------- */

.pgdgc-discord-reply {
  font-size: .84em;
  opacity: .72;
  margin: 0 0 .5em;
  padding: .3em 0 .3em .65em;
  border-left: 2px solid var(--pgdgc-line);
}

.pgdgc-discord-mention {
  font-weight: 600;
  padding: 0 .25em;
  border-radius: 3px;
  background: var(--pgdgc-soft);
}

.pgdgc-discord-emoji {
  height: 1.3em;
  width: auto;
  vertical-align: -.25em;
  display: inline;
  margin: 0 .05em;
}

.pgdgc-discord-img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
  margin: .6em 0 0;
}

.pgdgc-discord-code {
  overflow-x: auto;
  padding: .7em .9em;
  margin: .6em 0;
  border-radius: 4px;
  border: 1px solid var(--pgdgc-line);
  background: var(--pgdgc-soft);
  font-size: .88em;
}
.pgdgc-discord-bubble blockquote {
  margin: .5em 0;
  padding-left: .8em;
  border-left: 3px solid var(--pgdgc-line);
  opacity: .85;
}
.pgdgc-discord-bubble ul,
.pgdgc-discord-bubble ol { margin: .5em 0; padding-left: 1.3em; }

.pgdgc-discord-spoiler {
  background: currentColor;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color .12s ease;
}
.pgdgc-discord-spoiler:hover { background: transparent; }

.pgdgc-discord-reactions {
  margin: .6em 0 0;
  font-size: .85em;
  display: flex;
  flex-wrap: wrap;
  gap: .35em;
}
.pgdgc-discord-reaction {
  display: inline-flex;
  align-items: center;
  gap: .3em;
  padding: .12em .55em;
  border-radius: 11px;
  border: 1px solid var(--pgdgc-line);
  background: var(--pgdgc-soft);
  line-height: 1.6;
}

.pgdgc-discord-file { margin: .5em 0 0; font-size: .9em; }

.pgdgc-discord-empty {
  font-size: .95em;
  font-style: italic;
  opacity: .7;
  margin: 0 0 1.5em;
}

/* -- Calendar image ------------------------------------------------------ */

.pgdgc-discord-image { margin: 0 0 1.5em; }
.pgdgc-discord-image .pgdgc-discord-img { margin: 0; }
.pgdgc-discord-caption { margin-top: .8em; }

/* -- Responsive and preferences ------------------------------------------ */

@media (max-width: 480px) {
  .pgdgc-discord-message { gap: .6em; }
  .pgdgc-discord-avatar { flex-basis: 34px; width: 34px; height: 34px; }
  .pgdgc-discord-bubble { padding: .65em .8em; font-size: .93em; }
  .pgdgc-discord-feed { gap: 1.1em; }
}

@media (prefers-color-scheme: dark) {
  .pgdgc-discord-feed,
  .pgdgc-discord-intro,
  .pgdgc-discord-image {
    --pgdgc-line: rgba(255, 255, 255, .16);
    --pgdgc-fill: rgba(255, 255, 255, .05);
    --pgdgc-soft: rgba(255, 255, 255, .09);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pgdgc-discord-bubble,
  .pgdgc-discord-spoiler { transition: none; }
}

/* Reaction and inline emoji come through as unicode, which the body font of a
   custom theme will not have. Without this a 🥏 renders as an empty box. */
.pgdgc-discord-reaction,
.pgdgc-discord-bubble .pgdgc-discord-emoji + * {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji",
               "Twemoji Mozilla", "EmojiOne Color", sans-serif;
}
.pgdgc-discord-reaction > span:last-child {
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
