/* Pattern Graph — full page and local widget styles */

/* Full-page graph container */
#pattern-graph-container {
  --graph-border-color: var(--table-border-color, var(--sidebar-spacer, #c9b894));
  width: 100%;
  height: 80vh;
  min-height: 500px;
  border: 1px solid var(--graph-border-color);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  background: var(--bg, #fff);
}

.bartley-light #pattern-graph-container,
.bartley-light .local-graph-widget {
  --graph-border-color: #b8a375;
}

.bartley-dark #pattern-graph-container,
.bartley-dark .local-graph-widget {
  --graph-border-color: #4a4036;
}

#pattern-graph-container > svg {
  width: 100%;
  height: 100%;
  cursor: grab;
}

#pattern-graph-container > svg:active {
  cursor: grabbing;
}

/* Graph legend */
.graph-legend {
  position: absolute;
  top: 10px;
  left: 10px;
  background: var(--bg, #fff);
  border: 1px solid var(--graph-border-color);
  border-radius: 4px;
  padding: 8px 12px;
  font-size: 13px;
  z-index: 10;
  pointer-events: none;
}

.graph-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0;
}

.graph-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  transform: translateY(-0.12em);
}

.graph-legend-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  display: block;
  transform: translateY(-0.12em);
}

/* Graph controls */
.graph-controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 10;
}

.graph-controls button {
  width: 32px;
  height: 32px;
  border: 1px solid var(--graph-border-color);
  border-radius: 4px;
  background: var(--bg, #fff);
  color: var(--fg, #333);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.graph-controls button:hover {
  background: var(--sidebar-bg, #f0f0f0);
}

/* Graph search */
.graph-search {
  position: absolute;
  bottom: 10px;
  left: 10px;
  right: 10px;
  z-index: 10;
  display: flex;
  gap: 8px;
}

.graph-search input {
  flex: 1;
  max-width: 300px;
  padding: 6px 10px;
  border: 1px solid var(--graph-border-color);
  border-radius: 4px;
  background: var(--bg, #fff);
  color: var(--fg, #333);
  font-size: 13px;
}

.graph-search input::placeholder {
  color: var(--sidebar-fg, #999);
}

/* Node styles */
.graph-node {
  cursor: pointer;
}

.graph-label-layer {
  pointer-events: none;
}

.graph-node-mark,
.graph-node-hit {
  transform-box: fill-box;
  transform-origin: center;
}

.graph-node-mark {
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.graph-node-hit {
  fill: transparent;
  stroke: none;
  pointer-events: all;
}

.graph-node.dimmed .graph-node-mark {
  opacity: 0.15;
}

.graph-node-label.dimmed {
  opacity: 0.08;
}

.graph-node-label {
  font-size: 5px;
  fill: var(--fg, #333);
  pointer-events: none;
  text-anchor: middle;
  transition: opacity 0.15s ease;
}

/* Edge styles */
.graph-edge {
  stroke: #666;
  stroke-opacity: 0.35;
  stroke-width: 1px;
}

.graph-edge.dimmed {
  stroke-opacity: 0.05;
}

.graph-edge.highlighted {
  stroke-opacity: 0.8;
  stroke-width: 1.5px;
}

/* Local graph widget */
.local-graph-widget {
  --graph-border-color: var(--table-border-color, var(--sidebar-spacer, #c9b894));
  width: 100%;
  aspect-ratio: 1 / 1;
  min-height: 280px;
  border: 1px solid var(--graph-border-color);
  border-radius: 4px;
  margin: 1em 0;
  overflow: hidden;
  position: relative;
  background: var(--bg, #fff);
}

.local-graph-widget svg {
  width: 100%;
  height: 100%;
}

.local-graph-widget .graph-node-label {
  font-size: 11px;
}

.local-graph-widget .graph-edge {
  stroke-opacity: 0.45;
}

.local-graph-widget .graph-edge-label {
  font-size: 9px;
  pointer-events: none;
}

.local-graph-title {
  position: absolute;
  top: 6px;
  left: 10px;
  font-size: 12px;
  color: var(--sidebar-fg, #999);
  pointer-events: none;
}

.local-graph-expand {
  position: absolute;
  top: 6px;
  right: 10px;
  font-size: 11px;
  color: var(--links, #4183c4);
  text-decoration: none;
  cursor: pointer;
}

.local-graph-expand:hover {
  text-decoration: underline;
}
