/**
 * Collector Discussion — Modern threaded comment UI.
 *
 * Sections:
 * 1. Discussion wrapper
 * 2. Discussion starter (AI-seeded prompt)
 * 3. Contextual prompt buttons
 * 4. Reaction pills layout
 * 5. Comment thread layout (Reddit-style)
 * 6. Avatars
 * 7. Comment actions
 * 8. Thread collapse
 * 9. Mobile responsive
 */

/* ==========================================================================
   0. Market Stats Bar (homepage)
   ========================================================================== */

.market-stats-bar {
  margin: 0 0 24px;
  padding: 20px 16px;
  background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
  border-radius: 12px;
  text-align: center;
}

.market-stats-bar__inner {
  display: flex;
  justify-content: center;
  gap: 32px;
  flex-wrap: wrap;
}

.market-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.market-stat__number {
  font-size: 1.4rem;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: -0.5px;
}

.market-stat__label {
  font-size: 0.75rem;
  font-weight: 500;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.market-stats-bar__note {
  font-size: 0.78rem;
  color: #64748b;
  margin: 12px 0 0;
}

@media (max-width: 600px) {
  .market-stats-bar__inner {
    gap: 20px;
  }
  .market-stat__number {
    font-size: 1.15rem;
  }
  .market-stat__label {
    font-size: 0.7rem;
  }
}

/* ==========================================================================
   1. Discussion Wrapper
   ========================================================================== */

.collector-discussion {
  margin: 32px 0 24px;
  padding: 0;
}

.collector-discussion__header {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e2e8f0;
}

.collector-discussion__title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #1e293b;
  margin: 0 0 6px;
}

.collector-discussion__invite {
  font-size: 0.9rem;
  color: #64748b;
  margin: 0;
  line-height: 1.5;
}

/* ==========================================================================
   2. Discussion Starter (AI-seeded)
   ========================================================================== */

.cd-discussion-starter {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
  background: #f8fafc;
  border-left: 3px solid #667eea;
  border-radius: 0 8px 8px 0;
}

.cd-discussion-starter__avatar {
  flex-shrink: 0;
}

.cd-discussion-starter__avatar span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.cd-discussion-starter__body {
  flex: 1;
  min-width: 0;
}

.cd-discussion-starter__label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: #667eea;
  margin-bottom: 4px;
}

.cd-discussion-starter__body p {
  margin: 0;
  font-size: 0.9rem;
  color: #475569;
  line-height: 1.5;
}

/* ==========================================================================
   3. Contextual Prompt Buttons
   ========================================================================== */

.cd-prompts-heading {
  font-size: 0.9rem;
  font-weight: 600;
  color: #334155;
  margin: 0 0 10px;
}

.cd-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 20px;
}

.cd-prompt-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1.5px solid #bfdbfe;
  border-radius: 24px;
  background: #eff6ff;
  color: #1e40af;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: 0 1px 2px rgba(30, 64, 175, 0.06);
}

.cd-prompt-btn:hover {
  background: #dbeafe;
  border-color: #60a5fa;
  box-shadow: 0 2px 6px rgba(30, 64, 175, 0.12);
  transform: translateY(-1px);
}

/* ==========================================================================
   4. Reaction Pills (theme-level overrides)
   ========================================================================== */

.collector-reactions {
  margin: 24px 0;
  padding: 16px 0;
  border-top: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
}

.collector-reactions__title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 10px;
}

/* ==========================================================================
   4a. Comment form heading + comments heading
   ========================================================================== */

.cd-form-heading {
  font-size: 1rem;
  font-weight: 600;
  color: #334155;
  margin: 0 0 8px;
}

.cd-comments-heading {
  font-size: 1rem;
  font-weight: 600;
  color: #64748b;
  margin: 24px 0 12px;
  padding-top: 16px;
  border-top: 1px solid #e2e8f0;
}

/* ==========================================================================
   4b. "Be the first" nudge
   ========================================================================== */

.cd-be-first {
  text-align: center;
  padding: 16px;
  margin: 0 0 16px;
  font-size: 0.9rem;
  color: #64748b;
  font-style: italic;
  background: #f8fafc;
  border: 1px dashed #e2e8f0;
  border-radius: 8px;
}

/* ==========================================================================
   5. Comment Thread Layout (Reddit-style)
   ========================================================================== */

/* Human comment wrapper */
.cd-comment-wrapper {
  margin-bottom: 0 !important;
  padding: 0 !important;
  border: none !important;
  background: none !important;
}

