/* ================================================================
   THE TREE — Gazette default layout (2026-08-07)
   ----------------------------------------------------------------
   The baobab tree the diaspora sits under. Two-column spine:
   LEFT  = reading river (single dense column)
   RIGHT = persistent activity panel (Circle · Article chats · Rooms)

   Namespaced under .gazette-tree; scoped `body.tree-mode` toggles
   visibility with the legacy compact grid, gazette-masthead, and
   lead-rotator. Zero touch to existing render code — this layout
   builds from window.CURRENT_NEWS via tree.js wrapping renderArticles.
   ================================================================ */

/* Body-level mode gate ---------------------------------------------------- */
body.tree-mode #panel-news .gazette-masthead,
body.tree-mode #panel-news .lead-rotator,
body.tree-mode #panel-news #news-view-compact,
body.tree-mode #panel-news #news-timeline,
body.tree-mode #panel-news #news-views {
  display: none !important;
}
/* Must be `grid`, not `block` — this selector outranks the .gazette-tree
   rule below, so `block` here silently collapses the two-column spine and
   drops the talk rail to the bottom of the page. */
body.tree-mode #panel-news #gazette-tree { display: grid; }

/* When NOT in tree mode, keep the tree container hidden */
body:not(.tree-mode) #panel-news #gazette-tree { display: none; }

/* Radio / Video / Pods should override tree mode too */
body.radio-mode #panel-news #gazette-tree,
body.video-mode #panel-news #gazette-tree,
body.pods-mode  #panel-news #gazette-tree {
  display: none !important;
}

/* ================ TREE ROOT ================ */
.gazette-tree {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 30px;
  align-items: start;
  margin-top: 6px;
}
/* Masthead + heat-strip span both columns; the river and the talk spine
   share the row beneath them. */
.gazette-tree > .tree-river-head,
.gazette-tree > .tree-globe,
.gazette-tree > .tree-filter,
.gazette-tree > .tree-heat { grid-column: 1 / -1; }
.gazette-tree > .tree-river { grid-column: 1; }
.gazette-tree > .tree-talk  { grid-column: 2; }

@media (max-width: 1080px) {
  .gazette-tree { grid-template-columns: 1fr; gap: 18px; }
  .gazette-tree > .tree-river,
  .gazette-tree > .tree-talk { grid-column: 1; }
  /* One column: the agora comes BEFORE the river. It used to be
     display:none here, which meant a phone had no way into it at all. */
  .gazette-tree > .tree-talk  { order: 1; }
  .gazette-tree > .tree-river { order: 2; }
  .gazette-tree .tree-talk {
    position: static;
    max-height: 46vh;
  }
}

/* Layout switch pill — small, top-right of the river head. Lets us fall
   back to Newspaper (old compact grid) without a redeploy. */
