/* ═══════════════════════════════════════
   STORIED FLAVOURS — Gathering Page
   "In the Kitchen" / "Around the Fire"
   ═══════════════════════════════════════ */

/* ── Toolbar ──────────────────────────────────────────────────────────────── */

.gathering-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}

.gathering-toolbar .search-box {
  flex: 1;
  min-width: 200px;
}

.gathering-toolbar .form-select {
  width: auto;
  min-width: 130px;
}

/* ── Page shell ───────────────────────────────────────────────────────────── */

.gathering-page {
  position: relative;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--space-6) var(--space-6) var(--space-20);
}

.gathering-page::before {
  content: '';
  position: fixed;
  top: var(--topbar-height);
  left: var(--sidebar-width);
  right: 0;
  bottom: 0;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
}

.gathering-page--family::before {
  background-image: url('../assets/gathering-bg.png');
}

.gathering-page--circle::before {
  background-image: url('../assets/aroundthefire-bg.png');
}

.gathering-page > * {
  position: relative;
  z-index: 1;
}

/* ── Back nav ─────────────────────────────────────────────────────────────── */

.gathering-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-5);
}

/* Remove conversation button — quiet, owner/steward only */
.thread-remove-btn {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  opacity: 0.7;
  transition: opacity 0.15s, color 0.15s;
}
.thread-remove-btn:hover {
  opacity: 1;
  color: var(--color-error, #c0392b);
}

/* Per-message remove × button */
.btn-remove-message {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: var(--font-size-base);
  line-height: 1;
  padding: 0 var(--space-1);
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  margin-left: auto;
  flex-shrink: 0;
}
.thread-reply:hover .btn-remove-message,
.btn-remove-message:focus {
  opacity: 0.6;
}
.btn-remove-message:hover {
  opacity: 1 !important;
  color: var(--color-error, #c0392b);
}

.thread-reply-edited {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-style: italic;
}

.gathering-back-link {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s;
}

.gathering-back-link:hover {
  color: var(--color-amber-dark);
}

/* ── Page header ──────────────────────────────────────────────────────────── */

.gathering-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-6);
  margin-bottom: var(--space-8);
  flex-wrap: wrap;
}

.gathering-header-text {
  flex: 1;
  min-width: 0;
}

.gathering-title {
  font-size: var(--font-size-3xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-2);
  letter-spacing: -0.02em;
}

.gathering-subtitle {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

.gathering-start-btn {
  flex-shrink: 0;
  align-self: center;
}

/* ── Thread feed ──────────────────────────────────────────────────────────── */

.gathering-feed {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ── Thread card ──────────────────────────────────────────────────────────── */

.gathering-thread-card {
  background: var(--surface-card);
  border: 1px solid var(--color-brown-100);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.gathering-thread-card:hover {
  border-color: var(--color-brown-200);
  box-shadow: var(--shadow-sm);
}

/* Author row */
.gathering-thread-author {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.gathering-thread-avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-terracotta-light);
  color: var(--color-terracotta);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-sm);
  font-weight: 700;
  flex-shrink: 0;
}

.gathering-thread-author-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.gathering-thread-author-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.gathering-thread-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

/* Thread body */
.gathering-thread-body {
  padding-left: calc(36px + var(--space-3));
}

.gathering-thread-title {
  font-size: var(--font-size-base);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-2);
  line-height: 1.4;
}

.gathering-thread-preview {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.6;
}

/* Thread footer */
.gathering-thread-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding-left: calc(36px + var(--space-3));
  margin-top: var(--space-1);
}

