/* ==========================================================================
   Avezz Discussion Thread (Editorial Theme) & Unified Comment Tree
   1:1 UI/discussion.html Editorial preset + Compact Embedded Mode for Snaps/Reader
   ========================================================================== */

:root {
  --disc-surface: var(--surface, #ffffff);
  --disc-surface-alt: var(--surface-alt, #f3f4f6);
  --disc-surface-hover: var(--surface-hover, #e5e7eb);
  --disc-border: var(--border, #dfe3ea);
  --disc-border-soft: rgba(15, 23, 42, 0.08);
  --disc-text: var(--text, #111827);
  --disc-text-muted: var(--text-muted, #4b5563);
  --disc-text-soft: var(--text-soft, #6b7280);
  --disc-accent: var(--accent, #2563eb);
  --disc-accent-soft: rgba(37, 99, 235, 0.1);
  --disc-rose: #e11d48;
  --disc-rose-soft: rgba(225, 29, 72, 0.1);
  --disc-emerald: #059669;
  --disc-emerald-soft: rgba(5, 150, 105, 0.12);
  --disc-amber: #d97706;
  --disc-amber-soft: rgba(217, 119, 6, 0.12);
  --disc-pill-bg: #111827;
  --disc-pill-text: #ffffff;
  --tree-line: #111827;
  --tree-line-hover: #2563eb;
  --tree-hit-hover: rgba(37, 99, 235, 0.08);
  --tree-indent: 28px;
  --tree-width: 2px;
  --tree-radius: 10px;
}

[data-theme="dark"] {
  --disc-border-soft: rgba(255, 255, 255, 0.08);
  --disc-accent-soft: rgba(96, 165, 250, 0.16);
  --disc-rose: #fb7185;
  --disc-rose-soft: rgba(251, 113, 133, 0.16);
  --disc-emerald: #34d399;
  --disc-emerald-soft: rgba(52, 211, 153, 0.16);
  --disc-amber: #fbbf24;
  --disc-amber-soft: rgba(251, 191, 36, 0.16);
  --disc-pill-bg: #f3f4f6;
  --disc-pill-text: #111827;
  --tree-line: #71717a;
  --tree-line-hover: #60a5fa;
  --tree-hit-hover: rgba(96, 165, 250, 0.12);
}

/* ==========================================================================
   EDITORIAL THEME (ONLY FOR DISCUSSION THREADS — Forum/Forum.php)
   ========================================================================== */

body:has(.disc-editorial-page) {
  background: #f4efe6;
  color: #1c1917;
}

[data-theme="dark"] body:has(.disc-editorial-page) {
  background: #171412;
  color: #f5efe6;
}

body:has(.disc-editorial-page) .nav-shell {
  background: #fbf9f3;
  border-bottom-color: #d6cbb8;
}

[data-theme="dark"] body:has(.disc-editorial-page) .nav-shell {
  background: #201c19;
  border-bottom-color: #3d352e;
}

.disc-editorial-page {
  --disc-bg: #f4efe6;
  --disc-surface: #fbf9f3;
  --disc-surface-alt: #efe9dc;
  --disc-surface-hover: #e5dccb;
  --disc-border: #d6cbb8;
  --disc-border-soft: rgba(41, 37, 36, 0.1);
  --disc-text: #1c1917;
  --disc-text-muted: #44403c;
  --disc-text-soft: #78716c;
  --disc-accent: #b91c1c;
  --disc-accent-soft: rgba(185, 28, 28, 0.1);
  --disc-pill-bg: #1c1917;
  --disc-pill-text: #fbf9f3;
  --tree-line: #292524;
  --tree-line-hover: #b91c1c;
  --tree-hit-hover: rgba(185, 28, 28, 0.08);
  --tree-width: 2px;
  --tree-radius: 8px;

  max-width: 920px;
  margin: 0 auto;
  padding: 20px 16px 64px;
  font-family: Georgia, "Times New Roman", Cambria, serif;
  color: var(--disc-text);
}

[data-theme="dark"] .disc-editorial-page {
  --disc-bg: #171412;
  --disc-surface: #201c19;
  --disc-surface-alt: #292420;
  --disc-surface-hover: #342d28;
  --disc-border: #3d352e;
  --disc-border-soft: rgba(245, 239, 230, 0.1);
  --disc-text: #f5efe6;
  --disc-text-muted: #d6ccc2;
  --disc-text-soft: #a69b8f;
  --disc-accent: #f87171;
  --disc-accent-soft: rgba(248, 113, 113, 0.15);
  --disc-pill-bg: #f5efe6;
  --disc-pill-text: #1c1917;
  --tree-line: #a69b8f;
  --tree-line-hover: #f87171;
  --tree-hit-hover: rgba(248, 113, 113, 0.12);
}

/* Breadcrumb */
.disc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  font-size: 13px;
  color: var(--disc-text-soft);
}

.disc-breadcrumb a {
  color: var(--disc-text-muted);
  text-decoration: none;
  font-weight: 600;
}

.disc-breadcrumb a:hover {
  color: var(--disc-accent);
  text-decoration: underline;
}

.disc-breadcrumb-cur {
  color: var(--disc-text);
  font-weight: 700;
}

/* Main OP Topic Card (Left border flows directly into comment tree trunk) */
.topic-card {
  background: var(--disc-surface);
  border: var(--tree-width) solid var(--tree-line);
  border-radius: 4px 4px 4px 0;
  padding: 26px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
  display: flex;
  flex-direction: column;
  gap: 14px;
  position: relative;
  z-index: 2;
}

.topic-cover {
  width: 100%;
  max-height: 440px;
  aspect-ratio: 21 / 9;
  border-radius: 2px;
  object-fit: cover;
  display: block;
  background: var(--disc-surface-alt);
  filter: sepia(0.14) contrast(1.03);
}

.topic-title {
  font-family: Georgia, "Times New Roman", Cambria, serif;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.015em;
  color: var(--disc-text);
  margin: 0;
}

.topic-meta-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 0;
  border-top: 1px solid var(--disc-border-soft);
  border-bottom: 1px solid var(--disc-border-soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

.disc-author-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.disc-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--disc-pill-bg);
  color: var(--disc-pill-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-weight: 800;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
  text-decoration: none;
}

.disc-avatar img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.disc-avatar-sm {
  width: 22px;
  height: 22px;
  font-size: 10px;
}

.disc-author-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.disc-author-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  font-size: 13.5px;
  font-weight: 700;
}

.disc-author-name-line a {
  color: var(--disc-text);
  text-decoration: none;
}

.disc-author-name-line a:hover {
  color: var(--disc-accent);
}

.disc-author-sub {
  font-size: 12px;
  color: var(--disc-text-soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.disc-badge {
  display: inline-flex;
  align-items: center;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.3;
  text-decoration: none;
}

.disc-badge-op {
  background: var(--disc-accent-soft);
  color: var(--disc-accent);
}

.disc-badge-type {
  background: var(--disc-emerald-soft);
  color: var(--disc-emerald);
}

.disc-badge-tag {
  background: var(--disc-surface-alt);
  color: var(--disc-text-muted);
  border: 1px solid var(--disc-border);
}

.disc-badge-tag:hover {
  border-color: var(--disc-accent);
  color: var(--disc-accent);
}

.topic-body {
  font-size: 15.5px;
  line-height: 1.7;
  color: var(--disc-text);
  white-space: pre-line;
  word-break: break-word;
}

.topic-body a {
  color: var(--disc-accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.topic-tags-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.topic-owner-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

/* Social Action Row (Topic & Comments) */
.disc-social-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

.disc-social-btn {
  height: 28px;
  padding: 0 9px;
  border-radius: 7px;
  border: 0;
  font-size: 12px;
  font-weight: 600;
  color: var(--disc-text-muted);
  background: var(--disc-surface-alt);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s ease, color 0.14s ease;
}

.disc-social-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.disc-social-btn:hover {
  background: var(--disc-surface-hover);
  color: var(--disc-text);
}

.disc-social-btn.like.active {
  background: var(--disc-accent-soft);
  color: var(--disc-accent);
}

.disc-social-btn.deslike.active {
  background: var(--disc-rose-soft);
  color: var(--disc-rose);
}

.disc-social-btn.share.active {
  background: var(--disc-amber-soft);
  color: var(--disc-amber);
}

.disc-social-btn--danger:hover {
  background: var(--disc-rose-soft);
  color: var(--disc-rose);
}

/* ==========================================================================
   UNIFIED DISCUSSION TREE (CONTINUING FROM LEFT SIDE OF PARENT CARD)
   ========================================================================== */

.disc-tree {
  position: relative;
  width: 100%;
}

.tree-branch {
  margin-left: 0;
  padding-left: var(--tree-indent);
  padding-top: 10px;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Full-height clickable rail covering the tree gutter */
.tree-rail-hit {
  position: absolute;
  left: -4px;
  top: 0;
  bottom: 0;
  width: calc(var(--tree-indent) + 2px);
  z-index: 3;
  border: 0;
  padding: 0;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.14s ease;
}

.tree-rail-hit:hover {
  background: var(--tree-hit-hover);
}

.tree-branch:has(> .tree-rail-hit:hover) > .tree-item:not(:last-child)::before {
  background: var(--tree-line-hover);
}

.tree-branch:has(> .tree-rail-hit:hover) > .tree-item::after {
  border-color: var(--tree-line-hover);
}

.tree-item {
  position: relative;
  min-width: 0;
}

/* Continuous vertical trunk flush with parent's left border */
.tree-item:not(:last-child)::before {
  content: "";
  position: absolute;
  left: calc(var(--tree-indent) * -1);
  top: -12px;
  bottom: -10px;
  width: var(--tree-width);
  background: var(--tree-line);
  pointer-events: none;
  transition: background 0.14s ease;
}

/* Smooth rounded elbow emerging from the side into the child card */
.tree-item::after {
  content: "";
  position: absolute;
  left: calc(var(--tree-indent) * -1);
  top: -12px;
  width: calc(var(--tree-indent) + 2px);
  height: 36px;
  border-left: var(--tree-width) solid var(--tree-line);
  border-bottom: var(--tree-width) solid var(--tree-line);
  border-bottom-left-radius: var(--tree-radius);
  pointer-events: none;
  transition: border-color 0.14s ease;
}

/* Collapsed branch state */
.tree-branch.is-collapsed {
  padding-top: 6px;
}

.tree-branch.is-collapsed > .tree-item:not(.tree-item-collapsed) {
  display: none;
}

.tree-branch:not(.is-collapsed) > .tree-item-collapsed {
  display: none;
}

.tree-branch.is-collapsed > .tree-item-collapsed::after {
  top: -8px;
  height: 22px;
}

.tree-branch.is-collapsed > .tree-item-collapsed::before {
  display: none;
}

/* Closed path count pill attached directly to curved elbow */
.closed-path-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 26px;
  padding: 0 10px 0 6px;
  border-radius: 999px;
  background: var(--disc-surface);
  border: var(--tree-width) solid var(--tree-line);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: var(--disc-text);
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease, color 0.14s ease;
}

.closed-path-btn:hover,
.tree-branch:has(> .tree-rail-hit:hover) .closed-path-btn {
  background: var(--disc-accent-soft);
  border-color: var(--tree-line-hover);
  color: var(--tree-line-hover);
}

.collapsed-pill {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--tree-line);
  color: var(--disc-surface);
  font-size: 12px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.closed-path-btn:hover .collapsed-pill,
.tree-branch:has(> .tree-rail-hit:hover) .collapsed-pill {
  background: var(--tree-line-hover);
}

/* One-line auto-growing composer & inline reply */
.disc-composer {
  background: var(--disc-surface);
  border: var(--tree-width) solid var(--tree-line);
  border-radius: 8px;
  padding: 6px 8px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.disc-editorial-page .disc-composer {
  border-radius: 4px;
}

.disc-composer textarea {
  flex: 1;
  min-width: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 6px 8px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  color: var(--disc-text);
  min-height: 32px;
  max-height: 180px;
  resize: none;
  overflow-y: hidden;
  outline: none;
}

.disc-composer textarea::placeholder {
  color: var(--disc-text-soft);
}

.disc-composer-inline {
  margin-top: 8px;
  background: var(--disc-surface-alt);
}

.disc-composer-inline[hidden] {
  display: none;
}

.disc-btn-post {
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 7px;
  background: var(--disc-pill-bg);
  color: var(--disc-pill-text);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: opacity 0.14s ease;
}

.disc-btn-post:hover {
  opacity: 0.88;
}

.disc-btn-post:disabled {
  opacity: 0.55;
  cursor: wait;
}

.disc-btn-close {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  border: 1px solid var(--disc-border);
  background: var(--disc-surface);
  color: var(--disc-text-muted);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  cursor: pointer;
}

.disc-btn-close:hover {
  background: var(--disc-surface-hover);
  color: var(--disc-text);
}

/* Outlined Comment Card */
.comment-node {
  min-width: 0;
}

.comment-card {
  background: var(--disc-surface);
  border: var(--tree-width) solid var(--tree-line);
  border-radius: 10px;
  padding: 11px 13px 9px;
  position: relative;
  z-index: 1;
}

.disc-editorial-page .comment-card {
  border-radius: 4px;
}

.comment-card.has-children {
  border-bottom-left-radius: 0;
}

.comment-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--disc-text);
  white-space: pre-line;
  word-break: break-word;
  margin: 0 0 9px;
}

.disc-editorial-page .comment-text {
  font-family: Georgia, "Times New Roman", Cambria, serif;
  font-size: 14.5px;
  line-height: 1.62;
}

.comment-text a {
  color: var(--disc-accent);
  text-decoration: underline;
}

.comment-rating {
  margin-bottom: 6px;
}

.comment-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 7px;
  border-top: 1px solid var(--disc-border-soft);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

.comment-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.comment-profile {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-right: 4px;
  text-decoration: none;
}

.comment-author {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--disc-text);
  text-decoration: none;
}

.comment-author:hover {
  color: var(--disc-accent);
}

.comment-bar .disc-social-btn {
  height: 25px;
  padding: 0 7px;
  font-size: 11.5px;
  background: transparent;
}

.comment-bar .disc-social-btn:hover {
  background: var(--disc-surface-alt);
}

.comment-bar .disc-social-btn.like.active {
  background: var(--disc-accent-soft);
}

.comment-bar .disc-social-btn.deslike.active {
  background: var(--disc-rose-soft);
}

.comment-date {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--disc-text-soft);
  white-space: nowrap;
  margin-left: auto;
}

/* Inline Comment Edit Form */
.comment-edit-wrap {
  margin-top: 8px;
}

.comment-edit-wrap[hidden] {
  display: none;
}

.disc-empty-note {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  color: var(--disc-text-soft);
  padding: 10px 4px;
}

/* ==========================================================================
   COMPACT EMBEDDED MODE (Snaps Image/Post Scroll & Reader Comments Sheet)
   ========================================================================== */

.disc-tree--compact {
  --tree-indent: 18px;
  --tree-width: 1px;
  --tree-radius: 8px;
  --tree-line: var(--border, #d1d5db);
  --tree-line-hover: var(--accent, #2563eb);
  --tree-hit-hover: rgba(37, 99, 235, 0.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
}

[data-theme="dark"] .disc-tree--compact {
  --tree-line: rgba(255, 255, 255, 0.18);
  --tree-line-hover: #60a5fa;
}

.disc-tree--compact > .tree-branch {
  padding-left: 0;
  padding-top: 0;
  gap: 8px;
}

.disc-tree--compact > .tree-branch > .tree-rail-hit,
.disc-tree--compact > .tree-branch > .tree-item::before,
.disc-tree--compact > .tree-branch > .tree-item::after {
  display: none;
}

.disc-tree--compact .tree-branch {
  gap: 8px;
  padding-top: 8px;
}

.disc-tree--compact .comment-card {
  padding: 9px 11px 7px;
  border-radius: 10px;
  border-color: var(--tree-line);
}

.disc-tree--compact .comment-card.has-children {
  border-bottom-left-radius: 0;
}

.disc-tree--compact .comment-text {
  font-size: 13px;
  line-height: 1.45;
  margin-bottom: 6px;
}

.disc-tree--compact .comment-bar {
  padding-top: 5px;
  gap: 6px;
}

.disc-tree--compact .comment-bar .disc-social-btn {
  height: 23px;
  padding: 0 5px;
  font-size: 11px;
}

.disc-tree--compact .closed-path-btn {
  height: 24px;
  font-size: 11.5px;
}

.disc-tree--compact .disc-composer {
  padding: 4px 6px;
  border-radius: 8px;
}

.disc-tree--compact .disc-composer textarea {
  font-size: 12.5px;
  padding: 4px 6px;
  min-height: 28px;
}

.disc-tree--compact .disc-btn-post,
.disc-tree--compact .disc-btn-close {
  height: 28px;
  font-size: 11.5px;
}

.disc-tree--compact .disc-btn-close {
  width: 28px;
}

@media (max-width: 640px) {
  .disc-editorial-page {
    --tree-indent: 20px;
    padding: 14px 12px 56px;
  }

  .topic-card {
    padding: 16px;
  }

  .topic-title {
    font-size: 20px;
  }

  .comment-card {
    padding: 10px 11px 8px;
  }
}
