/* ============================================================
   SOVRA-FCL-MHCE — CLEAN CSS
   Version: 2.5 | NFIE Compliant
   ============================================================ */

/* ============================================================
   GLOBAL RESET & BASE
   ============================================================ */

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: monospace;
  background-color: #f9f9f9;
  color: #222;
}

.hidden {
  display: none !important;
}

/* ============================================================
   DESIGN TOKENS
   ============================================================ */

:root {
  --card-bg: #ffffff;
  --card-border: #e6e9ee;
  --muted: #6b7280;
  --accent: #0f172a;
  --radius: 10px;
  --gap: 12px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, monospace;
}

/* ============================================================
   BANNER
   ============================================================ */

.banner {
  background-color: #222;
  color: #fff;
  padding: 20px;
  text-align: center;
}

/* ============================================================
   SEARCH BAR
   ============================================================ */

.search-box {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  padding: 12px 20px;
  border-bottom: 1px solid #ccc;
  width: min(96vw, 1400px);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-anchor {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-box input[type="text"] {
  flex: 1;
  min-width: 0;
  padding: 8px;
  font-size: 16px;
}

.search-box button {
  padding: 8px 16px;
  font-size: 16px;
  cursor: pointer;
}

/* ============================================================
   CONTEXT CONTROL PANEL
   ============================================================ */

#contextControlToggle {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 1000;
}

.context-panel {
  position: fixed;
  top: 52px;
  left: 12px;
  z-index: 999;
  padding: 12px 14px;
  border: 1px solid #444;
  background: #111;
  color: #eee;
  font-size: 13px;
  line-height: 1.4;
}

.context-grid {
  display: grid;
  grid-template-columns: auto auto;
  grid-template-rows: repeat(3, auto);
  column-gap: 18px;
  row-gap: 10px;
}

.context-item {
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.context-label {
  font-weight: 500;
}

.context-item input[type="checkbox"] {
  margin-left: auto;
  cursor: pointer;
}

.tooltip-host {
  position: relative;
}

.tooltip {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 4px;
  background: #000;
  color: #ddd;
  border: 1px solid #333;
  padding: 6px 8px;
  font-size: 11px;
  line-height: 1.3;
  max-width: 220px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.tooltip-host:hover .tooltip {
  opacity: 1;
}

#closeContextPanel {
  margin-top: 12px;
  width: 100%;
  padding: 6px 8px;
  background: #222;
  color: #eee;
  border: 1px solid #444;
  cursor: pointer;
  font-size: 12px;
}

/* ============================================================
   DIAGNOSTIC SCORING PANEL (single instance, top-right)
   ============================================================ */

.diagnostic-panel {
  position: relative;
  width: 320px;
  margin: 8px 0 12px auto;
  background: #fafafa;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  color: #111;
}

.diagnostic-panel .diag-label span {
  opacity: 0;
  transition: opacity 0.2s ease;
}

.diagnostic-panel[data-active="true"] .diag-label span {
  opacity: 1;
}

/* ============================================================
   DIAGNOSTIC BAR (layout container for three-column display)
   ============================================================ */

.diagnostic-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: #f9f9f9;
  border: 1px solid #ccc;
  margin: 1em 0;
  padding: 1em;
  font-family: system-ui, sans-serif;
  gap: 1em;
}

.diagnostic-bar > div {
  flex: 1;
}

.diag-left {
  max-width: 25%;
}

.diag-center {
  max-width: 50%;
  text-align: center;
}

.diag-right {
  max-width: 25%;
  text-align: right;
}
.density-band {
  display: flex;
  gap: 24px;
  padding: 8px 12px;
  margin: 6px 0;
  font-size: 0.85rem;
  opacity: 0.85;
}

.density-item {
  display: flex;
  gap: 6px;
}

.density-label {
  color: #aaa;
}

.density-value {
  font-weight: 600;
}
/* ============================================================
   FIELD DENSITY BOX (CENTERED CONTEXT)
   ============================================================ */

.density-wrapper {
  display: flex;
  justify-content: center;
  margin: 10px 0 14px;
}

.density-box {
  width: 320px;
  background: #ffffff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: #111;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  opacity: 0.9;
}

.density-item {
  display: flex;
  gap: 6px;
  white-space: nowrap;
}

.density-label {
  color: var(--muted);
}

.density-value {
  font-weight: 600;
}

/* ============================================================
   RESULTS AREA
   ============================================================ */

#results {
  padding: 20px;
  background: #fff;
  border-top: 1px solid #ddd;
  line-height: 1.6;
}

