/* ── Pairo Base: ekosistem grafiği (graph.js) ────────────────────────────────
   Sahne bir Ink kartıdır (sistem alanı). Üstteki denetimler koyu zemin denetimi:
   krem yazı, krem çizgi, tokenlardan karışım zemin. Gölge yok, degrade yok.
   --pg-k-* ve --pg-s-* değerlerini graph.js jetonlardan okuyup yazar.
   ───────────────────────────────────────────────────────────────────────── */
.pg-root {
  --pg-ctl: color-mix(in srgb, var(--on-dark) 8%, var(--ink));
  --pg-ctl-hover: color-mix(in srgb, var(--on-dark) 14%, var(--ink));
  --pg-ctl-press: color-mix(in srgb, var(--on-dark) 4%, var(--ink));
  position: relative;
  width: 100%;
  height: clamp(420px, 70vh, 720px);
  min-height: 320px;
  background: var(--ink);
  color: var(--on-dark);
  border-radius: var(--r-xl);
  overflow: hidden;
  isolation: isolate;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.4;
  -webkit-user-select: none;
  user-select: none;
}
.pg-canvas {
  position: absolute; inset: 0;
  display: block; width: 100%; height: 100%;
  touch-action: none;
  cursor: grab;
}
.pg-canvas:focus-visible { outline: 2px solid var(--on-dark-line); outline-offset: -4px; box-shadow: none; border-radius: var(--r-xl); }
.pg-root.pg-on-node .pg-canvas { cursor: pointer; }
.pg-root.pg-panning .pg-canvas, .pg-root.pg-dragging .pg-canvas { cursor: grabbing; }

/* ── araç çubuğu ── */
.pg-toolbar {
  position: absolute; top: 12px; left: 12px; right: 12px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  pointer-events: none;
}
.pg-toolbar > * { pointer-events: auto; }

.pg-search {
  position: relative;
  display: flex; align-items: center;
  flex: 0 1 240px; min-width: 0;
  height: 36px;
  padding: 0 12px;
  gap: 8px;
  background: var(--pg-ctl);
  border: 1px solid var(--on-dark-line);
  border-radius: var(--r);
  color: var(--on-dark-muted);
  transition: background-color 160ms var(--ease), border-color 160ms var(--ease);
}
.pg-search:hover { background: var(--pg-ctl-hover); }
.pg-search:focus-within { border-color: var(--on-dark-muted); color: var(--on-dark); }
.pg-search svg { flex: none; }
.pg-search input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; padding: 0; margin: 0;
  background: transparent;
  color: var(--on-dark);
  font: 500 14px/1 var(--font);
}
.pg-search input::placeholder { color: var(--on-dark-muted); opacity: 1; }
.pg-search input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }
.pg-search input:focus-visible { box-shadow: none; }
.pg-root.pg-nomatch .pg-search { border-color: var(--pg-s-alert); }

.pg-chips {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  flex: 1 1 320px; min-width: 0;
}
.pg-chip, .pg-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 12px;
  background: var(--pg-ctl);
  border: 1px solid var(--on-dark-line);
  border-radius: var(--r);
  color: var(--on-dark);
  font: 500 13px/1 var(--font);
  white-space: nowrap;
  transition: background-color 160ms var(--ease), color 160ms var(--ease), transform 160ms var(--ease);
}
.pg-chip { height: 32px; padding: 0 10px; border-radius: var(--r-sm); }
.pg-btn { font-weight: 600; }
.pg-chip:hover, .pg-btn:hover { background: var(--pg-ctl-hover); }
.pg-chip:active, .pg-btn:active { transform: scale(.94); background: var(--pg-ctl-press); }
.pg-chip:focus-visible, .pg-btn:focus-visible, .pg-search:has(input:focus-visible) {
  outline: 2px solid var(--on-dark); outline-offset: 2px; box-shadow: none;
}
.pg-chip-n { color: var(--on-dark-muted); font-variant-numeric: tabular-nums; }
.pg-chip[aria-pressed="false"] { background: transparent; color: var(--on-dark-muted); }
.pg-chip[aria-pressed="false"] .pg-sw { background: transparent; box-shadow: none; border: 1.5px solid var(--on-dark-muted); }
.pg-chip[aria-pressed="false"] .pg-chip-label { text-decoration: line-through; text-decoration-thickness: 1px; }
.pg-fit { margin-left: auto; align-self: flex-start; }

