/* Proof bench + compose-confirm modal + verifier matrix —
 * see docs/UX.md §Proof Bench, §Disclosure, docs/STYLE-GUIDE.md §11.
 *
 * The compose-confirm modal uses the coral bounded-exception border
 * per STYLE-GUIDE §2 / §10.5 — considered disclosure is the one place
 * the bounded-exception border appears as primary chrome, not as
 * punctuation. */

.app-main:has(.proofs-hero) {
  max-inline-size: 1180px;
}

.proofs-hero {
  min-height: 100dvh;
  padding: var(--space-6) var(--space-6) var(--space-12);
  color: var(--color-text-body);
  display: grid;
  align-content: start;
}

.proofs-column {
  display: grid;
  width: min(100%, 1120px);
  margin-inline: auto;
  gap: var(--space-5);
  text-align: left;
}

.proofs-header {
  display: grid;
  gap: var(--space-3);
  max-width: 760px;
}

.proofs-header .hero-headline,
.proofs-header .hero-body {
  margin: 0;
}

/* Session-dev-key honesty banner. */
.proofs-notice {
  background: var(--color-accent-bounded-subtle);
  border-inline-start: 3px solid var(--color-accent-bounded);
  border-radius: var(--r-md);
  padding: var(--space-3) var(--space-4);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
  color: var(--color-text-bounded);
  margin: 0;
}

/* Issue-failure error — the red counterpart to `.proofs-notice` (which is
 * a coral bounded-exception *info* banner, never an error). The red edge
 * + tint carry the error identity; the message stays body-ink for full
 * legibility. */
.proofs-error {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border-inline-start: 3px solid var(--red-500);
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--red-500) 8%, transparent);
  color: var(--color-text-body);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  line-height: 1.5;
}

.proofs-card {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-5);
  background: var(--color-bg-elevated);
  border-radius: var(--r-lg);
  border: 1px solid var(--color-border-secondary);
}

.proofs-card-title {
  font-family: var(--font-display);
  font-size: 1.375rem;
  font-weight: 500;
  color: var(--color-text-heading);
  margin: 0;
}

.proofs-card-body {
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--color-text-body);
  margin: 0;
}

.proofs-empty {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  /* AA on the elevated `--mist` preview panel — see tokens.css. */
  color: var(--color-text-muted-on-elevated);
  padding: var(--space-4);
  border: 1px dashed var(--color-border-secondary);
  border-radius: var(--r-md);
  margin: 0;
}

.proofs-builder {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 0.85fr);
  gap: var(--space-4);
  align-items: start;
}

.proofs-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.proofs-panel,
.proofs-preview {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border-secondary);
  border-radius: var(--r-md);
}

.proofs-panel h2,
.proofs-preview h2 {
  font-family: var(--font-display);
  font-size: 1.5rem;
  line-height: 1.2;
  font-weight: 500;
  color: var(--color-text-heading);
  margin: 0;
}

/* The compound `h2.proofs-panel-eyebrow` selector keeps the issued-result
 * heading (a focusable <h2> carrying this class) on the overline role —
 * otherwise the generic `.proofs-preview h2` display rule above would win
 * by specificity and render it as a 1.5rem display heading. */
.proofs-panel-eyebrow,
h2.proofs-panel-eyebrow {
  font-family: var(--font-sans);
  font-size: 0.6875rem; /* §5.2 overline role */
  line-height: 1.3;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-primary-text);
  margin: 0;
}

.proofs-panel blockquote,
.proofs-preview blockquote {
  margin: 0;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-proof-inset);
  border-inline-start: 3px solid var(--color-primary-accent);
  border-radius: var(--r-md);
  color: var(--color-text-heading);
  font-family: var(--font-display);
  font-size: 1.125rem;
  line-height: 1.45;
  /* §5.4 — instrument-grade figures in the claim sentence's date/time. */
  font-variant-numeric: tabular-nums lining-nums;
}

.proofs-panel p,
.proofs-preview p {
  margin: 0;
}

.proofs-preview dt {
  font-family: var(--font-sans);
  font-size: 0.75rem;
  line-height: 1.3;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
  color: var(--color-text-muted);
}

.proofs-preview dd {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.4;
  font-weight: 500;
  color: var(--color-text-heading);
}

.proofs-preview {
  position: sticky;
  top: var(--space-6);
  align-self: start;
}

.proofs-optional {
  display: grid;
  gap: var(--space-3);
  padding: var(--space-4);
  /* §2 / §10.4 witness-flow card — the bounded-actor moment reads as
   * chrome (paper + 3px accent left edge), not a palette swap. Collapsed
   * by default; the chrome is identical open or closed. */
  background: var(--color-bg-surface);
  border: 1px solid var(--color-border-primary);
  border-inline-start: 3px solid var(--color-accent-bounded);
  border-radius: var(--r-lg);
}

.proofs-optional summary {
  color: var(--color-text-heading);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 500;
  line-height: 1.3;
}

/* §5.2 overline labelling the witness role on the witness-flow card. */
.proofs-optional-overline {
  display: block;
  margin-block-end: var(--space-1);
  font-family: var(--font-sans);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent-bounded);
}

/* Collapsed-summary sub-state hint so witness Pending / Corroborated status
 * is legible without expanding the witness <details>. */
.witness-summary-hint {
  margin-inline-start: var(--space-2);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted-on-elevated);
}

.proofs-optional p {
  color: var(--color-text-body);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
  margin: 0;
}

.proofs-optional[open] summary {
  margin-block-end: var(--space-1);
}

.proofs-action-row {
  display: grid;
  gap: var(--space-3);
  align-items: start;
}

.proofs-preview dl {
  display: grid;
  gap: var(--space-3);
  margin: 0;
}

