/*
 * A specification you can operate.
 *
 * The page is near-monochrome and colour is never decoration: it means state, and only three
 * states exist — proved, waiting, refused. Everything else is ink, paper and one rule weight.
 *
 * Structure comes from a left rail rather than from boxes. Every region that has a status, a
 * sequence position or an author puts that mark in the gutter, so the same glyph in the same
 * column means the same thing on every page. Cards would have said it too, and said it five
 * different ways.
 */

:root {
  color-scheme: light dark;

  --paper: #ffffff;
  --sunk: #f1f2f5;
  --ink: #10141c;
  --muted: #5b6270;
  --rule: #e1e4e9;
  --rule-firm: #c3c8d1;

  /* State. The only saturated things on the page. */
  --proved: #0f6b46;
  --proved-ink: #0a4a30;
  --waiting: #8a5000;
  --refused: #a42317;

  /* Who produced a thing. Marks in the gutter, never washes. */
  --verifier: #2b3fc4;
  --browser: #0b6f68;
  --issuer: #8a3a72;

  --display: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  --sans: "IBM Plex Sans", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --rail: 2.25rem;
  --measure: 64ch;
  --gutter: clamp(1.25rem, 5vw, 4rem);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #12151c;
    --sunk: #0b0e14;
    --ink: #e8eaee;
    --muted: #99a1ae;
    --rule: #262b34;
    --rule-firm: #3a414d;

    --proved: #4fc98d;
    --proved-ink: #9fe6c4;
    --waiting: #e0a14e;
    --refused: #ff8e82;

    --verifier: #93a2ff;
    --browser: #4fc9bd;
    --issuer: #e992c9;
  }
}

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

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.6;
  font-variant-numeric: tabular-nums;
  -webkit-text-size-adjust: 100%;
}

a { color: inherit; text-decoration-color: var(--rule-firm); text-underline-offset: 3px; }
a:hover { text-decoration-color: currentColor; }

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

.page {
  max-width: 54rem;
  margin: 0 auto;
  padding: clamp(2rem, 7vw, 5rem) var(--gutter) 6rem;
}

/* ------------------------------------------------------------------ heading */

.masthead { margin-bottom: clamp(2.5rem, 6vw, 4rem); }

.masthead h1 {
  font-family: var(--display);
  font-size: clamp(2.1rem, 7vw, 3.4rem);
  font-weight: 700;
  font-variation-settings: "wdth" 96, "opsz" 40;
  line-height: 1.04;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  max-width: 20ch;
  text-wrap: balance;
}

.masthead p {
  margin: 0;
  max-width: var(--measure);
  font-size: 1.0625rem;
  color: var(--muted);
}

/* The role marker sits in the rail, as everything identifying does. */
.role {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: lowercase;
  margin-bottom: 1.25rem;
  color: var(--muted);
}
.role::before {
  content: "";
  display: inline-block;
  width: 1.5rem;
  height: 2px;
  margin-right: 0.6rem;
  transform: translateY(-0.25em);
  background: currentColor;
}
.role.as-verifier { color: var(--verifier); }
.role.as-issuer { color: var(--issuer); }

h2 {
  font-family: var(--display);
  font-size: 1.375rem;
  font-weight: 600;
  font-variation-settings: "wdth" 98;
  letter-spacing: -0.012em;
  margin: 0 0 0.5rem;
}
h3 { font-size: 1rem; font-weight: 600; margin: 0 0 0.4rem; letter-spacing: -0.005em; }

/* --------------------------------------------------------------------- cast */

.cast {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.75rem;
  margin: 2rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  color: var(--muted);
}
.cast li { display: flex; align-items: baseline; gap: 0.5rem; }
.cast b { font-weight: 600; color: var(--ink); }
.cast .swatch {
  width: 0.65rem; height: 2px; flex: none;
  transform: translateY(-0.28em);
}
.cast .swatch.verifier { background: var(--verifier); }
.cast .swatch.browser { background: var(--browser); }
.cast .swatch.issuer { background: var(--issuer); }

/* ------------------------------------------------------------------- layout */

.columns { display: block; margin-top: clamp(2rem, 5vw, 3rem); }
.columns > * + * { margin-top: clamp(2.5rem, 6vw, 4rem); }

