/* The surface language.
 *
 * Orientation on top, no ceiling underneath. Two rules do most of the work:
 *
 *   1. NO BOXES. Structure comes from hairline rules, spacing, and type
 *      hierarchy. A bordered rectangle around every idea is what made the old
 *      landing feel like a control room, and it is a way of avoiding the
 *      harder question of what actually belongs together.
 *
 *   2. THE LANDING ORIENTS; DEEP SURFACES OPERATE. The command-center layer
 *      may summarize state, while configuration and instrumentation remain a
 *      deliberate step down.
 *
 * Tokens are the family's, unchanged — see foundation.css.
 */

/* ---- shell --------------------------------------------------------------- */

/* Block flow, not grid. A `position: sticky` grid item is confined to its own
 * grid area, so the rail would scroll away the moment the page got long —
 * which it does, two levels down. */
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--page);
}

/* ---- rail ----------------------------------------------------------------
 * The only chrome. It never grows: no tabs appear here as the app deepens,
 * because the breadcrumb is the navigation and it costs nothing when you are
 * at the top. */

.rail {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 20px;
  padding: 0 28px;
  height: 52px;
  border-bottom: 1px solid var(--line);
  background: var(--rail);
  position: sticky;
  top: 0;
  z-index: 40;
}

.rail-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: none;
  border: 0;
  padding: 0;
  color: inherit;
  cursor: pointer;
  font: inherit;
}
.rail-brand img { width: 15px; height: 15px; opacity: 0.9; }
.rail-word {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text);
}
.rail-brand:hover .rail-word { color: #fff; }

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.05em;
  min-width: 0;
  overflow: hidden;
}
.crumb {
  background: none; border: 0; padding: 0;
  font: inherit; letter-spacing: inherit;
  color: var(--dim);
  cursor: pointer;
  white-space: nowrap;
}
.crumb:hover { color: var(--muted); }
.crumb[aria-current="page"] { color: var(--muted); cursor: default; }
.crumb-sep { color: var(--dim); opacity: 0.4; }

.rail-right { display: flex; align-items: center; gap: 16px; }

.env-mark {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}
.env-mark.live { color: var(--danger); }

.rail-btn {
  background: none; border: 0; padding: 0;
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: var(--dim);
  cursor: pointer;
}
.rail-btn:hover { color: var(--text); }
.rail-btn.stop { color: var(--dim); }
.rail-btn.stop:hover { color: var(--danger); }
.rail-btn.stop.engaged { color: var(--danger); }

/* ---- landing -------------------------------------------------------------
 * Vertically composed, generously spaced, and deliberately short. If it needs
 * a scrollbar on a laptop, something has been added that does not belong. */

.landing { display: grid; place-items: start center; padding: 0 28px 72px; }
.landing-inner { width: 100%; max-width: 760px; padding-top: 12vh; }

.figure-block { display: grid; gap: 6px; margin-bottom: 44px; }
.figure-label {
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}
.figure {
  font-size: clamp(38px, 6vw, 58px);
  font-weight: 300;
  /* Tight tracking on a large figure reads as precision. Loose reads as a
   * marketing headline. */
  letter-spacing: -0.025em;
  line-height: 1;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.figure-sub {
  font-size: 12px;
  color: var(--dim);
  font-variant-numeric: tabular-nums;
}
.figure-sub .up { color: var(--electric-green); }
.figure-sub .down { color: var(--danger); }

/* ---- ask ----------------------------------------------------------------
 * A rule, not a field. The input is the primary act of the product and it
 * should look like writing a line, not filling in a form. */

.ask {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 12px;
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 10px;
  transition: border-color 120ms ease;
}
.ask:focus-within { border-bottom-color: var(--muted); }

.ask textarea {
  background: none;
  border: 0;
  resize: none;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  padding: 0;
  max-height: 40vh;
}
.ask textarea:focus { outline: none; }
.ask textarea::placeholder { color: var(--dim); }

.ask-go {
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 17px;
  cursor: pointer;
  padding: 0 2px 2px;
  line-height: 1;
}
.ask-go:hover { color: var(--text); }

.ask-openers {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 14px;
  min-height: 16px;
}
.opener {
  background: none; border: 0; padding: 0;
  font-family: inherit;
  font-size: 12px;
  color: var(--dim);
  cursor: pointer;
  text-align: left;
}
.opener:hover { color: var(--muted); }

/* ---- doors ---------------------------------------------------------------
 * A typographic index. Hairline-separated rows: title, one sentence, and a
 * live figure. No cards, no icons, no fills — the restraint is the point, and
 * every one of these opens onto real depth. */

.doors { margin-top: 64px; border-top: 1px solid var(--line); }

.door {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 8px 24px;
  width: 100%;
  padding: 17px 0 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  /* The only hover affordance: a hairline that brightens and text that lifts.
   * No translate, no background — motion on a list of seven reads as fidgety. */
  transition: border-color 120ms ease;
}
.door:hover { border-bottom-color: var(--line-strong); }

.door-title {
  grid-column: 1;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--muted);
  transition: color 120ms ease;
}
.door:hover .door-title { color: var(--text); }

