/* static/css/consensus_performance.css
 * Deliverable 10 of Consensus Calibration Tracking (Bill spec 2026-05-06).
 * Top-of-dashboard "Consensus Performance" widget.
 *
 * Mirrors existing main.css token usage (var(--bg-card), var(--accent), etc.)
 * to keep visual consistency with the rest of the dashboard.
 */

#consensus-performance-widget {
  background: var(--bg-card, #111113);
  border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
  border-top: 3px solid var(--accent, #10b981);
  border-radius: var(--radius-lg, 10px);
  padding: 20px 24px;
  margin: 0 0 20px 0;
  display: block;
  font-family: 'IBM Plex Sans', sans-serif;
}

#consensus-performance-widget .cpw-header {
  margin-bottom: 14px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

#consensus-performance-widget .cpw-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary, #f4f4f5);
  letter-spacing: -0.01em;
}

#consensus-performance-widget .cpw-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted, #b4b4bc);
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* ---------- Headline block ---------- */

#consensus-performance-widget .cpw-headline-block {
  margin-bottom: 16px;
}

#consensus-performance-widget .cpw-headline {
  font-size: 1.45rem;
  font-weight: 600;
  color: var(--text-primary, #f4f4f5);
  line-height: 1.3;
  margin-bottom: 4px;
}

#consensus-performance-widget .cpw-headline.cpw-empty-headline {
  color: var(--text-muted, #b4b4bc);
  font-size: 1.05rem;
  font-weight: 500;
  font-style: italic;
}

#consensus-performance-widget .cpw-wilson {
  font-size: 0.94rem;
  color: var(--text-secondary, #d4d4d8);
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
  margin-bottom: 8px;
}

/* Disclosure line — slightly muted but ALWAYS visible.
 * Per Bill spec 2026-05-06: "non-removable and renders even when n_live is small". */
#consensus-performance-widget .cpw-disclosure {
  font-size: 0.9rem;
  color: var(--text-muted, #b4b4bc);
  font-style: italic;
  border-left: 2px solid var(--border-default, rgba(255, 255, 255, 0.1));
  padding-left: 10px;
  line-height: 1.45;
}

/* ---------- Cohort toggle (prominent, not buried) ---------- */

#consensus-performance-widget .cpw-cohort-toggle {
  display: inline-flex;
  gap: 0;
  background: var(--bg-detail, #18181b);
  border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-md, 8px);
  padding: 3px;
  margin-bottom: 16px;
}

#consensus-performance-widget .cpw-cohort-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary, #d4d4d8);
  padding: 7px 16px;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: 'IBM Plex Sans', sans-serif;
}

#consensus-performance-widget .cpw-cohort-btn:hover {
  color: var(--text-primary, #f4f4f5);
  background: rgba(255, 255, 255, 0.03);
}

#consensus-performance-widget .cpw-cohort-btn.active {
  background: var(--accent, #10b981);
  color: #0a0a0a;
}

#consensus-performance-widget .cpw-cohort-btn:focus-visible {
  outline: 2px solid var(--accent, #10b981);
  outline-offset: 2px;
}

/* ---------- Filters ---------- */

#consensus-performance-widget .cpw-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

#consensus-performance-widget .cpw-filter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 130px;
}

#consensus-performance-widget .cpw-filter-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
  color: var(--text-muted, #b4b4bc);
  font-family: var(--font-mono, 'IBM Plex Mono', monospace);
}

#consensus-performance-widget .cpw-filter select {
  background: var(--bg-detail, #18181b);
  border: 1px solid var(--border-default, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-sm, 6px);
  color: var(--text-primary, #f4f4f5);
  padding: 6px 10px;
  font-size: 0.94rem;
  font-family: 'IBM Plex Sans', sans-serif;
  cursor: pointer;
}

#consensus-performance-widget .cpw-filter select:focus {
  border-color: var(--accent, #10b981);
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-muted, rgba(16, 185, 129, 0.15));
}

/* ---------- Chart + empty state ---------- */

#consensus-performance-widget .cpw-chart-wrap {
  position: relative;
  height: 280px;
  margin-bottom: 10px;
  background: var(--bg-detail, #18181b);
  border-radius: var(--radius-md, 8px);
  padding: 10px;
}

#consensus-performance-widget .cpw-empty {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #b4b4bc);
  font-size: 1rem;
  font-style: italic;
  text-align: center;
}

#consensus-performance-widget .cpw-footnote {
  font-size: 0.85rem;
  color: var(--text-muted, #b4b4bc);
  line-height: 1.45;
  margin-top: 6px;
}

/* FIX 2026-08-11: the three filter selects above declare `font-size: 0.94rem`
   = 15.04px. iOS Safari zooms the viewport whenever a focused form control is
   under 16px and does NOT zoom back out on blur, so tapping Sport / Market
   type / Window left the user on a panned page. Missing the threshold by
   0.96px is why it survived review — DevTools shows nothing.

   This rule lives HERE, not in main.css, for two reasons:
     * the base selector is (1,1,1) — an ID — so a `.cpw-filter select` rule
       would lose on specificity;
     * consensus_performance.css loads AFTER main.css (index.html), so an
       equal-specificity rule over there would lose on source order.
   Guarded by tests/test_mobile_form_zoom.py. */
@media (max-width: 639px) {
  #consensus-performance-widget .cpw-filter select {
    font-size: 16px;
    /* WCAG 2.5.5: still 130x36 after the font bump. Same specificity and
       same-sheet reasoning as above. */
    min-height: 44px;
  }
}