/* Regions, not cards: a hairline above and room to breathe. */
.panel {
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.panel > h2 + p { margin: 0 0 1.75rem; }
.panel p { max-width: var(--measure); }
.panel > h2 + p, .panel > h3 + p { color: var(--muted); }

/* ---------------------------------------------------------------------- form */

.field { margin-bottom: 1.5rem; max-width: 34rem; }
.field label { display: block; font-size: 0.875rem; font-weight: 600; margin-bottom: 0.4rem; }
.field .hint {
  font-size: 0.875rem;
  color: var(--muted);
  margin: 0.5rem 0 0;
  max-width: var(--measure);
}

input[type="email"], input[type="password"], input[type="text"] {
  width: 100%;
  font: inherit;
  padding: 0.65rem 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-bottom: 2px solid var(--rule-firm);
  border-radius: 0;
}
input[type="email"]:focus,
input[type="password"]:focus,
input[type="text"]:focus {
  outline: none;
  border-bottom-color: var(--verifier);
}
input::placeholder { color: var(--muted); opacity: 0.7; }

button, .button {
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  display: inline-block;
  padding: 0.6rem 1.25rem;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { background: transparent; color: var(--ink); }
button.quiet, .button.quiet {
  background: transparent;
  color: var(--ink);
  border-color: var(--rule-firm);
  font-weight: 500;
}
button.quiet:hover, .button.quiet:hover { border-color: var(--ink); }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button.as-issuer, .button.as-issuer { background: var(--issuer); border-color: var(--issuer); color: var(--paper); }
button.as-issuer:hover, .button.as-issuer:hover { background: transparent; color: var(--issuer); }

/*
 * The hidden input, shown. Normally invisible, which is exactly why it is on screen: the
 * nonce below is the one this page issued, and the browser writes the token into this field
 * in the instant before the form submits.
 */
.token-slot {
  margin-top: 1.25rem;
  border-top: 1px dashed var(--rule-firm);
  padding: 0.75rem 0 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  color: var(--muted);
  max-width: 34rem;
}
.token-slot .slot-state { display: flex; align-items: center; gap: 0.55rem; }
.token-slot .nonce { margin: 0.45rem 0 0; word-break: break-all; }
.token-slot .nonce b { color: var(--ink); font-weight: 400; }

.pulse { width: 0.4rem; height: 0.4rem; flex: none; border-radius: 50%; background: var(--rule-firm); }
.working .pulse { background: var(--browser); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .working .pulse { animation: none; opacity: 1; } }

/* ------------------------------------------------------- rail-marked lists */

.checklist { list-style: none; margin: 0; padding: 0; }
.checklist li {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  gap: 0 0.5rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--rule);
  font-size: 0.9375rem;
}
.checklist li:first-child { border-top: 1px solid var(--rule); }
.checklist .mark {
  font-size: 0.875rem;
  line-height: 1.7;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.checklist .yes .mark { color: var(--proved); }
.checklist .no .mark { color: var(--waiting); }
.checklist small { display: block; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.checklist code { font-size: 0.875em; }

/* ------------------------------------------------------------------ outcome */

/*
 * The one place boldness is spent. Everything else on the page is quiet so that this reads
 * as the event it is.
 */
.outcome {
  margin: 0 0 clamp(2rem, 5vw, 3rem);
  padding: 0 0 0 calc(var(--rail) + 0.5rem);
  position: relative;
}
.outcome::before {
  content: "";
  position: absolute;
  left: 0; top: 0.5rem; bottom: 0.5rem;
  width: 3px;
  background: var(--rule-firm);
}
.outcome h2 { font-size: clamp(1.5rem, 4vw, 2rem); margin-bottom: 0.5rem; }
.outcome p { margin: 0; max-width: var(--measure); color: var(--muted); }
.outcome .address { font-family: var(--mono); font-size: 0.9375em; color: var(--ink); }

.outcome.verified::before { background: var(--proved); }
.outcome.verified h2 { color: var(--proved-ink); }
.outcome.rejected::before { background: var(--refused); }
.outcome.rejected h2 { color: var(--refused); }
.outcome.fallback::before { background: var(--waiting); }
.outcome.fallback h2 { color: var(--waiting); }

/*
 * The token drawn as what it is: an issuer-signed JWT, a tilde, then the browser's key
 * binding. The join is the whole structure of an SD-JWT presentation, so it is drawn.
 */
.presentation {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  font-family: var(--mono);
  font-size: 0.75rem;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
}
.presentation .seg { flex: 1 1 15rem; min-width: 0; padding: 0.7rem 0; }
.presentation .seg .who {
  display: block;
  font-family: var(--sans);
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
}
.presentation .seg.evt .who { color: var(--issuer); }
.presentation .seg.kb .who { color: var(--browser); }
.presentation .seg .bytes { display: block; color: var(--muted); word-break: break-all; }
.presentation .joint {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.5rem;
  color: var(--rule-firm);
  font-size: 1.125rem;
}

/* -------------------------------------------------------------------- trace */

/* Same treatment as a panel: a hairline above and room, so sections do not run together. */
.trace {
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.trace > h2 { font-size: clamp(1.375rem, 3.5vw, 1.75rem); }
.trace > p { margin: 0 0 2rem; color: var(--muted); max-width: var(--measure); }
.trace ol { list-style: none; margin: 0; padding: 0; counter-reset: step; }

/* Numbered because the checks are a sequence: each is meaningful only once the one above
   it has held. The number lives in the rail, like every other marker. */
.step { counter-increment: step; position: relative; padding-left: var(--rail); }
.step > details { border-bottom: 1px solid var(--rule); }
.step:first-child > details { border-top: 1px solid var(--rule); }
.step > details > summary {
  cursor: pointer;
  padding: 0.85rem 0;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 0 0.75rem;
  align-items: baseline;
  list-style: none;
}
.step > details > summary::-webkit-details-marker { display: none; }
.step > details > summary::marker { content: ""; }
.step > details > summary::before {
  content: counter(step);
  position: absolute;
  left: 0;
  font-family: var(--mono);
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
}
.step.passed > details > summary::before { content: "✓"; color: var(--proved); }
.step.failed > details > summary::before { content: "✕"; color: var(--refused); }
.step.skipped { opacity: 0.5; }

.step .verdict { font-size: 0.8125rem; font-weight: 400; color: var(--muted); }
.step.passed .verdict { color: var(--proved); }
.step.failed .verdict { color: var(--refused); }
.step .what { margin: 0 0 1rem; color: var(--muted); font-size: 0.9375rem; max-width: var(--measure); }
.step .step-body { padding: 0 0 1.25rem; }
.step .failure {
  margin: 0 0 1.25rem;
  padding: 0 0 0 0.9rem;
  border-left: 2px solid var(--refused);
  font-size: 0.9375rem;
  max-width: var(--measure);
}
.step .network {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  margin: 0 0 1rem;
  word-break: break-all;
}

/* Data belongs to whoever produced it, which the rail says with a hairline. */
.data { margin: 0 0 1rem; }
.data > h4 {
  margin: 0 0 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--muted);
}
.data pre {
  margin: 0;
  padding: 0.75rem 0.9rem;
  overflow-x: auto;
  background: var(--sunk);
  border-left: 2px solid var(--rule-firm);
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.data.from-verifier pre { border-left-color: var(--verifier); }
.data.from-browser pre { border-left-color: var(--browser); }
.data.from-issuer pre { border-left-color: var(--issuer); }

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

.notes {
  margin-top: clamp(2.5rem, 6vw, 4rem);
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.notes p, .notes li { max-width: var(--measure); color: var(--muted); font-size: 0.9375rem; }

code {
  font-family: var(--mono);
  font-size: 0.875em;
  background: var(--sunk);
  padding: 0.12em 0.34em;
  border-radius: 2px;
}

.dns, code.dns {
  display: block;
  background: var(--sunk);
  border-left: 2px solid var(--issuer);
  padding: 0.85rem 1rem;
  overflow-x: auto;
  white-space: pre;
  font-size: 0.8125rem;
  line-height: 1.7;
  border-radius: 0;
}

/* One notice treatment, weighted by what it is telling you. */
.inline-warn {
  padding: 0 0 0 1rem;
  border-left: 2px solid var(--waiting);
  margin: 0 0 1.75rem;
  font-size: 0.9375rem;
}
.inline-warn p { margin: 0.3rem 0; max-width: var(--measure); }
.inline-warn :first-child { margin-top: 0; }
.inline-warn :last-child { margin-bottom: 0; }

hr { border: 0; border-top: 1px solid var(--rule); margin: 2rem 0; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* An address is a local part at a domain you hold, so the form asks for the part that
   varies and states the rest. The two read as one field. */
.address-input {
  display: flex;
  align-items: baseline;
  gap: 0.15rem;
  border-bottom: 2px solid var(--rule-firm);
  max-width: 34rem;
}
.address-input:focus-within { border-bottom-color: var(--verifier); }
.address-input input[type="text"] { flex: 1 1 8rem; min-width: 0; border-bottom: 0; }
.address-input .at { font-family: var(--mono); font-size: 0.9375rem; color: var(--muted); }
.address-input select {
  font: inherit;
  font-family: var(--mono);
  font-size: 0.9375rem;
  color: var(--ink);
  background: transparent;
  border: 0;
  padding: 0.65rem 0;
  cursor: pointer;
}

/* The provider has answered and the next move is the person's. */
.token-slot.ready { border-top-style: solid; border-top-color: var(--proved); color: var(--proved); }
.token-slot.ready .pulse { background: var(--proved); animation: none; opacity: 1; }
.token-slot.ready .nonce { color: var(--muted); }

/* ---------------------------------------------------------------------------
   Passkeys

   A list of passkeys is only useful if a row says which of your devices or
   managers made it — "Passkey, added 3 March" tells nobody anything. Hence the
   provider icon and name, which come from the AAGUID and are a label and
   nothing more: platform authenticators do not attest them.
   --------------------------------------------------------------------------- */

.passkey-list { list-style: none; margin: 0.75rem 0 0; padding: 0; }

.passkey {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.7rem 0;
  border-top: 1px solid var(--rule);
}
.passkey:last-child { border-bottom: 1px solid var(--rule); }

.pk-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  object-fit: contain;
  background: var(--sunk);
}
.pk-icon-none {
  display: grid;
  place-items: center;
  font-size: 1rem;
  color: var(--muted);
}

.pk-detail { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 0.1rem; }
.pk-detail b { font-size: 0.9375rem; }

.pk-meta { font-size: 0.8125rem; color: var(--muted); }
/* The raw identifier, for anyone who wants to check the claim above it. */
.pk-aaguid { font-family: var(--mono); font-size: 0.75rem; overflow-wrap: anywhere; }

.pk-actions { flex: 0 0 auto; display: flex; gap: 0.4rem; }
.pk-actions button { padding: 0.3rem 0.7rem; font-size: 0.8125rem; }

/* The report after a registration or a sign-in: a definition list of what the
   authenticator actually said, in the same frame the trace steps use. */
#pk-result dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.25rem 1rem;
  margin: 0.6rem 0 0;
  font-size: 0.875rem;
}
#pk-result dt { color: var(--muted); }
#pk-result dd { margin: 0; overflow-wrap: anywhere; }
#pk-result p { margin: 0.4rem 0 0; max-width: var(--measure); font-size: 0.875rem; }

.hint.ok { color: var(--proved); }
.hint.warn { color: var(--waiting); }

@media (max-width: 34rem) {
  .passkey { flex-wrap: wrap; }
  .pk-actions { width: 100%; justify-content: flex-end; }
}

/* ---------------------------------------------------------------------------
   The capability readout.

   Which of these a browser has differs by platform in ways the documentation
   does not reliably state, and on a phone there is no console to go and look.
   So the page shows what the browser said about itself.
   --------------------------------------------------------------------------- */

.caps { margin: 1rem 0 1.5rem; }

.caps > summary {
  cursor: pointer;
  font-family: var(--sans);
  font-size: 0.8125rem;
  color: var(--muted);
  padding: 0.35rem 0;
}
.caps > summary:hover { color: var(--ink); }

.caps dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1rem;
  margin: 0.6rem 0 0;
  font-size: 0.8125rem;
  align-items: baseline;
}
.caps dt { font-family: var(--sans); font-weight: 500; white-space: nowrap; }
.caps dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.caps dd code { font-family: var(--mono); font-size: 0.9em; }

.cap-mark { display: inline-block; width: 1.1em; font-weight: 700; }
.cap-yes .cap-mark { color: var(--proved); }
.cap-no .cap-mark { color: var(--refused); }
.cap-unknown .cap-mark { color: var(--muted); }
.cap-no { color: var(--muted); }

.caps .hint { margin-top: 0.8rem; font-family: var(--mono); font-size: 0.75rem; }

@media (max-width: 30rem) {
  .caps dl { grid-template-columns: 1fr; gap: 0.1rem; }
  .caps dd { margin-bottom: 0.5rem; }
}

/* Google's button is drawn by Google's library, so it arrives with its own
   dimensions and sits on its own rather than in the button row. */
.or-provider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  margin: 1.25rem 0 1rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  max-width: var(--measure);
}
.or-provider::before, .or-provider::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--rule);
}
#gsi-button { min-height: 44px; }