/* ============================================================
   SOVRA CARD SYSTEM
   ============================================================ */

.sovra-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  padding: 16px;
  margin: 12px 0;
  font-family: var(--font-sans);
  color: var(--accent);
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.card-title {
  font-size: 1rem;
  margin: 0;
  font-weight: 600;
}

.card-meta {
  display: flex;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--muted);
}

.hash-btn {
  background: transparent;
  border: 1px dashed var(--card-border);
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-family: monospace;
  color: var(--muted);
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.source-id {
  font-size: 0.8rem;
  color: var(--muted);
}

.raw-excerpt {
  background: #f8fafc;
  border-radius: 8px;
  padding: 10px;
  white-space: pre-wrap;
  border: 1px solid #f1f5f9;
  font-size: 0.95rem;
}

.card-foot {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  color: var(--muted);
}

.expand-provenance {
  background: transparent;
  border: 1px solid var(--card-border);
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--muted);
}

.provenance-panel {
  background: #f8fafc;
  border-radius: 6px;
  padding: 10px;
  font-size: 0.8rem;
}

.signed-manifest {
  white-space: pre-wrap;
  font-size: 0.75rem;
  color: var(--muted);
}

.card-link {
  display: inline-block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: #2e8bff;
}

.predicate-context {
  background: #f1f5f9;
  border-left: 3px solid #2e8bff;
  padding: 6px 10px;
  font-size: 0.85rem;
  border-radius: 4px;
}

/* ============================================================
   SOVRA VOICE OUTPUT (single instance)
   ============================================================ */

#voice-output {
  margin-top: 20px;
  padding: 12px;
  background-color: #0f0f0f;
  border-left: 4px solid #2e8bff;
  font-family: monospace;
  font-size: 0.9rem;
  color: #e0e0e0;
  white-space: pre-wrap;
  border-radius: 6px;
}

.voice-card {
  padding: 12px;
  background-color: #111;
  border-left: 3px solid #2e8bff;
  margin-bottom: 1rem;
}

.voice-text {
  line-height: 1.5;
  color: #e0e0e0;
  font-family: monospace;
  font-size: 0.9rem;
}

/* ============================================================
   QUAD-CORE CSR — ANALYSIS OUTPUT SURFACE
   ============================================================ */

#sovra-data-state {
  width: 100%;
  height: 4px;
  background-color: #444;
}

#sovra-data-state[data-mode="calibration"] {
  background-color: #666;
}

#sovra-data-state[data-mode="active"] {
  background-color: #2e8bff;
}

#sovra-analysis-output {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.5rem;
  padding: 0.75rem;
  font-family: monospace;
  font-size: 0.85rem;
  color: #e0e0e0;
}

#sovra-analysis-output pre:empty {
  display: none;
}

#analysis-zse,
#analysis-cdlm,
#analysis-delta,
#analysis-field {
  background-color: #111;
  border-left: 3px solid #333;
  padding: 0.5rem;
  white-space: pre-wrap;
}

#sovra-capabilities {
  display: none;
}

#sovra-raw-text {
  margin-top: 1rem;
}

#raw-text-output {
  background-color: #0b0b0b;
  color: #cfcfcf;
  padding: 0.75rem;
  font-family: monospace;
  font-size: 0.8rem;
  white-space: pre-wrap;
}

/* ============================================================
   VDU BLOCK
   ============================================================ */

.vdu-block {
  background: #0f0f0f;
  border-left: 4px solid #ff4444;
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
  font-family: monospace;
  font-size: 0.85rem;
  color: #e0e0e0;
}

/* ============================================================
   ZERO-SUM BLOCK
   ============================================================ */

.zse-block {
  background: #1a1a2e;
  border-left: 4px solid #f59e0b;
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
  font-family: monospace;
  font-size: 0.85rem;
  color: #e0e0e0;
}

.zse-term {
  margin: 8px 0;
}

.zse-term ul {
  margin: 4px 0 0 16px;
  padding: 0;
  font-size: 0.8rem;
  color: #aaa;
}

/* ============================================================
   DRIFT TIMELINE BLOCK
   ============================================================ */

.drift-block {
  background: #0f172a;
  border-left: 4px solid #818cf8;
  border-radius: 6px;
  padding: 12px 16px;
  margin: 12px 0;
  font-family: monospace;
  font-size: 0.85rem;
  color: #e0e0e0;
}

