/* /demos/goroutine-visualizer — the page's own chrome.
 *
 * IT OWNS NO COLORS OF ITS OWN. Every value here is a theme token from
 * css.css, so the page follows light and dark without this file deciding
 * anything — the mistake backpressure-lab's stylesheet made twice and had
 * removed in PF-S186d and PF-S194. Buttons use the shared .btn classes and are
 * not restyled here at all.
 *
 * THE STATE COLORS ARE THE ONE PLACE THAT NEEDS CARE, because a badge is the
 * page's whole vocabulary. They are keyed off the derived-state names the Go
 * constants define, and they are distinguished by more than hue — each carries
 * a different border weight and the text is the state's own name — so the
 * distinction survives a monochrome display and does not depend on color
 * vision.
 */

.gv__lede {
  max-width: 68ch;
}

.gv__where,
.gv__reading,
.gv__honesty,
.gv__planned {
  max-width: 74ch;
  margin: 2rem 0;
}

.gv__h {
  margin-top: 2rem;
  font-size: 1.1rem;
}

/* --- the control panel ---------------------------------------------------- */

.gv__panel {
  margin: 2rem 0;
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.gv__controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: 1.25rem;
}

.gv__group {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.gv__group-label {
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.gv__field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.gv__field label {
  font-size: 0.9rem;
}

.gv__check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.gv__hint,
.gv__role-note {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.gv__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.gv__status {
  margin: 1rem 0 0;
  font-size: 0.92rem;
  color: var(--muted);
}

/* --- the deadlock banner -------------------------------------------------- */

.gv__deadlock {
  margin: 1rem 0 0;
  padding: 0.9rem 1rem;
  border: 2px solid var(--danger, #c0392b);
  border-radius: 10px;
  background: color-mix(in srgb, var(--danger, #c0392b) 12%, transparent);
}

.gv__deadlock[hidden] {
  display: none;
}

/* --- the tiles ------------------------------------------------------------ */

.gv__readout {
  margin-top: 1.5rem;
}

.gv__tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 0.75rem;
}

.gv__tile {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.gv__tile--leak {
  border-width: 2px;
}

.gv__tile-label {
  font-size: 0.78rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
}

.gv__tile-value {
  font-size: 1.9rem;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.gv__tile-sub {
  font-size: 0.82rem;
  color: var(--muted);
}

/* --- the channel canvas --------------------------------------------------- */

.gv__channel {
  margin-top: 1.25rem;
}

.gv__channel-head {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9rem;
}

.gv__channel-head strong {
  font-size: 1.2rem;
  font-variant-numeric: tabular-nums;
}

.gv__channel-cap {
  color: var(--muted);
}

.gv__slots {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0.5rem 0;
  min-height: 26px;
}

.gv__slot {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.gv__slot--full {
  background: var(--accent, currentColor);
  border-color: var(--accent, currentColor);
}

/* The zero-capacity case. There is no slot to fill, so the marker is a ring
 * rather than a box — the shape says "nothing sits here" before the caption
 * beside it says the same in words. */
.gv__rendezvous {
  width: 22px;
  height: 22px;
  border: 2px dashed var(--muted);
  border-radius: 50%;
}

.gv__slots-caption {
  margin: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* --- the goroutine list --------------------------------------------------- */

.gv__goroutines {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.gv__g {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.gv__g-name {
  font-family: var(--mono, ui-monospace, monospace);
  font-weight: 600;
}

.gv__g-arm,
.gv__g-asked {
  font-size: 0.82rem;
  color: var(--muted);
}

.gv__kill {
  margin-left: auto;
}

.gv__badge {
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.78rem;
}

/* The blocked states carry a heavier border than running, so "this one is
 * stuck" reads without relying on color. */
.gv__badge--blocked_send,
.gv__badge--blocked_recv,
.gv__badge--blocked_select {
  border-width: 2px;
  border-style: dashed;
}

.gv__g--blocked_send,
.gv__g--blocked_recv {
  border-left: 3px solid var(--danger, #c0392b);
}

.gv__g--blocked_select {
  border-left: 3px solid var(--muted);
}

.gv__g--done,
.gv__g--canceled {
  opacity: 0.6;
}

.gv__empty {
  font-size: 0.9rem;
  color: var(--muted);
}

.gv__empty[hidden] {
  display: none;
}

/* --- the trace ------------------------------------------------------------ */

.gv__trace {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0;
  max-height: 20rem;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: 0.8rem;
}

.gv__trace-line {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.3rem 0.6rem;
  border-bottom: 1px solid var(--border);
}

.gv__trace-line:last-child {
  border-bottom: 0;
}

.gv__trace-at,
.gv__trace-who {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.gv__trace-note {
  color: var(--muted);
  flex-basis: 100%;
}

@media (max-width: 640px) {
  .gv__controls {
    grid-template-columns: 1fr;
  }

  .gv__kill {
    margin-left: 0;
  }
}
