/* The wiring page, on top of style.css's tokens. Status colours keep
   contrast in both modes; out of date also gets a "!" mark and a thicker
   line, so colour is never the only sign. Each edge kind has a colour
   (--kind-<kind>) and, in wiring.ts, a line style. */
:root {
  --line-strong: #a8a297;
  --lane: #f4f1ea;
  --status-current: #15803d;
  --status-behind: #c2410c;
  --status-unknown: #8a857c;
  --status-none: #b8b2a7;
  --status-planned: #7c3aed;
  --kind-upstream: #2563eb;
  --kind-watched: #2563eb;
  --kind-submodule: #7c3aed;
  --kind-art: #0e7490;
  --kind-rules: #4d7c0f;
  --kind-cargo: #a16207;
  --kind-maven: #0f766e;
  --kind-publishes: #0f766e;
  --kind-data: #15803d;
  --kind-runtime: #be185d;
  --kind-flake: #0e7490;
  --kind-workflow: #78716c;
  --kind-checkout: #15803d;
  --kind-vendored: #64748b;
  --kind-agents: #4f46e5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --line-strong: #6b665e;
    --lane: #252421;
    --status-current: #4ade80;
    --status-behind: #fb923c;
    --status-unknown: #a39d93;
    --status-none: #57534c;
    --status-planned: #c4b5fd;
    --kind-upstream: #60a5fa;
    --kind-watched: #60a5fa;
    --kind-submodule: #a78bfa;
    --kind-art: #22d3ee;
    --kind-rules: #a3e635;
    --kind-cargo: #facc15;
    --kind-maven: #2dd4bf;
    --kind-publishes: #2dd4bf;
    --kind-data: #4ade80;
    --kind-runtime: #f472b6;
    --kind-flake: #22d3ee;
    --kind-workflow: #a8a29e;
    --kind-checkout: #4ade80;
    --kind-vendored: #94a3b8;
    --kind-agents: #818cf8;
  }
}

/* The map needs the width: wider than the other pages. */
main.wiring {
  max-width: 1600px;
}

.wiring > p {
  max-width: 80ch;
}

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

#controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  align-items: center;
  margin: 12px 0;
}

#controls input[type="search"] {
  font: inherit;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  max-width: 100%;
}

#controls fieldset {
  flex: 1 1 100%;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 12px 10px;
  min-width: 0;
}

#controls legend button,
#copy {
  font: inherit;
  font-size: 0.8rem;
  background: none;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--accent);
  cursor: pointer;
}

#kinds {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 0.9rem;
}

.split {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

/* wiring.ts sets the height from the map's shape. */
#graph {
  height: 70vh;
  min-height: 420px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
}

#details {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

#details h2 {
  font-size: 1.05rem;
}

#details h3 {
  margin-top: 12px;
  font-size: 0.95rem;
}

#details ul {
  padding-left: 1.2em;
}

#details dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 2px 10px;
}

#details dd {
  margin: 0;
}

@media (min-width: 1500px) {
  .split {
    grid-template-columns: 1fr 340px;
  }

  #details {
    max-height: 70vh;
    overflow-y: auto;
  }
}

/* Status badges: a mark and words, not colour alone. */
.status {
  font-weight: 600;
  white-space: nowrap;
}

.status.current {
  color: var(--status-current);
}

.status.behind {
  color: var(--status-behind);
}

.status.unknown,
.status.none {
  color: var(--muted);
  font-weight: 400;
}

.status.planned {
  color: var(--status-planned);
}

.legend ul {
  list-style: none;
  padding: 0;
  font-size: 0.9rem;
}

.swatch {
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
}

.swatch.box,
.swatch.oval,
.swatch.hex {
  width: 22px;
  height: 14px;
  border: 1.5px solid var(--line-strong);
  background: var(--card);
}

.swatch.box {
  border-radius: 4px;
}

.swatch.box.fork {
  border: 4px double var(--accent);
}

/* An edge kind's line: its colour and style. */
.swatch.kind {
  width: 26px;
  border-top: 3px solid var(--kind);
}

.swatch.kind.dashed {
  border-top-style: dashed;
}

.swatch.kind.dotted {
  border-top-style: dotted;
}

.swatch.oval {
  border-radius: 7px;
  background: var(--tile);
}

.swatch.hex {
  clip-path: polygon(20% 0, 80% 0, 100% 30%, 100% 70%, 80% 100%, 20% 100%, 0 70%, 0 30%);
  background: var(--line-strong);
}

/* The edge table scrolls inside its box; the page itself never does. */
.scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.scroll table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
}

.scroll th,
.scroll td {
  text-align: left;
  vertical-align: top;
  padding: 6px 8px;
  border-bottom: 1px solid var(--line);
}

.scroll th {
  background: var(--tile);
  position: sticky;
  top: 0;
}

.scroll td small {
  color: var(--muted);
  overflow-wrap: anywhere;
}

#notes {
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

/* The static Mermaid picture scrolls inside its box at a readable size; its source scrolls too. */
.mermaid .diagram {
  display: block;
  overflow: auto;
  max-height: 85vh;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--card);
  padding: 8px;
}

.mermaid .diagram img {
  display: block;
  width: 3200px;
  max-width: none;
  height: auto;
}

.source-head {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

.source-head h3 {
  margin: 0;
}

.mermaid pre.source {
  max-height: 32em;
  overflow: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--tile);
  font-size: 12px;
  line-height: 1.45;
}