.drift-meta {
  font-size: 0.8rem;
  color: #aaa;
  margin-bottom: 8px;
}

.drift-era {
  margin: 6px 0;
  padding: 6px 0;
  border-bottom: 1px solid #1e293b;
}

.drift-terms {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 2px;
}

.empty {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 8px 0;
}

.section-label {
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}

/* ============================================================
   RESULTS TWO-COLUMN LAYOUT
   Left: drift timeline sidebar | Right: search result cards
   ============================================================ */

.results-container {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  padding: 20px;
  background: #fff;
  border-top: 1px solid #ddd;
}

.results-left {
  flex: 0 0 260px;
  min-width: 0;
}

.results-right {
  flex: 1;
  min-width: 0;
  line-height: 1.6;
}

/* Hide left column when empty */
.results-left:empty {
  display: none;
}

/* ============================================================
   TEMPORAL DRIFT TIMELINE PANEL
   Sits between diagnostic bar and results
   Gated — hidden until Drift Core fires
   ============================================================ */

.drift-timeline-panel {
  background: #0a0a14;
  border: 1px solid #1e1e3a;
  border-top: 2px solid #818cf8;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
  font-family: monospace;
  font-size: 0.8rem;
  color: #9a9ab8;
}

.drift-panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #6a6a8a;
  font-size: 0.7rem;
  letter-spacing: 2px;
  margin-bottom: 0.6rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #1e1e3a;
}

