/* Form H components. Tokens live in tokens.css; nothing here declares a raw
 * colour. Selectors are kept single-class and flat so nothing silently
 * out-specifies anything else. */

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

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

body {
  margin: 0;
  /* The page composites over a ground the host paints in its own theme, so
     this must be explicit or the page borrows the wrong background. */
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: var(--t-body);
  line-height: 1.55;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.page {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
  display: flex;
  flex-direction: column;
  gap: var(--gap-lg);
}

/* ------------------------------------------------------------ form-header */
/* Registry name and form number. A form number is not decoration: it tells
   the holder this is one instrument among several, which is true. */
.form-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--gap-sm) var(--gap-md);
  border-bottom: 3px solid var(--ink);
  padding-bottom: 0.45rem;
  font-family: var(--f-data);
  font-size: var(--t-xs);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--muted);
}
.form-header .registry { color: var(--ink); font-weight: 600; }

.page-title {
  font-family: var(--f-ui);
  font-size: var(--t-h2);
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.15;
  margin: 0;
  text-wrap: balance;
  max-width: 26ch;
}
.page-lede {
  margin: 0;
  max-width: 60ch;
  color: var(--muted);
  font-size: var(--t-lead);
}

.section-title {
  font-family: var(--f-ui);
  font-size: var(--t-h3);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
}

/* ----------------------------------------------------------------- notice */
/* Names a consequence. The critical variant is the only place the trustee
   reality is stated before the holder commits, so it leads the page. */
