/*
 * stratt-landing — lab-notebook surface, AAA-contrast self-audit document.
 *
 * Adapted from apps/audit-viewer with two surface-specific extensions:
 *   1. .demo zone — paste-YAML/compute-Blake3 widget inside the demo event
 *   2. .install zone — copy-to-clipboard cmd block inside the install event
 *
 * Same canonical tokens (--bg, --fg, --hairline, --stamp, --accent,
 * --space-*, --font-sans, --font-mono, --border-radius-*, --state-focus).
 * Same constraints: status-plus-glyph, flat at rest, 75ch container ceiling
 * for prose, prose ≤65ch via per-element max-width, JS-off path is the
 * default reading path. The interactive widgets are progressive: the page
 * reads as a finished document with JS off.
 *
 * P2.3 typeset+layout pass: 5-step modular type scale (1.25× ratio),
 * letter-spacing+case as the structural microcopy lever (so weight 500 stays
 * load-bearing), inter-zone spacing rhythm via --space-xl, and a wider
 * container at ≥1280 / ≥1920 so tabular blocks breathe while prose stays at
 * its own measure.
 */

/* Type scale tokens (--t-meta / --t-body / --t-h2 / --t-h1 / --t-display,
   --lh-tight, --lh-meta) are declared in @stratt/design-system/tokens.css,
   loaded as public/tokens.css ahead of this sheet. No local redeclaration. */

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--line-height-normal);
  color: var(--fg);
  background: var(--bg);
}

body {
  min-height: 100vh;
}

code,
pre {
  font-family: var(--font-mono);
}

a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: none;
  box-shadow: var(--state-focus);
  border-radius: var(--border-radius-sm);
}

/* ── Page shell ───────────────────────────────────────────────────────── */

.audit {
  max-width: 75ch;
  margin: 0 auto;
  padding: var(--space-lg) var(--space-md) var(--space-xl);
  display: flex;
  flex-direction: column;
  gap: var(--space-xl);
}

@media (min-width: 48rem) {
  .audit {
    padding-block: var(--space-xl);
  }
}

@media (min-width: 80rem) {  /* ≥1280 — laptop+ */
  .audit {
    max-width: 85ch;
  }
}

@media (min-width: 120rem) { /* ≥1920 — desktop */
  .audit {
    max-width: 100ch;
  }
}

/* Structural microcopy — uppercase + tracking is the hierarchy lever for
   labels, captions, table headers. Lets weight 500 stay reserved for the
   handful of load-bearing emphases (h1, hash centerpiece, primary link). */
.events thead th,
.events caption,
.summary__head dt,
.crypto__label,
.hash__label,
.demo__row-label,
.demo__label {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 400;
  font-size: var(--t-meta);
  line-height: var(--lh-meta);
  opacity: 0.72;
}

/* ── Zone 1: provenance ───────────────────────────────────────────────── */

.provenance {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: var(--space-xs) var(--space-md);
  padding-bottom: var(--space-sm);
  border-bottom: 1px solid var(--hairline);
  font-size: var(--t-meta);
  line-height: var(--lh-meta);
  color: var(--fg);
}

.provenance code {
  font-size: 0.95em;
}

.provenance__issuer {
  white-space: nowrap;
}

/* ── Zone 2: verification stamp ───────────────────────────────────────── */

.stamp {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto auto;
  column-gap: var(--space-md);
  row-gap: var(--space-xs);
  align-items: start;
  padding: var(--space-md) var(--space-md);
  border: 1px solid var(--accent);
  border-radius: var(--border-radius-md);
  background: var(--stamp);
  page-break-inside: avoid;
  break-inside: avoid;
}

.stamp__glyph {
  grid-row: 1 / span 3;
  font-size: var(--t-display);
  line-height: 1;
  font-weight: 400;
  color: var(--accent);
}

.stamp__word {
  font-size: var(--t-h1);
  line-height: var(--lh-tight);
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  color: var(--accent);
}

.stamp__meaning {
  max-width: 60ch;
  font-size: var(--t-body);
  margin: 0;
}

.stamp__signer {
  margin: 0;
  font-size: var(--t-meta);
  line-height: var(--lh-meta);
}

.stamp__signer code {
  font-size: 0.95em;
}

