/* Community — cards, topic list, chat.
   Colors come only from the theme tokens in design-tokens.css (--accent-color,
   --border-color, --surface-color, ...), so light/dark mode follow automatically and
   the pages stay on-brand with the rest of the site. */

/* ------------------------------------------------------------------ cards */

.community-card {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  background-color: var(--surface-color);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.community-card:hover {
  border-color: var(--accent-color);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.06);
}

.community-card-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.community-card-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-size: 20px;
  color: var(--accent-color);
  background-color: var(--surface-alt-color);
}

.community-card-title {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.3;
}

.community-card-title a {
  color: var(--heading-color);
  text-decoration: none;
}

.community-card-title a:hover {
  color: var(--accent-color);
}

.community-card-desc {
  margin: 0;
  font-size: 14px;
  color: var(--secondary-color);
}

.community-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  font-size: 13px;
  color: var(--secondary-color);
}

.community-card-meta i {
  margin-right: 4px;
}

.community-card-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.community-card-link {
  font-size: 14px;
  text-decoration: none;
  white-space: nowrap;
}

/* ----------------------------------------------------------------- badges */

.community-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  color: var(--secondary-color);
  background-color: var(--surface-alt-color);
  border: 1px solid var(--border-color);
}

/* Accent = "you're in / it's open to you". Neutral = closed or waiting. */
.community-badge-open,
.community-badge-member,
.community-badge-owner,
.community-badge-mod {
  color: var(--accent-color);
  background-color: color-mix(in srgb, var(--accent-color), transparent 92%);
  border-color: color-mix(in srgb, var(--accent-color), transparent 75%);
}

.community-badge-closed,
.community-badge-pending {
  color: var(--secondary-color);
  background-color: var(--surface-alt-color);
  border-color: var(--border-color);
}

/* ----------------------------------------------------------- detail page */

.community-detail-page {
  padding-top: 24px;
}

.community-cover {
  border-radius: 16px;
  overflow: hidden;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
}

.community-cover-banner {
  height: 120px;
  background-image: linear-gradient(135deg, var(--accent-color), var(--accent-color-dark));
}

.community-cover-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 20px;
  padding: 0 28px 22px;
}

.community-cover-avatar {
  flex: 0 0 88px;
  width: 88px;
  height: 88px;
  margin-top: -34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 20px;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--contrast-color, #fff);
  background-image: linear-gradient(135deg, var(--accent-color), var(--accent-color-dark));
  border: 4px solid var(--surface-color);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.community-cover-main {
  flex: 1 1 260px;
  min-width: 0;
  padding-bottom: 2px;
}

.community-cover-title {
  margin: 0 0 8px;
  font-size: 28px;
  line-height: 1.2;
  color: var(--heading-color);
}

.community-cover-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 14px;
  color: var(--secondary-color);
}

.community-cover-stats i {
  margin-right: 4px;
}

.community-cover-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding-bottom: 2px;
}

.community-locked-panel {
  margin-top: 32px;
  padding: 48px 24px;
  text-align: center;
  border-radius: 12px;
  border: 1px dashed var(--border-color);
}

.community-locked-panel i {
  font-size: 40px;
  color: var(--secondary-color);
}

.community-locked-panel h3 {
  margin: 16px 0 8px;
  font-size: 20px;
  color: var(--heading-color);
}

.community-locked-panel p {
  margin: 0;
  color: var(--secondary-color);
}

/* ------------------------------------------------------ two-column body */

.community-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 28px;
  margin-top: 32px;
}

.community-body-main {
  min-width: 0;
}

.community-section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  font-size: 18px;
  color: var(--heading-color);
}

.community-section-count {
  padding: 1px 9px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--secondary-color);
  background-color: var(--surface-alt-color);
}

/* --------------------------------------------------------------- sidebar */

.community-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.community-panel {
  padding: 20px;
  border-radius: 12px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
}

.community-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--secondary-color);
}