.gathering-thread-footer-left {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.gathering-thread-replies {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-weight: 500;
}

.gathering-thread-replies--none {
  font-style: italic;
  font-weight: 400;
}

.gathering-thread-entity-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--font-size-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

.gathering-thread-entity-badge--recipe {
  background: var(--color-amber-light);
  color: var(--color-amber-dark);
}

.gathering-thread-entity-badge--story {
  background: var(--color-sage-light, #f0f5ee);
  color: var(--color-sage);
}

.gathering-thread-entity-badge--celebration {
  background: var(--color-dusty-rose-light, #f5efef);
  color: var(--color-dusty-rose);
}

/* Thread card open indicator — now a span inside an <a> */

/* Thread card as anchor link — reset link styles */
a.gathering-thread-card {
  display: flex;
  text-decoration: none;
  color: inherit;
}

a.gathering-thread-card:hover {
  border-color: var(--color-brown-200);
  box-shadow: var(--shadow-sm);
}

.gathering-thread-open-btn {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-amber-dark);
  flex-shrink: 0;
}

a.gathering-thread-card:hover .gathering-thread-open-btn {
  text-decoration: underline;
}

/* Simplified empty state (no CTA — composer is always available above) */
.gathering-empty {
  text-align: center;
  padding: var(--space-10) var(--space-8);
  max-width: 520px;
  margin: 0 auto;
}

.gathering-empty-icon {
  font-size: 2.5rem;
  margin-bottom: var(--space-4);
  line-height: 1;
}

.gathering-empty-body {
  font-size: var(--font-size-base);
  color: var(--text-muted);
  line-height: 1.7;
  margin: 0;
  font-style: italic;
}

/* ── Composer block ────────────────────────────────────────────────────────── */

.composer-block {
  background: var(--surface-card);
  border: 1px solid var(--color-brown-100);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-bottom: var(--space-6);
}

.composer-header {
  margin-bottom: var(--space-4);
}

.composer-title {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-1);
}

.composer-sub {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

/* ── Starter prompt ────────────────────────────────────────────────────────── */

.composer-starter {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: var(--color-amber-light);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
  transition: opacity 0.3s ease;
}

.composer-starter--faded {
  opacity: 0.35;
  pointer-events: none;
}

.composer-starter-label {
  font-size: var(--font-size-xs);
  font-weight: 700;
  color: var(--color-amber-dark);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.composer-starter-text {
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
  font-style: italic;
  line-height: 1.5;
}

/* ── Composer form ─────────────────────────────────────────────────────────── */

.composer-body-group {
  margin-bottom: var(--space-3);
}

.composer-body {
  resize: vertical;
  min-height: 96px;
}

.composer-optional-fields {
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-brown-100);
  margin-bottom: var(--space-3);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.composer-ref-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.composer-ref-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.composer-ref-type-row {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.composer-ref-type-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-brown-200);
  background: var(--surface-card);
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.composer-ref-type-btn:hover {
  background: var(--color-amber-light);
  border-color: var(--color-amber);
}

.composer-ref-type-btn--active {
  background: var(--color-amber-light);
  border-color: var(--color-amber-dark);
  color: var(--color-amber-dark);
  font-weight: 600;
}

.composer-ref-select {
  margin-top: var(--space-1);
}

.composer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.composer-expand-btn {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
}

.composer-expand-btn:hover {
  color: var(--color-amber-dark);
}

/* ── Thread detail page ────────────────────────────────────────────────────── */

.thread-detail-page .gathering-title {
  /* inherit from gathering-page */
}

/* Thread header — the opening post */
.thread-detail-header {
  background: var(--surface-card);
  border: 1px solid var(--color-brown-100);
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-8);
  margin-bottom: var(--space-6);
}

.thread-detail-author-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.thread-detail-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-terracotta-light);
  color: var(--color-terracotta);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-base);
  font-weight: 700;
  flex-shrink: 0;
}

.thread-detail-author-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.thread-detail-author-name {
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--text-secondary);
}

.thread-detail-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.thread-detail-title {
  font-size: var(--font-size-xl);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-4);
  line-height: 1.35;
  letter-spacing: -0.01em;
}

.thread-detail-opening-body {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  line-height: 1.75;
  white-space: pre-wrap;
  /* Opening body has a bit more presence than a reply */
  font-size: var(--font-size-base);
}

/* Attachment reference badge */
.thread-detail-ref-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: 500;
}

.thread-detail-ref-badge--recipe {
  background: var(--color-amber-light);
  color: var(--color-amber-dark);
}

.thread-detail-ref-badge--story {
  background: var(--color-sage-light, #f0f5ee);
  color: var(--color-sage);
}

.thread-detail-ref-badge--celebration {
  background: var(--color-dusty-rose-light, #f5efef);
  color: var(--color-dusty-rose);
}

.thread-detail-ref-link {
  color: inherit;
  text-decoration: underline;
  font-weight: 600;
}

/* ── Replies section ────────────────────────────────────────────────────────── */

.thread-replies-section {
  margin-bottom: var(--space-6);
}

.thread-replies-header {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
}

.thread-replies-count {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.thread-replies-divider {
  flex: 1;
  height: 1px;
  background: var(--color-brown-100);
}

.thread-replies-empty {
  padding: var(--space-6) 0;
}

.thread-replies-empty p {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
}

/* ── Reply items ────────────────────────────────────────────────────────────── */

.thread-reply-list {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.thread-reply {
  padding: var(--space-5) 0;
  border-bottom: 1px solid var(--color-brown-100);
}

.thread-reply:last-child {
  border-bottom: none;
}

.thread-reply-author-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.thread-reply-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-cream);
  color: var(--text-secondary);
  border: 1px solid var(--color-brown-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-xs);
  font-weight: 700;
  flex-shrink: 0;
}

.thread-reply-meta {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.thread-reply-author-name {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-secondary);
}

.thread-reply-time {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
}

.thread-reply-body {
  font-size: var(--font-size-base);
  color: var(--text-primary);
  line-height: 1.7;
  padding-left: calc(32px + var(--space-3));
  white-space: pre-wrap;
}

/* ── Reply composer ─────────────────────────────────────────────────────────── */

.thread-reply-composer {
  background: var(--surface-card);
  border: 1px solid var(--color-brown-100);
  border-radius: var(--radius-lg);
  padding: var(--space-5) var(--space-6);
  margin-top: var(--space-6);
}

.thread-reply-composer-label {
  font-size: var(--font-size-base);
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 var(--space-4);
}

.thread-reply-composer-input {
  resize: vertical;
  min-height: 96px;
  margin-bottom: var(--space-3);
}

.thread-reply-composer-footer {
  display: flex;
  justify-content: flex-end;
}

/* ── Thread archive actions ─────────────────────────────────────────────────
   The user-initiated bridge from conversation content into the archive.
   Restrained, warm, secondary — these are not primary CTAs.
   ─────────────────────────────────────────────────────────────────────────── */

.thread-archive-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-5);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-brown-100);
}

