/* Signal Engine — Market Forces page
   Self-contained per this codebase's existing convention (see entities.css,
   ask.js, workspace.js) — each page owns its own token set rather than
   sharing a bundle. Values chosen to sit close to entities.css's dark-blue
   palette so the two pages read as the same product. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #08101a;
  --surface:    #0d1520;
  --surface-2:  #111c2b;
  --surface-3:  #162130;
  --border:     #1e2d3d;
  --accent:     #1a6bfa;
  --accent-dim: rgba(26, 107, 250, 0.15);
  --ember:      #ff7a4d;
  --ember-dim:  rgba(255, 122, 77, 0.12);
  --text:       #dce6f0;
  --muted:      #7a90a8;
  --faint:      #4a5f72;
  --radius:     10px;
  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
}

body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 15px;
  min-height: 100vh;
}

/* ── Toolbar / env tabs ── */
.mf-toolbar {
  border-bottom: 1px solid var(--border);
  padding: 0.75rem 1.5rem;
}
.mf-toolbar-inner { max-width: 880px; margin: 0 auto; }

.env-tabs {
  display: inline-flex;
  gap: 0.25rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 3px;
}
.env-tab {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.85rem;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  background: transparent;
  color: var(--muted);
  transition: all 0.15s;
  white-space: nowrap;
}
.env-tab:hover { color: var(--text); }
.env-tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.env-tab.active { background: var(--accent); color: #fff; }

/* ── Intro ── */
#mf-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 5rem;
}

.mf-intro { margin-bottom: 2rem; }
.mf-title {
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}
.mf-subtitle {
  color: var(--muted);
  font-size: 0.95rem;
  max-width: 60ch;
  font-weight: 300;
}

.loading, .mf-empty, .mf-error {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 2rem 0;
}
.mf-error { color: #ef4444; }

/* ── Cards ── */
#mf-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.mf-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
}

.mf-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 1.1rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
}

.mf-card-title-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.mf-card-title {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.mf-domain-badge {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 9px;
}

.mf-card-meta {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  white-space: nowrap;
}
.mf-trend { color: var(--text); }
.mf-signal-count { font-variant-numeric: tabular-nums; }

/* ── Narrative sections ── */
.mf-section { margin-bottom: 1.1rem; }
.mf-section:last-of-type { margin-bottom: 0; }

.mf-section-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--faint);
  margin-bottom: 0.4rem;
}

.mf-field-name {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.25rem;
}

.mf-narrative {
  font-size: 0.9rem;
  color: var(--text);
  opacity: 0.88;
  max-width: 68ch;
}

/* ── Evidence ── */
.mf-evidence-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.mf-evidence-item {
  background: var(--surface-2);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  border-left: 2px solid var(--accent);
}
.mf-evidence-summary {
  font-size: 0.85rem;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.mf-evidence-why {
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
  margin-bottom: 0.3rem;
}
.mf-evidence-footer {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  font-family: var(--mono);
  font-size: 0.68rem;
}
.mf-evidence-source { color: var(--accent); text-decoration: none; }
.mf-evidence-source:hover { text-decoration: underline; }
.mf-evidence-relevance { color: var(--faint); }

/* ── Entities ── */
.mf-entity-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.mf-entity-tag {
  font-size: 0.75rem;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.2rem 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.mf-entity-count {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--faint);
}

/* ── Metrics ── */
.mf-metrics {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1.5rem;
}
.mf-metric {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 160px;
  min-width: 140px;
}
.mf-metric-label {
  font-family: var(--mono);
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--faint);
  width: 62px;
  flex-shrink: 0;
}
.mf-metric-track {
  flex: 1;
  height: 4px;
  background: var(--surface-3);
  border-radius: 2px;
  overflow: hidden;
}
.mf-metric-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.mf-metric-fill--momentum { background: var(--ember); }
.mf-metric-pct {
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.mf-confidence {
  font-family: var(--mono);
  font-size: 0.65rem;
  color: var(--muted);
  white-space: nowrap;
}

@media (max-width: 560px) {
  .mf-card { padding: 1.1rem 1.25rem; }
  .mf-metric { flex: 1 1 100%; }
}
