/* Moji platform mockups: shared foundation.
   Encodes research/research-style-bible.md: near-monochrome dark-first,
   hairline borders, one accent, no decorative shadows, tabular numerals.
   The four Moji shape colours appear only as status/series colours and in
   the weave mark, never as brand washes. */

/* Light is the primary theme; [data-theme="dark"] overrides. */
:root {
  --bg-canvas: #f7f7f8;
  --bg-surface: #ffffff;
  --bg-raised: #f1f2f4;
  --bg-inset: #eceef0;

  --border-subtle: rgba(15, 17, 20, 0.07);
  --border-default: rgba(15, 17, 20, 0.12);
  --border-strong: rgba(15, 17, 20, 0.20);

  --text-primary: #14161a;
  --text-secondary: #5a616b;
  --text-muted: #868e98;
  --text-disabled: #b3b9c0;

  --accent: #2f5fe0;
  --accent-hover: #2450c4;
  --accent-quiet: rgba(47, 95, 224, 0.10);

  /* status set (colour lives in dots, thin rules, badges, chart series) */
  --ok: #1a7f37;
  --warn: #9a6700;
  --err: #d1242f;
  --queued: #6e7781;
  --paused: #8250df;

  /* chart series (validated vs #ffffff, dataviz six-checks) */
  --s1: #2f5fe0;
  --s2: #0a8a73;
  --s3: #96690f;
  --s4: #a83d63;

  /* canvas extras */
  --dot-grid: rgba(15, 17, 20, 0.10);
  --frame-fill: rgba(15, 17, 20, 0.015);
  --minimap-bg: rgba(255, 255, 255, 0.92);
  --btn-primary-ink: #ffffff;

  /* moji shape colours, reserved for the weave + item glyphs */
  --moji-gold: #CA8A04;
  --moji-blue: #2563EB;
  --moji-green: #059669;
  --moji-orange: #EA580C;

  --sans: 'Inter', 'Geist', -apple-system, 'Segoe UI', sans-serif;
  --mono: 'JetBrains Mono', 'Geist Mono', ui-monospace, 'SF Mono', monospace;

  --r-chip: 4px;
  --r-ctl: 6px;
  --r-panel: 8px;

  --shadow-pop: 0 8px 24px -8px rgba(15, 17, 20, 0.18);
  --shadow-modal: 0 16px 48px -12px rgba(15, 17, 20, 0.22);

  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

:root[data-theme="dark"] {
  --bg-canvas: #08090b;
  --bg-surface: #0e1013;
  --bg-raised: #16181c;
  --bg-inset: #050608;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #e8eaed;
  --text-secondary: #9aa0a8;
  --text-muted: #6b7280;
  --text-disabled: #4b5157;

  --accent: #4a7dff;
  --accent-hover: #5f8dff;
  --accent-quiet: rgba(74, 125, 255, 0.12);

  --ok: #3fb950;
  --warn: #d29922;
  --err: #f0574a;
  --queued: #8b949e;
  --paused: #a371f7;

  /* chart series (validated vs #0e1013, dataviz six-checks) */
  --s1: #4a7dff;
  --s2: #21a496;
  --s3: #bd831d;
  --s4: #c2557a;

  --dot-grid: rgba(255, 255, 255, 0.055);
  --frame-fill: rgba(255, 255, 255, 0.015);
  --minimap-bg: rgba(8, 9, 11, 0.9);
  --btn-primary-ink: #ffffff;

  --shadow-pop: 0 8px 24px -8px rgba(0, 0, 0, 0.6);
  --shadow-modal: 0 16px 48px -12px rgba(0, 0, 0, 0.7);
}

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

html, body {
  height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--sans);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-quiet); }

/* ---------- type roles ---------- */
.t-page   { font-size: 20px; font-weight: 600; letter-spacing: -0.014em; line-height: 1.25; }
.t-sect   { font-size: 15px; font-weight: 600; letter-spacing: -0.011em; line-height: 1.35; }
.t-body   { font-size: 13px; font-weight: 400; }
.t-dense  { font-size: 12px; }
.t-micro  {
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted); line-height: 1.3;
}
.t-mono   { font-family: var(--mono); font-size: 12px; font-variant-numeric: tabular-nums; letter-spacing: 0; }
.t-num    { font-variant-numeric: tabular-nums; }

