/* =============================================================
   citation-graph.css - styling for the interactive D3 graph
   mounted into <div id="citation-graph"> on the landing page.

   Matches the wider showcase palette: subtle borders, muted
   greys, coloured accents only on the data nodes themselves.
   ============================================================= */

.cg-mount {
  position: relative;
  width: 100%;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  /* Full-width parent gives us room for a taller graph. show-mock parent
     doesn't impose a height, so set one here. */
  min-height: 540px;
  display: flex;
  flex-direction: column;
  /* Black & white at rest; reveal the full colour palette on hover. A CSS
     filter is palette-agnostic, so it works regardless of the D3-assigned
     node/legend colours inside. */
  filter: grayscale(1);
  transition: filter 0.35s ease;
}
.cg-mount:hover {
  filter: grayscale(0);
}

/* --- Toolbar (legend + actions) ---------------------------------- */
.cg-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  flex-wrap: wrap;
}
.cg-legend {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.cg-legend-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font: 500 11px Inter, sans-serif;
  color: var(--ink-2);
  cursor: pointer;
  transition: opacity 0.12s, border-color 0.12s;
}
.cg-legend-pill:hover { border-color: var(--ink); color: var(--ink); }
.cg-legend-pill.off   { opacity: 0.35; }
.cg-legend-pill .cg-dot {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
}
.cg-legend-pill .cg-count {
  color: var(--muted);
  font-weight: 400;
}
.cg-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}
.cg-btn {
  padding: 5px 10px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: 500 11px Inter, sans-serif;
  color: var(--ink-2);
  cursor: pointer;
  transition: border-color 0.12s, color 0.12s, background 0.12s;
}
.cg-btn:hover { border-color: var(--ink); color: var(--ink); background: var(--card); }

/* --- SVG canvas -------------------------------------------------- */
.cg-svg-wrap {
  position: relative;
  flex: 1;
  min-height: 480px;
  background: #fff;
  /* faint dot grid backdrop, like the in-app graph viewport */
  background-image: radial-gradient(circle, #f1f1f1 1px, transparent 1px);
  background-size: 24px 24px;
}
.cg-svg {
  display: block;
  width: 100%;
  height: 100%;
}

/* --- Node labels ------------------------------------------------- */
.cg-label {
  font: 500 10.5px Inter, sans-serif;
  fill: #374151;
  pointer-events: none;
  user-select: none;
}
.cg-label-center {
  font: 700 12px Inter, sans-serif;
  fill: #fff;
  pointer-events: none;
  user-select: none;
}

/* --- Hover tooltip ---------------------------------------------- */
.cg-tip {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  background: #111;
  color: #fff;
  font: 500 12px Inter, sans-serif;
  padding: 8px 10px;
  border-radius: 6px;
  max-width: 240px;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  line-height: 1.35;
}
.cg-tip strong { font-weight: 600; }
.cg-tip-meta { color: #d4d4d8; font-size: 10.5px; }

/* --- Click-pinned detail "bottom sheet" -------------------------- */
/* Mirrors the Tauri app's SmartSidebar bottom sheet - slides up from
   the bottom of the graph viewport when a node is pinned. */
.cg-detail {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  background: #fff;
  border-top: 1px solid var(--line);
  padding: 14px 18px;
  font: 400 12.5px Inter, sans-serif;
  color: var(--ink-2);
  box-shadow: 0 -10px 30px rgba(0,0,0,0.06);
  transform: translateY(100%);
  pointer-events: none;
  transition: transform 0.22s ease;
  z-index: 3;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 18px;
}
.cg-detail.open {
  transform: translateY(0);
  pointer-events: auto;
}
.cg-detail-type {
  font: 700 9.5px Inter, sans-serif;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.04);
}
.cg-detail-body { min-width: 0; }
.cg-detail-title {
  font: 700 14px Inter, sans-serif;
  color: var(--ink);
  margin-bottom: 2px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cg-detail-meta {
  color: var(--muted);
  font-size: 11.5px;
  margin-bottom: 6px;
}
.cg-detail-abs {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.5;
  max-height: 56px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
/* Two-button action group on the right of the detail sheet. */
.cg-detail-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cg-detail-add,
.cg-detail-open {
  padding: 8px 14px;
  border-radius: 8px;
  font: 600 12px Inter, sans-serif;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.cg-detail-add {
  background: #1B8036;
  color: #fff;
  border: 1px solid #1B8036;
}
.cg-detail-add:hover { background: #134F22; border-color: #134F22; }
.cg-detail-add.is-added {
  background: #fff;
  color: #1B8036;
  border: 1px solid #A6CBA9;
  cursor: default;
}
.cg-detail-add.is-added:hover { background: #fff; }

/* "Open PDF" - secondary, outlined. Flashing state on click swaps
   to a green-tinted confirmation that says where the real open
   happens (the Sciwand desktop app). */
.cg-detail-open {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
}
.cg-detail-open:hover {
  background: var(--card);
  border-color: var(--ink-2);
}
.cg-detail-open.is-flashing {
  background: #EEF6F0;
  border-color: #A6CBA9;
  color: #134F22;
  cursor: default;
}

/* --- Entrance "live" pulse --------------------------------------
   Class added on first viewport entry; runs a brief node pop +
   subtle ring under the focal paper so the user sees the graph is
   alive and interactive, then is removed so drag/hover take over. */
.cg-mount.cg-awakening .cg-node circle {
  transform-box: fill-box;
  transform-origin: center;
  animation: cg-node-wake 0.9s cubic-bezier(.34,1.56,.64,1) both;
}
.cg-mount.cg-awakening .cg-node-center circle {
  animation: cg-node-wake 0.9s cubic-bezier(.34,1.56,.64,1) both,
             cg-center-pulse 1.1s ease-out both;
}
.cg-mount.cg-awakening .cg-links line {
  animation: cg-link-wake 0.9s ease-out both;
}
@keyframes cg-node-wake {
  0%   { transform: scale(0.0); opacity: 0; }
  60%  { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
@keyframes cg-center-pulse {
  0%   { filter: drop-shadow(0 0 0 rgba(27,128,54,0.0)); }
  35%  { filter: drop-shadow(0 0 18px rgba(27,128,54,0.55)); }
  100% { filter: drop-shadow(0 0 0 rgba(27,128,54,0.0)); }
}
@keyframes cg-link-wake {
  0%   { stroke-dasharray: 4 200; stroke-dashoffset: 200; opacity: 0; }
  100% { stroke-dasharray: none; stroke-dashoffset: 0; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .cg-mount.cg-awakening .cg-node circle,
  .cg-mount.cg-awakening .cg-node-center circle,
  .cg-mount.cg-awakening .cg-links line { animation: none !important; }
}

/* Dummy-data note in the toolbar */
.cg-dummy-note {
  margin-left: auto;
  font: italic 500 10.5px Inter, sans-serif;
  color: var(--muted);
  padding: 4px 10px;
  background: #fff;
  border: 1px dashed var(--line);
  border-radius: 999px;
}

@media (max-width: 760px) {
  .cg-mount { min-height: 380px; }
  .cg-svg-wrap { min-height: 320px; }
  .cg-detail {
    /* on mobile, move detail under the toolbar so it doesn't cover nodes */
    position: static;
    width: auto;
    margin: 10px 14px 12px;
    box-shadow: none;
  }
}
