/* =============================================================
   SCA Opportunities — Common Room + member profile pages
   Loaded on top of styles.css + auth.css
   ============================================================= */

.new-post-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--s-6);
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  margin-bottom: var(--s-7);
}

.new-post-card textarea {
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--white);
  font-family: inherit;
  font-size: 0.9375rem;
  color: var(--ink);
  resize: vertical;
}

.new-post-card textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash);
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.posts-empty {
  text-align: center;
  padding: var(--s-8) var(--s-4);
  color: var(--ink-mute);
}

.post-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-5);
}

.post-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  margin-bottom: var(--s-3);
}

.post-author {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}

.account-avatar--sm {
  width: 32px;
  height: 32px;
}

.account-avatar--sm span {
  font-size: 0.75rem;
}

.post-author-avatar-link {
  display: flex;
  flex-shrink: 0;
}

.post-author-name {
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
}

.post-author-name:hover {
  text-decoration: underline;
}

.post-time {
  font-size: 0.8125rem;
  color: var(--ink-mute);
}

.post-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0 0 var(--s-2);
  cursor: pointer;
}

.post-body {
  color: var(--ink);
  font-size: 0.9375rem;
  white-space: pre-wrap;
  margin: 0 0 var(--s-3);
}

.post-body a,
.comment-body-text a {
  color: var(--gold);
  word-break: break-word;
}

.mention-link {
  font-weight: 600;
}

.mention-all {
  background: var(--gold-wash);
  padding: 0.1em 0.4em;
  border-radius: var(--radius-sm);
}

.mention-option-all .mention-all-icon span {
  color: var(--gold);
  font-weight: 700;
}

.post-card.post-highlight {
  animation: post-highlight-flash 2s ease;
}

@keyframes post-highlight-flash {
  0% { background: var(--gold-wash); }
  100% { background: var(--white); }
}

/* -------------------------------------------------------------
   @mention autocomplete
   ------------------------------------------------------------- */
.mention-menu {
  position: fixed;
  z-index: 500;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: 0 12px 30px -12px rgba(26, 26, 26, 0.2);
  max-height: 220px;
  overflow-y: auto;
  min-width: 200px;
}

.mention-option {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  width: 100%;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  text-align: left;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--ink);
}

.mention-option:hover,
.mention-option.is-active {
  background: var(--cream);
}

.mention-option .account-avatar--sm {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.mention-option .account-avatar--sm span {
  font-size: 0.625rem;
}

.post-actions {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  font-size: 0.8125rem;
}

.post-toggle-comments,
.post-share,
.post-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 0.8125rem;
}

.post-toggle-comments,
.post-share {
  color: var(--ink-mute);
  font-weight: 600;
}

.post-delete {
  color: var(--red);
}

.comment-share {
  display: block;
  margin-top: var(--s-1);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-size: 0.75rem;
  color: var(--ink-mute);
  font-weight: 600;
}

.comment-share:hover {
  color: var(--gold);
}

.post-comments {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.comment {
  display: flex;
  gap: var(--s-3);
}

.comment-body {
  background: var(--cream);
  border-radius: var(--radius-sm);
  padding: var(--s-3);
  flex: 1;
}

.comment-body-text {
  margin: var(--s-1) 0 0;
  font-size: 0.875rem;
  white-space: pre-wrap;
}

.comment-form {
  display: flex;
  gap: var(--s-3);
  margin-top: var(--s-2);
}

.comment-form input {
  flex: 1;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
}

.companion-stats {
  display: flex;
  gap: var(--s-6);
  margin-top: var(--s-5);
}

.companion-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  color: inherit;
}

.companion-stat strong {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--ink);
}

.companion-stat span {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-mute);
}

.member-self-note {
  font-size: 0.875rem;
  color: var(--ink-mute);
  font-style: italic;
}

.member-message-hint {
  font-size: 0.8125rem;
  color: var(--ink-mute);
  max-width: 220px;
  text-align: right;
}

/* -------------------------------------------------------------
   Students directory
   ------------------------------------------------------------- */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-5);
}

.member-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-3);
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--s-5);
  color: inherit;
}

.member-card:hover {
  border-color: var(--gold-soft);
  color: inherit;
}