/* ---------- surfaces ---------- */
.panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-panel);
}
.raised { background: var(--bg-raised); }
.inset  { background: var(--bg-inset); border: 1px solid var(--border-subtle); border-radius: var(--r-ctl); }

/* ---------- app chrome ---------- */
.app {
  display: grid;
  height: 100vh;
  overflow: hidden;
  grid-template-rows: 48px 1fr 28px;
}
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-default);
}
.statusbar {
  display: flex; align-items: center; gap: 20px;
  padding: 0 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  font-family: var(--mono); font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}

.brand { display: flex; align-items: center; gap: 9px; }
.brand svg { display: block; }
.brand .wordmark {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 900;
  font-variation-settings: 'opsz' 144;
  font-size: 15px;
  letter-spacing: 0.01em;
  color: var(--text-primary);
}

.crumb { display: flex; align-items: center; gap: 8px; color: var(--text-secondary); font-size: 13px; }
.crumb .sep { color: var(--text-disabled); }
.crumb .here { color: var(--text-primary); }

/* ---------- nav / rails ---------- */
.navlink {
  display: flex; align-items: center; gap: 10px;
  height: 32px; padding: 0 10px;
  border-radius: var(--r-ctl);
  color: var(--text-secondary);
  cursor: pointer; text-decoration: none;
}
.navlink:hover { background: var(--bg-raised); color: var(--text-primary); }
.navlink.active { background: var(--accent-quiet); color: var(--text-primary); }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 12px;
  border-radius: var(--r-ctl);
  border: 1px solid var(--border-default);
  background: var(--bg-raised);
  color: var(--text-primary);
  font: 500 12.5px var(--sans);
  white-space: nowrap;
  flex: none;
  cursor: pointer;
  transition: border-color 140ms var(--ease), background 140ms var(--ease);
}
.btn:hover { border-color: var(--border-strong); }
.btn.primary { background: var(--accent); border-color: transparent; color: var(--btn-primary-ink); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.quiet { background: transparent; border-color: transparent; color: var(--text-secondary); }
.btn.quiet:hover { background: var(--bg-raised); color: var(--text-primary); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--bg-canvas), 0 0 0 4px var(--accent); }

.seg {
  display: inline-flex; align-items: center;
  border: 1px solid var(--border-default);
  border-radius: var(--r-ctl);
  overflow: hidden;
  background: var(--bg-surface);
  flex: none;
}
.seg button {
  height: 28px; padding: 0 12px;
  border: 0; background: transparent;
  color: var(--text-secondary);
  font: 500 12px var(--sans);
  white-space: nowrap;
  cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--border-subtle); }
.seg button.on { background: var(--bg-raised); color: var(--text-primary); }

/* ---------- status ---------- */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.dot.ok { background: var(--ok); }
.dot.run { background: var(--accent); }
.dot.warn { background: var(--warn); }
.dot.err { background: var(--err); }
.dot.q { background: var(--queued); }
.dot.paused { background: var(--paused); }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  height: 20px; padding: 0 8px;
  border: 1px solid var(--border-default);
  border-radius: 999px;
  font-size: 11px; font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 18px; padding: 0 6px;
  border-radius: var(--r-chip);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
  font-family: var(--mono); font-size: 10.5px;
  font-variant-numeric: tabular-nums;
  color: var(--text-secondary);
  white-space: nowrap;
}

/* ---------- tables ---------- */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th {
  text-align: left;
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-default);
  position: sticky; top: 0; background: var(--bg-surface); z-index: 2;
}
table.grid td {
  padding: 0 12px;
  height: 32px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  white-space: nowrap;
}
table.grid td.num, table.grid th.num { text-align: right; font-variant-numeric: tabular-nums; }
table.grid td.mono { font-family: var(--mono); font-size: 11.5px; color: var(--text-secondary); }
table.grid tbody tr:hover td { background: var(--bg-raised); }
table.grid tr.sel td { background: var(--accent-quiet); }

