/* IGNITION / FURNACE shared mobile-first stylesheet.
   Leased to Claude under codex/0018-CLAUDE-PAGES.md. Same visual language
   as the existing OI Flow pages (see ui/css/root.css's palette), but this
   file is fully self-contained -- it does not depend on root.css loading
   first, so this page never silently breaks if a shared file changes.
   Mobile-first: base rules target 360px; min-width media queries add
   360->768->1440 layout. No fixed-width tables, no page-wide horizontal
   scroll -- wide content (book/timeline tables) scrolls inside its own
   bounded container only. */

:root {
  --bg-base: #050608;
  --bg-surface: #0a0c0f;
  --bg-elevated: #10141a;
  --border: #1c2230;
  --border-bright: #2a3448;
  --text-primary: #e8edf5;
  --text-secondary: #9aa8bd;
  --text-dim: #5b6b81;
  --sovereign: #c4a35a;
  --signal-live: #00ff88;
  --signal-warn: #ffb800;
  --signal-alert: #ff3b3b;
  --signal-neutral: #4a6080;
  --font-display: "JetBrains Mono", "IBM Plex Mono", ui-monospace, monospace;
  --font-body: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  --touch-min: 44px;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-body);
}

body {
  padding-bottom: 64px; /* room for bottom nav on small screens */
}

.mono {
  font-family: var(--font-display);
  font-variant-numeric: tabular-nums;
}

/* ------------------------------------------------------------- a11y */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

a:focus-visible,
button:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--sovereign);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------------------------------------------------------- header group */

/* Header + source banner scroll together as one sticky unit -- avoids two
   independently-sticky siblings both pinning to top:0 and overlapping. */
.mf-header-group {
  position: sticky;
  top: 0;
  z-index: 10;
}

/* --------------------------------------------------------- source banner */

/* Always visible and never dismissible. The state is derived from the latest
   durable source timestamp, not merely from API reachability. */
.mf-source-banner {
  padding: 8px 12px;
  background: var(--signal-alert);
  color: var(--bg-base);
  font-size: 12px;
  text-align: center;
  letter-spacing: 0.02em;
}

.mf-source-banner[data-source-state="LIVE"] {
  background: var(--signal-live);
}

.mf-source-banner[data-source-state="OBSERVING"],
.mf-source-banner[data-source-state="OFFLINE"],
.mf-source-banner[data-source-state="DELAYED"] {
  background: var(--signal-warn);
}

.mf-source-banner[data-source-state="STALE"],
.mf-source-banner[data-source-state="UNAVAILABLE"] {
  background: var(--signal-alert);
}

.mf-source-banner strong {
  font-weight: 700;
}

.mf-setup-summary, .mf-quality { font-size: 11px; margin-top: 5px; overflow-wrap: anywhere; }
.mf-quality { color: var(--sovereign); }
.mf-capability-details { margin: 10px 12px; font-size: 12px; color: var(--text-secondary); overflow-wrap: anywhere; }
.mf-capability-details summary { min-height: 32px; cursor: pointer; }
.mf-capability-details p { margin: 4px 0 8px; }
#mf-pending-banner { margin: 10px 12px; max-width: calc(100% - 24px); }

/* --------------------------------------------------------------- header */

.mf-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.mf-header h1 {
  font-size: 16px;
  margin: 0;
  color: var(--sovereign);
  letter-spacing: 0.04em;
}

.mf-market-switch {
  display: inline-flex;
  gap: 6px;
}

.mf-market-switch a {
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 10px;
  min-height: var(--touch-min);
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 12px;
}

.mf-market-switch a[aria-current="page"] {
  color: var(--bg-base);
  background: var(--sovereign);
  border-color: var(--sovereign);
}

.mf-badge {
  font-size: 10px;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-bright);
  color: var(--text-secondary);
  white-space: nowrap;
}

.mf-badge.mf-screening {
  color: var(--signal-warn);
  border-color: var(--signal-warn);
}

.mf-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  width: 100%;
  font-size: 11px;
  color: var(--text-secondary);
}

.mf-status-row [data-mf-health="LIVE"] { color: var(--signal-live); }
.mf-status-row [data-mf-health="STALE"],
.mf-status-row [data-mf-health="PARTIAL"] { color: var(--signal-warn); }
.mf-status-row [data-mf-health="DISCONNECTED"],
.mf-status-row [data-mf-health="DATA_INSUFFICIENT"] { color: var(--signal-alert); }

