/* Merlyn stack — tokens come from styles.css. */

.stackpage {
  min-height: 100svh;
}

.stack-shell {
  padding-block: clamp(24px, 5vw, 44px) 72px;
}

.stack-head h1 {
  margin: 14px 0 16px;
  font-size: clamp(2.3rem, 9vw, 3.4rem);
  letter-spacing: -0.04em;
}

.stack-head h1 em {
  font-style: normal;
  background: linear-gradient(96deg, #f6d9c3, var(--rust-3) 45%, var(--rust-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(175deg, rgba(28, 24, 20, 0.72), rgba(13, 12, 10, 0.92));
  padding: 16px;
}

.card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.card__head h2 {
  margin: 0;
  font-size: 0.92rem;
  letter-spacing: -0.01em;
}

.card__note {
  margin: 10px 0 0;
  color: var(--muted-2);
  font-size: 0.72rem;
  line-height: 1.55;
}

/* ── bridge ─────────────────────────────────────────────────────────────── */

.bridge-grid {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.bridge-grid > *,
.bridge-grid .card {
  min-width: 0;
}

.bridge-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 12px;
}

.bridge-stats dt {
  color: var(--muted-2);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.bridge-stats dd {
  margin: 4px 0 0;
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.bridge-stats code {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--rust-3);
}

.bridge-note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.bridge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bridge-token {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.bridge-token[hidden] {
  display: none;
}

.bridge-token label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.74rem;
}

.bridge-token label span {
  color: var(--muted-2);
}

.bridge-token code {
  font-family: var(--mono);
  font-size: 0.72rem;
}

.bridge-token__row {
  display: flex;
  gap: 8px;
}

.bridge-token input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.78rem;
}

.bridge-token input:focus {
  outline: 2px solid var(--rust);
  outline-offset: 1px;
}

.bridge-curl {
  margin: 14px 0 0;
  min-width: 0;
  max-inline-size: 100%;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: rgba(0, 0, 0, 0.4);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.7;
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
}

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

.feed {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 340px;
  overflow-y: auto;
}

.feed__empty {
  color: var(--muted-2);
  font-size: 0.78rem;
  line-height: 1.5;
  padding: 10px 2px;
}

.feed__item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.02);
}

.feed__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: start;
  min-width: 52px;
  height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid var(--line-2);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.feed__item[data-action="buy"] .feed__action {
  color: var(--profit);
  border-color: rgba(79, 203, 146, 0.35);
  background: rgba(79, 203, 146, 0.08);
}

.feed__item[data-action="sell"] .feed__action {
  color: var(--loss);
  border-color: rgba(226, 102, 89, 0.35);
  background: rgba(226, 102, 89, 0.08);
}

.feed__item[data-action="close"] .feed__action {
  color: var(--gold);
  border-color: rgba(232, 193, 122, 0.35);
  background: rgba(232, 193, 122, 0.08);
}

.feed__item[data-action="wait"] .feed__action {
  color: var(--muted);
}

.feed__main {
  min-width: 0;
}

.feed__top {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px 10px;
}

.feed__top strong {
  font-size: 0.82rem;
}

.feed__top span {
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 0.7rem;
}

.feed__note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

/* ── status chips ───────────────────────────────────────────────────────── */

.chip--bridge {
  color: var(--rust-3);
  border-color: rgba(224, 122, 72, 0.3);
  background: rgba(224, 122, 72, 0.08);
}

.chip--research {
  color: #8fbcff;
  border-color: rgba(143, 188, 255, 0.28);
  background: rgba(143, 188, 255, 0.07);
}

.chip--pattern {
  color: var(--gold);
  border-color: rgba(232, 193, 122, 0.28);
  background: rgba(232, 193, 122, 0.07);
}

.chip--data {
  color: var(--muted);
}

.chip--permissive {
  color: var(--profit);
  border-color: rgba(79, 203, 146, 0.28);
  background: rgba(79, 203, 146, 0.07);
}

.chip--copyleft {
  color: var(--loss);
  border-color: rgba(226, 102, 89, 0.28);
  background: rgba(226, 102, 89, 0.07);
}

/* ── licence note ───────────────────────────────────────────────────────── */

.licence-card {
  margin-top: 14px;
}

.licence-card p {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.6;
}

.licence-card p:last-child {
  margin-bottom: 0;
}

/* ── repos ──────────────────────────────────────────────────────────────── */

.stack-repos {
  margin-top: 30px;
}

.stack-repos__head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.stack-repos__head h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.stack-repos__legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
}

.repo-grid {
  display: grid;
  gap: 12px;
}

.repo-empty {
  color: var(--muted-2);
  font-size: 0.8rem;
}

.repo {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: linear-gradient(175deg, rgba(28, 24, 20, 0.6), rgba(13, 12, 10, 0.9));
}

.repo__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.repo__name {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
}

.repo__repo {
  margin: 2px 0 0;
  color: var(--muted-2);
  font-family: var(--mono);
  font-size: 0.68rem;
  overflow-wrap: anywhere;
}

.repo__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex-shrink: 0;
}

.repo__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  color: var(--muted-2);
  font-size: 0.7rem;
}

.repo__role {
  margin: 0;
  color: var(--text);
  font-size: 0.82rem;
  line-height: 1.5;
}

.repo__take {
  margin: 0;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.55;
}

.repo__take b {
  color: var(--rust-3);
  font-weight: 600;
}

.repo__caution {
  margin: 0;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted-2);
  font-size: 0.7rem;
  line-height: 1.5;
}

.repo__link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  color: var(--rust-3);
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
}

.repo__link:hover {
  color: var(--rust);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.stack-disclaimer {
  margin-top: 26px;
  color: var(--muted-2);
  font-size: 0.7rem;
  line-height: 1.6;
}

/* ── responsive ─────────────────────────────────────────────────────────── */

@media (min-width: 760px) {
  .repo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 980px) {
  .bridge-grid {
    grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
    align-items: start;
  }

  .repo-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .bridge-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .repo__head {
    flex-direction: column;
  }
}
