/* Copied from node_modules/reactflow/dist/style.css to avoid runtime imports */
/* this gets exported as style.css and can be used for the default theming */
/* these are the necessary styles for React Flow, they get used by base.css and style.css */

/* Global Safari font rendering fixes */
* {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

.react-flow {
  direction: ltr;
}
.react-flow__container {
  position: absolute;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
}
.react-flow__pane {
  z-index: 1;
  cursor: -webkit-grab;
  cursor: grab;
}
.react-flow__pane.selection {
    cursor: pointer;
  }
.react-flow__pane.dragging {
    cursor: -webkit-grabbing;
    cursor: grabbing;
  }
.react-flow__viewport {
  transform-origin: 0 0;
  z-index: 2;
  pointer-events: none;
}
.react-flow__renderer {
  z-index: 4;
}
.react-flow__selection {
  z-index: 6;
}
.react-flow__nodesselection-rect:focus,
.react-flow__nodesselection-rect:focus-visible {
  outline: none;
}
.react-flow .react-flow__edges {
  pointer-events: none;
  overflow: visible;
  z-index: 5; /* Ensure edges render above Panel overlays */
}
.react-flow__edge-path,
.react-flow__connection-path {
  stroke: var(--acg-edge, #9A8A76);
  stroke-width: 1;
  fill: none;
}
.react-flow__edge {
  pointer-events: visibleStroke;
  cursor: pointer;
}
.react-flow__edge.animated path {
    stroke-dasharray: 5;
    -webkit-animation: dashdraw 0.5s linear infinite;
            animation: dashdraw 0.5s linear infinite;
  }
.react-flow__edge.animated path.react-flow__edge-interaction {
    stroke-dasharray: none;
    -webkit-animation: none;
            animation: none;
  }
.react-flow__edge.inactive {
    pointer-events: none;
  }
.react-flow__edge.selected,
  .react-flow__edge:focus,
  .react-flow__edge:focus-visible {
    outline: none;
  }
.react-flow__edge.selected .react-flow__edge-path,
  .react-flow__edge:focus .react-flow__edge-path,
  .react-flow__edge:focus-visible .react-flow__edge-path {
    stroke: var(--acg-edge-active, #D4AF37);
  }
.react-flow__edge-textwrapper {
    pointer-events: all;
  }
.react-flow__edge-textbg {
  fill: white;
}
.react-flow__edge-text {
  pointer-events: none;
  user-select: none;
}

/* Herodotus customizations */
/* Candidate edges: dashed neutral */
.react-flow__edge.edge-candidate path.react-flow__edge-path {
  stroke: var(--acg-text-muted, #9A8A76);
  stroke-width: 2;
  stroke-dasharray: 6;
}

/* Neighbor highlight (amber/gold) */
.react-flow__edge.neighbor-edge path.react-flow__edge-path {
  stroke: var(--acg-selection-drag, #f59e0b);
  stroke-width: 2.5;
}

/* Make free source handle a bit more apparent on hover */
.react-flow__handle.source:hover {
  box-shadow: 0 0 0 2px var(--acg-accent, #D4AF37);
  cursor: crosshair;
}

/* Theming variables - synchronized with ACG Design System */
[data-theme='dark'] {
  --page-bg: var(--acg-bg, #0D0C0B);
  --node-bg: var(--acg-card, #1A1815);
  --node-border: var(--acg-border, #3D3530);
  --node-text: var(--acg-text, #D4C4B0);
  --node-inner-frame-bg: rgba(0,0,0,0.2);
  --selected-edge-stroke: var(--acg-edge-active, #D4AF37);
  --button-bg: var(--acg-surface, #2A2520);
  --button-text: var(--acg-text, #D4C4B0);
  --accent: var(--acg-accent, #D4AF37);
  --surface: var(--acg-surface, #2A2520);
  --heading-font: 'Playfair Display', Georgia, serif;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}
[data-theme='light'] {
  --page-bg: var(--acg-bg, #F5F0EB);
  --node-bg: var(--acg-card, #FFFFFF);
  --node-border: var(--acg-border, #D4C4B0);
  --node-text: var(--acg-text, #2D2926);
  --node-inner-frame-bg: var(--acg-input, #FAF8F6);
  --selected-edge-stroke: var(--acg-edge-active, #D4AF37);
  --button-bg: var(--acg-surface, #EDE6DF);
  --button-text: var(--acg-text, #2D2926);
  --accent: var(--acg-accent, #D4AF37);
  --surface: var(--acg-surface, #EDE6DF);
  --heading-font: 'Playfair Display', Georgia, serif;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
}

/* Canvas vignette: DISABLED — ::before on .react-flow breaks viewport centering/zoom.
   TODO: implement vignette via a dedicated overlay div outside ReactFlow's DOM. */

/* Custom node look */
.react-flow__node-custom {
  background: var(--node-bg);
  /* let the CLJS component set the exact border; avoid double-borders */
  border: none;
  color: var(--node-text);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  font-size: 12px;
  /* do NOT enforce a default min-width; compact cards must be truly narrow */
  min-width: 0;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out, border-color 0.2s ease-in-out;
}
.node-title-wrapper {
  background: var(--node-inner-frame-bg);
  padding: 8px 12px;
  border-bottom: 1px solid var(--node-border);
  border-radius: 7px 7px 0 0;
}
.node-title {
  font-weight: 600;
  color: var(--node-text);
  /* Safari font rendering fixes */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  letter-spacing: normal;
  word-spacing: normal;
  text-align: left;
}
.node-tags-wrapper { padding: 8px 12px; }
.node-tags { display: flex; flex-wrap: wrap; gap: 5px; }
.node-tag { padding: 3px 8px; border-radius: 12px; font-size: 10px; font-weight: 500; color: var(--acg-text-strong, #F5F0EB); background: var(--acg-surface, #2A2520); border: 1px solid var(--acg-border, #3D3530); }

/* Compact variant */
.react-flow__node-custom.compact {
  /* exact wrapper box size to eliminate any extra right gap */
  width: 120px !important;
  min-width: 120px !important;
  max-width: 120px !important;
  /* padding participates in the box model (box-sizing:border-box is set inline) */
  padding: 4px 6px;
}
.react-flow__node-custom.compact .node-title-wrapper { padding: 0; border-bottom: none; background: none; }
.react-flow__node-custom.compact .node-title { font-size: 10px; }
.react-flow__node-custom.compact .node-tags-wrapper { display: none; }
.react-flow__connection {
  pointer-events: none;
}
.react-flow__connectionline path {
    stroke: var(--acg-edge, #9A8A76);
    stroke-width: 1;
  }
.react-flow__nodes {
  transform-origin: 0 0;
  z-index: 3;
}
.react-flow__node {
  position: absolute;
  user-select: none;
  pointer-events: all;
  transform-origin: 0 0;
  /* ensure outer wrapper contributes no extra gap */
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  box-shadow: none !important; /* remove extra outer rim */
}
.react-flow__node-default.selectable:focus,
.react-flow__node-default.selectable:focus-visible {
  outline: none;
}
.react-flow__node-default.selectable:focus .react-flow__node-default {
    border-color: var(--acg-edge-active, #D4AF37);
  }
.react-flow__node.dragging {
  cursor: -webkit-grabbing;
  cursor: grabbing;
}
.react-flow__node.selectable:focus,
.react-flow__node.selectable:focus-visible {
  outline: none;
}
.react-flow__node.selected .react-flow__node-default,
  .react-flow__node:focus .react-flow__node-default,
  .react-flow__node:focus-visible .react-flow__node-default {
    border-color: var(--acg-edge-active, #D4AF37);
  }
.react-flow__nodesselection {
  z-index: 8;
  transform-origin: left top;
  pointer-events: none;
}
.react-flow__nodesselection-rect {
  position: absolute;
  pointer-events: all;
  cursor: -webkit-grabbing;
  cursor: grabbing;
}
.react-flow__handle {
  position: absolute;
  z-index: 2;
  width: 6px;
  height: 6px;
  background: var(--acg-handle, #C5A581);
  border: 1px solid var(--acg-card, #FFFFFF);
  border-radius: 100%;
}
.react-flow__handle.connectable {
    pointer-events: all;
  }
.react-flow__handle-bottom {
  top: auto;
  left: 50%;
  bottom: -6px;
  transform: translate(-50%);
}
.react-flow__handle-bottom.source {
  bottom: -6px;
}
.react-flow__handle-top {
  top: -6px;
  left: 50%;
  transform: translate(-50%);
}
.react-flow__handle-left {
  top: 50%;
  left: -6px;
  transform: translateY(-50%);
}
.react-flow__handle-right {
  right: -6px;
  top: 50%;
  transform: translateY(-50%);
}
.react-flow__edgeupdater {
  cursor: move;
  pointer-events: all;
}
.react-flow__panel {
  position: absolute;
  z-index: 5;
}
.react-flow__attribution {
  position: absolute;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.5);
  padding: 2px 3px;
  border-radius: 2px;
  color: #999;
}
.react-flow__attribution a {
    text-decoration: none;
    color: #999;
  }
.react-flow__attribution.right {
  right: 10px;
}
.react-flow__attribution.left {
  left: 10px;
}
.react-flow__attribution.bottom {
  bottom: 10px;
}
.react-flow__attribution.top {
  top: 10px;
}
@-webkit-keyframes dashdraw {
  from {
    stroke-dashoffset: 10;
  }
}
@keyframes dashdraw {
  from {
    stroke-dashoffset: 10;
  }
}
.react-flow__minimap {
  background-color: #fff;
  border-radius: 2px;
}
.react-flow__controls {
  background-color: #fefefe;
  border: 1px solid #eee;
  border-radius: 2px;
  box-shadow: 0 2px 10px 1px rgba(0, 0, 0, 0.05);
}
.react-flow__controls-button {
  border: none;
  background: transparent;
  border-right: 1px solid #eee;
  cursor: pointer;
  padding: 5px;
}
.react-flow__controls-button svg {
    transition: all 0.2s ease 0s;
  }
.react-flow__controls-button:hover svg {
    transform: scale(1.1);
  }
.react-flow__controls-button:disabled {
    pointer-events: none;
  }
.react-flow__resize-control.handle {
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--acg-border-subtle, #4A433D);
  border-radius: 100%;
}
.react-flow__resize-control.line {
  position: absolute;
  border: 1px solid var(--acg-border-subtle, #4A433D);
}
.react-flow__resize-control.left .line,
.react-flow__resize-control.right .line {
  height: 100%;
}
.react-flow__resize-control.top .line,
.react-flow__resize-control.bottom .line {
  width: 100%;
}
.react-flow__resize-control.handle.left {
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
}
.react-flow__resize-control.handle.right {
  right: -8px;
  top: 50%;
  transform: translateY(-50%);
}
.react-flow__resize-control.handle.top {
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
}
.react-flow__resize-control.handle.bottom {
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
}
.react-flow__resize-control.left .line {
  left: -1px;
}
.react-flow__resize-control.right .line {
  right: -1px;
}
.react-flow__resize-control.top .line {
  top: -1px;
}
.react-flow__resize-control.bottom .line {
  bottom: -1px;
}
.react-flow__node-default {
  background: var(--acg-card, #FFFFFF);
  color: var(--acg-text, #2D2926);
  padding: 10px;
  border-radius: 2px;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  border: 1px solid var(--acg-border, #D4C4B0);
  font-size: 12px;
}
.react-flow__edge-textbg {
  fill: white;
}
.react-flow__edge-text {
  fill: black;
  font-size: 10px;
  dominant-baseline: ideographic;
  text-anchor: middle;
}
.react-flow__node-custom.selected {
  border-color: var(--selected-edge-stroke);
  box-shadow: 0 0 10px var(--selected-edge-stroke);
}

/* =============================================================================
   Handle styling for connector visibility
   - handle-visible: invisible (for active connections)
   - handle-hidden: triangle indicator (for connections to hidden nodes)
   - handle-open: circle (for new connections)
   ============================================================================= */

/* Visible connections: tiny invisible handle so edge connects at node edge */
.react-flow__handle.handle-visible {
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  background: transparent !important;
  border: none !important;
  opacity: 0;
}

/* Hidden connections: tiny handle + triangle pseudo-element */
.react-flow__handle.handle-hidden {
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  background: transparent !important;
  border: none !important;
}

/* Override default -6px positioning to put ALL handles exactly at node edge */
.react-flow__handle.handle-visible.react-flow__handle-left,
.react-flow__handle.handle-hidden.react-flow__handle-left,
.react-flow__handle.handle-open.react-flow__handle-left {
  left: 0 !important;
}
.react-flow__handle.handle-visible.react-flow__handle-right,
.react-flow__handle.handle-hidden.react-flow__handle-right,
.react-flow__handle.handle-open.react-flow__handle-right {
  right: 0 !important;
}
.react-flow__handle.handle-visible.react-flow__handle-top,
.react-flow__handle.handle-hidden.react-flow__handle-top,
.react-flow__handle.handle-open.react-flow__handle-top {
  top: 0 !important;
}
.react-flow__handle.handle-visible.react-flow__handle-bottom,
.react-flow__handle.handle-hidden.react-flow__handle-bottom,
.react-flow__handle.handle-open.react-flow__handle-bottom {
  bottom: 0 !important;
}

/* Hidden edge triangles - always point INTO the node based on handle position */
/* Handle on LEFT → triangle points RIGHT (into node) */
.react-flow__handle.handle-hidden.react-flow__handle-left::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 0 4px 7px;
  border-color: transparent transparent transparent var(--acg-handle-indicator, #9A8A76);
}

/* Handle on RIGHT → triangle points LEFT (into node) */
.react-flow__handle.handle-hidden.react-flow__handle-right::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 4px 7px 4px 0;
  border-color: transparent var(--acg-handle-indicator, #9A8A76) transparent transparent;
}

/* Handle on TOP → triangle points DOWN (into node) */
.react-flow__handle.handle-hidden.react-flow__handle-top::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 7px 4px 0 4px;
  border-color: var(--acg-handle-indicator, #9A8A76) transparent transparent transparent;
}

/* Handle on BOTTOM → triangle points UP (into node) */
.react-flow__handle.handle-hidden.react-flow__handle-bottom::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 0;
  height: 0;
  border-style: solid;
  border-width: 0 4px 7px 4px;
  border-color: transparent transparent var(--acg-handle-indicator, #9A8A76) transparent;
}

/* Open handles: tiny anchor + circle visual via ::after */
.react-flow__handle.handle-open {
  width: 1px !important;
  height: 1px !important;
  min-width: 0 !important;
  min-height: 0 !important;
  background: transparent !important;
  border: none !important;
}
.react-flow__handle.handle-open::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--acg-handle-indicator, #9A8A76);
  border: 1px solid var(--acg-card, #FFFFFF);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: auto;
}

/* Light/dark theme adjustments handled via ACG CSS variables */
