/*
 * Components (issue #43): small purposeful classes on the token system.
 * If a screen needs a new visual, extend a token or a component here —
 * never inline a one-off value in a view.
 */

/* Site chrome */

header.site {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.nav {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-3) var(--space-4);
  display: flex;
  gap: var(--space-4);
  align-items: baseline;
}

.nav a {
  color: var(--accent);
  text-decoration: none;
}

.nav a:hover {
  text-decoration: underline;
}

.nav a.brand {
  color: var(--ink);
  font-weight: var(--weight-bold);
}

main {
  max-width: var(--measure);
  margin: 0 auto;
  padding: var(--space-5) var(--space-4) var(--space-8);
}

/* Buttons: .btn is the primary action; variants for the rest */

.btn {
  display: inline-block;
  font: inherit;
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--accent);
  border-radius: var(--radius-md);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  text-decoration: none;
}

.btn:hover {
  filter: brightness(1.08);
}

.btn--secondary {
  background: var(--surface);
  color: var(--accent);
}

.btn--secondary:hover {
  background: var(--accent);
  color: var(--accent-ink);
  filter: none;
}

.btn--danger {
  background: var(--surface);
  border-color: var(--danger);
  color: var(--danger);
}

.btn--danger:hover {
  background: var(--danger);
  color: var(--accent-ink);
  filter: none;
}

/* Cards */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  margin: var(--space-4) 0;
}

/* Tables: the bordered listing treatment */

.table {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table th,
.table td {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

.table th {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.table tbody tr:last-child td {
  border-bottom: none;
}

.table td.content p {
  margin: 0;
}

/* Status badges: one variant per lifecycle meaning (see
   ApplicationHelper::STATUS_VARIANT — the single mapping, tested) */

.badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  background: var(--neutral-bg);
  color: var(--muted);
}

.badge--info {
  background: var(--info-bg);
  color: var(--info);
}

.badge--success {
  background: var(--success-bg);
  color: var(--success);
}

.badge--warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.badge--danger {
  background: var(--danger-bg);
  color: var(--danger);
}

/* Form fields: label above control, consistent rhythm */

.form-field {
  margin: 0 0 var(--space-4);
}

.form-field label {
  display: block;
  margin-bottom: var(--space-1);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.form-field input,
.form-field select,
.form-field textarea {
  min-width: 0;
  width: 100%;
  max-width: 28rem;
}

/* Flashes */

.flash {
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

.flash--notice {
  background: var(--success-bg);
  border: 1px solid var(--success-line);
  color: var(--success);
}

.flash--alert {
  background: var(--danger-bg);
  border: 1px solid var(--danger-line);
  color: var(--danger);
}

/* Empty states (listings with nothing to show) */

.empty-state {
  padding: var(--space-6) var(--space-4);
  border: 1px dashed var(--line);
  border-radius: var(--radius-lg);
  text-align: center;
  color: var(--muted);
}

/* Filter forms (issue #42): one compact row of labeled controls */

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3) var(--space-4);
  align-items: flex-end;
  margin-bottom: var(--space-5);
}

.filters p {
  margin: 0;
}

.filters label {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.filters input[type="text"],
.filters select {
  min-width: 11rem;
}

.filters .actions {
  align-items: center;
}

.filters .actions a {
  color: var(--muted);
  font-size: var(--text-sm);
}

/* Action rows (decision buttons, lifecycle transitions) */

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.actions form {
  display: inline;
}

/* Triage needs rows (issue #41) */

.need-row {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  margin: 0 0 var(--space-4);
}

/* Engagement show */

/* A value meant to be carried somewhere else by hand — a handoff link
   (continue_url, Bible §12.2), a 52-character public key (issue #116).
   Transcription is the failure mode, so the value is always selectable and
   always has its own copy button. */

.copy-field {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.copy-field input {
  flex: 1;
  font-family: ui-monospace, monospace;
  font-size: var(--text-sm);
}

/* A labelled value: the label above, the value below, stacked so a long
   key never fights its label for the same line. */

.field {
  margin: var(--space-3) 0;
}

.field__label {
  display: block;
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-1);
}

.field p {
  margin: 0;
}

/* Posture notes (issue #116): one per fact that is otherwise implicit.
   The left rule carries the severity, so the note reads as a statement
   about the node rather than as an alert about the page. */

.posture {
  border-left: 3px solid var(--line);
  padding: var(--space-2) 0 var(--space-2) var(--space-3);
  margin: var(--space-3) 0;
}

.posture--danger {
  border-left-color: var(--danger-line);
}

.posture--warning {
  border-left-color: var(--warning-line);
}

.posture--info {
  border-left-color: var(--info-line);
}

.posture__headline {
  margin: 0 0 var(--space-1);
  font-weight: var(--weight-semibold);
}

.table caption {
  caption-side: top;
  text-align: left;
  color: var(--muted);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
}