.cd-comment {
  display: flex;
  gap: 12px;
  padding: 12px 0;
}

.cd-comment__body {
  flex: 1;
  min-width: 0;
}

.cd-comment__header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.cd-comment__author {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
}

.cd-comment__author a {
  color: #1e293b;
  text-decoration: none;
}

.cd-comment__author a:hover {
  color: #667eea;
}

.cd-comment__level {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 1px 8px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  white-space: nowrap;
}

.cd-comment__time {
  font-size: 0.78rem;
  color: #94a3b8;
}

.cd-comment__subject {
  font-size: 0.95rem;
  font-weight: 600;
  color: #334155;
  margin: 2px 0 6px;
}

.cd-comment__content {
  font-size: 0.9rem;
  color: #334155;
  line-height: 1.7;
}

.cd-comment__content p {
  margin: 0 0 10px;
}

.cd-comment__content p:last-child {
  margin-bottom: 0;
}

/* Preserve line breaks in discussion replies (plain text stored with newlines) */
.discussion-node .cd-comment__content .field--name-comment-body.field__item,
.page-node-type-discussion .cd-comment__content .field--name-comment-body.field__item,
.page-node-type-discussion .field--name-comment-body.field__item {
  white-space: pre-line;
  word-wrap: break-word;
}

/* Bullet lists in comments */
.cd-comment__content ul,
.cd-comment__content ol {
  margin: 8px 0;
  padding-left: 1.5em;
}

.cd-comment__content li {
  margin-bottom: 4px;
}

/* Thread indentation (Drupal uses .indented divs) */
.discussion-comments .indented {
  margin-left: 0;
  padding-left: 24px;
  border-left: 2px solid #e2e8f0;
}

.discussion-comments .indented .indented {
  padding-left: 20px;
}

/* Max visible depth: flatten at 3+ levels on desktop */
.discussion-comments .indented .indented .indented {
  padding-left: 16px;
  border-left-color: #f1f5f9;
}

/* ==========================================================================
   6. Avatars
   ========================================================================== */

.cd-avatar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  line-height: 1;
}

/* ==========================================================================
   7. Comment Actions
   ========================================================================== */

.cd-comment__actions {
  margin-top: 6px;
}

