/*
Identity pages (SPEC-identity §2 "UI", node I5): /account, the one-time key and invite pages, /admin, /a/:id, /join.
Loaded after /styles.css on those pages only, so it reuses its tokens (--ink, --paper, --card, --rule, --phosphor,
--mono, --display, --radius, --shadow) and adds nothing to any other page. Same world as DESIGN.md: white cards on
hairlines, phosphor only as text on ink, light only, motion limited to state changes.
*/

.identity {
  padding-top: 36px;
}

.agent-onboarding pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.id-header h1 {
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.id-lede {
  font: 400 18px / 1.6 var(--serif);
  color: var(--ink);
}

.id-meta {
  margin: 6px 0;
  font-size: 13px;
  color: var(--muted);
}

.id-standing {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
}

/* ---- cards ----------------------------------------------------------------------------------------------------- */

.id-card {
  margin: 20px 0;
  padding: 18px 20px;
  background: var(--card);
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 28px -22px rgba(16, 20, 24, 0.22);
}

.id-card > h2 {
  margin: 0 0 8px;
  font-size: 21px;
}

.id-card > :last-child {
  margin-bottom: 0;
}

.id-card h3 {
  margin: 22px 0 8px;
  font: 600 12px var(--mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.id-notice {
  margin: 14px 0;
  padding: 10px 14px;
  border: 1px solid var(--rule-strong);
  border-left: 3px solid var(--ink);
  border-radius: 8px;
  background: var(--well);
  font-size: 15.5px;
}

.id-notice[data-state="quarantined"],
.id-notice[data-invite="malformed"] {
  border-left-color: var(--wait);
  background: var(--wait-fill);
}

.id-notice[data-state="banned"] {
  border-left-color: var(--bad);
  background: var(--bad-fill);
}

/* ---- badges ---------------------------------------------------------------------------------------------------- */

.id-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 8px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--well);
  color: var(--ink);
  font: 600 12px / 1.5 var(--mono);
  white-space: nowrap;
}

.id-badge[data-tier="T2"],
.id-badge[data-role="admin"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--phosphor);
}

.id-badge[data-role="agent"] {
  border-style: dashed;
}

.id-badge[data-state="active"],
.id-badge[data-state="open"] {
  border-color: var(--ok);
  color: var(--ok-ink);
  background: var(--ok-fill);
}

.id-badge[data-state="quarantined"] {
  border-color: var(--wait);
  color: var(--wait-ink);
  background: var(--wait-fill);
}

.id-badge[data-state="banned"],
.id-badge[data-state="revoked"] {
  border-color: var(--bad);
  color: var(--bad-ink);
  background: var(--bad-fill);
}

.id-badge[data-state="used"],
.id-badge[data-state="expired"] {
  color: var(--muted);
  background: var(--old-fill);
}

/* ---- facts, tables --------------------------------------------------------------------------------------------- */

.id-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 12px 0;
  font-size: 15px;
}

.id-facts dt {
  font: 500 12.5px / 1.9 var(--mono);
  color: var(--muted);
}

.id-facts dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.id-limits,
.id-table {
  font-size: 15px;
}

.id-limits th {
  font: 500 13px var(--mono);
  letter-spacing: 0;
  text-transform: none;
  color: var(--ink);
}

.id-limits td {
  text-align: right;
}

.id-scroll {
  overflow-x: auto;
}

.id-audit td {
  font-size: 12.5px;
  white-space: nowrap;
}

.id-audit td.id-details {
  white-space: normal;
  overflow-wrap: anywhere;
  min-width: 14em;
}

.id-list {
  margin: 0;
  padding-left: 20px;
}

.id-list li + li {
  margin-top: 6px;
}

/* ---- agents ---------------------------------------------------------------------------------------------------- */

.id-agents {
  margin: 10px 0 18px;
  padding: 0;
  list-style: none;
}

.id-agent {
  padding: 12px 0;
  border-top: 1px solid var(--rule);
}

.id-agent:last-child {
  border-bottom: 1px solid var(--rule);
}

.id-agent[data-state="revoked"] {
  opacity: 0.72;
}

.id-agent-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
}

.id-agent-name {
  font-weight: 600;
}

.id-agent-purpose {
  margin: 4px 0;
  font: 400 16px / 1.55 var(--serif);
}

.id-scopes {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  vertical-align: baseline;
}

.id-scope {
  padding: 0 6px;
  border: 1px solid var(--rule-strong);
  border-radius: 6px;
  color: var(--ink);
}

/* ---- forms and buttons ----------------------------------------------------------------------------------------- */

.id-form {
  display: grid;
  gap: 12px;
  margin: 14px 0 0;
}

.id-search {
  grid-template-columns: 1fr auto;
  align-items: end;
}

.id-field {
  display: grid;
  gap: 5px;
}

.id-field > span,
.id-fieldset legend {
  font: 500 12.5px / 1.4 var(--mono);
  color: var(--muted);
}

.id-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.id-field input,
.id-field textarea,
.id-field select,
.id-action input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: 400 15px / 1.4 var(--mono);
}

.id-field textarea {
  font-family: var(--serif);
  font-size: 16px;
  resize: vertical;
}

.id-field input:focus,
.id-field textarea:focus,
.id-field select:focus,
.id-action input:focus {
  outline: 2px solid var(--ink);
  outline-offset: 1px;
}

.id-fieldset {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
}

.id-check {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
  font-size: 15px;
}

.id-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.id-admin-actions {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.id-action {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
}

.id-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--ink);
  border-radius: 9px;
  background: var(--card);
  color: var(--ink);
  font: 600 13.5px var(--mono);
  text-decoration: none;
  cursor: pointer;
}

.id-button:hover {
  background: var(--well);
}

.id-button[data-tone="primary"] {
  background: var(--ink);
  color: var(--phosphor);
}

.id-button[data-tone="danger"] {
  border-color: var(--bad);
  color: var(--bad-ink);
}

.id-button[data-tone="danger"]:hover {
  background: var(--bad-fill);
}

.id-button:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

.id-signout {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.id-signout p {
  margin: 0;
}

/* ---- one-time secrets ------------------------------------------------------------------------------------------ */

.id-secret,
.id-example {
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: var(--radius);
  font: 500 14px / 1.55 var(--mono);
  overflow-x: auto;
}

.id-secret {
  background: var(--ink);
  color: var(--phosphor);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

.id-example {
  background: var(--well);
  border: 1px solid var(--rule);
  color: var(--ink);
}

/* ---- small screens --------------------------------------------------------------------------------------------- */

@media (max-width: 719px) {
  .identity {
    padding-top: 24px;
  }

  .id-card {
    padding: 14px;
  }

  .id-field-row,
  .id-action,
  .id-search {
    grid-template-columns: 1fr;
  }

  .id-facts {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .id-facts dd {
    margin-bottom: 8px;
  }
}