/* ── göstergeler: tür noktası, durum halkası, akış ── */
.pg-sw {
  flex: none; display: inline-block;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--pg-c, var(--on-dark));
}
.pg-sw-org { --pg-c: var(--pg-k-org); width: 12px; height: 12px; }
.pg-sw-workspace { --pg-c: var(--pg-k-workspace); }
.pg-sw-project { --pg-c: var(--pg-k-project); }
.pg-sw-person { --pg-c: var(--pg-k-person); width: 8px; height: 8px; }
.pg-sw-channel { --pg-c: var(--pg-k-channel); width: 8px; height: 8px; }
.pg-sw-system {
  --pg-c: var(--pg-k-system);
  border-radius: calc(var(--r-xs) / 2);
  border: 1.5px solid var(--on-dark);
}
.pg-ring {
  flex: none; display: inline-block;
  width: 10px; height: 10px; border-radius: 50%;
  border: 2px solid var(--pg-r, var(--on-dark));
}
.pg-ring-ok { --pg-r: var(--pg-s-ok); }
.pg-ring-warn { --pg-r: var(--pg-s-warn); }
.pg-ring-alert { --pg-r: var(--pg-s-alert); }
.pg-ring-off { --pg-r: var(--pg-s-off); border-style: dashed; }
.pg-flow { display: inline-flex; color: var(--on-dark-muted); }
.pg-flow svg { width: 16px; height: 16px; }

/* ── gösterge paneli ── */
.pg-legend {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  max-width: calc(100% - 24px);
  pointer-events: none;
}
.pg-legend > * { pointer-events: auto; }
.pg-legend-toggle { display: none; }
.pg-legend-body {
  display: flex; flex-wrap: wrap; align-items: flex-start; gap: 4px 16px;
  max-width: 420px;
  padding: 12px;
  background: var(--pg-ctl);
  border: 1px solid var(--on-dark-line);
  border-radius: var(--r-lg);
  color: var(--on-dark-muted);
  font-size: 12px; line-height: 16px;
}
.pg-legend-title {
  flex: 0 0 100%;
  margin-bottom: 4px;
  font: 600 13px/16px var(--display);
  letter-spacing: -.01em;
  color: var(--on-dark);
}
.pg-legend-list {
  display: flex; flex-wrap: wrap; gap: 4px 12px;
  margin: 0; padding: 0; list-style: none;
  flex: 0 0 100%;
}
.pg-legend-list li { display: inline-flex; align-items: center; gap: 6px; min-height: 20px; }

/* ── ipucu kartı ── */
.pg-tip {
  position: absolute; left: 0; top: 0; z-index: 2;
  width: max-content; max-width: 260px;
  padding: 12px;
  background: var(--ink-2);
  border: 1px solid var(--on-dark-line);
  border-radius: var(--r);
  color: var(--on-dark);
  pointer-events: none;
}
.pg-tip-title {
  font: 600 16px/20px var(--display);
  letter-spacing: -.01em;
  overflow-wrap: anywhere;
}
.pg-tip-kind, .pg-tip-status {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px;
  font-size: 13px; line-height: 17px; font-weight: 500;
}
.pg-tip-kind { color: var(--on-dark-muted); }
.pg-tip-status { color: var(--on-dark); }
.pg-tip-meta {
  margin: 8px 0 0; padding: 8px 0 0; list-style: none;
  border-top: 1px solid var(--on-dark-line);
  color: var(--on-dark-muted);
  font-size: 13px; line-height: 18px;
}
.pg-tip-meta li { overflow-wrap: anywhere; }

.pg-empty {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 24px;
  color: var(--on-dark-muted);
  font-size: 14px; text-align: center;
  pointer-events: none;
}

/* ── dar kap: araç çubuğu iki satır, gösterge düğmeye katlanır, ipucu altta ── */
.pg-narrow .pg-toolbar { gap: 8px; }
.pg-narrow .pg-search { flex: 1 1 140px; }
.pg-narrow .pg-chips {
  order: 3; flex: 0 0 calc(100% + 24px);
  flex-wrap: nowrap; overflow-x: auto;
  margin: 0 -12px; padding: 0 12px;
  scroll-padding: 0 12px;
  scrollbar-width: none;
  touch-action: pan-x;
  overscroll-behavior-x: contain;
}
.pg-narrow .pg-chips::-webkit-scrollbar { display: none; }
.pg-narrow .pg-fit { margin-left: 0; }
.pg-narrow .pg-legend-toggle { display: inline-flex; }
.pg-narrow .pg-legend-body { display: none; max-width: min(320px, calc(100vw - 48px)); }
.pg-narrow.pg-legend-open .pg-legend-body { display: flex; order: -1; }
.pg-narrow .pg-tip { left: 12px; right: 12px; top: auto; bottom: 60px; width: auto; max-width: none; }
.pg-narrow.pg-legend-open .pg-tip { display: none; }

@media (pointer: coarse) {
  .pg-chip { height: 40px; }
  .pg-btn, .pg-search { height: 44px; }
  .pg-search input { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-chip, .pg-btn, .pg-search { transition: none; }
  .pg-chip:active, .pg-btn:active { transform: none; }
}