.notice {
  border: 1px solid var(--rule);
  border-left-width: 5px;
  padding: 0.8rem 1rem;
  max-width: 62ch;
  background: var(--fill);
}
.notice > .label {
  display: block;
  font-family: var(--f-data);
  font-size: var(--t-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-weight: 700;
  margin-bottom: 0.2rem;
  color: var(--muted);
}
.notice > p { margin: 0; font-size: var(--t-sub); }
.notice + .notice { margin-top: var(--gap-sm); }

.notice.critical { border-color: var(--sig-critical); background: var(--sig-critical-wash); }
.notice.critical > .label { color: var(--sig-critical); }
.notice.caution { border-color: var(--sig-pending); background: var(--sig-pending-wash); }
.notice.caution > .label { color: var(--sig-pending); }
.notice.affirm { border-color: var(--sig-verified); background: var(--sig-verified-wash); }
.notice.affirm > .label { color: var(--sig-verified); }

/* ------------------------------------------------- requirement / register */
/* One ruled grid. `.requirement` is the numbered onboarding step; `.record-row`
   is the same rule-work reused for registers of agents, passports and events
   in plan 02. They share a border box so a page can mix them. */
.register {
  border: 1px solid var(--ink);
  display: flex;
  flex-direction: column;
}

.requirement,
.record-row {
  display: grid;
  grid-template-columns: 2.75rem 1fr auto;
  align-items: center;
  gap: 0 var(--gap-md);
  border-bottom: 1px solid var(--rule);
  padding: 0;
}
.requirement:last-child,
.record-row:last-child { border-bottom: 0; }
.requirement.current { background: var(--fill); }
.requirement.satisfied .index { color: var(--sig-verified); }

.requirement > .index,
.record-row > .index {
  align-self: stretch;
  display: grid;
  place-items: center;
  border-right: 1px solid var(--rule);
  font-family: var(--f-data);
  font-size: var(--t-cap);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.requirement > .body,
.record-row > .body {
  padding: 0.7rem 0.25rem 0.7rem 0;
  min-width: 0;
}
.requirement .name,
.record-row .name {
  display: block;
  font-family: var(--f-ui);
  font-size: var(--t-sub);
  font-weight: 700;
}
/* The register's human content is the record voice. */
.record-row .name { font-family: var(--f-record); font-weight: 400; font-size: var(--t-body); }

.requirement .machine,
.record-row .machine {
  display: block;
  font-family: var(--f-data);
  font-size: var(--t-xs);
  color: var(--muted);
  letter-spacing: 0.03em;
  margin-top: 0.12rem;
  overflow-wrap: anywhere;
}

.requirement > .state,
.record-row > .state {
  align-self: stretch;
  display: grid;
  place-items: center;
  border-left: 1px solid var(--rule);
  padding: 0.4rem 0.7rem;
}

/* ------------------------------------------------------------ state-badge */
/* State is a word inside a border, not a colour alone. */
.state-badge {
  font-family: var(--f-data);
  font-size: var(--t-xs);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
  border: 1px solid currentColor;
  padding: 0.15rem 0.45rem;
  white-space: nowrap;
  text-align: center;
  color: var(--muted);
}
.state-badge.required { color: var(--sig-critical); }
.state-badge.pending { color: var(--sig-pending); }
.state-badge.verified { color: var(--sig-verified); }
.state-badge.revoked { color: var(--sig-critical); text-decoration: line-through; }
.state-badge.expired { color: var(--muted); text-decoration: line-through; }
.state-badge.waiting { color: var(--muted); border-style: dashed; }

/* -------------------------------------------------------------- data-page */
/* Label over value, from the passport data page. Used for holder and passport
   detail, where the point is that every value came from a verified source. */
.data-page {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: var(--gap-md) var(--gap-lg);
  border: 1px solid var(--rule);
  padding: 1rem;
  background: var(--fill);
}
.datum { display: flex; flex-direction: column; gap: 0.1rem; min-width: 0; }
.datum > .label {
  font-family: var(--f-data);
  font-size: var(--t-xs);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--muted);
}
.datum > .value {
  font-family: var(--f-record);
  font-size: var(--t-body);
  overflow-wrap: anywhere;
}
/* Identifiers and hashes are machine fact, not record prose. */
.datum > .value.machine { font-family: var(--f-data); font-size: var(--t-cap); }
.datum.unfilled > .value { color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------- code-plate */
.code-plate {
  display: flex;
  gap: var(--gap-md);
  align-items: center;
  flex-wrap: wrap;
  border: 1px solid var(--rule);
  padding: 0.9rem;
}
.code-plate .plate {
  /* The code must stay dark-on-white in both themes or it will not scan. */
  background: #ffffff;
  padding: 0.5rem;
  border: 1px solid var(--ink);
  flex: 0 0 auto;
}
.code-plate .plate img { display: block; width: min(11rem, 45vw); height: auto; }
.code-plate .caption {
  font-family: var(--f-data);
  font-size: var(--t-xs);
  line-height: 1.7;
  color: var(--muted);
  margin: 0;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.code-plate .caption strong { color: var(--ink); font-weight: 700; }

/* ---------------------------------------------------------- capture-frame */
.capture-frame {
  display: flex;
  flex-direction: column;
  gap: var(--gap-sm);
  align-items: flex-start;
}
.capture-frame video,
.capture-frame canvas {
  width: 100%;
  max-width: 20rem;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: var(--fill);
  border: 1px solid var(--ink);
  display: block;
}

/* ------------------------------------------------------------------ field */
.field { display: flex; flex-direction: column; gap: var(--gap-xs); max-width: 26rem; }
.field > label {
  font-family: var(--f-data);
  font-size: var(--t-xs);
  letter-spacing: var(--track-label);
  text-transform: uppercase;
  color: var(--muted);
}
.field > input {
  font-family: var(--f-record);
  font-size: var(--t-body);
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.55rem 0.65rem;
  width: 100%;
}
.field > input::placeholder { color: var(--muted); opacity: 1; }

/* ----------------------------------------------------------------- action */
.action-bar { display: flex; gap: var(--gap-sm); align-items: center; flex-wrap: wrap; }

.btn {
  font-family: var(--f-ui);
  font-size: var(--t-sub);
  font-weight: 700;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
  padding: 0.7rem 1.3rem;
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: var(--muted); border-color: var(--muted); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.secondary { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn.secondary:hover:not(:disabled) { background: var(--fill); border-color: var(--ink); }

.fineprint { font-size: var(--t-sm); color: var(--muted); margin: 0; max-width: 46ch; }

a { color: var(--ink); text-underline-offset: 0.15em; }
a:hover { color: var(--muted); }

/* ------------------------------------------------------------------- step */
.step { display: flex; flex-direction: column; gap: var(--gap-md); }
.step > .step-head { display: flex; flex-direction: column; gap: var(--gap-xs); }
.step-eyebrow {
  font-family: var(--f-data);
  font-size: var(--t-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ------------------------------------------------------------------- seal */
.seal { width: 4rem; height: 4rem; flex: 0 0 auto; color: var(--seal); }

/* ----------------------------------------------------------- chain-strip */
/* The append-only log is the registry's central integrity claim. Showing it
   on every page is cheap honesty. */
.chain-strip {
  border-top: 1px solid var(--rule);
  padding-top: 0.6rem;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap-sm) var(--gap-md);
  justify-content: space-between;
  font-family: var(--f-data);
  font-size: var(--t-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.chain-strip .intact { color: var(--sig-verified); }
.chain-strip .broken { color: var(--sig-critical); }

/* ---------------------------------------------------------------- message */
.message {
  border: 1px solid var(--rule);
  border-left-width: 5px;
  padding: 0.7rem 0.9rem;
  font-size: var(--t-sub);
  max-width: 62ch;
  background: var(--fill);
}
.message.error { border-color: var(--sig-critical); background: var(--sig-critical-wash); }
.message.ok { border-color: var(--sig-verified); background: var(--sig-verified-wash); }
.message.info { border-color: var(--rule); }

/* ------------------------------------------------------------- responsive */
@media (max-width: 40rem) {
  .page { padding: 1.25rem 1rem 3rem; gap: var(--gap-md); }
  .page-title { font-size: var(--t-h3); }
  .page-lede { font-size: var(--t-body); }

  /* The badge becomes a third line rather than squeezing the name. */
  .requirement,
  .record-row { grid-template-columns: 2.25rem 1fr; }
  .requirement > .state,
  .record-row > .state {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--rule);
    place-items: center start;
    padding: 0.35rem 0.6rem;
  }
  .action-bar .btn { flex: 1 1 auto; }
}

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