/* KPNGraph -- styles for the shared political-network graph module
   (frontend/graph.js). Loaded by the public site and by the admin
   "Political Network" page; every class is prefixed kpn- so it never
   collides with a host page's own styles. */

.kpn-graph {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 300px;
  height: 100%;
  min-height: 0;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
}

.kpn-controls,
.kpn-details {
  background: white;
  padding: 18px;
  overflow-y: auto;
  min-height: 0;
}

.kpn-controls { border-right: 1px solid #dde3ea; }
.kpn-details { border-left: 1px solid #dde3ea; }
.kpn-controls section { margin-bottom: 26px; }

.kpn-graph h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 0 0 12px;
  color: #5d6879;
}

.kpn-year-display { text-align: center; margin-bottom: 8px; }
.kpn-year-value { font-size: 34px; font-weight: 700; }
.kpn-year-slider { width: 100%; }
.kpn-range-labels { display: flex; justify-content: space-between; font-size: 11px; color: #778293; }
.kpn-metric { display: flex; justify-content: space-between; margin: 8px 0; font-size: 13px; }
.kpn-controls label { display: block; margin: 8px 0; font-size: 13px; }
.kpn-hint, .kpn-legend-note { font-size: 12px; color: #788395; margin: 6px 0; }

.kpn-controls select {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #dde3ea;
  border-radius: 6px;
  font-size: 13px;
  background: white;
}

.kpn-graph-area { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: #f5f7fa; }
.kpn-svg { display: block; width: 100%; height: 100%; }
.kpn-loading {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 10;
  background: white; padding: 9px 14px; border-radius: 7px; box-shadow: 0 2px 12px rgba(0,0,0,0.12);
}
.kpn-mode-empty {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%); z-index: 9;
  max-width: min(460px, calc(100% - 32px)); background: white; padding: 10px 14px; border-radius: 7px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.12); font-size: 13px; line-height: 1.4; color: #334155;
}
.kpn-hidden { display: none; }

.kpn-link { stroke: #8793a3; stroke-opacity: 0.42; }
.kpn-node { cursor: pointer; stroke: white; stroke-width: 1.5px; }
.kpn-node-ring { fill: none; pointer-events: none; }
.kpn-node-marker { pointer-events: none; font-size: 11px; text-anchor: middle; }
.kpn-node-label { pointer-events: none; font-size: 10px; fill: #263244; paint-order: stroke; stroke: white; stroke-width: 3px; stroke-linejoin: round; }
.kpn-link.kpn-dimmed { stroke-opacity: 0.08; }
.kpn-node.kpn-dimmed { opacity: 0.25; }
.kpn-link.kpn-selected { stroke-opacity: 0.95; }
.kpn-node.kpn-selected { stroke: #172033; stroke-width: 3px; }
.kpn-node.kpn-filtered, .kpn-node-ring.kpn-filtered, .kpn-node-label.kpn-filtered { opacity: 0.12 !important; }
.kpn-link.kpn-filtered { stroke-opacity: 0.06 !important; }

.kpn-legend-categories { margin-top: 10px; }
.kpn-legend-item { display: flex; align-items: center; gap: 8px; font-size: 12px; margin: 5px 0; }
.kpn-legend-swatch { display: inline-block; width: 22px; height: 4px; border-radius: 2px; }

.kpn-playback { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.kpn-playback button { padding: 4px 8px; border-radius: 6px; border: 1px solid #dde3ea; background: white; cursor: pointer; font-size: 13px; }
.kpn-playback button.kpn-active { background: #2f6fed; color: white; border-color: #2f6fed; }
.kpn-playback select { width: auto; padding: 4px 6px; font-size: 12px; }
.kpn-timeline { width: 100%; height: 46px; margin-top: 8px; display: block; }
.kpn-tick { stroke: #c9d1dc; }
.kpn-tick-label { font-size: 9px; fill: #788395; }
.kpn-marker { cursor: pointer; font-size: 12px; }
.kpn-cursor { stroke: #2f6fed; stroke-width: 2px; }

.kpn-detail-name { font-size: 19px; font-weight: 700; margin-bottom: 6px; }
.kpn-detail-key { color: #788395; font-size: 12px; margin-bottom: 18px; }
.kpn-detail-row { margin: 10px 0; font-size: 13px; }
.kpn-detail-row span { display: block; color: #788395; font-size: 11px; margin-bottom: 2px; }
.kpn-event-box { margin-top: 18px; padding: 12px; background: #f1f4f8; border-radius: 8px; font-size: 12px; }
.kpn-detail-section { margin-top: 16px; padding-top: 12px; border-top: 1px solid #eef1f5; }
.kpn-detail-section h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #788395; }
.kpn-metric-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12px; }
.kpn-metric-grid span { display: block; color: #788395; font-size: 10px; }
.kpn-link-list { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.kpn-link-list li { padding: 5px 0; border-bottom: 1px dotted #eef1f5; }
.kpn-text-button { background: none; border: none; padding: 0; color: #2f6fed; cursor: pointer; font: inherit; text-align: left; }
.kpn-text-button:hover { text-decoration: underline; }
.kpn-event-item { padding: 6px 0; border-bottom: 1px dotted #eef1f5; font-size: 12px; }
.kpn-event-date { color: #788395; font-size: 11px; }
.kpn-event-delta { font-weight: 600; }
.kpn-provenance { margin-top: 4px; font-size: 11px; }
.kpn-provenance a { color: #2f6fed; word-break: break-all; }

.kpn-traj-state { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; color: white; background: #8793a3; }
.kpn-traj-state.active { background: #1f9d55; }
.kpn-traj-state.weakening { background: #d97706; }
.kpn-traj-state.marginalized { background: #ea580c; }
.kpn-traj-state.critical { background: #dc2626; }
.kpn-traj-state.locked_out { background: #7f1d1d; }
.kpn-traj-state.recovering { background: #0891b2; }
.kpn-factor-table { width: 100%; border-collapse: collapse; font-size: 11px; }
.kpn-factor-table td { padding: 3px 4px; border-bottom: 1px dotted #eef1f5; }
.kpn-bar { height: 6px; background: #2f6fed; border-radius: 3px; }
.kpn-bar-pressure { background: #dc2626; }
.kpn-na { color: #98a2b3; font-style: italic; }
.kpn-mini-chart { width: 100%; height: 120px; display: block; margin-top: 6px; }
.kpn-axis { stroke: #dde3ea; }
.kpn-axis-label { font-size: 8px; fill: #788395; }
.kpn-series-influence { fill: none; stroke: #2f6fed; stroke-width: 1.5px; }
.kpn-series-viability { fill: none; stroke: #1f9d55; stroke-width: 1.5px; }
.kpn-series-barrier { fill: none; stroke: #dc2626; stroke-width: 1.5px; }
.kpn-threshold { stroke: #dc2626; stroke-dasharray: 3 3; stroke-width: 1px; }
.kpn-mini-chart .kpn-cursor { stroke: #172033; stroke-width: 1px; stroke-dasharray: 2 2; }
.kpn-chart-legend { font-size: 10px; color: #788395; }
.kpn-chart-legend span { display: inline-block; margin-right: 8px; }
.kpn-decline-path li { font-size: 12px; }
.kpn-when { color: #788395; font-size: 11px; }

.kpn-whatif { margin-top: 16px; padding: 12px; background: #fffbeb; border: 1px solid #fde68a; border-radius: 8px; font-size: 12px; }
.kpn-whatif h3 { margin: 0 0 8px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: #92400e; }
.kpn-whatif-controls { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.kpn-whatif-controls input { width: 70px; padding: 4px 6px; border: 1px solid #dde3ea; border-radius: 6px; }
.kpn-whatif-controls button { padding: 5px 10px; border-radius: 6px; border: none; background: #2f6fed; color: white; cursor: pointer; font-size: 12px; }
.kpn-whatif table { width: 100%; border-collapse: collapse; font-size: 11px; }
.kpn-whatif td, .kpn-whatif th { padding: 3px 4px; text-align: left; border-bottom: 1px solid #fde68a; }
.kpn-delta-up { color: #1f9d55; }
.kpn-delta-down { color: #dc2626; }

/* host-page extras rendered into .kpn-extra-controls */
.kpn-extra-controls section { margin-bottom: 26px; }
.kpn-extra-controls input[type="text"], .kpn-extra-controls input[type="date"] { width: 100%; padding: 6px 8px; border: 1px solid #dde3ea; border-radius: 6px; font-size: 13px; }
.kpn-extra-controls button { padding: 5px 10px; border-radius: 6px; border: 1px solid #dde3ea; background: white; cursor: pointer; font-size: 12px; margin: 2px 2px 2px 0; }
.kpn-extra-controls .kpn-error { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; padding: 8px 10px; border-radius: 8px; font-size: 12px; margin-top: 8px; }

/* admin-only decorations (candidate overlay / compare ghosts / preview) */
.kpn-link.kpn-dashed, .kpn-node.kpn-dashed { stroke-dasharray: 4 3; }
.kpn-link.kpn-candidate-overlay { stroke: #7c3aed; stroke-opacity: 0.9; }
.kpn-node.kpn-candidate-overlay { stroke: #7c3aed; stroke-width: 3px; }
.kpn-link.kpn-preview-impact { stroke: #d97706; stroke-opacity: 0.95; }
.kpn-node.kpn-preview-impact { stroke: #d97706; stroke-width: 3px; }
.kpn-node.kpn-removed { opacity: 0.35; }
.kpn-link.kpn-removed { stroke-opacity: 0.15; }
.kpn-badge { pointer-events: none; font-size: 10px; font-weight: 700; }
.kpn-badge-change { fill: #172033; }
.kpn-badge-candidate { fill: #7c3aed; font-style: italic; font-weight: 400; }
.kpn-badge-preview { fill: #d97706; }

@media (max-width: 900px) {
  .kpn-graph { grid-template-columns: 190px minmax(0, 1fr); }
  .kpn-details { display: none; }
}