.tree-layout-switch {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-mute); letter-spacing: 0.08em;
  text-transform: uppercase;
  display: inline-flex; gap: 4px; align-items: center;
}
.tree-layout-switch button {
  background: transparent; border: 1px solid var(--rule);
  color: var(--ink-mute); padding: 3px 9px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase;
  cursor: pointer;
}
.tree-layout-switch button.on {
  background: var(--accent-forest, #2D5016); color: #fff;
  border-color: var(--accent-forest, #2D5016);
}

/* ================ RIVER (LEFT) ================ */
.tree-river { min-width: 0; }

.tree-river-head {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 10px; margin: 0 0 14px;
  border-bottom: 2px solid var(--accent-bark, #6B4423);
  gap: 16px; flex-wrap: wrap;
}
.tree-river-head h1 {
  font-family: var(--font-head); font-weight: 700;
  font-size: 32px; letter-spacing: -0.02em;
  color: var(--accent-bark, #6B4423); margin: 0;
}
.tree-river-head h1 em {
  font-style: italic; color: var(--accent-forest, #2D5016); font-weight: 500;
}
.tree-river-head .now {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--ink-mute); letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* World graph — country bubbles sized by how many stories name them, linked
   when two countries appear in the SAME story. Replaces the heat strip, which
   read from a fixture and never matched the river. See tree-graph.js. */
.tree-globe {
  margin: 0 0 20px;
  background: var(--surface-warm, #F6F1E6);
  border: 1px solid var(--rule); border-radius: 6px;
  overflow: hidden;
}
.tree-globe-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 8px 12px; border-bottom: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: 11.5px;
}
.tree-globe-head .label {
  color: var(--ink-mute); letter-spacing: 0.14em;
  text-transform: uppercase; font-weight: 600; font-size: 10px;
}
.tree-globe-head .meta { color: var(--ink); font-weight: 600; }

/* Controls cluster — hint + size cycle + hide/show. The hint lives inside
   .gctl now, so the cluster (not the hint) takes the auto margin. */
.tree-globe-head .gctl {
  margin-left: auto; display: inline-flex; align-items: center; gap: 8px;
}
.tree-globe-head .gctl .hint { color: var(--ink-mute); font-size: 10px; }
.tree-globe-head .gctl button {
  background: transparent; border: 1px solid var(--rule);
  color: var(--ink-mute); padding: 2px 8px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 9.5px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.tree-globe-head .gctl button:hover {
  color: var(--accent-forest, #2D5016);
  border-color: var(--accent-forest, #2D5016);
}

.tree-globe-stage { height: 250px; touch-action: none; }
.tree-globe.gsize-s .tree-globe-stage { height: 170px; }
.tree-globe.gsize-l .tree-globe-stage { height: 360px; }
.tree-globe.closed .tree-globe-stage { display: none; }
.tree-globe-stage svg { display: block; cursor: grab; }
.tree-globe-stage svg:active { cursor: grabbing; }

.tree-globe .glinks line { stroke: var(--ink-mute); stroke-opacity: 0.28; }
.tree-globe .gnode circle { stroke: var(--surface-warm, #F6F1E6); stroke-width: 1.5; }
/* Labels sit in their own layer above every bubble, so a big country's circle
   can't paint over a small country's name. */
.tree-globe .glabels text {
  font-family: var(--font-mono); font-size: 11px; font-weight: 700;
  fill: var(--accent-bark, #6B4423);
  pointer-events: none; paint-order: stroke;
  stroke: var(--surface-warm, #F6F1E6); stroke-width: 3.5px; stroke-linejoin: round;
}
.tree-globe .gnode { cursor: pointer; }
.tree-globe .gnode:focus { outline: none; }
.tree-globe .gnode:focus circle,
.tree-globe .gnode:hover circle { stroke: var(--accent-forest, #2D5016); stroke-width: 2.5; }
/* The invisible 44px thumb target must stay invisible. It sits under the
   visible dot, so without this the rules above ring it in forest green at a
   radius far wider than the country it belongs to. Placed after them, and
   matched on hover and focus too, so it wins on order not on weight. */
.tree-globe .gnode circle.ghit,
.tree-globe .gnode:focus circle.ghit,
.tree-globe .gnode:hover circle.ghit { stroke: none; }
/* Focus mode: tapping a country dims everything it never shares a story with. */
.tree-globe .gnode.dim { opacity: 0.16; }
.tree-globe .gnode.lit circle { stroke: var(--accent-forest, #2D5016); stroke-width: 2.5; }
.tree-globe .glinks line.dim { stroke-opacity: 0.05; }

@media (max-width: 560px) {
  .tree-globe.gsize-l .tree-globe-stage { height: 300px; }
  .tree-globe-head .gctl .hint { display: none; }
}
@media (prefers-reduced-motion: reduce) { .tree-globe-stage svg { transition: none; } }

/* Country filter pill — appears when a globe tap filters the river */
.tree-filter {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 0 0 14px;
  background: var(--accent-forest-tint, #E4EBD8);
  border: 1px solid var(--accent-forest, #2D5016);
  border-radius: 999px;
  font-family: var(--font-mono); font-size: 11.5px;
}
.tree-filter .label {
  color: var(--accent-forest-deep, #1F3A0F); font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
}
.tree-filter .count { color: var(--ink-soft); font-size: 10.5px; }
.tree-filter .clear {
  margin-left: auto; background: var(--accent-forest, #2D5016); color: #fff;
  border: 0; padding: 4px 12px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.08em; text-transform: uppercase; cursor: pointer;
}
.tree-filter .clear:hover { background: var(--accent-forest-deep, #1F3A0F); }

/* Heat-strip — the fallback when d3 is unavailable or too few countries named */
.tree-heat {
  display: flex; gap: 18px; align-items: center; flex-wrap: nowrap;
  padding: 8px 12px; margin: 0 0 20px;
  background: var(--surface-warm, #F6F1E6); border-radius: 6px;
  border: 1px solid var(--rule);
  font-family: var(--font-mono); font-size: 11.5px;
  overflow-x: auto; white-space: nowrap;
}
.tree-heat .label {
  color: var(--ink-mute); letter-spacing: 0.14em;
  text-transform: uppercase; font-weight: 600; font-size: 10px;
  padding-right: 8px; border-right: 1px solid var(--rule);
  flex: 0 0 auto;
}
.tree-heat .item {
  color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer; flex: 0 0 auto;
}
.tree-heat .item:hover { color: var(--accent-forest, #2D5016); }
.tree-heat .item .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent-sage, #8FA68E);
}
.tree-heat .item.hot .dot {
  background: var(--accent-terracotta, #B5503E);
  animation: tree-pulse var(--breath-dur, 5s) var(--ease-breath, ease-in-out) infinite;
}
.tree-heat .item.warm .dot { background: var(--accent-gold, #C9A24F); }
.tree-heat .item .n {
  color: var(--accent-forest, #2D5016); font-weight: 600; margin-left: 2px;
}
@keyframes tree-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.4); }
}

/* Section band — for "From your circle" + "Africa" + etc */
.tree-band {
  display: flex; align-items: baseline; gap: 14px;
  margin: 26px 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--rule);
}
.tree-band .label {
  font-family: var(--font-mono); font-size: 12px;
  font-weight: 600; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--accent-bark, #6B4423);
}
.tree-band .count {
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--ink-mute); letter-spacing: 0.10em;
}
.tree-band .more {
  margin-left: auto; font-family: var(--font-mono); font-size: 10.5px;
  color: var(--accent-forest, #2D5016); text-transform: uppercase;
  letter-spacing: 0.10em; cursor: pointer; text-decoration: none;
}
.tree-band.circle { border-bottom-color: var(--accent-forest, #2D5016); }
.tree-band.circle .label { color: var(--accent-forest, #2D5016); }

/* Sign-in gate (public read, sign-in to engage) */
.tree-gate {
  padding: 10px 14px; margin: 10px 0 4px;
  background: var(--accent-forest-tint, #E4EBD8);
  border: 1px solid var(--accent-forest, #2D5016);
  border-radius: 8px;
  font-family: var(--font-mono); font-size: 12px;
  color: var(--accent-forest-deep, #1F3A0F);
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap;
}
.tree-gate button {
  background: var(--accent-forest, #2D5016); color: #fff; border: 0;
  padding: 6px 12px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 11px;
  letter-spacing: 0.10em; text-transform: uppercase; cursor: pointer;
}
.tree-gate button:hover { background: var(--accent-forest-deep, #1F3A0F); }

/* Story row — the primary river item */
.tree-story {
  display: grid; grid-template-columns: 1fr 180px; gap: 20px;
  padding: 22px 0; border-bottom: 1px solid var(--rule);
  animation: tree-fadeIn var(--dur-fast, 330ms) var(--ease, ease-out) both;
}
.tree-story.wide { grid-template-columns: 1fr; }
/* Most feed items carry no image — those stories run full width. */
.tree-story.no-art { grid-template-columns: 1fr; }
.tree-story .thumb {
  width: 100%; aspect-ratio: 4/3; border-radius: 6px;
  background: var(--accent-bark-tint, #EADDC8);
  display: block; overflow: hidden;
}
.tree-story.wide .thumb { aspect-ratio: 21/9; }
.tree-story .thumb-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.tree-story .kicker {
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--accent-terracotta, #B5503E); margin: 0 0 4px;
}
.tree-story .title {
  font-family: var(--font-head); font-weight: 600; color: var(--ink);
  margin: 0 0 8px; line-height: 1.15;
  font-size: 22px; letter-spacing: -0.014em;
  text-decoration: none; cursor: pointer; display: block;
}
.tree-story.wide .title {
  font-size: 34px; letter-spacing: -0.022em;
}
.tree-story .title:hover { color: var(--accent-forest, #2D5016); }
/* Long unbroken tokens (URLs, hashtags) must never widen the column. */
.tree-story .title, .tree-story .summary { overflow-wrap: anywhere; }

/* Phones. The desktop 1fr/180px split leaves ~150px of text at 390px, which
   wraps headlines to a ragged tower. Shrink the thumb to a square, tighten
   the gap, and step the type down so the text column stays readable. */
@media (max-width: 640px) {
  .tree-story {
    grid-template-columns: 1fr 104px;
    gap: 14px; padding: 18px 0;
  }
  .tree-story .thumb { aspect-ratio: 1/1; }
  .tree-story .title { font-size: 18px; }
  .tree-story.wide .title { font-size: 27px; }
  .tree-story .summary { font-size: 15px; line-height: 1.5; }
}
.tree-story .summary {
  font-family: var(--font-body-serif, "Crimson Pro", serif);
  font-size: 16px; line-height: 1.55;
  color: var(--ink-soft); margin: 0 0 10px;
}
.tree-story .byline {
  font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-mute);
  letter-spacing: 0.04em;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-bottom: 8px;
}
.tree-story .byline .src {
  color: var(--accent-bark, #6B4423); font-weight: 600;
}
.tree-story .byline a { color: inherit; text-decoration: none; }
.tree-story .byline a:hover { color: var(--accent-forest, #2D5016); }
.tree-story .foot { display: flex; gap: 8px; flex-wrap: wrap; }

.tree-live {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--font-mono); font-size: 10.5px; color: var(--ink-mute);
  padding: 2px 8px; border-radius: 999px;
  background: var(--surface-warm, #F6F1E6);
  border: 1px solid var(--rule);
}
.tree-live.hot {
  color: var(--accent-terracotta, #B5503E);
  border-color: var(--accent-terracotta-soft, #F4DDD3);
  background: var(--accent-terracotta-soft, #F4DDD3);
}
.tree-live .n { color: var(--accent-forest, #2D5016); font-weight: 600; }

/* Chat peek — inline latest comment on a story. Signature move. */
.tree-peek {
  margin-top: 10px; padding: 8px 12px;
  background: var(--surface-warm, #F6F1E6);
  border-left: 3px solid var(--accent-forest, #2D5016);
  border-radius: 0 6px 6px 0;
  font-family: var(--font-body-serif, "Crimson Pro", serif);
  font-size: 14px; line-height: 1.5;
  color: var(--ink-soft);
}
.tree-peek b {
  color: var(--accent-bark, #6B4423);
  font-family: var(--font-mono); font-size: 11px;
  font-weight: 600; margin-right: 6px;
}
.tree-peek .join {
  display: block; margin-top: 4px;
  font-family: var(--font-mono); font-size: 10.5px;
  color: var(--accent-forest, #2D5016);
  text-transform: uppercase; letter-spacing: 0.10em; cursor: pointer;
}

/* 9-cell "what's alive right now" grid */
.tree-nine {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin: 14px 0 20px;
}
@media (max-width: 640px) {
  .tree-nine { grid-template-columns: repeat(2, 1fr); }
}
.tree-nine .cell {
  padding: 12px 14px 10px;
  background: var(--surface-warm, #F6F1E6);
  border: 1px solid var(--rule);
  border-radius: 8px; min-height: 108px;
  display: flex; flex-direction: column; justify-content: space-between;
  cursor: pointer;
  transition: transform 160ms ease-out, box-shadow 160ms ease-out, border-color 160ms;
}
.tree-nine .cell:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-2, 0 4px 14px rgba(74,46,22,0.10));
  border-color: var(--accent-forest, #2D5016);
}
.tree-nine .cell.hot {
  border-color: var(--accent-terracotta-soft, #F4DDD3);
  background: var(--accent-terracotta-soft, #F4DDD3);
}
.tree-nine .cell.circle {
  border-left: 3px solid var(--accent-forest, #2D5016);
}
.tree-nine .cell .region {
  font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--ink-soft);
}
.tree-nine .cell.circle .region { color: var(--accent-forest, #2D5016); }
.tree-nine .cell .head {
  font-family: var(--font-head); font-weight: 600; font-size: 15.5px;
  line-height: 1.2; color: var(--ink); margin: 4px 0 8px;
}
.tree-nine .cell .foot {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-soft);
}
.tree-nine .cell .foot .heat {
  color: var(--accent-terracotta-deep, #8E3B2C); font-weight: 700;
}

/* ================ RIGHT: TALK SPINE ================ */
.tree-talk {
  position: sticky; top: 12px;
  border: 1px solid var(--rule); border-radius: 10px;
  background: var(--surface-elevated, #FFFFFF);
  max-height: calc(100vh - 40px);
  display: flex; flex-direction: column;
  overflow: hidden;
}
.tree-talk-tabs {
  display: flex; border-bottom: 1px solid var(--rule);
  background: var(--surface-soft, #FAF6EC);
}
.tree-talk-tab {
  flex: 1; padding: 10px 6px; text-align: center;
  font-family: var(--font-mono); font-size: 10.5px;
  letter-spacing: 0.10em; text-transform: uppercase;
  color: var(--ink-mute); cursor: pointer;
  border-right: 1px solid var(--rule); background: transparent;
}
.tree-talk-tab:last-child { border-right: 0; }
.tree-talk-tab.on {
  background: var(--surface-elevated, #FFFFFF);
  color: var(--accent-forest, #2D5016);
  border-bottom: 2px solid var(--accent-forest, #2D5016);
  margin-bottom: -1px;
}
.tree-talk-tab .n {
  display: inline-block; margin-left: 4px;
  background: var(--accent-forest, #2D5016); color: #fff;
  border-radius: 999px; padding: 1px 6px; font-size: 9.5px;
}
.tree-talk-body {
  flex: 1; overflow-y: auto; padding: 4px 0;
  scrollbar-width: thin;
}
.tree-talk-row {
  display: grid; grid-template-columns: 32px 1fr;
  gap: 10px; padding: 10px 14px;
  border-bottom: 1px solid var(--rule-soft, #EFEAD9);
  cursor: pointer;
}
.tree-talk-row:hover { background: var(--surface-warm, #F6F1E6); }
.tree-talk-row.hot {
  border-left: 3px solid var(--accent-terracotta, #B5503E);
  padding-left: 11px;
}
/* The fill arrives from the API (r.color) and the initials are white, so a pale
   colour rendered at 2.40:1. tree.js wraps the supplied colour in color-mix()
   to darken it — done there rather than with an inset scrim here so the darkened
   value shows up in getComputedStyle and scratch/contrast-check.mjs can measure
   the thing that actually ships. */
.tree-talk-row .avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
  color: #fff;
}
.tree-talk-row .who {
  font-family: var(--font-mono); font-size: 11px; color: var(--ink);
  font-weight: 600;
}
.tree-talk-row .who .when {
  color: var(--ink-mute); font-weight: 400; margin-left: 6px;
}
.tree-talk-row .snippet {
  font-family: var(--font-body-serif, "Crimson Pro", serif);
  font-size: 13.5px; line-height: 1.4;
  color: var(--ink-soft); margin-top: 3px;
}
.tree-talk-row .on-article {
  font-family: var(--font-mono); font-size: 9.5px;
  color: var(--accent-forest, #2D5016); text-transform: uppercase;
  letter-spacing: 0.08em; margin-top: 4px;
  display: inline-block;
}
.tree-talk-compose {
  padding: 10px 12px; border-top: 1px solid var(--rule);
  background: var(--surface-warm, #F6F1E6);
}
.tree-talk-compose input {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--rule); border-radius: 6px;
  font-family: var(--font-body-serif, "Crimson Pro", serif);
  font-size: 13.5px;
  background: var(--surface-elevated, #FFFFFF);
  color: var(--ink);
  box-sizing: border-box;
}
/* iOS Safari force-zooms the page on focus of any control under 16px and does
   not zoom back out. Coarse pointer only, so the desktop spine keeps its
   tighter 13.5px. */
@media (pointer: coarse) {
  .tree-talk-compose input { font-size: 16px; }
}

.tree-talk-compose input:disabled {
  color: var(--ink-mute); cursor: not-allowed;
  background: var(--surface-soft, #FAF6EC);
}

/* Empty state — before articles load, or when filtered to zero */
.tree-empty {
  padding: 60px 24px; text-align: center;
  font-family: var(--font-mono); font-size: 12px; color: var(--ink-mute);
  letter-spacing: 0.06em;
}

@keyframes tree-fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* Kill the black planet-host globe in Tree mode — replaced by heat-strip.
   Extra defensive: some panel-news sub-elements set display:block inline. */
body.tree-mode #panel-news .planet-host,
body.tree-mode #panel-news #news-planet-host {
  display: none !important;
}