.community-panel-text {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

.community-panel-link {
  display: inline-block;
  margin-top: 14px;
  font-size: 13px;
  text-decoration: none;
}

.community-panel-hint {
  margin: 14px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--secondary-color);
}

.community-avatar-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.community-avatar-chip {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  color: var(--contrast-color, #fff);
  background-color: var(--accent-color);
  transition: transform 0.15s ease;
}

.community-avatar-chip:hover {
  color: var(--contrast-color, #fff);
  transform: translateY(-2px);
}

.community-avatar-more {
  color: var(--secondary-color);
  background-color: var(--surface-alt-color);
  border: 1px solid var(--border-color);
}

.community-avatar-more:hover {
  color: var(--accent-color);
}

.community-avatar-sm {
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  font-size: 11px;
}

.community-mod-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.community-mod-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.community-mod-list a {
  text-decoration: none;
  color: var(--heading-color);
  font-weight: 500;
}

.community-mod-list a:hover {
  color: var(--accent-color);
}

/* ------------------------------------------------------------ topic list */

.community-topic-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.community-topic-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  transition: border-color 0.2s ease;
}

.community-topic-row:hover {
  border-color: var(--accent-color);
  color: inherit;
}

.community-topic-icon {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--accent-color);
  background-color: var(--surface-alt-color);
}

.community-topic-main {
  flex: 1;
  min-width: 0;
}

.community-topic-main h4 {
  margin: 0 0 2px;
  font-size: 16px;
  color: var(--heading-color);
}

.community-topic-meta {
  font-size: 13px;
  color: var(--secondary-color);
}

.community-topic-count {
  font-size: 13px;
  white-space: nowrap;
  color: var(--secondary-color);
}

/* ------------------------------------------------------------ topic head */

.community-topic-head {
  padding: 20px 24px;
  border-radius: 14px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  /* The title is the anchor of the page — give it an accent spine so it reads as a
     header and not as the first line of the conversation. */
  border-left: 4px solid var(--accent-color);
}

.community-topic-head-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px;
}

.community-topic-head-icon {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 18px;
  color: var(--accent-color);
  background-color: var(--surface-alt-color);
}

.community-topic-head-main {
  flex: 1 1 260px;
  min-width: 0;
}

.community-topic-head-title {
  margin: 0 0 6px;
  font-size: 24px;
  line-height: 1.25;
  font-weight: 700;
  color: var(--heading-color);
  overflow-wrap: anywhere;
}

.community-topic-head-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: var(--secondary-color);
}

.community-topic-head-meta i {
  margin-right: 4px;
}

.community-topic-head-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.community-topic-description {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
  color: var(--default-color);
}

.community-topic-description > *:last-child {
  margin-bottom: 0;
}

/* ------------------------------------------------------------------ chat */

.community-chat {
  margin-top: 20px;
  padding: 8px 12px 16px;
  border-radius: 14px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
}

.community-messages {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 8px 4px;
}

.community-message {
  display: flex;
  gap: 12px;
  padding: 10px 8px;
  border-radius: 10px;
}

.community-message-avatar {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  color: var(--contrast-color, #fff);
  background-color: var(--accent-color);
  transition: transform 0.15s ease;
}

.community-message-avatar:hover {
  color: var(--contrast-color, #fff);
  transform: translateY(-1px);
}

/* Your own messages: muted avatar + accent-tinted bubble, so you can scan the thread
   for "who said what" without reading the names. */
.community-message.is-mine .community-message-avatar {
  background-color: var(--secondary-color);
}

.community-message.is-mine .community-message-bubble {
  border-color: color-mix(in srgb, var(--accent-color), transparent 70%);
  background-color: color-mix(in srgb, var(--accent-color), transparent 94%);
}

/* The bubble carries the message; the row itself stays transparent. */
.community-message-bubble {
  padding: 10px 14px;
  border-radius: 12px;
  border-top-left-radius: 4px;
  background-color: var(--surface-alt-color);
  border: 1px solid var(--border-color);
  transition: border-color 0.15s ease;
}

.community-message:hover .community-message-bubble {
  border-color: color-mix(in srgb, var(--accent-color), transparent 60%);
}

.community-message-body {
  flex: 1;
  min-width: 0;
}

.community-message-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 4px;
}

.community-message-author {
  font-weight: 600;
  text-decoration: none;
  color: var(--heading-color);
}

.community-message-author:hover {
  color: var(--accent-color);
}

.community-message-date,
.community-message-edited {
  font-size: 12px;
  color: var(--secondary-color);
}

.community-message-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s ease;
}

