/*
 * DIRECTIONAL WORKSTATION — the research workspace.
 *
 * A THIRD PRODUCT SURFACE, and it must not be mistaken for either of the
 * other two. The directional terminal (css/livecore.css) is a near-black
 * trading floor around a price chart; the arbitrage desk (css/arbitrage.css)
 * is a cooler slate ground built on paired leg cards. This is neither: it is
 * a READING surface — a research notebook, not a trading floor.
 *
 * So the identity is documentary rather than operational: a warm-neutral
 * ground, an indigo accent that is neither the terminal's green nor the
 * desk's teal, generous measure for prose, and no price chart at all. There
 * is nothing here to watch tick, because nothing here ticks.
 *
 * THE SIGNATURE ELEMENT IS THE REASON LIST. The honest headline of this
 * workspace is a refusal, so the refusals are the most prominent thing on
 * the page: each one gets its own block, its own BLOCKING marker and its own
 * explanation, rather than being collapsed into a single status word.
 *
 * DENSITY COMES FROM THE SPACING SCALE, NOT THE TYPE SCALE. Text stays
 * readable at a desk; the panels tighten.
 *
 * Nothing in this file encodes a number that means anything. Every value on
 * the page is written by js/workstation.js from a real backend snapshot, and
 * anything the backend did not send renders as an em dash.
 */

:root {
  color-scheme: dark;

  --ground:      #101014;
  --surface:     #17171d;
  --surface-2:   #1e1e26;
  --surface-3:   #262630;
  --line:        #30303c;
  --line-soft:   #23232c;

  --ink:         #eceaf3;
  --ink-2:       #b0acc0;
  --ink-3:       #7d7991;

  /* Indigo is the research accent: not the terminal's green, not the
     desk's teal. A shared accent would make three products look like
     three tabs of one. */
  --accent:      #8b7cf6;
  --accent-dim:  #574ba8;
  --amber:       #e3a74a;
  --block:       #e0607a;
  --ok:          #58c99a;

  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;

  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 8px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------------------------------------------------- system bar */

#system-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: var(--sp-3); }

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: var(--accent-dim);
  color: #fff;
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: 0.5px;
}

.brand-name { font-weight: 600; letter-spacing: 0.2px; }
.brand-sub  { color: var(--ink-3); font-size: 12px; }

.switcher { display: flex; gap: var(--sp-1); }

.switcher a {
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius);
  color: var(--ink-2);
  text-decoration: none;
  font-size: 13px;
  border: 1px solid transparent;
}

.switcher a:hover { background: var(--surface-2); color: var(--ink); }

.switcher a.on {
  background: var(--surface-3);
  color: var(--ink);
  border-color: var(--line);
}

.bar-spacer { flex: 1 1 auto; }

.pill-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.pill {
  display: inline-flex;
  align-items: baseline;
  gap: var(--sp-2);
  padding: 2px var(--sp-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 11px;
}

.pill-k { color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.5px; }
.pill-v { color: var(--ink); }

.pill-ok    .pill-v { color: var(--ok); }
.pill-warn  .pill-v { color: var(--amber); }
.pill-block .pill-v { color: var(--block); }
.pill-idle  .pill-v { color: var(--ink-3); }

/* -------------------------------------------------------------- layout */

#main {
  flex: 1 1 auto;
  padding: var(--sp-4);
  display: grid;
  gap: var(--sp-4);
  grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
  align-content: start;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--sp-4);
  min-width: 0;
}

.panel-wide { grid-column: 1 / -1; }

/* The gate is the headline of this workspace, so it reads first and it
   reads differently. */
.panel-gate {
  grid-column: 1 / -1;
  border-color: var(--accent-dim);
  background:
    linear-gradient(180deg, rgba(139, 124, 246, 0.07), transparent 120px),
    var(--surface);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}

.panel-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--ink-2);
}

.badge {
  font-family: var(--mono);
  font-size: 11px;
  padding: 2px var(--sp-2);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}

.badge-ok    { color: var(--ok);    border-color: var(--ok); }
.badge-block { color: var(--block); border-color: var(--block); }

.gate-headline {
  margin: 0 0 var(--sp-4);
  font-size: 16px;
  line-height: 1.4;
  max-width: 78ch;
}

.note {
  color: var(--ink-3);
  font-size: 12px;
  margin: var(--sp-3) 0 0;
  max-width: 78ch;
}

.empty { color: var(--ink-3); font-size: 12px; }

.contract-statement {
  margin: 0 0 var(--sp-3);
  font-size: 15px;
  max-width: 78ch;
}

/* ---------------------------------------------- the reason list (signature) */

.reason-list, .invariant-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--sp-2);
}

.reason {
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: var(--sp-2) var(--sp-3);
}

/* A blocking reason is marked by colour AND by the word BLOCKING, never
   by colour alone. */
.reason-active {
  border-left-color: var(--block);
  background: var(--surface-3);
}

.reason-head {
  display: flex;
  align-items: baseline;
  gap: var(--sp-3);
  flex-wrap: wrap;
}

.reason-mark {
  font-family: var(--mono);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--ink-3);
  min-width: 9ch;
}

.reason-active .reason-mark { color: var(--block); font-weight: 700; }

.reason-head code {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  word-break: break-word;
}

.reason-detail {
  margin: var(--sp-1) 0 0;
  color: var(--ink-2);
  font-size: 12px;
  max-width: 86ch;
}

.invariant-list li {
  display: grid;
  grid-template-columns: 22ch 1fr;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  background: var(--surface-2);
  font-size: 12px;
}

.invariant-list code {
  font-family: var(--mono);
  color: var(--accent);
}

.invariant-list span { color: var(--ink-2); }

@media (max-width: 640px) {
  .invariant-list li { grid-template-columns: 1fr; gap: var(--sp-1); }
}

/* ------------------------------------------------------------ key/value */

.kv {
  display: grid;
  grid-template-columns: minmax(12ch, auto) 1fr;
  gap: var(--sp-1) var(--sp-4);
  margin: 0;
}

.kv dt { color: var(--ink-3); font-size: 12px; }

.kv dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 12px;
  word-break: break-all;
}

/* ------------------------------------------------------------- controls */

.control-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-4);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--line-soft);
  flex-wrap: wrap;
}

.btn {
  font: inherit;
  font-size: 12px;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink);
  cursor: pointer;
}

.btn:hover:not(:disabled) { background: var(--surface-3); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-warn { border-color: var(--amber); color: var(--amber); }

.control-note {
  color: var(--ink-3);
  font-size: 12px;
  flex: 1 1 24ch;
  min-width: 0;
}

/* --------------------------------------------------------------- tables */

/* Wide content scrolls inside its own container; the page body must never
   scroll sideways. */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}

.grid {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 12px;
}

.grid th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  background: var(--surface-2);
  color: var(--ink-3);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}

.grid td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--line-soft);
  white-space: nowrap;
  vertical-align: top;
}

.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover { background: var(--surface-2); }

.grid td.ok     { color: var(--ok); }
.grid td.warn   { color: var(--amber); }
.grid td.muted  { color: var(--ink-3); }

/* The reason a candidate was not taken is the most important column, so
   it is the one allowed to wrap. */
.grid td.reason-cell {
  white-space: normal;
  min-width: 34ch;
  max-width: 60ch;
  color: var(--ink-2);
}

/* --------------------------------------------------------------- footer */

#footer {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
  flex-wrap: wrap;
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-3);
  font-family: var(--mono);
  font-size: 11px;
}

#footer .sep { color: var(--line); }
