/* Characteristic layer colors for Article Map satellites and their legend.
   Timeline track colors are owned by graph-timeline.css. Consumers carry
   literal fallbacks per the theme rule. Chosen to collide with none of the
   seven article-type colors. */
:root {
  --graph-prop-accent: #0d9488;
  --graph-theory-accent: #d84315;
  --graph-legend-group-title-color: var(--whisper, #6e6354);
  --graph-edge-color: #5b5b5b;
  --graph-accent-stroke-width: 3.5px;
}

html.coal,
html.navy,
html.ayu,
.bartley-dark {
  --graph-edge-color: #b8bec6;
  --graph-legend-group-title-color: #b8bec6;
}

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

/* Full-page graph container */
#article-graph-container {
  --graph-border-color: var(--table-border-color, var(--sidebar-spacer, #c9b894));
  --graph-mark-plate: var(--bg, #fff);
  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 #article-graph-container,
.bartley-light .local-graph-widget {
  --graph-border-color: #b8a375;
}

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

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

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

/* Graph legend */
.graph-legend {
  position: absolute;
  top: 52px;
  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: auto;
}

.graph-legend-toggle {
  width: 100%;
  border: 0;
  padding: 2px 0;
  background: transparent;
  color: var(--fg, #333);
  font: inherit;
  line-height: 1.35;
  text-align: left;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.graph-legend-toggle[aria-pressed="false"] {
  opacity: 0.38;
}

.graph-legend-toggle:hover {
  opacity: 0.72;
}

.graph-legend-toggle[aria-pressed="true"]:hover {
  opacity: 0.82;
}

.graph-legend-toggle:focus-visible {
  outline: 2px solid var(--links, #6e1f1f);
  outline-offset: 2px;
}

.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;
}

.graph-legend-icon {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
  display: block;
}

.graph-legend-group {
  display: flow-root;
}

.graph-legend-group + .graph-legend-group {
  margin-top: 10px;
}

.graph-legend-group-title {
  margin: 0 0 2px;
  color: var(--graph-legend-group-title-color, #6e6354);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Graph controls */
.graph-controls {
  position: absolute;
  top: 10px;
  left: 10px;
  display: flex;
  flex-direction: row;
  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(--surface, #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(--whisper, #6e6354);
}

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

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

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

.graph-node:focus-visible .graph-node-hit {
  stroke: var(--links, #6e1f1f);
  stroke-width: 2px;
  outline: none;
}

.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;
}

.graph-node-label--layer {
  font-size: 5px;
}

.graph-node-label-code {
  font-family: var(--mono-font, monospace);
  font-size: 4.25px;
  fill-opacity: 0.72;
}

.graph-node-label-title {
  font-size: 5px;
}

/* Predicate labels on the rolled-over node's edges (subject → predicate →
   object, incoming edges inverted). Scoped to the map container so the
   attribute-driven labels in the Connections widget keep their own colors. */
#article-graph-container .graph-edge-label {
  font-size: 5px;
  fill: var(--fg, #333);
  opacity: 0.8;
  pointer-events: none;
  text-anchor: middle;
}

/* Edge styles */
.graph-edge {
  stroke: var(--graph-edge-color, #5b5b5b);
  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;
}

/* Optional grounded-graph layers */
.graph-layer-node {
  cursor: pointer;
}

/* One layer-mark construction, three paths per mark, painted in this order:
   accent (outer-only, stroked in state rules), plate (opaque, occludes both the
   edge beneath the node and the accent's inner half), ring (opposite-wound
   compound path, hollow under the pinned nonzero fill rule). The accent and
   the plate share one `d`, so no accent stroke of any width, at any zoom, in
   any state, can paint inside the plate — which is why every layer-accent
   stroke-width below is exactly TWICE its intended visible weight.
   The plate's colour is the HOST SURFACE's own background, supplied by
   --graph-mark-plate, which every hosting container declares in the same rule
   block as its own `background`. The page's --bg is the current value on all
   three surfaces, but that is a fact about today's stylesheet, not a licence
   to hard-code it here. */
.graph-layer-mark { stroke: none; }
.graph-layer-mark--accent { fill: none; }
.graph-layer-mark--plate { fill: var(--graph-mark-plate, var(--bg, #fff)); }
.graph-layer-mark--ring { fill-rule: nonzero; }

.graph-layer-node--withheld .graph-layer-mark--ring {
  fill: var(--whisper, #6e6354);
}

.graph-layer-node--dead {
  opacity: 0.42;
}

.graph-layer-node.dimmed > .graph-layer-mark--ring {
  fill-opacity: 0.15;
}

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

.graph-layer-node.highlighted > .graph-layer-mark--accent {
  stroke: var(--links, #6e1f1f);
  stroke-width: 3px;
  vector-effect: non-scaling-stroke;
}

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

.graph-layer-edge.highlighted {
  stroke-opacity: 0.85;
  stroke-width: 1.4px;
}

.graph-layer-edge {
  stroke: var(--graph-edge-color, #5b5b5b);
  stroke-width: 0.8px;
  stroke-opacity: 0.34;
  vector-effect: non-scaling-stroke;
}

.graph-layer-edge--bridged {
  stroke-dasharray: 1 2;
  stroke-linecap: round;
  stroke-opacity: 0.30;
}

.graph-layer-edge--contradicts,
.graph-layer-edge--adverse {
  stroke: var(--links, #6e1f1f);
  stroke-dasharray: 4 3;
  stroke-opacity: 0.68;
}

/* Local graph widget */
.local-graph-widget {
  --graph-border-color: var(--table-border-color, var(--sidebar-spacer, #c9b894));
  --graph-mark-plate: var(--bg, #fff);
  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(--whisper, #6e6354);
  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;
}

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

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

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

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

.graph-layer-node:focus-visible > .graph-layer-mark--accent,
.graph-layer-node.graph-node-open > .graph-layer-mark--accent {
  outline: none;
  stroke: var(--links, #6e1f1f);
  stroke-width: calc(var(--graph-accent-stroke-width, 3.5px) * 2);
  vector-effect: non-scaling-stroke;
}

.graph-layer-node.graph-node-open {
  opacity: 1;
}

.graph-layer-node.graph-node-open > .graph-layer-mark--accent {
  filter: drop-shadow(0 0 4px var(--links, #6e1f1f));
}

.graph-layer-node.graph-node-open.dimmed > .graph-layer-mark--accent {
  stroke-opacity: 1;
}

.graph-layer-node.graph-node-open.dimmed > .graph-layer-mark--ring {
  fill-opacity: 1;
}

@media print {
  .graph-controls,
  .graph-search {
    display: none !important;
  }
}