.community-message:hover .community-message-actions {
  opacity: 1;
}

/* Touch devices have no hover — keep the buttons visible there. */
@media (hover: none) {
  .community-message-actions {
    opacity: 1;
  }
}

.community-msg-btn {
  border: none;
  background: none;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--secondary-color);
  cursor: pointer;
}

.community-msg-btn:hover {
  color: var(--accent-color);
  background-color: var(--surface-alt-color);
}

/* ------------------------------------------------- wiki link picker modal */

.wiki-link-results {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 320px;
  overflow-y: auto;
}

.wiki-link-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  background-color: transparent;
  border: 1px solid var(--border-color);
}

.wiki-link-item:hover {
  border-color: var(--accent-color);
  background-color: var(--surface-alt-color);
}

.wiki-link-item-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--heading-color);
}

.wiki-link-item-summary {
  font-size: 12px;
  line-height: 1.4;
  color: var(--secondary-color);
}

/* --------------------------------------------------------------- replies */

/* The quote of the message being replied to. Clicking it jumps to the original, which
   is how a reply-to-a-reply chain stays followable without nesting the markup. */
.community-quote {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-bottom: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  border-left: 3px solid var(--accent-color);
  background-color: color-mix(in srgb, var(--accent-color), transparent 92%);
  text-decoration: none;
  cursor: pointer;
}

.community-quote:hover {
  background-color: color-mix(in srgb, var(--accent-color), transparent 85%);
}

.community-quote-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-color);
}

.community-quote-text {
  font-size: 12px;
  line-height: 1.4;
  color: var(--secondary-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Jump target: a brief pulse so the eye can find the quoted message after scrolling. */
@keyframes community-flash {
  0% { background-color: color-mix(in srgb, var(--accent-color), transparent 75%); }
  100% { background-color: transparent; }
}

.community-message.is-flash {
  animation: community-flash 1.6s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .community-message.is-flash {
    animation: none;
    outline: 2px solid var(--accent-color);
  }
}

.community-reply-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border-left: 3px solid var(--accent-color);
  background-color: color-mix(in srgb, var(--accent-color), transparent 92%);
}

.community-reply-banner > i {
  color: var(--accent-color);
}

.community-reply-banner-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.community-reply-banner-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-color);
}

.community-reply-banner-text {
  font-size: 12px;
  color: var(--secondary-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-message-content {
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.community-message-content p:last-child {
  margin-bottom: 0;
}

.community-message-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.community-message-content table {
  max-width: 100%;
}

/* -------------------------------------------------------------- composer */

.community-composer {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border-color);
}

.community-composer-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.community-composer-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 600;
  color: var(--contrast-color, #fff);
  background-color: var(--accent-color);
}

.community-composer-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--heading-color);
}

.community-composer-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.community-composer-hint {
  font-size: 12px;
  color: var(--secondary-color);
}

.community-composer-hint kbd {
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--secondary-color);
  background-color: var(--surface-alt-color);
  border: 1px solid var(--border-color);
  box-shadow: none;
}

/* Pushed hard right so the send button stays anchored to the corner. */
.community-composer-status {
  margin-left: auto;
  font-size: 13px;
  color: var(--secondary-color);
}

.community-composer-status.is-error {
  color: #d64545;
}