.cd-comment__actions .comment ul.links {
  display: flex;
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.cd-comment__actions .comment ul.links li {
  margin: 0;
  padding: 0;
}

.cd-comment__actions .comment ul.links li a,
.cd-comment__actions ul.links li a {
  font-size: 0.78rem;
  font-weight: 500;
  color: #94a3b8;
  text-decoration: none;
  padding: 2px 4px;
  border-radius: 3px;
  transition: color 0.15s;
}

.cd-comment__actions .comment ul.links li a:hover,
.cd-comment__actions ul.links li a:hover {
  color: #667eea;
  background: #f1f5f9;
}

/* Hide the subject field in comment form — auto-generated */
.collector-discussion .comment-form .field--name-subject {
  display: none;
}

/* Style the comment form textarea */
.collector-discussion .comment-form textarea {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
  transition: border-color 0.15s;
}

.collector-discussion .comment-form textarea:focus {
  border-color: #667eea;
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Style the submit button */
.collector-discussion .comment-form .form-submit {
  background: #667eea;
  color: #fff;
  border: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.collector-discussion .comment-form .form-submit:hover {
  background: #5a67d8;
}

/* ==========================================================================
   8. Thread Collapse
   ========================================================================== */

.cd-thread-toggle {
  display: inline-block;
  padding: 4px 12px;
  margin: 4px 0 8px 44px;
  font-size: 0.78rem;
  font-weight: 500;
  color: #667eea;
  background: none;
  border: none;
  cursor: pointer;
  border-radius: 4px;
}

.cd-thread-toggle:hover {
  background: #eff6ff;
}

.cd-thread-collapsed {
  display: none;
}

/* ==========================================================================
   9. Mobile Responsive
   ========================================================================== */

@media (max-width: 600px) {
  .collector-discussion__title {
    font-size: 1.1rem;
  }

  .cd-prompts {
    flex-direction: column;
  }

  .cd-prompt-btn {
    width: 100%;
    justify-content: center;
  }

  .cd-comment {
    gap: 10px;
  }

  .cd-avatar {
    width: 30px;
    height: 30px;
    font-size: 0.75rem;
  }

  .discussion-comments .indented {
    padding-left: 16px;
  }

  .discussion-comments .indented .indented {
    padding-left: 12px;
  }

  .discussion-comments .indented .indented .indented {
    padding-left: 8px;
    border-left: none;
  }

  .cd-discussion-starter {
    padding: 10px 12px;
  }
}

/* ==========================================================================
   Scroll Cue (homepage below hero)
   ========================================================================== */

.scroll-cue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 0.5rem 0 0.25rem 0;
  opacity: 0.5;
  transition: opacity 0.3s;
  text-decoration: none;
  cursor: pointer;
}

.scroll-cue:hover {
  opacity: 0.8;
  text-decoration: none;
}

.scroll-cue__arrow {
  font-size: 1.2rem;
  color: #718096;
  animation: scrollBounce 2s ease-in-out infinite;
}

.scroll-cue__text {
  font-size: 0.8rem;
  color: #718096;
  letter-spacing: 0.5px;
}

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

/* ==========================================================================
   Mid-Feed CTA (homepage secondary conversion prompt)
   ========================================================================== */

.mid-feed-cta {
  margin: 2rem 0;
  padding: 0;
}

.mid-feed-cta__inner {
  text-align: center;
  padding: 2rem 1.5rem;
  background: #fff;
  border: 2px solid #d4af37;
  border-radius: 16px;
}

.mid-feed-cta__title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #1a202c;
  margin: 0 0 0.5rem 0;
}

.mid-feed-cta__text {
  color: #4a5568;
  font-size: 0.95rem;
  margin: 0 0 1.25rem 0;
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.mid-feed-cta__btn {
  display: inline-block;
  background: linear-gradient(135deg, #d4af37 0%, #b8931f 100%);
  color: #fff;
  padding: 0.875rem 2.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
  border-radius: 50px;
  box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
  transition: box-shadow 0.2s, transform 0.2s;
}

.mid-feed-cta__btn:hover {
  box-shadow: 0 6px 20px rgba(212, 175, 55, 0.45);
  transform: translateY(-1px);
  color: #fff;
  text-decoration: none;
}

/* ==========================================================================
   Value Guide Cross-Link (appraisal pages)
   ========================================================================== */

.value-guide-crosslink {
  margin: 1.5rem 0;
}

.value-guide-crosslink a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #fffdf5 0%, #fff9e6 100%);
  border: 1px solid #e8d48b;
  border-radius: 10px;
  text-decoration: none;
  color: #2d3748;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.value-guide-crosslink a:hover {
  border-color: #d4af37;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.15);
  text-decoration: none;
}

.value-guide-crosslink__icon {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.value-guide-crosslink__text {
  flex: 1;
  font-size: 0.9rem;
  line-height: 1.4;
  color: #4a5568;
}

.value-guide-crosslink__text strong {
  color: #1a365d;
}

.value-guide-crosslink__arrow {
  color: #d4af37;
  font-size: 1.2rem;
  font-weight: 700;
  flex-shrink: 0;
}

/* ==========================================================================
   Appraisal Page Breadcrumb (SEO structured navigation)
   ========================================================================== */

.appraisal-breadcrumb {
  margin: 0 0 1rem 0;
  font-size: 0.82rem;
}

.appraisal-breadcrumb__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0;
}

.appraisal-breadcrumb__list li {
  color: #718096;
}

.appraisal-breadcrumb__list li:not(:last-child)::after {
  content: "›";
  margin: 0 6px;
  color: #cbd5e0;
}

.appraisal-breadcrumb__list li a {
  color: #4a5568;
  text-decoration: none;
}

.appraisal-breadcrumb__list li a:hover {
  color: #2c5282;
  text-decoration: underline;
}

.appraisal-breadcrumb__list li[aria-current="page"] {
  color: #1a202c;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 300px;
}

/* ==========================================================================
   Discussion Node Page
   ========================================================================== */

.discussion-node {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 1rem 2rem;
}

.discussion-header {
  margin: 0 0 1.5rem;
}

.discussion-header__title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #1a202c;
  margin: 0 0 0.75rem;
  line-height: 1.3;
}

.discussion-header__meta {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.discussion-header__author {
  display: flex;
  align-items: center;
  gap: 8px;
}

.cd-avatar--sm {
  width: 32px;
  height: 32px;
  font-size: 0.8rem;
}

.discussion-header__author-name {
  font-weight: 600;
  color: #2d3748;
  font-size: 0.9rem;
}

.discussion-header__time {
  color: #718096;
  font-size: 0.85rem;
}

.discussion-body {
  font-size: 1rem;
  line-height: 1.7;
  color: #2d3748;
  margin: 0 0 1.5rem;
}

.discussion-body p {
  margin: 0 0 1rem;
}

.discussion-body a {
  color: #2c5282;
  text-decoration: underline;
}

.discussion-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.5rem;
}

.discussion-images__item img {
  width: 100%;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.discussion-back {
  margin: 0 0 2rem;
  padding-top: 1rem;
  border-top: 1px solid #e2e8f0;
}

.discussion-comments {
  margin: 0;
}

.discussion-comments .discussions-section-title {
  margin-bottom: 1rem;
}

/* Hide admin tabs on discussion node pages for non-admin users */
.page-node-type-discussion .tabs,
.page-node-type-discussion nav.tabs,
.page-node-type-discussion .block-local-tasks-block {
  display: none;
}

/* Show admin tabs for admins */
body.role--administrator .page-node-type-discussion .tabs,
body.role--administrator .page-node-type-discussion nav.tabs,
body.role--administrator .page-node-type-discussion .block-local-tasks-block,
body.toolbar-horizontal .page-node-type-discussion .tabs,
body.toolbar-horizontal .page-node-type-discussion nav.tabs,
body.toolbar-horizontal .page-node-type-discussion .block-local-tasks-block {
  display: block;
}

/* Discussion reply page — hide clutter (use very specific selectors to avoid hiding textarea) */
.page-node-type-discussion .comment-form .field--name-subject,
.page-node-type-discussion .comment-comment-form .field--name-subject {
  display: none !important;
}

.page-node-type-discussion .comment-form .filter-wrapper,
.page-node-type-discussion .comment-comment-form .filter-wrapper,
.page-node-type-discussion .comment-form .filter-guidelines,
.page-node-type-discussion .comment-comment-form .filter-guidelines,
.page-node-type-discussion .comment-form .filter-help,
.page-node-type-discussion .comment-comment-form .filter-help {
  display: none !important;
}

.page-node-type-discussion fieldset.simple-sitemap-fieldset,
.page-node-type-discussion [data-drupal-selector="edit-simple-sitemap"] {
  display: none !important;
}

/* Discussion reply page — style form elements */
.page-node-type-discussion .layout-content textarea {
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
  width: 100%;
  transition: border-color 0.15s;
}

.page-node-type-discussion .layout-content textarea:focus {
  border-color: #667eea;
  outline: none;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.page-node-type-discussion .layout-content .form-submit {
  background: #667eea;
  color: #fff;
  border: none;
  padding: 10px 24px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.page-node-type-discussion .layout-content .form-submit:hover {
  background: #5a67d8;
}

/* Discussion reply form */
.discussion-reply-context {
  padding: 10px 14px;
  background: #f7fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #4a5568;
  margin-bottom: 0.5rem;
}

.discussion-reply-hint {
  font-size: 0.85rem;
  color: #718096;
  margin: 0 0 1rem;
  font-style: italic;
}

.discussion-reply-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: #1a202c;
  margin: 1.5rem 0 0.75rem;
}

/* Style Reply links on each comment */
.cd-comment__actions .comment ul.links li a {
  font-size: 0.8rem;
  color: #718096;
  text-decoration: none;
  font-weight: 500;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s;
}

.cd-comment__actions .comment ul.links li a:hover {
  color: #2c5282;
  background: #ebf4ff;
}

/* Comment attached images — thumbnail gallery with Colorbox */
.cd-comment__images {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 0.5rem 0 0.75rem;
}

html body a.cd-comment__image-link,
html body a.cd-comment__image-link.colorbox,
html body a.cd-comment__image-link.cboxElement {
  display: block !important;
  width: 140px !important;
  height: 140px !important;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  transition: border-color 0.2s, box-shadow 0.2s;
  flex-shrink: 0;
  clear: none !important;
  margin-bottom: 0 !important;
}

html body a.cd-comment__image-link:hover {
  border-color: #d4af37;
  box-shadow: 0 2px 8px rgba(212, 175, 55, 0.2);
}

html body a.cd-comment__image-link img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  max-width: none !important;
  max-height: none !important;
  image-orientation: from-image;
}

@media (max-width: 768px) {
  html body a.cd-comment__image-link,
  html body a.cd-comment__image-link.colorbox,
  html body a.cd-comment__image-link.cboxElement {
    width: 110px !important;
    height: 110px !important;
  }

  .discussion-header__title {
    font-size: 1.3rem;
  }

  .discussion-images {
    grid-template-columns: 1fr;
  }
}