.thread-archive-btn {
  background: none;
  border: none;
  padding: 0;
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--color-amber-dark);
  cursor: pointer;
  text-decoration: underline;
  text-decoration-color: transparent;
  transition: text-decoration-color 0.15s, color 0.15s;
  font-family: inherit;
}

.thread-archive-btn:hover {
  text-decoration-color: currentColor;
}

.thread-archive-sep {
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  user-select: none;
}

/* ── Archive action modal body ────────────────────────────────────────────── */

.archive-action-modal {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.archive-action-desc {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  margin: 0;
  line-height: 1.6;
}

.archive-action-textarea {
  resize: vertical;
  min-height: 120px;
  font-size: var(--font-size-sm);
  line-height: 1.7;
}

.archive-action-empty {
  font-size: var(--font-size-sm);
  color: var(--text-muted);
  font-style: italic;
  margin: 0;
  line-height: 1.6;
}

/* ── Recipe picker ────────────────────────────────────────────────────────── */

.recipe-picker-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--color-brown-100);
  border-radius: var(--radius-md);
  padding: var(--space-1);
}

.recipe-picker-item {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
}

.recipe-picker-item:hover {
  background: var(--color-amber-light);
}

.recipe-picker-item--selected {
  background: var(--color-amber-light);
  outline: 2px solid var(--color-amber-dark);
  outline-offset: -2px;
}

.recipe-picker-item-title {
  font-size: var(--font-size-sm);
  font-weight: 500;
  color: var(--text-primary);
}

/* ── Responsive ───────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .gathering-page {
    padding: var(--space-5) var(--space-4) var(--space-16);
  }

  .gathering-header {
    margin-bottom: var(--space-5);
  }

  .gathering-title {
    font-size: var(--font-size-2xl);
  }

  .gathering-thread-body,
  .gathering-thread-footer {
    padding-left: 0;
  }

  .gathering-thread-card {
    padding: var(--space-4);
  }

  .composer-block {
    padding: var(--space-4);
  }

  .thread-detail-header {
    padding: var(--space-5);
  }

  .thread-reply-body {
    padding-left: 0;
  }

  .thread-reply-composer {
    padding: var(--space-4);
  }

  .composer-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .composer-submit {
    width: 100%;
  }
}

/* ── Composer microcopy ──────────────────────────────────────────────────────── */

.composer-microcopy {
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: var(--space-2);
}

/* ── Rotating placeholder overlay ───────────────────────────────────────────── */

.composer-placeholder-wrap {
  position: relative;
}

.composer-placeholder-overlay {
  position: absolute;
  top: 10px;
  left: 12px;
  right: 12px;
  color: var(--text-muted);
  pointer-events: none;
  transition: opacity 0.35s ease;
  font-size: var(--font-size-sm);
  user-select: none;
  line-height: 1.5;
}

.composer-placeholder-overlay.fading {
  opacity: 0;
}

/* ── Conversation clustering ─────────────────────────────────────────────────── */

.thread-cluster {
  display: flex;
  flex-direction: column;
}

/* Remove bottom border from the last reply in each cluster */
.thread-cluster .thread-reply:last-child {
  border-bottom: none;
}

/* Quiet timestamp label between conversation clusters */
.thread-cluster-divider {
  text-align: center;
  font-size: var(--font-size-xs);
  color: var(--text-muted);
  font-style: italic;
  padding: var(--space-7) 0 var(--space-3);
  opacity: 0.65;
  letter-spacing: 0.02em;
  user-select: none;
}
