/* ============================================================
   akwOS — shared components
   Every rule here names Tier 2 aliases from `tokens.css` only, so
   the same stylesheet paints correctly on the light product surface
   and inside the dark marketing shell. Nothing below knows which.

   This file exists because ten selectors — .av .feed .grade .ring
   .st .st-todo .tag .tag-green .tag-red .plan-pct — were defined
   twice, in `site.css` and `app.css`, with different rules and two
   incompatible status vocabularies. One definition each, here.
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; }

/* ── Type ──────────────────────────────────────────────────── */
.u-mono  { font-family: var(--mono); }
.u-num   { font-variant-numeric: tabular-nums; }
.u-trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

code {
  font-family: var(--mono); font-size: .9em;
  background: var(--bg-sunken); color: var(--text-body);
  padding: .1em .38em; border-radius: var(--r-xs);
}

/* ── Panel ─────────────────────────────────────────────────── */
.panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-lg); overflow: hidden; margin-bottom: 18px;
}
.panel-h {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; border-bottom: 1px solid var(--border-subtle);
}
.panel-h h2 {
  font-size: var(--fs-13); font-weight: 620;
  letter-spacing: -.01em; margin: 0; color: var(--text);
}
.panel-h .sub {
  font-size: var(--fs-11); color: var(--text-dim);
  margin-left: auto; font-variant-numeric: tabular-nums;
}

/* ── Tile ──────────────────────────────────────────────────── */
.tiles {
  display: grid; gap: 12px; margin-bottom: 22px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.tile {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-md); padding: 15px 16px;
}
.tile b {
  display: block; font-size: var(--fs-26); font-weight: 660;
  letter-spacing: -.03em; line-height: 1.15; color: var(--text);
  font-variant-numeric: tabular-nums;
}
.tile span { display: block; font-size: var(--fs-11); color: var(--text-dim); margin-top: 2px; }
.tile.is-ok     b { color: var(--ok); }
.tile.is-warn   b { color: var(--warn); }
.tile.is-danger b { color: var(--danger); }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 13px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface);
  font-family: inherit; font-size: var(--fs-12); font-weight: 560;
  color: var(--text-body); cursor: pointer; white-space: nowrap;
  transition: background .16s, border-color .16s, opacity .16s;
}
.btn:hover              { background: var(--surface-hover); }
.btn:disabled           { opacity: .45; cursor: not-allowed; }
.btn:focus-visible      { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.is-solid           { background: var(--solid); border-color: var(--solid); color: var(--solid-fg); }
.btn.is-solid:hover     { background: var(--solid-hover); }
.btn.is-quiet           { border-color: transparent; background: transparent; }
.btn.is-quiet:hover     { background: var(--surface-hover); }
.btn.is-lg              { height: 42px; padding: 0 20px; font-size: var(--fs-14); border-radius: var(--r-full); }

/* ── Filter chip — the grid's column/segment control ───────── */
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 11px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: var(--surface);
  font-family: inherit; font-size: var(--fs-12); font-weight: 540;
  color: var(--text-muted); cursor: pointer; white-space: nowrap;
  transition: background .16s, color .16s, border-color .16s;
}
.chip:hover        { background: var(--surface-hover); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--solid); border-color: var(--solid); color: var(--solid-fg); }
.chip .chip-n      { font-variant-numeric: tabular-nums; opacity: .65; }
.chip .dot         { margin-right: -1px; }

/* ── Input ─────────────────────────────────────────────────── */
.input {
  height: 32px; padding: 0 11px; border-radius: var(--r);
  border: 1px solid var(--border); background: var(--surface);
  font-family: inherit; font-size: var(--fs-12); color: var(--text);
  min-width: 0; transition: border-color .16s;
}
.input::placeholder { color: var(--text-dim); }
.input:focus        { outline: none; border-color: var(--accent); }

/* ── Status pill — ONE vocabulary ──────────────────────────
   `site.css` had .st-done/.st-run/.st-open/.st-todo and `app.css`
   had .st-landed/.st-running/.st-review/.st-todo/.st-closed for the
   same five states. These names win; the other set is deleted. */