.door-metric {
  grid-column: 2;
  grid-row: 1;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  color: var(--dim);
  white-space: nowrap;
}
.door-metric.attention { color: var(--amber, #f5c15d); }

.door-blurb {
  grid-column: 1 / -1;
  font-size: 12px;
  line-height: 1.55;
  color: var(--dim);
  margin-top: 4px;
  max-width: 62ch;
}

/* ---- deep ----------------------------------------------------------------
 * One column, one purpose. The header states what this is in a sentence,
 * because a person who drilled two levels deep should never have to guess. */

.deep { display: grid; place-items: start center; padding: 0 28px 96px; }
.deep-inner { width: 100%; max-width: 860px; padding-top: 48px; }

.deep-head { margin-bottom: 32px; }
.deep-head h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.015em;
  color: var(--text);
}
.deep-head p {
  margin: 8px 0 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--dim);
  max-width: 68ch;
}

.deep-body { display: grid; gap: 34px; }

/* Sections are separated by a rule and a label, never by a border. */
.panel { display: grid; gap: 12px; }
.panel > h2 {
  margin: 0;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}
.panel-note {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--dim);
  max-width: 70ch;
}

/* The workhorse: a hairline-separated data row. Replaces every box in the
 * previous design. Label left, value right, optional note underneath. */
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 6px 20px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: 0; }
.row-k { font-size: 13px; color: var(--muted); }
.row-v {
  font-size: 13px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.row-v.dim { color: var(--dim); }
.row-v.up { color: var(--electric-green); }
.row-v.down { color: var(--danger); }
.row-n {
  grid-column: 1 / -1;
  font-size: 11px;
  line-height: 1.55;
  color: var(--dim);
  max-width: 70ch;
}
.row-mono { font-family: var(--mono); font-size: 11px; }

/* A row you can open. Same hairline, plus a chevron. */
.row.tap { cursor: pointer; border: 0; border-bottom: 1px solid var(--line); }
.row.tap:hover .row-k { color: var(--text); }
.row.tap .row-v::after {
  content: "›";
  margin-left: 10px;
  color: var(--dim);
}

/* Left-edge accent, for state that must be legible at a glance. Used instead
 * of a coloured box, which is the same information at ten times the weight. */
.mark { border-left: 2px solid var(--line-strong); padding-left: 12px; }
.mark.good { border-left-color: var(--electric-green-line); }
.mark.warn { border-left-color: var(--amber-line, rgba(245, 193, 93, 0.42)); }
.mark.bad  { border-left-color: var(--danger-line); }

/* ---- deeper --------------------------------------------------------------
 * The way down. Always at the bottom, always the same shape, so descending
 * becomes muscle memory rather than a hunt. */

.deeper { margin-top: 44px; border-top: 1px solid var(--line); }
.deeper:empty { display: none; }
.deeper-label {
  display: block;
  padding: 18px 0 4px;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
}
.deeper .door { padding: 13px 0; }
.deeper .door-title { font-size: 13px; }

/* ---- talk ---------------------------------------------------------------- */

.talk { display: block; padding-bottom: 96px; }
.talk-inner { padding: 40px 28px 12px; }
.stream {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  display: grid;
  gap: 26px;
}
/* Docked to the viewport so a long conversation never pushes the input off
 * screen, and backed so text does not scroll visibly underneath it. */
.ask-docked {
  position: sticky;
  bottom: 0;
  width: min(760px, calc(100% - 56px));
  margin: 0 auto;
  padding: 14px 0 20px;
  background: linear-gradient(to bottom, transparent, var(--page) 22%);
  border-bottom: 0;
}
.ask-docked textarea { border-bottom: 1px solid var(--line-strong); padding-bottom: 10px; }
.ask-docked:focus-within textarea { border-bottom-color: var(--muted); }

/* ---- dense instrumentation ----------------------------------------------
 * Only inside INSTRUMENT panels. Density is earned by depth: this would be
 * noise on the landing and is exactly right two steps in. */

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 32px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 28px; }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* Wide instrumentation scrolls in its own box so the page never does. */
.matrix-scroll { overflow-x: auto; max-width: 100%; }
.matrix-scroll .matrix { min-width: max-content; }

