/* ====================================================================
   EVIDENCE STYLING — single source of truth.

   Every class involved in the evidence chain UI lives here:
     - inline citation links in LLM prose (.ai-source-link)
     - the modal (.evidence-popup-*, .evidence-section, .evidence-item)
     - the uniform item layout (Trigger / Evidence / Source / Original
       source / Source location lines inside .evidence-item)
     - compact pills (.evidence-mini, .inline-evidence)
     - the "Map" / "Map All" map-fly buttons
     - misc legacy renderers (.evidence-cell, .evidence-content-excerpt,
       .evidence-label / .evidence-quote / .evidence-meta etc.)

   Load this file LAST in index.html. No evidence rules live in
   querying_panel.css or geodesy_panel_redesign.css — keep it that way.
   ==================================================================== */

/* ====================================================================
   1. CITATION LINK — single rule for every clickable evidence link.

   `.ai-source-link` is the canonical class for any clickable evidence
   reference. One rule applies everywhere (LLM prose, evidence-item
   Source / Original source lines, modal anchors, etc.) so cursor +
   highlight behaviour is uniform. The legacy parent-scoped form
   (`.ai-msg.answer .ai-source-link`, `.analysis-text .ai-source-link`)
   is intentionally removed — its scoping caused links inside the
   evidence modal to render without a pointer cursor.

   Sources with no wired click target are NOT rendered as links — they
   use a plain `.evidence-source-value` span (no `.ai-source-link`), so
   only genuinely navigable references carry link styling.
   ==================================================================== */