.st {
  display: inline-flex; align-items: center;
  font-size: var(--fs-10); font-weight: 560; white-space: nowrap;
  padding: 3px 9px; border-radius: var(--r-sm);
}
.st-landed  { background: var(--ok-tint);      color: var(--ok-tint-fg); }
.st-running { background: var(--accent-tint);  color: var(--accent-tint-fg); }
.st-review  { background: var(--warn-tint);    color: var(--warn-tint-fg); }
.st-todo    { background: var(--neutral-tint); color: var(--neutral-tint-fg); }
.st-closed  { background: var(--neutral-tint); color: var(--text-dim); }

/* ── Freshness tag ─────────────────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; flex: none;
  font-size: var(--fs-10); white-space: nowrap;
  padding: 3px 8px; border-radius: var(--r-sm);
  background: var(--neutral-tint); color: var(--neutral-tint-fg);
}
.tag-green { background: var(--ok-tint);     color: var(--ok-tint-fg); }
.tag-amber { background: var(--warn-tint);   color: var(--warn-tint-fg); }
.tag-red   { background: var(--danger-tint); color: var(--danger-tint-fg); }

/* Provenance tier. `vendored` resolves to the same values as a bare
   `.tag`, and is still written out: a row that says "vendored" and a
   row that says nothing are different claims, and the second one is
   what the grid showed before six repositories fed it. */
.tag-authored { background: var(--tier-authored); color: var(--tier-authored-fg); }
.tag-vendored { background: var(--tier-vendored); color: var(--tier-vendored-fg); }

/* ── Evidence grade badge ──────────────────────────────────── */
.grade {
  display: inline-flex; align-items: center; height: 19px; padding: 0 7px;
  border-radius: var(--r-xs); font-family: var(--mono);
  font-size: var(--fs-10); font-weight: 620;
  letter-spacing: .03em; text-transform: uppercase;
}
.g-measured { background: var(--grade-measured); color: var(--grade-measured-fg); }
.g-observed { background: var(--grade-observed); color: var(--grade-observed-fg); }
.g-known    { background: var(--grade-known);    color: var(--grade-known-fg); }
.g-inferred { background: var(--grade-inferred); color: var(--grade-inferred-fg); }

/* ── Freshness dot ─────────────────────────────────────────── */
.dot {
  width: 8px; height: 8px; border-radius: 50%; flex: none;
  background: var(--border-strong);
}
.dot.is-fresh  { background: var(--ok); }
.dot.is-watch  { background: var(--warn); }
.dot.is-stale  { background: var(--danger); }

/* ── Avatar ────────────────────────────────────────────────── */
.av {
  display: inline-grid; place-items: center; flex: none;
  width: 22px; height: 22px; border-radius: 50%;
  font-size: var(--fs-10); font-weight: 680;
  font-style: normal; color: var(--accent-fg);
}
.av.is-lg { width: 30px; height: 30px; font-size: var(--fs-13); }

/* ── Mono pill — a skill name, a tool name ─────────────────── */
.pill {
  display: inline-flex; align-items: center;
  font-family: var(--mono); font-size: var(--fs-10);
  padding: 2px 7px; border-radius: var(--r-xs);
  background: var(--neutral-tint); color: var(--text-body);
}

/* ── Key/value rows ────────────────────────────────────────── */
.kv { display: grid; }
.kv-row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 12px 16px; border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-12); color: var(--text-muted);
}
.kv-row:last-child { border-bottom: 0; }
.kv-row b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.kv-row b.is-warn { color: var(--warn); }

/* The working-group row carries three things on its right — a tier
   tag, an evidence grade and a count line — where every other kv-row
   carries one value. `flex: none` on the group keeps the three from
   being squeezed by a long repository role on the left, which is
   prose and should wrap instead. */
.kv-row .wg-v {
  display: inline-flex; align-items: center; gap: 8px; flex: none;
}
.kv-row .wg-v .sub { font-family: var(--mono); font-size: var(--fs-10); }

/* ============================================================
   Tabular review — the grid
   Rows are the things that exist on disk; columns are attributes
   measured from them. This is the surface the whole product is,
   not one view among four: Knowledge, Plugins, Skills and Agents
   are four datasets rendered through this same table.
   ============================================================ */

