/* ---------------------------------------------------------------------------
   Shared foundation — tokens, reset, type, controls.
   Loaded by every page before its own stylesheet.

   Design intent: an editorial tool, not a template. Structure comes from
   hairline rules and whitespace rather than cards, shadows and pills. One
   typeface, deliberate weights, sparing accent. The data-visualisation tokens
   at the bottom are validated (single-hue ordinal ramp, three-tier status);
   do not substitute values there without re-running the validator.
--------------------------------------------------------------------------- */

:root {
  /* Ink */
  --ink:        #16161a;
  --ink-2:      #54545c;
  --ink-3:      #8b8b93;
  --ink-invert: #ffffff;

  /* Rules and planes */
  --rule:       #e3e1dd;
  --rule-2:     #c9c7c2;
  --paper:      #ffffff;
  --plane:      #f7f6f4;
  --plane-2:    #efedea;

  /* Accents — used sparingly, never decoratively */
  --accent:     #16161a;
  --gold:       #8f7239;
  --gold-wash:  #f6f1e7;

  /* Data visualisation — validated single-hue ordinal ramp (light→dark).
     Checks passed on a #ffffff surface: monotone lightness, adjacent ΔL ≥ 0.06,
     light-end contrast 2.11:1, single hue (4° spread). */
  --seq-1: #a8b3c8;
  --seq-2: #8592ac;
  --seq-3: #67769a;
  --seq-4: #4a5878;
  --seq-5: #2e3a54;
  --seq-6: #1b2438;
  /* Sequential-only wash for the near-zero end of a continuous scale, where
     receding toward the surface is correct. Never used for ordinal marks. */
  --seq-wash: #edeff4;
  --seq-track: #e4e7ee;

  /* Status — three tiers. Validated on #ffffff: all inside the lightness band,
     chroma floor met, worst adjacent normal-vision ΔE 17.1, all ≥ 3:1 contrast.
     A fourth amber/orange tier was cut: it collided with warning (ΔE 3.9). */
  --good: #1f7a52;
  --warn: #a8761c;
  --crit: #97302f;
  --good-wash: #edf5f1;
  --warn-wash: #faf4e8;
  --crit-wash: #f9eeed;

  /* Code surfaces — the UCP protocol trace and any raw payload display.
     Dark-on-light to match the editorial system rather than a terminal look. */
  --code-bg:  #f4f4f2;
  --code-ink: #2b2b31;

  /* Chart chrome */
  --grid:     #ececea;
  --baseline: #c9c7c2;

  --measure: 1240px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv05" 1, "ss03" 1;
}

a { color: inherit; text-decoration: none; }

h1, h2, h3, h4 { margin: 0; font-weight: 500; letter-spacing: -0.01em; }

/* ---- shared chrome ------------------------------------------------------ */

.chrome {
  border-bottom: 1px solid var(--rule);
  background: var(--paper);
  position: sticky;
  top: 0;
  z-index: 40;
}
.chrome-inner {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 0 32px;
  height: 60px;
  display: flex;
  align-items: center;
  gap: 36px;
}

.wordmark {
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.34em;
  white-space: nowrap;
}

.chrome-nav { display: flex; align-items: center; gap: 26px; flex: 1; }
.chrome-nav a {
  font-size: 12.5px;
  color: var(--ink-3);
  padding: 20px 0;
  border-bottom: 1px solid transparent;
  transition: color .15s, border-color .15s;
}
.chrome-nav a:hover { color: var(--ink); }
.chrome-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

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

/* Engine readiness — a dot and a word, no vendor name. */
.engine {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 11.5px; color: var(--ink-3);
}
.engine::before {
  content: ""; width: 5px; height: 5px; border-radius: 50%;
  background: var(--good);
}
.engine[data-state="off"]::before { background: var(--crit); }

/* ---- typography helpers ------------------------------------------------- */

.eyebrow {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.lede {
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 62ch;
}

.muted { color: var(--ink-3); }
.hidden { display: none !important; }

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

.btn {
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 12px 20px;
  border-radius: 2px;
  border: 1px solid var(--ink);
  background: var(--ink);
  color: var(--ink-invert);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #2e2e36; border-color: #2e2e36; }
.btn:disabled { opacity: .35; cursor: not-allowed; }

.btn.ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-2);
}
.btn.ghost:hover:not(:disabled) { background: var(--plane); border-color: var(--ink-3); }

.btn.quiet {
  background: transparent; border-color: transparent; color: var(--ink-3);
  padding: 12px 8px; text-transform: none; letter-spacing: 0;
  font-size: 12.5px;
}
.btn.quiet:hover:not(:disabled) { color: var(--ink); background: transparent; }

.field { display: block; }
.field > span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin-bottom: 5px;
}
input, select, textarea {
  width: 100%;
  font: inherit;
  font-size: 13.5px;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 2px;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--ink-3);
}
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%),
                    linear-gradient(135deg, var(--ink-3) 50%, transparent 50%);
  background-position: calc(100% - 15px) 51%, calc(100% - 11px) 51%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
  padding-right: 30px;
}

/* Focus ring for keyboard users only. */
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---- status + rating primitives ---------------------------------------- */

.tag {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; letter-spacing: 0.03em;
  padding: 3px 8px; border-radius: 2px;
  background: var(--plane-2); color: var(--ink-2);
  white-space: nowrap;
}
/* Status tags always pair colour with a word — colour never carries meaning
   alone, per the accessibility rule. */
.tag[data-status="good"] { background: var(--good-wash); color: var(--good); }
.tag[data-status="warning"] { background: var(--warn-wash); color: var(--warn); }
.tag[data-status="critical"] { background: var(--crit-wash); color: var(--crit); }

/* Rating: filled/empty marks plus the numeral, so it is never shape-only. */
.rating { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.rating-marks { letter-spacing: 0.12em; font-size: 12px; color: var(--gold); }
.rating-marks .off { color: var(--rule-2); }
.rating-value { font-size: 12.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

.status-text { font-size: 12.5px; min-height: 18px; color: var(--ink-3); }
.status-text.error { color: var(--crit); }
.status-text a { color: var(--ink); border-bottom: 1px solid var(--rule-2); }

/* ---- spinner ------------------------------------------------------------ */
.spin {
  display: inline-block; width: 11px; height: 11px; vertical-align: -1px;
  border: 1.5px solid var(--rule-2); border-top-color: var(--ink-2);
  border-radius: 50%; animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---- signed-in chrome --------------------------------------------------- */

.session { display: inline-flex; align-items: center; gap: 12px; }
.session-user {
  display: inline-flex; flex-direction: column; align-items: flex-end;
  line-height: 1.25; text-align: right;
}
.session-name { font-size: 12.5px; color: var(--ink); }
.session-role { font-size: 10.5px; color: var(--ink-3); letter-spacing: .02em; }
.session-out { padding: 8px 4px; }

.denied-banner {
  background: var(--warn-wash);
  border-bottom: 1px solid var(--warn);
  color: var(--ink-2);
  font-size: 12.5px;
  padding: 10px 32px;
}
.denied-banner strong { font-weight: 500; color: var(--ink); }

/* ---- brand ------------------------------------------------------------- */
/* The wordmark is text by default and an image when a logo is uploaded. */
.wordmark { letter-spacing: var(--wordmark-tracking, 0.34em); }
.wordmark-logo {
  display: block; height: 22px; width: auto; max-width: 200px;
  object-fit: contain;
}
.foot .wordmark-logo { height: 16px; }