.ai-source-link {
  color: var(--gd-amber, #e07b00);
  cursor: pointer;
  text-decoration: none;
  border-bottom: 1px dotted var(--gd-amber, #e07b00);
  transition:
    border-bottom-style 0.1s ease,
    background-color 0.1s ease;
}
.ai-source-link:hover {
  color: var(--gd-amber, #e07b00);
  border-bottom-style: solid;
  background-color: rgba(224, 123, 0, 0.08);
}

.evidence-unverified {
  color: var(--gd-amber, #e07b00);
  background-color: rgba(224, 123, 0, 0.08);
  border-inline-start: 3px solid currentColor;
  padding: 6px 8px;
  margin: 6px 0;
}

/* Footnote-style citation marker: compact superscript [n], like academic
   end-of-sentence referencing. Brackets are added via CSS so the link text
   stays a bare number. */
.ai-cite-num {
  vertical-align: super;
  font-size: 0.7em;
  border-bottom: none;
  padding: 0 0.5px;
}
.ai-cite-num::before {
  content: "[";
}
.ai-cite-num::after {
  content: "]";
}
/* Inline citation controls match the specificity of the shared button styles. */
button.ai-cite-more {
  appearance: none;
  display: inline;
  padding: 0 0.5px;
  background: transparent;
  border: 0;
  border-radius: 0;
  color: var(--gd-amber, #e07b00);
  font: inherit;
  font-size: 0.7em;
  line-height: 1;
  letter-spacing: normal;
  white-space: nowrap;
}
button.ai-cite-more:is(:hover, :active, :focus) {
  background: transparent;
  box-shadow: none;
}
button.ai-cite-more:is(:hover, [aria-expanded="true"]) {
  text-decoration: underline;
}
button.ai-cite-more:focus-visible {
  outline: 1px solid currentColor;
  outline-offset: 1px;
}
/* Citation with nowhere to go (its tab closed, or its source unknown): muted; a click
   says why. */
.ai-cite-dead {
  color: var(--gd-text-muted, #888);
  border-bottom: none;
}
/* Citation location and navigation. */
.ai-cite-pop {
  position: fixed;
  z-index: 10000;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 8px;
  box-sizing: border-box;
  max-width: min(420px, calc(100vw - 16px));
  max-height: min(240px, 55vh);
  overflow: auto;
  padding: 6px 8px;
  background: var(--gd-surface, #131a24);
  border: 1px solid var(--gd-stroke, #2a3a52);
  border-radius: 0;
  font-size: var(--gd-sz-sm, 0.75rem);
  color: var(--gd-text-hi, #e8edf5);
}
.ai-cite-pop-src {
  overflow-wrap: anywhere;
  line-height: 1.4;
}
.ai-cite-pop-note {
  color: var(--gd-text-muted, #888);
}
.ai-cite-pop-go {
  padding: 3px 8px;
  border: 1px solid var(--gd-stroke, #2a3a52);
  border-radius: 0;
  background: var(--gd-elevated, #1a2333);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* ====================================================================
   2. MODAL (popup) — overlay + window chrome
   ==================================================================== */

.evidence-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.evidence-popup {
  background: var(--gd-base, var(--bg-primary, #fff));
  border: 1px solid var(--gd-stroke, var(--border-light, #e5e7eb));
  border-top: 2px solid var(--gd-amber, #e07b00);
  border-radius: var(--gd-r, var(--radius-md, 6px));
  width: 500px;
  max-height: 80vh;
  overflow: hidden;
  box-shadow: 0 16px 60px rgba(0, 0, 0, 0.8);
}
.evidence-popup--large {
  width: 700px;
  max-width: 90vw;
  display: flex;
  flex-direction: column;
}
.evidence-popup--large .evidence-popup-content {
  max-height: calc(80vh - 120px);
}

.evidence-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 14px;
  border-bottom: 1px solid var(--gd-rim, var(--border-light, #e5e7eb));
  background: var(--gd-surface, var(--bg-secondary, #f8f9fa));
}
.evidence-popup-header-content {
  flex: 1;
  margin-right: 16px;
}
.evidence-popup-title {
  font-family: var(--gd-font-mono);
  font-size: var(--gd-sz-xs, var(--font-size-xs));
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--gd-text-low, var(--text-muted, #9ca3af));
}
.evidence-popup-subtitle {
  font-size: var(--gd-sz-lg, var(--font-size-sm));
  font-weight: 500;
  color: var(--gd-text-hi, var(--text-primary, #1f2937));
  margin-top: 3px;
}
.evidence-popup-meta {
  font-family: var(--gd-font-mono, "SF Mono", "Menlo", "Consolas", monospace);
  font-size: var(--gd-sz-xs, var(--font-size-xs));
  color: var(--gd-text-low, var(--text-muted, #9ca3af));
  margin-top: 3px;
}
.evidence-popup-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--gd-text-low, var(--text-muted, #6b7280));
  line-height: 1;
  transition: color var(--gd-t, 0.12s ease);
}
.evidence-popup-close:hover {
  color: var(--gd-text-hi, var(--text-primary, #1a1d23));
}

.evidence-popup-content {
  padding: 14px;
  overflow-y: auto;
  max-height: calc(80vh - 60px);
}

.evidence-popup-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--gd-rim, var(--border-light, #e5e7eb));
  background: var(--gd-surface, transparent);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.evidence-popup-close-btn {
  background: var(--gd-amber, var(--color-accent-orange, #cc6600));
  color: #000;
  border: none;
  padding: 5px 12px;
  border-radius: var(--gd-r, 4px);
  cursor: pointer;
  font-family: var(--gd-font-mono);
  font-size: var(--gd-sz-sm, var(--font-size-sm));
  font-weight: 600;
  letter-spacing: 0.3px;
  transition: opacity var(--gd-t, 0.12s ease);
}
.evidence-popup-close-btn:hover {
  opacity: 0.85;
}

/* ====================================================================
   3. EVIDENCE SECTION + ITEM (cards inside the modal)
   ==================================================================== */

.evidence-section {
  margin-bottom: 16px;
}
.evidence-section:last-child {
  margin-bottom: 0;
}
.evidence-section-header {
  font-weight: 600;
  font-size: var(--font-size-xs);
  margin-bottom: 8px;
  color: var(--text-muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.evidence-item {
  padding: 8px 10px;
  border-left: 2px solid var(--border-medium, #d1d5db);
  margin-bottom: 4px;
  background: transparent;
  border-radius: 0;
  font-size: var(--font-size-sm);
}
.evidence-item:last-child {
  margin-bottom: 0;
}
.evidence-item.connection {
  border-left-color: #22c55e;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Network-edge evidence: structured "Detailed Relationships"-style lines. */
.evidence-meta {
  font-size: var(--font-size-xs);
  margin: 1px 0;
}
.evidence-edge-sentence {
  margin-top: 4px;
  font-style: italic;
  color: var(--text-secondary, #4b5563);
}

/* Type-specific left border on .evidence-item — also used by .evidence-mini below */
.evidence-item.language {
  border-left-color: #3b82f6;
}
.evidence-item.semantic {
  border-left-color: #8b5cf6;
}
.evidence-item.proximity {
  border-left-color: #ef4444;
}
.evidence-item.attribute {
  border-left-color: #f59e0b;
}
.evidence-item.aggregate-stat,
.evidence-item.batch-result-summary {
  border-left-color: #64748b;
}

.evidence-subsection {
  margin-top: 8px;
  padding-top: 6px;
  border-top: 1px solid var(--border-light, #e5e7eb);
}

/* ====================================================================
   4. UNIFORM ITEM LAYOUT
   Trigger / Evidence / Source / Original source / Source location — each
   on its own block-level line inside .evidence-item. Strong label muted;
   value in primary text colour; all lines share size so indices stay
   visible. (.evidence-source is repurposed here — the legacy badge form
   used outside .evidence-item is defined in §8 below.)
   ==================================================================== */

.evidence-item .evidence-trigger,
.evidence-item .evidence-content,
.evidence-item .evidence-source,
.evidence-item .evidence-original-source,
.evidence-item .evidence-source-location {
  display: block;
  background: transparent;
  margin-left: 0;
  padding: 0;
  font-size: var(--font-size-sm);
  color: var(--text-primary, #1a1d23);
  border-radius: 0;
  line-height: 1.4;
  margin-top: 2px;
}
.evidence-item .evidence-trigger strong,
.evidence-item .evidence-content strong,
.evidence-item .evidence-source strong,
.evidence-item .evidence-original-source strong,
.evidence-item .evidence-source-location strong {
  color: var(--text-muted, #6b7280);
  font-weight: 600;
  margin-right: 4px;
}
/* ====================================================================
   5. LEGACY ITEM SUB-ELEMENTS (older renderers)
   ==================================================================== */

.evidence-id {
  font-weight: 500;
  font-family: var(--gd-font-mono, monospace);
}
.evidence-type {
  color: var(--text-muted, #6b7280);
  font-size: var(--font-size-xs);
}
.evidence-desc {
  color: var(--text-primary, #1a1d23);
}
.evidence-detail {
  font-size: var(--font-size-xs);
  color: var(--text-muted, #6b7280);
  margin-top: 4px;
  font-family: var(--gd-font-mono, monospace);
}
.evidence-meta-header {
  font-size: var(--font-size-xs);
  color: var(--text-muted, #6b7280);
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-light, #e5e7eb);
}
.evidence-label {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--text-secondary, #4b5563);
  margin-bottom: 3px;
}
.evidence-label i {
  margin-right: 5px;
  opacity: 0.5;
  font-size: var(--font-size-xs);
}
.evidence-quote {
  font-size: var(--font-size-sm);
  color: var(--text-primary, #374151);
  background: transparent;
  padding: 4px 0 4px 8px;
  border-left: 2px solid var(--border-light, #e5e7eb);
  border-radius: 0;
  font-style: italic;
  margin-top: 3px;
  line-height: 1.5;
}
.evidence-meta {
  font-family: var(--gd-font-mono, "SF Mono", "Menlo", "Consolas", monospace);
  font-size: var(--font-size-xs);
  color: var(--text-muted, #9ca3af);
  margin-top: 3px;
}

.evidence-show-more {
  display: inline-block;
  padding: 6px 0;
  font-size: var(--font-size-xs);
  color: var(--color-accent-orange, #cc6600);
  cursor: pointer;
  font-weight: 500;
}
.evidence-show-more:hover {
  text-decoration: underline;
}

/* ====================================================================
   6. MAP BUTTONS (inline per-item + "Map All" in modal footer)
   ==================================================================== */

.evidence-map-btn {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  background: var(--bg-tertiary, #e5e7eb);
  color: var(--text-secondary, #374151);
  border: none;
  border-radius: 3px;
  font-size: var(--font-size-xs);
  font-weight: 500;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
}
.evidence-map-btn:hover {
  background: var(--color-accent-orange, #cc6600);
  color: white;
}
.evidence-map-btn i {
  font-size: var(--font-size-2xs);
}
.evidence-map-btn--all {
  margin-left: 0;
  margin-right: auto;
  padding: 4px 10px;
  font-size: var(--font-size-xs);
}

/* ====================================================================
   7. COMPACT PILLS (inline preview rows)
   ==================================================================== */

.inline-evidence {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
}
.evidence-mini {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 6px;
  background: transparent;
  border-left: 2px solid var(--gd-stroke, var(--border-light, #e5e7eb));
  border-radius: 0;
  font-size: var(--gd-sz-sm, var(--font-size-sm));
  color: var(--gd-text-hi, var(--text-primary, #374151));
  line-height: 1.4;
}
.evidence-mini i {
  font-size: var(--font-size-2xs);
  opacity: 0.5;
  flex-shrink: 0;
}
.evidence-mini.language {
  border-left-color: var(--gd-blue, #3b82f6);
}
.evidence-mini.semantic {
  border-left-color: #8b5cf6;
}
.evidence-mini.proximity {
  border-left-color: var(--gd-red, #ef4444);
}
.evidence-mini.attribute {
  border-left-color: var(--gd-amber, #f59e0b);
}
.evidence-mini.more {
  border-left-color: transparent;
  color: var(--text-muted, #9ca3af);
  font-size: var(--font-size-xs);
  padding: 3px 8px;
}

/* ====================================================================
   8. LEGACY .evidence-source BADGE (compact inline contexts ONLY).
   The rule inside .evidence-item in §4 overrides this for modal cards.
   ==================================================================== */

.evidence-source {
  font-size: 0.75rem;
  color: var(--text-tertiary, #9ca3af);
  background: var(--bg-tertiary, #f3f4f6);
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 8px;
  font-weight: 400;
}

/* ====================================================================
   10. MISC (used by tables / cells / report excerpts)
   ==================================================================== */

.evidence-cell {
  display: inline-block;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.evidence-content-excerpt {
  padding: 8px 12px;
  margin-bottom: 8px;
  background: var(--bg-secondary, #f8f9fa);
  border-left: 3px solid var(--color-accent-orange, #cc6600);
  color: var(--text-secondary, #4b5563);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
  border-radius: 2px;
}