.stamp__key {
  margin-left: 0.25em;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ── Zone 3: build fingerprint centerpiece ────────────────────────────── */

.hash {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  padding-block: var(--space-md);
  border-block: 1px solid var(--hairline);
  page-break-inside: avoid;
  break-inside: avoid;
}

.hash__label {
  margin: 0;
  /* Inherits structural-microcopy rules (uppercase, tracking, --t-meta). */
  color: var(--fg);
}

.hash__value {
  display: block;
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  background: var(--stamp);
  border: 1px solid var(--hairline);
  border-radius: var(--border-radius-sm);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--t-h2);
  font-weight: 500;
  line-height: var(--lh-meta);
  letter-spacing: 0.01em;
  word-break: break-all;
  overflow-wrap: anywhere;
  user-select: all;
  cursor: text;
}

.hash__value:focus-visible {
  outline: none;
  box-shadow: var(--state-focus);
}

.hash__hint {
  margin: 0;
  max-width: 65ch;
  font-size: var(--t-body);
  line-height: var(--line-height-normal);
}

.hash__hint code {
  font-size: 0.95em;
}

/* ── Zone 4: summary ──────────────────────────────────────────────────── */

.summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.summary__head {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-sm) var(--space-md);
  margin: 0;
  padding: var(--space-sm) 0;
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
  page-break-inside: avoid;
  break-inside: avoid;
}

@media (min-width: 36rem) {
  .summary__head {
    grid-template-columns: 1fr 1fr;
  }
}

.summary__head > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  min-width: 0;
}

.summary__head dt {
  /* Inherits structural-microcopy rules. */
  color: var(--fg);
}

.summary__head dd {
  margin: 0;
  font-size: var(--t-body);
  max-width: 60ch;
  overflow-wrap: break-word;
}

/* ── Events table ─────────────────────────────────────────────────────── */

.events {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--t-body);
  table-layout: auto;
}

.events caption {
  /* Inherits structural-microcopy rules. */
  text-align: left;
  padding-bottom: var(--space-xs);
}

.events thead th {
  /* Inherits structural-microcopy rules. */
  text-align: left;
  padding: var(--space-xs) var(--space-sm) var(--space-xs) 0;
  border-bottom: 1px solid var(--hairline);
}

.events tbody td {
  padding: var(--space-sm) var(--space-sm) var(--space-sm) 0;
  border-bottom: 1px solid var(--hairline);
  vertical-align: top;
}

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

.events td:last-child,
.events th:last-child {
  padding-right: 0;
}

.events code {
  font-size: 0.875em;
}

.chip {
  font-size: var(--t-meta);
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0.72;
}

.event__desc {
  margin: 0 0 var(--space-xs);
  max-width: 55ch;
}

.event__action {
  margin: var(--space-xs) 0 0;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-xs) var(--space-sm);
}

.event__link {
  font-weight: 500;
}

.event__token {
  font-size: 0.875em;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.event__meta {
  font-size: var(--t-meta);
  line-height: var(--lh-meta);
  opacity: 0.72;
}

.event__muted {
  font-size: var(--t-body);
  opacity: 0.72;
}

.fingerprint {
  display: inline-block;
  max-width: 22ch;
  font-size: 0.85em;
  font-feature-settings: "tnum" 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
  opacity: 0.72;
}

.fingerprint--none {
  font-size: var(--t-body);
  opacity: 0.4;
}

/* ── Demo widget (single input → canonical JSON → live Blake3) ────────── */

.demo {
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.demo__source {
  margin: 0 0 var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--hairline);
  border-radius: var(--border-radius-sm);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: var(--t-meta);
  line-height: var(--line-height-normal);
  white-space: pre;
  overflow-x: auto;
}

.demo__source [id="demo-slug"] {
  color: var(--accent);
}

.demo__label {
  /* Inherits structural-microcopy rules; .demo__label is the visual <label>
     tied to the input, not a heading — keep it at meta scale. */
}

.demo__input {
  width: 100%;
  max-width: 32ch;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--hairline);
  border-radius: var(--border-radius-sm);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--t-body);
  line-height: var(--lh-meta);
}

.demo__input:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--state-focus);
}

.demo__hint {
  margin: 0;
  font-size: var(--t-meta);
  line-height: var(--line-height-normal);
  max-width: 65ch;
  opacity: 0.85;
}

.demo__hint code {
  font-size: 0.95em;
}

.demo__row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: var(--space-xs) var(--space-sm);
  margin: var(--space-xs) 0 0;
  font-size: var(--t-meta);
}