.grid-wrap { overflow: auto; max-height: calc(100vh - 260px); }

.grid {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: var(--fs-12);
}

.grid thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--surface); text-align: left;
  font-size: var(--fs-10); font-weight: 600;
  letter-spacing: .07em; text-transform: uppercase;
  color: var(--text-dim); white-space: nowrap;
  padding: 9px 14px; border-bottom: 1px solid var(--border);
}
.grid thead th.is-num { text-align: right; }

/* Sortable header. aria-sort carries the state; the caret reads it,
   so the DOM says which column is sorted without a class to sync. */
.grid thead th[aria-sort] { cursor: pointer; user-select: none; }
.grid thead th[aria-sort]:hover { color: var(--text-body); }
.grid thead th[aria-sort]::after {
  content: "↕"; margin-left: 5px; opacity: .3; font-size: 9px;
}
.grid thead th[aria-sort="ascending"]::after  { content: "↑"; opacity: .9; }
.grid thead th[aria-sort="descending"]::after { content: "↓"; opacity: .9; }

.grid tbody td {
  padding: 10px 14px; border-bottom: 1px solid var(--border-subtle);
  color: var(--text-body); vertical-align: middle;
}
.grid tbody td.is-num {
  text-align: right; font-variant-numeric: tabular-nums;
  color: var(--text-muted);
}
.grid tbody tr:last-child td { border-bottom: 0; }
.grid tbody tr:hover td      { background: var(--surface-hover); }
.grid tbody tr[aria-selected="true"] td { background: var(--accent-tint); }
.grid tbody tr.is-stale td   { background: var(--danger-wash); }

.grid .col-select { width: 36px; }
.grid .col-select input { accent-color: var(--accent); }

/* The primary cell: name on top, its source path underneath. Every
   row can be traced back to the file it was measured from. */
.cell-name  { font-weight: 560; color: var(--text); }
.cell-src   {
  display: block; margin-top: 2px;
  font-family: var(--mono); font-size: var(--fs-10); color: var(--text-dim);
}

/* ── Grid toolbar ──────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 11px 14px; border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}
.toolbar .spacer { margin-left: auto; }
.toolbar .count  {
  font-size: var(--fs-11); color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}

/* ── Selection bar — appears only with a selection ─────────── */
.selbar {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px; background: var(--accent-tint);
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--fs-12); color: var(--accent-tint-fg);
}
.selbar b { font-variant-numeric: tabular-nums; }

/* ── Empty state ───────────────────────────────────────────── */
.empty {
  padding: 44px 20px; text-align: center;
  color: var(--text-dim); font-size: var(--fs-12);
}

/* ── Notice ────────────────────────────────────────────────── */
.notice {
  display: flex; gap: 12px; padding: 15px 16px; margin-bottom: 18px;
  background: var(--warn-wash); border: 1px solid var(--warn-border);
  border-radius: var(--r-md);
}
.notice .ni {
  display: grid; place-items: center; flex: none;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--warn); color: var(--akw-n-1000);
  font-size: var(--fs-12); font-weight: 700;
}
.notice b { display: block; font-size: var(--fs-13); margin-bottom: 3px; color: var(--text); }
.notice p { margin: 0; font-size: var(--fs-12); color: var(--warn-wash-fg); }

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

/* ── Slot occupancy ────────────────────────────────────────
   Which authored slots a plugin filled, and which it left to the
   framework default. Absence is the signal, so every slot in the
   vocabulary gets a mark whether it is occupied or not — a list of
   only the filled ones cannot show that ten of eleven plugins are
   a single skill in a wrapper. See docs/agent-slots.md. */
.slots { display: inline-flex; gap: 3px; align-items: center; }
.slots i {
  width: 15px; height: 15px; border-radius: var(--r-xs);
  display: grid; place-items: center; flex: none;
  font-family: var(--mono); font-size: 8.5px; font-weight: 700;
  font-style: normal; text-transform: uppercase;
  background: var(--neutral-tint); color: var(--text-dim);
  border: 1px dashed var(--border-strong);
}
.slots i[data-on="1"] {
  background: var(--accent); color: var(--accent-fg);
  border: 1px solid var(--accent);
}
