/* ==========================================================================
   Network Graph Styles - Brand Dark Theme
   ========================================================================== */

:root {
  --graph-bg-primary: #0d1117;
  --graph-bg-secondary: #161b22;
  --graph-accent-primary: #D2691E;
  --graph-accent-hover: #A0520F;
  --graph-accent-secondary: #E8943B;
  --graph-glow-orange: rgba(210, 105, 30, 0.4);
  --graph-text-light: #f0f6fc;
  --graph-text-secondary: #8b949e;
  --graph-border: #30363d;
  --graph-tag-color: #6e7681;
}

/* Network Graph Container */
.network-graph {
  background: var(--graph-bg-primary);
  border: 1px solid var(--graph-border);
  border-radius: 8px;
  margin: var(--space-lg) 0;
  overflow: hidden;
}

/* Graph Controls */
.graph-controls {
  background: var(--graph-bg-secondary);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--graph-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.btn-reset {
  background: var(--graph-accent-primary);
  color: var(--graph-text-light);
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--font-family);
  font-size: 0.9rem;
  transition: background-color 0.2s ease;
}

.btn-reset:hover,
.btn-reset:focus {
  background: var(--graph-accent-hover);
}

.btn-reset.active {
  background: var(--graph-accent-secondary);
}

/* Filtered state */
.network-graph.filtered {
  border-color: var(--graph-accent-secondary);
  box-shadow: 0 0 8px rgba(232, 148, 59, 0.3);
}

.network-graph.filtered .graph-controls {
  border-bottom-color: var(--graph-accent-secondary);
}

.graph-instructions {
  color: var(--graph-text-secondary);
}

.graph-instructions details {
  font-size: 0.85rem;
}

.graph-instructions summary {
  cursor: pointer;
  color: var(--graph-accent-secondary);
}

.graph-instructions ul {
  margin: 0.5rem 0 0;
  padding-left: 1.2rem;
}

.graph-instructions li {
  margin-bottom: 0.25rem;
}

/* Graph Viewport */
.graph-viewport {
  position: relative;
  width: 100%;
  height: 500px;
  overflow: hidden;
}

.graph-viewport svg {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--graph-bg-primary);
}

/* ---- Nodes ---- */
.graph-node {
  cursor: grab;
  stroke-width: 2px;
  transition: opacity 0.3s ease;
}

/* Post nodes: standout orange */
.graph-node.post {
  fill: var(--graph-accent-primary);
  stroke: var(--graph-text-light);
  cursor: pointer;
}

/* Tag nodes: subtle grey */
.graph-node.tag {
  fill: var(--graph-tag-color);
  stroke: var(--graph-border);
  stroke-width: 1px;
}

.graph-node:hover {
  fill: var(--graph-accent-hover) !important;
}

.graph-node.tag:hover {
  fill: var(--graph-text-secondary) !important;
}

/* Selected post node */
.graph-node.selected {
  stroke: var(--graph-accent-secondary);
  stroke-width: 3px;
  filter: drop-shadow(0 0 8px var(--graph-glow-orange));
}

/* Hover glow - stroke only, no geometric changes */
.brand-node-glow {
  stroke: var(--graph-accent-primary);
  stroke-width: 3px;
}

/* Dragging: no outline box, just grabbing cursor */
.graph-node:active {
  cursor: grabbing;
  outline: none;
}

/* ---- Edges ---- */
.graph-edge {
  stroke: var(--graph-text-secondary);
  stroke-opacity: 0.15;
  stroke-width: 1px;
  fill: none;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.graph-edge.post-tag {
  stroke-opacity: 0.1;
}

.graph-edge.post-post {
  stroke: var(--graph-accent-secondary);
  stroke-opacity: 0.25;
  stroke-width: 1.5px;
  stroke-dasharray: 3, 3;
}

.graph-edge.active {
  stroke-opacity: 0.6;
  stroke: var(--graph-accent-primary);
}

/* ---- Labels ---- */
.graph-label {
  font-family: var(--font-family);
  text-anchor: middle;
  pointer-events: none;
  user-select: none;
}

/* Tag labels: light and subtle */
.graph-label.tag {
  fill: var(--graph-text-secondary);
  font-weight: 400;
  font-size: 10px;
  opacity: 0.7;
}

/* Post labels: bold, hidden until hover/select */
.graph-label.post {
  fill: var(--graph-text-light);
  opacity: 0;
  transition: opacity 0.2s ease;
  font-size: 12px;
  font-weight: 700;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9);
}

.graph-label.post.visible {
  opacity: 1;
}

/* ---- Sidebar post list ---- */
.post-list-compact .post-title {
  color: var(--color-text);
  font-weight: 500;
}

.post-list-compact li:hover .post-title {
  color: var(--color-accent);
}

.post-list-compact .post-meta-row {
  display: flex;
  align-items: center;
  gap: 0;
  margin-top: var(--space-xs);
}

.post-list-compact .post-meta-row time {
  display: inline;
  margin-top: 0;
}

.post-meta-divider {
  margin: 0 0.4rem;
  color: var(--color-text-secondary);
  opacity: 0.4;
}

.go-to-post-link {
  font-size: 0.85rem;
  color: var(--color-text-secondary);
  text-decoration: none;
  transition: color 0.2s ease;
  white-space: nowrap;
}

.go-to-post-link:hover {
  color: var(--color-accent);
  text-decoration: underline;
}

/* ---- Status ---- */
.graph-status {
  padding: var(--space-sm) var(--space-md);
  text-align: center;
  color: var(--graph-text-secondary);
  background: var(--graph-bg-secondary);
  min-height: 1.5em;
}

.loading-message {
  color: var(--graph-accent-secondary);
}

.error-message {
  color: #ff6b6b;
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
  .graph-viewport {
    height: 400px;
  }

  .graph-controls {
    flex-direction: column;
    align-items: stretch;
  }

  .graph-instructions {
    order: 1;
  }

  .btn-reset {
    order: 2;
    align-self: center;
    min-height: 44px;
    min-width: 44px;
    padding: 0.75rem 1.25rem;
  }

  .graph-node.post {
    r: 22;
  }

  .graph-node.tag {
    r: 22;
  }
}

/* ---- Accessibility ---- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-links {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.skip-links:focus-within {
  position: fixed;
  top: 0;
  left: 0;
  width: auto;
  height: auto;
  z-index: 1000;
  background: var(--graph-bg-primary);
  padding: 0.5rem;
  border: 2px solid var(--graph-accent-primary);
  border-radius: 0 0 4px 0;
  overflow: visible;
}

.skip-link {
  display: block;
  color: var(--graph-text-light);
  background: var(--graph-accent-primary);
  padding: 0.5rem 1rem;
  margin-bottom: 0.25rem;
  border-radius: 4px;
  text-decoration: none;
  transition: background-color 0.2s ease;
}

.skip-link:hover,
.skip-link:focus {
  background: var(--graph-accent-hover);
}

/* Focus indicator for keyboard nav - not for drag/click */
.graph-node:focus {
  outline: 3px solid var(--graph-accent-primary);
  outline-offset: 2px;
}

.graph-node:focus:not(:focus-visible) {
  outline: none;
}

.btn-reset:focus {
  outline: 3px solid var(--graph-accent-primary);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .graph-node,
  .graph-edge,
  .graph-label {
    transition: none;
  }

  .brand-node-glow {
    filter: none;
  }
}