.member-card-name {
  font-family: var(--font-display);
  font-size: 1rem;
  margin: 0;
}

.member-card-meta {
  font-size: 0.8125rem;
  color: var(--ink-mute);
  margin: 0;
}

/* -------------------------------------------------------------
   Nav unread badge (Messages link)
   ------------------------------------------------------------- */
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: var(--s-2);
  border-radius: 999px;
  background: var(--gold);
  color: var(--white);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

/* -------------------------------------------------------------
   Messages page
   ------------------------------------------------------------- */
.messages-shell {
  display: grid;
  grid-template-columns: 320px 1fr;
  max-width: var(--container);
  margin: var(--s-6) auto var(--s-9);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-height: 65vh;
  max-height: 78vh;
}

.conversations-panel {
  grid-column: 1;
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.conversations-header {
  padding: var(--s-5) var(--s-5) var(--s-4);
  border-bottom: 1px solid var(--line);
}

.conversations-list {
  display: flex;
  flex-direction: column;
}

.conversations-empty {
  padding: var(--s-6) var(--s-5);
  color: var(--ink-mute);
  font-size: 0.9375rem;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  width: 100%;
  padding: var(--s-4) var(--s-5);
  background: none;
  border: none;
  border-bottom: 1px solid var(--line);
  text-align: left;
  cursor: pointer;
}

.conversation-item:hover {
  background: var(--cream);
}

.conversation-item-body {
  flex: 1;
  min-width: 0;
}

.conversation-item-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
}

.conversation-item-name {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.9375rem;
}

.conversation-item-time {
  font-size: 0.75rem;
  color: var(--ink-mute);
  flex-shrink: 0;
}

.conversation-item-preview {
  margin: var(--s-1) 0 0;
  font-size: 0.8125rem;
  color: var(--ink-mute);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-unread {
  flex-shrink: 0;
  margin-left: 0;
}

.thread-panel {
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.thread-placeholder {
  grid-column: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-mute);
  text-align: center;
  padding: var(--s-6);
}

.thread-header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.thread-back {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0 var(--s-2) 0 0;
  color: var(--ink);
}

.thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-5);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.thread-bubble-row {
  display: flex;
}

.thread-bubble-row.is-own {
  justify-content: flex-end;
}

.thread-bubble {
  max-width: 72%;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--radius);
  background: var(--cream);
}

.thread-bubble-row.is-own .thread-bubble {
  background: var(--gold-wash);
}

.thread-bubble p {
  margin: 0;
  font-size: 0.9375rem;
  white-space: pre-wrap;
  word-break: break-word;
}

.thread-bubble-time {
  display: block;
  margin-top: var(--s-1);
  font-size: 0.6875rem;
  color: var(--ink-mute);
}

.thread-form {
  display: flex;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

.thread-form input {
  flex: 1;
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9375rem;
}

.thread-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-wash);
}

/* -------------------------------------------------------------
   Mobile — Common Room, member profiles, messages
   ------------------------------------------------------------- */
@media (max-width: 720px) {
  .new-post-card {
    padding: var(--s-4);
  }

  .post-card {
    padding: var(--s-4);
  }

  .post-card-head {
    gap: var(--s-2);
  }

  .companion-stats {
    gap: var(--s-5);
  }

  .comment {
    gap: var(--s-2);
  }

  .comment-form {
    flex-direction: column;
    align-items: stretch;
  }

  .comment-form button {
    align-self: flex-end;
  }

  .member-message-hint {
    max-width: none;
    text-align: left;
  }

  .member-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: var(--s-3);
  }

  .member-card {
    padding: var(--s-4);
  }
}

@media (max-width: 768px) {
  .messages-shell {
    display: block;
    margin: 0;
    border: none;
    border-radius: 0;
    max-height: none;
    min-height: calc(100vh - 140px);
  }

  .conversations-panel {
    border-right: none;
    height: 100%;
  }

  .conversations-header {
    padding: var(--s-4);
  }

  .thread-placeholder {
    display: none;
  }

  .thread-back {
    display: inline-flex;
  }

  .messages-shell.show-thread .conversations-panel {
    display: none;
  }

  .thread-panel {
    height: calc(100vh - 140px);
  }

  .thread-bubble {
    max-width: 85%;
  }
}