.demo__row-label {
  /* Inherits structural-microcopy rules. */
  min-width: 7.5em;
}

.demo__expected,
.demo__output {
  flex: 1 1 32ch;
  min-width: 0;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--hairline);
  border-radius: var(--border-radius-sm);
  background: var(--stamp);
  font-family: var(--font-mono);
  font-size: var(--t-meta);
  word-break: break-all;
  overflow-wrap: anywhere;
}

.demo__output[data-state="match"] {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 500;
}

.demo__output[data-state="mismatch"] {
  border-style: dashed;
  border-color: var(--fg);
}

.demo__output[data-state="error"] {
  border-style: dashed;
  border-color: var(--fg);
  background: var(--bg);
  color: var(--fg);
  font-style: italic;
  opacity: 0.7;
}

.demo__error {
  margin: var(--space-xs) 0 0;
  padding: 0.25rem 0.5rem;
  border-left: none;
  border: 1px dashed var(--fg);
  border-radius: var(--border-radius-sm);
  background: var(--bg);
  font-family: var(--font-mono);
  font-size: var(--t-meta);
  color: var(--fg);
}

/* ── Install widget ───────────────────────────────────────────────────── */

.install {
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.install__cmd {
  margin: 0;
  padding: var(--space-sm) var(--space-md);
  border: 1px solid var(--hairline);
  border-radius: var(--border-radius-sm);
  background: var(--stamp);
  font-family: var(--font-mono);
  font-size: var(--t-body);
  user-select: all;
  cursor: text;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.install__copy {
  align-self: flex-start;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: var(--t-meta);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.install__hint {
  margin: 0;
  font-size: var(--t-meta);
  line-height: var(--line-height-normal);
  max-width: 65ch;
  opacity: 0.85;
}

.install__hint code {
  font-size: 0.95em;
}

/* ── Cryptographic detail ─────────────────────────────────────────────── */

.crypto {
  border-top: 1px solid var(--hairline);
  padding-top: var(--space-sm);
}

.crypto details {
  font-size: var(--t-body);
}

.crypto summary {
  cursor: pointer;
  font-weight: 400;
  padding: var(--space-xs) 0;
  list-style-position: outside;
}

.crypto__body {
  padding-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.crypto__label {
  /* Inherits structural-microcopy rules. */
  margin: var(--space-sm) 0 0;
}

.crypto__label:first-child {
  margin-top: 0;
}

.crypto__token,
.crypto__mono {
  margin: 0;
  padding: var(--space-sm);
  border: 1px solid var(--hairline);
  border-radius: var(--border-radius-sm);
  background: var(--bg);
  font-size: var(--t-meta);
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.crypto__copy {
  align-self: flex-start;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-size: var(--t-meta);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.crypto__prose {
  margin: 0;
  max-width: 65ch;
  font-size: var(--t-body);
}

/* ── Footer cite ──────────────────────────────────────────────────────── */

.cite {
  border-top: 1px solid var(--hairline);
  padding-top: var(--space-sm);
  font-size: var(--t-meta);
  color: var(--fg);
  opacity: 0.85;
}

.cite p {
  margin: 0;
}

.cite code {
  overflow-wrap: anywhere;
}

.cite__commit {
  color: inherit;
}

/* ── Print ────────────────────────────────────────────────────────────── */

@page {
  margin: 0.75in;
}

@media print {
  html {
    font-size: 11pt;
  }

  .audit {
    max-width: none;
    padding: 0;
    gap: 1rem;
  }

  a {
    color: var(--fg);
    text-decoration: none;
  }

  .crypto details > summary {
    display: none;
  }

  .crypto details > .crypto__body {
    display: flex !important;
    padding-top: 0;
  }

  .crypto__copy,
  .install__copy {
    display: none;
  }

  .stamp,
  .hash,
  .summary__head,
  .events tr,
  .crypto,
  .cite {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .hash__value {
    background: transparent;
    border-color: var(--fg);
    padding-inline: 0;
    font-size: var(--t-h2);
  }

  /* Replace the screen-only 14…6 stub with the full 64-hex from `title` so
     paper copies carry the canonical fingerprint for every ledger event. */
  .fingerprint {
    max-width: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    background: transparent;
    padding: 0;
    font-size: 0;
  }

  .fingerprint::before {
    content: attr(title);
    font-size: var(--t-meta);
    font-family: var(--font-mono);
    word-break: break-all;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
    animation: none !important;
  }
}
