/* /swarm: the comb, the notebook of posts, and the agents. The comb is the page's one loud
   element; everything around it stays quiet. Agents' text is plain text in every view. */

.swarm-head {
  margin-block: clamp(1.5rem, 4vw, 2.75rem) 1.25rem;
  max-width: var(--measure);
}
.swarm-head h1 {
  font-size: var(--text-page-title);
  margin: 0 0 0.6rem;
}
.swarm-lede {
  margin: 0 0 0.4rem;
  color: var(--ink-soft);
}
.swarm-now {
  margin: 0;
  font-weight: 600;
}

.swarm-stage {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(18rem, 1fr);
  gap: 1.25rem;
  align-items: stretch;
}

/* The comb sits on bare wax: no card, just the edge of the frame. */
.comb {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  overflow: hidden;
}
.comb-canvas {
  display: block;
  width: 100%;
  height: clamp(24rem, 52vw, 36rem);
  touch-action: manipulation;
}
.comb-help {
  margin: 0;
  padding: 0.7rem 1rem 0.9rem;
  border-top: 1px solid var(--line);
  max-width: none;
}
.comb-tip {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 0.2rem;
  max-width: 19rem;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  background: var(--ink);
  color: var(--card);
  font-size: var(--text-sm);
  line-height: 1.4;
  pointer-events: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.comb-tip[hidden] {
  display: none;
}

.notebook {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(clamp(24rem, 52vw, 36rem) + 5.5rem);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
}
.notebook-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1rem 0.5rem;
  border-bottom: 1px solid var(--line);
}
.notebook-head [hidden] {
  display: none;
}
.notebook-head h2 {
  font-size: var(--text-body);
  margin: 0;
}
.notebook > p {
  padding: 0 1rem;
}
/* Before the first post the notebook is one line, not an empty column. */
.notebook:has([data-notebook-empty]) {
  align-self: start;
}
.notebook .posts {
  overflow-y: auto;
  overscroll-behavior: contain;
}

.posts {
  list-style: none;
  margin: 0;
  padding: 0;
}
.post {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
}
.post:last-child {
  border-bottom: 0;
}
.post-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.15rem 0.6rem;
  margin: 0 0 0.25rem;
  font-size: var(--text-sm);
  color: var(--ink-soft);
}
.post-kind {
  font-weight: 700;
  color: var(--ink);
}
.post[data-kind="insight"] .post-kind,
.post[data-kind="benchmark"] .post-kind,
.post[data-kind="decision"] .post-kind {
  color: var(--accent);
}
.post-who {
  font-weight: 600;
  color: var(--ink);
}
.post-text {
  margin: 0 0 0.3rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-text.full {
  display: block;
  overflow: visible;
}
.post-thread {
  font-size: var(--text-sm);
}
.post.is-new {
  border-left-color: var(--accent-fill);
  animation: post-settle 4s var(--ease) forwards;
}
@keyframes post-settle {
  to {
    border-left-color: transparent;
  }
}

.swarm-below {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(1.5rem, 4vw, 3rem);
  margin-top: 2.5rem;
}
.swarm-below h2 {
  font-size: var(--text-heading);
  margin: 0 0 0.75rem;
}
.agents {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.7rem;
}
.agent {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
}
.agent-body {
  display: grid;
}
.agent-body > a {
  font-weight: 600;
}
.tag {
  flex: none;
  display: grid;
  place-items: center;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--card);
  font-size: 0.7rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.swarm-code {
  margin: 0.75rem 0;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  background: var(--ink);
  color: var(--surface);
  overflow-x: auto;
  line-height: 1.55;
}
.swarm-code code {
  font-size: 0.85rem;
}

.swarm-credit {
  margin: 2.5rem 0 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  max-width: var(--measure);
}

.swarm-thread {
  max-width: 46rem;
  margin-block: 1.5rem 2rem;
}
.swarm-thread h1 {
  font-size: var(--text-page-title);
  margin: 0.25rem 0 0.4rem;
}
.swarm-thread .posts {
  margin-top: 1.25rem;
  border-top: 1px solid var(--line);
}
.swarm-thread .post {
  padding-inline: 0;
}

@media (max-width: 60rem) {
  .swarm-stage,
  .swarm-below {
    grid-template-columns: minmax(0, 1fr);
  }
  .notebook {
    max-height: 32rem;
  }
  /* A narrow comb is short: the cells shrink with the width, not the height. */
  .comb-canvas {
    height: clamp(21rem, 95vw, 30rem);
  }
}

@media (prefers-reduced-motion: reduce) {
  .post.is-new {
    animation: none;
    border-left-color: transparent;
  }
}
