/* Arbiter / Trace — class-first component styles.
   The tech stack is deliberately non-React: these classes ARE the component system,
   usable from plain HTML / htmx server-rendered fragments. The .jsx files elsewhere in
   this project are thin cosmetic wrappers over these classes for design tooling only. */

/* ---------- base ---------- */

.arbiter-base,
body.arbiter-base {
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: var(--text-body-size);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

.mono { font-family: var(--font-mono); }
.tnum { font-variant-numeric: tabular-nums; }

:where(.arbiter-base) :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: var(--text-body-size);
  font-weight: var(--weight-medium);
  line-height: 1;
  padding: 0 var(--space-4);
  height: 40px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color var(--motion-control) var(--ease),
              border-color var(--motion-control) var(--ease),
              color var(--motion-control) var(--ease);
}
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}
.btn-secondary:hover { background: var(--surface-raised); border-color: var(--ink); }

.btn-ghost { background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-tint); }

.btn:disabled, .btn[aria-disabled="true"] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-small); }
.btn-lg { height: 48px; padding: 0 var(--space-6); font-size: var(--text-body-lg); }

/* ---------- status labels (word + glyph + color; never color alone) ---------- */

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-label);
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-compact);
  border: 1px solid currentColor;
}
.status-blocker, .status-critical { color: var(--status-blocker); background: var(--status-blocker-tint); }
.status-concern, .status-major    { color: var(--status-concern); background: var(--status-concern-tint); }
.status-note, .status-minor       { color: var(--status-note); background: var(--status-note-tint); }
.status-pass                      { color: var(--status-pass); background: var(--status-pass-tint); }
.status-nit                       { color: var(--muted); background: transparent; }
.status-accent                    { color: var(--accent); background: var(--accent-tint); }

/* ---------- forms ---------- */

.field { display: flex; flex-direction: column; gap: var(--space-2); }
.field-label {
  font-size: var(--text-small);
  font-weight: var(--weight-medium);
  color: var(--ink);
}
.field-hint { font-size: var(--text-small); color: var(--muted); }

.input, .select {
  font-family: var(--font-sans);
  font-size: var(--text-body-size);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: 40px;
  padding: 0 var(--space-3);
  transition: border-color var(--motion-control) var(--ease);
}
.input.mono { font-family: var(--font-mono); }
.input:hover, .select:hover { border-color: var(--ink); }
.input:focus-visible, .select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}
.input:disabled, .select:disabled { opacity: 0.45; cursor: not-allowed; }

/* toggle */
.toggle {
  position: relative;
  width: 40px; height: 24px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  padding: 0;
  transition: background-color var(--motion-control) var(--ease);
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform var(--motion-control) var(--ease),
              background-color var(--motion-control) var(--ease);
}
.toggle[aria-checked="true"] { background: var(--accent); border-color: var(--accent); }
.toggle[aria-checked="true"]::after { transform: translateX(16px); background: var(--accent-ink); }

/* ---------- cards & rules ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
}
.card-raised { background: var(--surface-raised); border-color: var(--line); }

.rule { border: 0; border-top: 1px solid var(--line-soft); margin: 0; }
.rule-strong { border-top-color: var(--line); }

/* ---------- code wells & locators ---------- */

.code-well {
  background: var(--surface-code);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-small);
  line-height: 1.6;
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
}

.locator {
  font-family: var(--font-mono);
  font-size: var(--text-small);
  color: var(--ink);
  font-weight: var(--weight-medium);
}
.locator .locator-line { color: var(--accent); }

/* diff change bars */
.diff-add { box-shadow: inset 3px 0 0 var(--status-pass); padding-left: var(--space-2); }
.diff-del { box-shadow: inset 3px 0 0 var(--status-blocker); padding-left: var(--space-2); }

/* ---------- trace line (signature motif) ---------- */

.trace {
  position: relative;
  padding-left: var(--space-5);
}
.trace::before {
  content: "";
  position: absolute;
  left: 6px; top: 4px; bottom: 4px;
  width: 1px;
  background: var(--line);
}
.trace-step { position: relative; }
.trace-step::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--space-5) + 3px);
  top: 7px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--canvas);
  border: 1px solid var(--line);
}
.trace-step.trace-active::before {
  background: var(--accent);
  border-color: var(--accent);
}

/* ---------- ledger (usage is a statement, not a speedometer) ---------- */

.ledger {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-body-size);
}
.ledger th, .ledger td {
  text-align: left;
  padding: var(--space-2) 0;
  border-bottom: 1px solid var(--line-soft);
}
.ledger td:last-child, .ledger th:last-child {
  text-align: right;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.ledger tr:last-child th, .ledger tr:last-child td { border-bottom: 0; }
.ledger .ledger-total th, .ledger .ledger-total td {
  border-top: 1px solid var(--line);
  font-weight: var(--weight-semibold);
}

/* progress rule — secondary cue only */
.progress-rule {
  height: 2px;
  background: var(--line-soft);
  border-radius: 1px;
  overflow: hidden;
}
.progress-rule > span {
  display: block;
  height: 100%;
  background: var(--accent);
}

/* ---------- tabs ---------- */

.tabs {
  display: flex;
  gap: var(--space-6);
  border-bottom: 1px solid var(--line-soft);
}
.tab {
  appearance: none;
  background: none;
  border: 0;
  font-family: var(--font-sans);
  font-size: var(--text-body-size);
  color: var(--muted);
  padding: var(--space-2) 0 var(--space-3);
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--motion-control) var(--ease);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] {
  color: var(--ink);
  font-weight: var(--weight-medium);
  border-bottom-color: var(--accent);
}

/* ---------- misc ---------- */

.kbd {
  font-family: var(--font-mono);
  font-size: var(--text-micro);
  border: 1px solid var(--line-soft);
  border-bottom-width: 2px;
  border-radius: var(--radius-compact);
  padding: 1px 5px;
  background: var(--surface);
}

@media (prefers-reduced-motion: reduce) {
  .arbiter-base *, .arbiter-base *::before, .arbiter-base *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
