/* ABOUTME: Stitch topology editor — detail-card grid with edge buttons + connection list. */
/* ABOUTME: Mirrors v1 viz/stitch.py's _build_topology_context CSS conventions. */

.topo-wrap {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 60px);
  background: var(--ind-paper, #f5efe1);
}

.topo-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: #fff;
  border-bottom: 2px solid var(--ind-ink, #1a1a1a);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12px;
}
.topo-bar-left { display: flex; gap: 12px; align-items: center; }
.topo-bar-right { display: flex; gap: 12px; align-items: center; }
.topo-title { font-weight: 800; letter-spacing: 0.5px; }
.topo-title .topo-variant { color: var(--ind-ink-soft, #555); font-weight: 600; }
.topo-hint { font-size: 11px; color: var(--ind-ink-soft, #555); }
.topo-jump {
  padding: 4px 8px; border: 1.5px solid var(--ind-ink); background: #fff;
  font-weight: 800; text-decoration: none; color: var(--ind-ink);
}
.topo-jump:hover { background: #fff5dc; }

.topo-body {
  flex: 1; min-height: 0;
  display: grid; grid-template-columns: 1fr 320px;
}

.topo-cards {
  overflow-y: auto;
  padding: 16px;
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-content: start;
}

.detail-card {
  position: relative;
  background: #fff;
  border: 2px solid var(--ind-ink, #1a1a1a);
  box-shadow: 3px 3px 0 var(--ind-ink, #1a1a1a);
  padding: 28px 10px 28px 28px; /* room for edge buttons */
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column;
}
.detail-card-label {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px; font-weight: 800;
  margin-bottom: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.detail-card-thumb {
  flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center;
  background: #f8f8f4; border: 1px solid #ddd;
}
.detail-card-thumb img {
  max-width: 100%; max-height: 100%; object-fit: contain;
  filter: grayscale(0.05);
}

/* Edge buttons — top/right/bottom/left zones around the card. */
.ez {
  position: absolute;
  background: transparent;
  border: 2px dashed transparent;
  cursor: pointer;
  padding: 0;
}
.ez:hover { background: rgba(255, 200, 60, 0.15); border-color: var(--ind-orange, #d97706); }
.ez.connected { background: rgba(100, 180, 90, 0.18); border-color: var(--ind-green, #4d8a3d); }
.ez.selected { background: rgba(80, 140, 220, 0.28) !important; border: 2px solid #2563eb !important; }
.ez-top    { left: 28px; right: 10px; top: 0;    height: 24px; }
.ez-bottom { left: 28px; right: 10px; bottom: 0; height: 24px; }
.ez-left   { left: 0;    top: 28px;   bottom: 28px; width: 24px; }
.ez-right  { right: 0;   top: 28px;   bottom: 28px; width: 24px; }

/* Sidebar — connection list. */
.topo-side {
  background: #fff;
  border-left: 2px solid var(--ind-ink, #1a1a1a);
  padding: 14px;
  overflow-y: auto;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
}
.topo-side h3 {
  margin: 0 0 8px 0; font-size: 12px; font-weight: 800; letter-spacing: 0.5px;
}
.topo-count { color: var(--ind-ink-soft, #555); font-weight: 600; }
.topo-conn-list { list-style: none; margin: 0; padding: 0; }
.topo-conn {
  border: 1.5px solid var(--ind-gray, #aaa);
  padding: 6px 8px;
  margin-bottom: 6px;
  background: var(--ind-paper-alt, #faf6e9);
}
.topo-conn.calibrated { border-color: var(--ind-green, #4d8a3d); }
.topo-conn.fp { border-color: var(--ind-red, #b91c1c); opacity: 0.85; }
.topo-conn-pair { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.topo-edge {
  font-size: 9px; padding: 1px 4px; background: var(--ind-paper-alt);
  border: 1px solid var(--ind-gray); text-transform: uppercase;
}
.topo-arrow { color: var(--ind-ink-soft, #555); }
.topo-conn-meta { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.topo-tag {
  font-size: 9px; padding: 1px 4px; text-transform: uppercase; font-weight: 800;
}
.topo-tag.cal { color: var(--ind-green, #4d8a3d); border: 1px solid currentColor; }
.topo-tag.fp { color: var(--ind-red, #b91c1c); border: 1px solid currentColor; }
.topo-tag.raw { color: var(--ind-ink-soft, #555); border: 1px solid currentColor; }
.topo-del {
  background: transparent; border: none; cursor: pointer; color: var(--ind-red);
  font-size: 16px; line-height: 1; padding: 0 4px;
}
.topo-del:hover { background: var(--ind-red); color: #fff; }

/* Toast */
.topo-toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--ind-ink); color: #fff; padding: 8px 14px;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; font-weight: 800;
  box-shadow: 3px 3px 0 var(--ind-ink-soft);
  z-index: 100;
}
.topo-toast.err { background: var(--ind-red); }
