/* ============================================================
   jcrihani.com — knowledge-graph view
   (loads after style.css; reuses its theme variables)
   ============================================================ */

/* view switching */
#graph-view { display: none; }
#graph-view.active { display: block; }
#list-view.hidden-view { display: none; }
body.graph-mode { overflow: hidden; }
.graph-mode .list-only { display: none !important; }

/* full-bleed graph stage under the nav */
#graph-view {
  position: relative;
  height: calc(100vh - 62px);
  overflow: hidden;
  background: transparent;   /* ambient gold-field shows through */
}
#graph-viewport {
  position: absolute; inset: 0; cursor: grab; touch-action: none;
}
#graph-viewport.grabbing { cursor: grabbing; }
#graph-stage {
  position: absolute; top: 0; left: 0; width: 2800px; height: 2800px;
  transform-origin: 0 0;
}
#graph-edges { position: absolute; top: 0; left: 0; width: 2800px; height: 2800px; overflow: visible; pointer-events: none; }
#edge-path { fill: none; stroke: color-mix(in srgb, var(--accent) 42%, transparent); stroke-width: 1.6; }

/* nodes */
.gnode {
  position: absolute; transform: translate(-50%, -50%);
  font-family: var(--sans); font-size: 14px; font-weight: 600; line-height: 1.15;
  border: 1px solid var(--line); background: var(--bg-elev); color: var(--ink);
  border-radius: 999px; padding: 10px 16px; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow); display: inline-flex; align-items: center; gap: 8px;
  transition: background .18s, color .18s, border-color .18s, box-shadow .18s, opacity .25s, transform .18s;
  will-change: left, top;
}
.gnode:hover { border-color: var(--accent); transform: translate(-50%, -50%) scale(1.05); z-index: 5; }
.gnode.hidden { opacity: 0; pointer-events: none; }
.gnode .gtoggle {
  width: 16px; height: 16px; border-radius: 50%; display: inline-grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-size: 12px; position: relative; flex: none;
}
.gnode .gtoggle::before { content: "+"; font-weight: 700; line-height: 1; }
.gnode.open .gtoggle::before { content: "–"; }

/* root (photo) */
.gnode.root { padding: 0; border: none; background: none; box-shadow: none; }
.gnode.root-photo img {
  width: 128px; height: 128px; border-radius: 50%; object-fit: cover;
  border: 3px solid var(--accent); box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 16%, transparent), var(--shadow);
}
.gnode.root:hover { transform: translate(-50%, -50%) scale(1.03); }

/* branch nodes = filled accent; leaves = subtle */
.gnode.branch { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.gnode.branch .gtoggle { background: color-mix(in srgb, var(--on-accent) 22%, transparent); color: var(--on-accent); }
.gnode.branch:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
.gnode.leaf { background: var(--bg-elev); color: var(--ink); font-weight: 500; }
.gnode.active { box-shadow: 0 0 24px 2px color-mix(in srgb, var(--accent) 42%, transparent), var(--shadow); z-index: 6; }

/* hint + controls */
.graph-hint {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  font-size: 13px; color: var(--ink-faint); background: color-mix(in srgb, var(--bg) 82%, transparent);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 16px; backdrop-filter: blur(8px);
  pointer-events: none; z-index: 8; text-align: center;
}
.graph-controls { position: absolute; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 8; }
.graph-controls button {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--ink); font-size: 18px; cursor: pointer; box-shadow: var(--shadow);
  display: grid; place-items: center; transition: border-color .2s, color .2s;
}
.graph-controls button:hover { border-color: var(--accent); color: var(--accent); }

/* view toggle in nav */
.view-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; margin-left: 8px; }
.view-toggle button {
  border: none; background: none; color: var(--ink-soft); font-size: 13px; font-weight: 600;
  padding: 6px 14px; cursor: pointer; transition: background .2s, color .2s;
}
.view-toggle button.on { background: var(--accent); color: #fff; }

/* detail panel */
#detail-panel {
  position: absolute; top: 0; right: 0; height: 100%; width: min(400px, 92vw);
  background: var(--bg-elev); border-left: 1px solid var(--line); box-shadow: -12px 0 40px rgba(0,0,0,.14);
  padding: 30px 30px 40px; overflow-y: auto; transform: translateX(100%);
  transition: transform .34s cubic-bezier(.4,0,.2,1); z-index: 12;
}
#detail-panel.open { transform: none; }
.d-close {
  position: absolute; top: 18px; right: 18px; width: 34px; height: 34px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink-soft); cursor: pointer; font-size: 14px;
}
.d-close:hover { border-color: var(--accent); color: var(--accent); }
.d-eyebrow { font-size: 12px; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); font-weight: 700; margin: 6px 0 10px; }
.d-title { font-family: var(--serif); font-size: 26px; line-height: 1.15; margin-bottom: 6px; }
.d-sub { color: var(--accent); font-weight: 600; font-size: 15px; margin-bottom: 18px; }
.d-body { color: var(--ink-soft); font-size: 15px; line-height: 1.6; }
.d-lead { color: var(--ink); font-size: 16px; margin-bottom: 12px; }
.d-list { list-style: none; padding: 0; margin: 6px 0 14px; }
.d-list li { position: relative; padding-left: 18px; margin: 8px 0; }
.d-list li::before { content: "›"; position: absolute; left: 2px; color: var(--accent); font-weight: 700; }
.d-meta { color: var(--ink-faint); font-size: 14px; }
.d-chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 14px; }
.d-chips span { font-size: 13px; padding: 5px 11px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.d-link { display: inline-block; margin-top: 6px; color: var(--accent); font-weight: 600; word-break: break-word; }
.d-status { margin-top: 14px; font-size: 12px; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: .06em; }

@media (max-width: 620px) {
  .gnode { font-size: 13px; padding: 8px 13px; }
  .gnode.root-photo img { width: 96px; height: 96px; }
  .graph-hint { font-size: 12px; bottom: 14px; width: max-content; max-width: 92vw; }
}
@media (prefers-reduced-motion: reduce) {
  .gnode, #detail-panel, #graph-stage { transition: none !important; }
}