.proofs-preview-row {
  display: grid;
  gap: var(--space-1);
}

.proofs-preview dd {
  margin: 0;
}

/* §10.4 proof-surface card — the issued result reads as a proof token
 * (paper + grain + --r-xl), distinct from the elevated --mist preview
 * panel. The nested ProofMatrix `.verify-card` is flattened *here only*
 * (scoped) so the surface is one cohesive card, without touching the
 * shared `.verify-card` the verifier relies on. */
.proofs-issued {
  display: grid;
  gap: var(--space-4);
  padding: var(--space-6);
  background: var(--color-bg-proof);
  border: 1px solid var(--color-border-proof);
  border-radius: var(--r-xl);
}

.proofs-issued .verify-card {
  background: transparent;
  border: 0;
  padding: 0;
}

/* Modal overlay + card. Considered-disclosure callout: coral
 * bounded-exception border (per STYLE-GUIDE §2 / §10.5) on a dark
 * scrim, centred. */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-6);
  background: rgba(14, 22, 20, 0.45); /* slate-950 @ 45% */
  z-index: 100;
}

.modal-card {
  position: relative; /* anchor for absolutely-positioned descendants */
  width: min(60ch, 100%);
  max-height: 90dvh;
  overflow-y: auto;
  background: var(--color-bg-page);
  border-inline-start: 3px solid var(--color-accent-bounded);
  border-radius: var(--r-lg);
  padding: var(--space-6);
  display: grid;
  gap: var(--space-4);
  box-shadow: 0 24px 64px -16px rgba(14, 22, 20, 0.35);
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 500;
  color: var(--color-text-bounded);
  margin: 0;
}

.modal-section {
  display: grid;
  gap: var(--space-2);
}

.modal-section-title {
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 500;
  color: var(--color-text-heading);
  margin: 0;
}

.modal-section p,
.modal-section ul {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.55;
  color: var(--color-text-body);
  margin: 0;
  padding-inline-start: var(--space-5);
}

.modal-section code {
  font-family: var(--font-mono);
  font-size: 0.875rem;
  background: var(--color-bg-elevated);
  padding: 0 var(--space-1);
  border-radius: var(--r-sm);
  color: var(--color-primary-text);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  justify-content: flex-end;
  margin-block-start: var(--space-2);
}

.modal-error {
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  color: var(--red-500);
  margin: 0;
}

/* Verifier matrix — every field on its own row, never aggregated. */
.matrix-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: var(--space-2);
  border-block-start: 1px solid var(--color-border-secondary);
  padding-block-start: var(--space-3);
}

.matrix-row {
  display: grid;
  grid-template-columns: 14ch minmax(0, 1fr);
  gap: var(--space-3);
  font-family: var(--font-sans);
  font-size: 0.9375rem;
  line-height: 1.5;
}

.matrix-label {
  /* AA on the elevated `.verify-card` (--mist) — see tokens.css. Shared
   * with the verify bundle; dark mode keeps the current value. */
  color: var(--color-text-muted-on-elevated);
  font-weight: 500;
}

.matrix-value {
  color: var(--color-text-heading);
  word-break: break-all;
  /* §5.4 — tabular figures for the validity window / range / hex rows. */
  font-variant-numeric: tabular-nums lining-nums;
}

.matrix-mono {
  font-family: var(--font-mono);
  font-size: 0.875rem;
}

@media (max-width: 760px) {
  .app-main:has(.proofs-hero) {
    max-inline-size: 640px;
  }
  .proofs-builder,
  .proofs-field-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .proofs-preview {
    position: static;
  }
}

@media (max-width: 480px) {
  .proofs-hero {
    padding: var(--space-5) var(--space-4) var(--space-8);
  }
  .modal-card {
    padding: var(--space-4);
  }
  .matrix-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
}

/* ---------------------------------------------------------------- */
/* §8.5 — the locus pulse, the signature motion.                    */
/*                                                                  */
/* Fires once when the user issues a proof: the beacon mark anchors */
/* the matrix head at icon-2xl (48px per §11.1) and its accent dot  */
/* scales 1.0 → 1.4 → 1.0 with a brightness lift over 300ms. The    */
/* ring does not move. animation-delay 120ms aligns with the §8.5   */
/* choreography window (the dot pulse runs 120–420ms; the dot       */
/* settles by 500ms). Reduced motion suppresses the keyframes;      */
/* the dot is drawn in its rest state on first paint.               */
/* ---------------------------------------------------------------- */

.matrix-beacon-anchor {
  display: grid;
  place-items: center;
  margin-block-end: var(--space-3);
  color: var(--color-text-heading);
}

.matrix-beacon-anchor svg {
  inline-size: 48px;
  block-size: 48px;
  display: block;
}

.matrix-beacon-anchor .beacon-dot {
  /* Transform-origin matches the dot's centre so the scale lift
   * stays anchored to the locus rather than drifting off-axis. */
  transform-origin: 12px 8.855px;
  transform-box: fill-box;
  animation: locus-pulse 300ms 120ms var(--ease-out) 1 forwards;
}

@keyframes locus-pulse {
  0%   { transform: scale(1.0); filter: brightness(1.0); }
  50%  { transform: scale(1.4); filter: brightness(1.15); }
  100% { transform: scale(1.0); filter: brightness(1.0); }
}

@media (prefers-reduced-motion: reduce) {
  .matrix-beacon-anchor .beacon-dot {
    animation: none;
  }
}

.disclosure-chip {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--space-2);
  border: 1px solid var(--color-border-secondary);
  border-radius: var(--r-full);
  background: var(--color-bg-surface);
  color: var(--color-text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0;
  text-transform: lowercase;
}