.mf-login-link {
  color: var(--text-secondary);
  font-size: 11px;
  margin-left: auto;
}

/* ------------------------------------------------------------------ tabs */

.mf-tabs {
  display: flex;
  gap: 4px;
  padding: 8px 12px 0;
  border-bottom: 1px solid var(--border);
}

.mf-tab {
  min-height: var(--touch-min);
  padding: 8px 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
}

.mf-tab[aria-selected="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--sovereign);
}

.mf-panel[hidden] {
  display: none !important;
}

/* ----------------------------------------------------------------- cards */

.mf-list {
  list-style: none;
  margin: 0;
  padding: 10px 12px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mf-empty {
  padding: 32px 16px;
  text-align: center;
  color: var(--text-secondary);
}

.mf-empty strong {
  display: block;
  font-size: 15px;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.mf-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.mf-card-head {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: none;
  border: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
  min-height: var(--touch-min);
}

.mf-rank {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--sovereign);
  width: 1.6em;
  flex: none;
}

.mf-card-title {
  flex: 1;
  min-width: 0;
}

.mf-symbol {
  font-size: 14px;
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
}

.mf-contract {
  font-size: 11px;
  color: var(--text-secondary);
  white-space: normal;
  overflow-wrap: anywhere;
}

.mf-direction {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border-bright);
  flex: none;
}

.mf-direction[data-direction="UP"] { color: var(--signal-live); border-color: var(--signal-live); }
.mf-direction[data-direction="DOWN"] { color: var(--signal-alert); border-color: var(--signal-alert); }

.mf-card-body {
  padding: 0 12px 12px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.mf-measure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

@media (min-width: 480px) {
  .mf-measure-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.mf-measure {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 8px;
}

.mf-measure-label {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mf-measure-value {
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--text-primary);
}

.mf-measure-value[data-status="UNAVAILABLE"],
.mf-measure-value[data-status="NOT_APPLICABLE"] {
  color: var(--text-dim);
  font-family: var(--font-body);
  font-size: 11px;
}

.mf-reason {
  margin: 8px 0;
  padding: 8px;
  background: var(--bg-surface);
  border-radius: 6px;
  border-left: 3px solid var(--sovereign);
}

.mf-timeline {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  border-left: 2px solid var(--border-bright);
}

.mf-timeline li {
  position: relative;
  padding: 6px 0 6px 14px;
}

.mf-timeline time {
  display: block;
  font-size: 10px;
  color: var(--text-dim);
}

.mf-export-btn,
.mf-load-more {
  min-height: var(--touch-min);
  padding: 8px 14px;
  border-radius: 6px;
  border: 1px solid var(--border-bright);
  background: var(--bg-elevated);
  color: var(--text-primary);
  font-size: 12px;
  cursor: pointer;
}

/* ----------------------------------------------------------------- diagnostics */

.mf-diag-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px 0;
}

.mf-diag-controls label {
  font-size: 11px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.mf-diag-controls input,
.mf-diag-controls select {
  min-height: var(--touch-min);
  background: var(--bg-elevated);
  border: 1px solid var(--border-bright);
  color: var(--text-primary);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.mf-table-scroll {
  overflow-x: auto;
  margin: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.mf-table-scroll table {
  border-collapse: collapse;
  width: 100%;
  min-width: 480px;
  font-size: 12px;
}

.mf-table-scroll th,
.mf-table-scroll td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

.mf-table-scroll th {
  color: var(--text-secondary);
  font-weight: 600;
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
}

/* -------------------------------------------------------------- live region */

.mf-live-region {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.mf-paused-banner {
  padding: 8px 12px;
  background: var(--signal-warn);
  color: var(--bg-base);
  font-size: 12px;
  text-align: center;
}

.mf-paused-banner[hidden] {
  display: none !important;
}

/* -------------------------------------------------------------- desktop */

@media (min-width: 768px) {
  .mf-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 1440px) {
  .mf-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .mf-header,
  .mf-tabs {
    padding-left: 24px;
    padding-right: 24px;
  }
}

/* -------------------------------------------------------------- 200% zoom */

@media (min-resolution: 1dppx) {
  html {
    text-size-adjust: 100%;
  }
}