/* A matrix. Hairlines only — no cell borders, no zebra. */
.matrix { width: 100%; border-collapse: collapse; font-size: 11px; }
.matrix th, .matrix td {
  padding: 7px 10px 7px 0;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.matrix th {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}
.matrix td { color: var(--muted); }
.matrix td.num, .matrix th.num { text-align: right; padding-right: 0; }
.matrix .yes { color: var(--electric-green); }
.matrix .no  { color: var(--dim); opacity: 0.5; }
.matrix tr:last-child td { border-bottom: 0; }

/* A horizontal magnitude bar, drawn on the baseline rather than in a box. */
.bar { display: grid; grid-template-columns: 1fr; height: 2px; background: var(--line); }
.bar > i { display: block; height: 2px; background: var(--muted); }
.bar > i.good { background: var(--electric-green); }
.bar > i.bad { background: var(--danger); }

/* A sequence — protocol stages, a chain of command, an order lifecycle. */
.seq { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.seq-step {
  font-size: 11px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.seq-step.explore { color: var(--electric-blue); }
.seq-arrow { color: var(--dim); opacity: 0.45; font-size: 10px; }

/* Inline key/value pairs for a dense header strip. */
.stat-strip { display: flex; flex-wrap: wrap; gap: 4px 36px; padding: 2px 0 14px; }
.stat { display: grid; gap: 2px; }
.stat-k {
  font-size: 9px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--dim);
}
.stat-v {
  font-size: 17px; font-weight: 300; letter-spacing: -0.01em;
  color: var(--text); font-variant-numeric: tabular-nums;
}
.stat-v.small { font-size: 13px; font-weight: 400; }

/* Designed empty state. A rule and a sentence, never a dashed rectangle. */
.nothing {
  padding: 16px 0 4px;
  border-left: 2px solid var(--line);
  padding-left: 14px;
}
.nothing b { display: block; font-size: 13px; font-weight: 500; color: var(--muted); }
.nothing p { margin: 6px 0 0; font-size: 12px; line-height: 1.6; color: var(--dim); max-width: 62ch; }

/* ---- controls, restyled to the same language ----------------------------- */

.act {
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line-strong);
  padding: 5px 0;
  font-family: inherit;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  justify-self: start;
}
.act:hover { color: var(--text); border-bottom-color: var(--muted); }
.act.danger { color: var(--danger); border-bottom-color: var(--danger-line); }
.act-row { display: flex; flex-wrap: wrap; gap: 26px; padding-top: 4px; }

/* Accessibility parity with the reference implementation: it raises contrast the same way. */
@media (prefers-contrast: more) {
  :root {
    --muted: #c1cad7;
    --line: rgba(223, 234, 249, 0.42);
  }
}

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