.drift-query-echo {
  color: #c8c8e8;
  font-size: 0.72rem;
  letter-spacing: 0;
  max-width: 60%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

/* Era blocks — horizontal scroll row */
.drift-era-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.drift-era-block {
  background: #12121e;
  border: 1px solid #2a2a4a;
  border-radius: 4px;
  padding: 0.4rem 0.6rem;
  min-width: 110px;
  flex: 1;
}

.drift-era-label {
  color: #c8c8e8;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.15rem;
}

.drift-era-meta {
  color: #6a6a8a;
  font-size: 0.68rem;
  margin-bottom: 0.25rem;
}

.drift-era-terms {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem;
  margin-bottom: 0.2rem;
}

.drift-term {
  display: inline-block;
  background: #1e1e2e;
  color: #8a8aaa;
  padding: 0 0.25rem;
  border-radius: 2px;
  font-size: 0.67rem;
}

.drift-no-terms {
  color: #3a3a5a;
  font-size: 0.67rem;
}

/* Trifold flags per era */
.drift-trifold-flags {
  display: flex;
  gap: 0.2rem;
  margin-top: 0.2rem;
}

.trifold-flag {
  display: inline-block;
  width: 16px;
  height: 16px;
  line-height: 16px;
  text-align: center;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 2px;
}

.trifold-r { background: #3a1a1a; color: #f87171; }
.trifold-c { background: #1a2a3a; color: #60a5fa; }
.trifold-i { background: #1a3a1a; color: #4ade80; }

/* Shift delta row */
.drift-shift-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.7rem;
  color: #6a6a8a;
  padding-top: 0.4rem;
  border-top: 1px solid #1e1e3a;
}

.drift-shift-block {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.drift-shift-span {
  color: #8a8aaa;
}

.drift-shift-delta.pos { color: #4ade80; }
.drift-shift-delta.neg { color: #f87171; }

.drift-shift-flag {
  color: #818cf8;
  font-size: 0.68rem;
}

/* ============================================================
   CENTER PANEL — Quad Core Field Summary
   Sits in diag-center between Sovra Voice and CDLM scores
   ============================================================ */

.center-panel {
  background: #0a0a14;
  border: 1px solid #1e1e3a;
  border-top: 2px solid #4a4a6a;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  font-family: monospace;
  font-size: 0.78rem;
  color: #9a9ab8;
  text-align: left;
  width: 100%;
}

.center-panel-header {
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: #6a6a8a;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #1e1e3a;
  text-align: center;
}

.center-field-row {
  display: flex;
  justify-content: space-around;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #1e1e3a;
}

.center-field-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.center-field-label {
  font-size: 0.62rem;
  color: #6a6a8a;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.center-field-value {
  font-size: 0.85rem;
  font-weight: 700;
  color: #c8c8e8;
}

.center-field-raw {
  font-size: 0.6rem;
  color: #4a4a6a;
}

.center-scores-row {
  display: flex;
  justify-content: space-around;
  gap: 0.5rem;
  margin-bottom: 0.4rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid #1e1e3a;
}

.center-score-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.center-score-num {
  font-size: 1.1rem;
  font-weight: 700;
  color: #c8c8e8;
  line-height: 1;
}

.center-score-label {
  font-size: 0.6rem;
  color: #6a6a8a;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.center-gates-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: center;
}

.gate-active {
  display: inline-block;
  background: #1e1e2e;
  border: 1px solid #3a3a5a;
  color: #8a8aaa;
  padding: 0.1rem 0.35rem;
  border-radius: 3px;
  font-size: 0.6rem;
  letter-spacing: 0.5px;
}

/* ============================================================
   PTF PANEL — Primary Source Scan (F.I.D.A.R.C.H.)
   Gated behind rawData — appears above drift timeline
   ============================================================ */

.ptf-panel {
  background: #0a0a14;
  border: 1px solid #1e1e3a;
  border-top: 2px solid #4a4a6a;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin: 0.5rem 0;
  font-family: monospace;
  font-size: 0.78rem;
  color: #9a9ab8;
}

.ptf-header {
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: #6a6a8a;
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #1e1e3a;
}

.ptf-row {
  display: flex;
  justify-content: space-between;
  padding: 0.15rem 0;
  border-bottom: 1px solid #0f0f1a;
}

.ptf-label {
  color: #6a6a8a;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ptf-value {
  color: #c8c8e8;
  font-weight: 600;
  font-size: 0.78rem;
}

/* ============================================================
   PTF SUMMATION — inside provenance panel on first card only
   Hidden until Provenance button clicked (panel is hidden by default)
   ============================================================ */

.ptf-summation {
  background: #0a0a14;
  border: 1px solid #1e1e3a;
  border-top: 2px solid #4a4a6a;
  border-radius: 6px;
  padding: 0.6rem 0.8rem;
  margin-bottom: 0.75rem;
  font-family: monospace;
  font-size: 0.78rem;
  color: #9a9ab8;
}

.ptf-summ-header {
  font-size: 0.65rem;
  letter-spacing: 2px;
  color: #6a6a8a;
  margin-bottom: 0.45rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid #1e1e3a;
}

.ptf-summ-row {
  display: flex;
  justify-content: space-between;
  padding: 0.12rem 0;
  border-bottom: 1px solid #0f0f1a;
}

.ptf-summ-label {
  color: #6a6a8a;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.ptf-summ-value {
  color: #c8c8e8;
  font-weight: 600;
  font-size: 0.78rem;
}

.ptf-summ-signal {
  margin-top: 0.4rem;
  padding-top: 0.35rem;
  border-top: 1px solid #1e1e3a;
  color: #9a9ab8;
  font-size: 0.72rem;
  line-height: 1.4;
}

/* ============================================================
   GATE INDICATOR ROW
   Sits at bottom of diagnostic bar — registers active gates
   ============================================================ */

.gate-indicator-row {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding-top: 0.5rem;
  margin-top: 0.5rem;
  border-top: 1px solid #d1d5db;
  justify-content: center;
}

.gate-indicator {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  font-family: monospace;
  font-size: 0.65rem;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.gate-on {
  background: #1e1e2e;
  border: 1px solid #4a4a6a;
  color: #c8c8e8;
}

.gate-off {
  background: #f1f5f9;
  border: 1px solid #d1d5db;
  color: #9ca3af;
}

/* Drift shift arrow — quantity direction indicator */
.drift-shift-arrow {
  color: #9a9ab8;
  font-size: 0.85rem;
  margin: 0 0.2rem;
}

/* Flat line — no document count change between periods */
.drift-shift-flat {
  color: #4a4a6a;
  font-size: 0.7rem;
  font-style: italic;
  letter-spacing: 0.5px;
}

/* First card score strip — structural read, first source only */
.card-score-strip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-top: 1px solid #e2e8f0;
  background: #f8f8fc;
  font-family: monospace;
  font-size: 0.7rem;
}

.card-score-item {
  display: flex;
  gap: 0.25rem;
  align-items: baseline;
}

.card-score-label {
  color: #6a6a8a;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.card-score-val {
  color: #1e1e2e;
  font-weight: 600;
}

.card-score-sep {
  color: #c8c8e8;
}
