/* =========================================================
   Operation Scarecrow — section map
   Loaded only by the section hub and the argument page.
   Everything drawn comes from
   operation-scarecrow/data/scarecrow-map.json; no page, colour
   or position is hardcoded here.
   ========================================================= */

.sc-graph {
  position: relative;
  margin-top: 2.25rem;
}

/* Breaks the constellation out of the text column so it reads as a
   spread rather than a widget. 94vw dodges the scrollbar rounding
   that bites with a flat 100vw. */
.sc-graph--bleed {
  width: min(94vw, 1180px);
  margin-left: 50%;
  transform: translateX(-50%);
}

/* Soft tier-coloured wash, echoing the hero's gradients. */
.sc-graph-stage-wrap { position: relative; }
.sc-graph-stage-wrap::before {
  content: '';
  position: absolute;
  inset: -4% -2%;
  pointer-events: none;
  background:
    radial-gradient(ellipse 42% 52% at 24% 32%, rgba(168, 85, 247, 0.06), transparent 70%),
    radial-gradient(ellipse 40% 50% at 76% 68%, rgba(45, 212, 191, 0.05), transparent 70%);
}
html[data-theme="light"] .sc-graph-stage-wrap::before {
  background:
    radial-gradient(ellipse 42% 52% at 24% 32%, rgba(147, 51, 234, 0.05), transparent 70%),
    radial-gradient(ellipse 40% 50% at 76% 68%, rgba(13, 148, 136, 0.045), transparent 70%);
}

/* Fallback content — replaced once the graph renders. */
.sc-graph-fallback p { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 0.75rem; }
.sc-graph-fallback ul { list-style: none; columns: 2; column-gap: 2.5rem; }
.sc-graph-fallback li { margin-bottom: 0.4rem; break-inside: avoid; }
.sc-graph-fallback a { color: var(--accent); text-decoration: none; font-size: 0.9rem; }
.sc-graph-fallback a:hover { text-decoration: underline; }
@media (max-width: 640px) { .sc-graph-fallback ul { columns: 1; } }

/* ---------- Controls ---------- */

.sc-graph-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.6rem 1.5rem;
  margin-bottom: 0.5rem;
}

.sc-toggle {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: none;
  border: none;
  border-bottom: 1px solid var(--accent);
  padding: 0 0 0.2rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.sc-toggle:hover { opacity: 0.65; }

.sc-legend { display: flex; flex-wrap: wrap; gap: 0.3rem 1.1rem; margin-left: auto; }
.sc-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.sc-legend-swatch { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.sc-legend-item--spine .sc-legend-swatch {
  background: transparent !important;
  border: 1px solid var(--text-muted);
}

/* ---------- Stage ---------- */

.sc-graph-stage {
  display: block;
  width: 100%;
  height: auto;
  position: relative;
  touch-action: manipulation;
  opacity: 0;
  transition: opacity 0.7s ease;
}
.sc-graph.is-live .sc-graph-stage { opacity: 1; }

.sc-edge {
  stroke: var(--border);
  stroke-width: 1.2;
  fill: none;
  transition: stroke 0.25s, opacity 0.25s;
}
.sc-edge--tether { stroke-dasharray: 2 5; opacity: 0.55; }
.sc-edge.is-related { stroke: var(--text-dim); opacity: 1; }
.sc-edge.is-muted { opacity: 0.12; }

.sc-node { cursor: pointer; outline: none; }
.sc-node-glow { pointer-events: none; transition: opacity 0.25s; }
.sc-node-ring {
  fill: none;
  stroke: transparent;
  stroke-width: 1.4;
  transition: stroke 0.25s;
}
.sc-node-dot { transition: stroke 0.25s, fill 0.25s; }

.sc-node:hover .sc-node-ring,
.sc-node:focus-visible .sc-node-ring,
.sc-node.is-selected .sc-node-ring { stroke: var(--text-dim); }
.sc-node:hover .sc-node-glow,
.sc-node.is-selected .sc-node-glow { opacity: 1.6; }
.sc-node--spine:hover .sc-node-dot,
.sc-node--spine.is-selected .sc-node-dot { stroke: var(--text); }

.sc-node.is-muted { opacity: 0.22; }

.sc-node-label {
  font-family: var(--font-serif);
  fill: var(--text);
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--bg);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.sc-node-label--minor {
  font-family: var(--font-body);
  fill: var(--text-dim);
  opacity: 0;
  transition: opacity 0.25s;
}
.sc-node:hover .sc-node-label--minor,
.sc-node:focus-visible .sc-node-label--minor,
.sc-node.is-selected .sc-node-label--minor { opacity: 1; }

/* ---------- Preview card ---------- */

.sc-preview {
  display: none;
  position: relative;
  max-width: 40rem;
  margin-top: 0.5rem;
  padding: 1.3rem 1.5rem 1.4rem 1.7rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 3px;
}
.sc-preview.is-open { display: block; }
.sc-preview::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--sc-accent, var(--text-muted));
}

.sc-preview-eyebrow {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 0.55rem;
}
.sc-preview-title {
  font-family: var(--font-serif);
  font-size: 1.2rem;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: 0.5rem;
}
.sc-preview-blurb {
  color: var(--text-dim);
  font-size: 0.93rem;
  line-height: 1.65;
  margin-bottom: 0.75rem;
}
.sc-preview-meta {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.95rem;
}
.sc-preview-link {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--accent);
  padding-bottom: 0.15rem;
  transition: opacity 0.2s;
}
.sc-preview-link:hover { opacity: 0.65; }

.sc-preview-close {
  position: absolute;
  top: 0.6rem;
  right: 0.7rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.2rem 0.35rem;
}
.sc-preview-close:hover { color: var(--text); }

.sc-hint {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.07em;
  color: var(--text-muted);
  margin-top: 0.9rem;
}

@media (max-width: 640px) {
  .sc-legend { margin-left: 0; width: 100%; }
  .sc-graph--bleed { width: 100%; margin-left: 0; transform: none; }
}

/* ---------------------------------------------------------
   Entrance motion
   Nodes and edges are held invisible until the layout animation
   reaches them, so nothing appears before it starts moving. The
   layout itself is solved off-screen and tweened — see the note
   above solve() in scarecrow-graph.js.
   --------------------------------------------------------- */
.sc-node { transition: opacity 0.34s ease; }
.sc-node.sc-is-pending,
.sc-edge.sc-is-pending { opacity: 0; }

@media (prefers-reduced-motion: reduce) {
  .sc-node, .sc-edge { transition: none; }
  .sc-node.sc-is-pending, .sc-edge.sc-is-pending { opacity: 1; }
}