/* ---------- meters ---------- */
.meter {
  height: 4px; border-radius: 2px;
  background: var(--bg-raised);
  overflow: hidden; position: relative;
}
.meter > i {
  display: block; height: 100%;
  background: var(--accent);
  border-radius: 2px;
}
.meter > i.ok { background: var(--ok); }
.meter > i.warn { background: var(--warn); }
.meter > i.err { background: var(--err); }
.meter .cap {
  position: absolute; top: -2px; bottom: -2px; width: 1.5px;
  background: var(--text-secondary);
}

/* ---------- stat tiles ---------- */
.stat { padding: 14px 16px; }
.stat .v { font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; letter-spacing: -0.014em; }
.stat .l { margin-top: 2px; }
.stat .d { font-size: 11px; font-variant-numeric: tabular-nums; margin-top: 4px; }
.stat .d.up { color: var(--ok); }
.stat .d.down { color: var(--err); }

/* ---------- the Inspector: the shell's right panel (VS Code position) ---------- */
.inspector {
  background: var(--bg-surface);
  border-left: 1px solid var(--border-default);
  overflow-y: auto;
  display: flex; flex-direction: column; min-height: 0;
}
.insphead {
  display: flex; align-items: center; gap: 8px;
  min-height: 34px; padding: 0 14px;
  border-bottom: 1px solid var(--border-default);
  flex: none; position: sticky; top: 0; background: var(--bg-surface); z-index: 3;
}
.insphead .lbl {
  font-size: 11px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-muted);
}
.insphead .obj { margin-left: auto; font: 500 11px var(--mono); color: var(--text-secondary); }
.inspector .isect { padding: 12px 14px; border-bottom: 1px solid var(--border-subtle); display: flex; flex-direction: column; gap: 9px; }
.inspector .isect:last-child { border-bottom: 0; }
.inspector .irow { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.inspector .irow .k { font-size: 12px; color: var(--text-secondary); }
.inspector .irow .v { font: 12px var(--mono); font-variant-numeric: tabular-nums; }
.inspector .irow .v.sans { font-family: var(--sans); font-size: 12px; color: var(--text-secondary); }
.inspector .linemeter { margin: 2px 0; }

/* ---------- scrollbars ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--border-default); border-radius: 5px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-corner { background: transparent; }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- the walk narrator: demo apparatus, NOT product chrome ----------
   Amber + dashed so it reads as overlay narration; activated only by ?tour=
   links from the flow board; never ships in the real product. */
.tourdot {
  position: fixed; z-index: 999; width: 13px; height: 13px; border-radius: 50%;
  background: var(--warn); pointer-events: none;
  animation: tourpulse 1.5s ease-out infinite;
}
@keyframes tourpulse {
  0% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 45%, transparent); }
  70% { box-shadow: 0 0 0 13px transparent; }
  100% { box-shadow: 0 0 0 3px transparent; }
}
.tourtip {
  position: fixed; z-index: 999; width: 292px;
  background: var(--bg-surface);
  border: 1.5px dashed var(--warn); border-radius: var(--r-panel);
  box-shadow: var(--shadow-modal); padding: 11px 13px;
}
.tourtip .tt-lane { font: 600 10px var(--mono); letter-spacing: 0.06em; color: var(--warn); text-transform: uppercase; margin-bottom: 5px; }
.tourtip .tt-note { font-size: 12.5px; color: var(--text-primary); line-height: 1.5; }
.tourtip .tt-act { font-size: 11.5px; color: var(--text-secondary); line-height: 1.5; margin-top: 6px; }
.tourtip .tt-act b { color: var(--text-primary); font-weight: 500; }
.tourtip .tt-foot { display: flex; gap: 6px; align-items: center; margin-top: 10px; }
.tourfocus { outline: 2px dashed var(--warn) !important; outline-offset: 3px; cursor: pointer; }

.demopill {
  position: fixed; right: 12px; bottom: 34px; z-index: 998;
  height: 22px; padding: 0 9px;
  border: 1.5px dashed var(--warn); border-radius: 999px;
  background: var(--bg-surface); color: var(--warn);
  font: 600 10px var(--mono); letter-spacing: 0.05em; text-transform: uppercase;
  cursor: pointer;
}
.demopill.off { border-color: var(--border-strong); color: var(--text-muted); }