.community-locked {
  margin-top: 16px;
  padding: 16px;
  border-radius: 10px;
  text-align: center;
  font-size: 14px;
  color: var(--secondary-color);
  background-color: var(--surface-alt-color);
  border: 1px solid var(--border-color);
}

/* ----------------------------------------------------------- forms/lists */

.community-form-card {
  padding: 28px;
  margin-top: 24px;
  border-radius: 12px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
}

.community-policy-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  margin-bottom: 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  cursor: pointer;
}

.community-policy-option:has(input:checked) {
  border-color: var(--accent-color);
  background-color: var(--surface-alt-color);
}

.community-policy-option label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
}

.community-policy-option span {
  font-size: 13px;
  color: var(--secondary-color);
}

/* Delete lives on the settings page (community:edit), fenced off below the form. */
.community-danger-zone {
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
}

.community-danger-title {
  margin: 0 0 6px;
  font-size: 16px;
  color: #d64545;
}

.community-danger-desc {
  margin: 0 0 14px;
  font-size: 14px;
  color: var(--secondary-color);
}

/* -------------------------------------------------------- members page */

/* Compact header for the sub-pages (members), echoing the detail cover. */
.community-page-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  border-radius: 14px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
}

.community-page-head-avatar {
  flex: 0 0 56px;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  font-size: 20px;
  font-weight: 700;
  text-decoration: none;
  color: var(--contrast-color, #fff);
  background-image: linear-gradient(135deg, var(--accent-color), var(--accent-color-dark));
}

.community-page-head-avatar:hover {
  color: var(--contrast-color, #fff);
}

.community-page-head-main {
  flex: 1 1 200px;
  min-width: 0;
}

.community-page-head-title {
  margin: 0 0 2px;
  font-size: 22px;
  color: var(--heading-color);
}

.community-page-head-sub {
  font-size: 14px;
  color: var(--secondary-color);
}

.community-page-head-sub a {
  text-decoration: none;
  font-weight: 600;
}

/* Pending requests are fenced off so they read as an inbox, not as members. */
.community-pending-panel {
  margin-top: 28px;
  padding: 20px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--accent-color), transparent 75%);
  background-color: color-mix(in srgb, var(--accent-color), transparent 96%);
}

.community-pending-panel .community-section-title {
  margin-bottom: 14px;
}

.community-member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 10px;
}

.community-member-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 12px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  transition: border-color 0.2s ease;
}

.community-member-card:hover {
  border-color: var(--accent-color);
}

.community-member-card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.community-member-card-name {
  font-weight: 600;
  text-decoration: none;
  color: var(--heading-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-member-card-name:hover {
  color: var(--accent-color);
}

.community-member-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--secondary-color);
}

.community-member-card-date {
  white-space: nowrap;
}

.community-member-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.community-avatar-lg {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  font-size: 15px;
}

.community-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--secondary-color);
  border: 1px dashed var(--border-color);
  border-radius: 12px;
}

.community-empty i {
  font-size: 36px;
  display: block;
  margin-bottom: 12px;
}

.community-empty p {
  margin: 0;
}

/* The sidebar drops below the topics rather than squeezing them. */
@media (max-width: 991.98px) {
  .community-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 20px;
  }
}

@media (max-width: 575.98px) {
  /* Cards go vertical so the action buttons get a full row instead of a 40px sliver. */
  .community-member-card {
    flex-wrap: wrap;
  }

  .community-member-card-actions {
    width: 100%;
  }

  .community-cover-body {
    align-items: flex-start;
    padding: 0 18px 18px;
  }

  .community-cover-avatar {
    flex-basis: 68px;
    width: 68px;
    height: 68px;
    margin-top: -26px;
    font-size: 24px;
  }

  .community-cover-title {
    font-size: 22px;
  }

  .community-cover-actions {
    width: 100%;
  }

  .community-messages {
    max-height: none;
  }
}
