/* ─────────────────────────────────────────────────────────────────
   sign-cli web demo — minimal, modern, scroll-driven.

   Layout: single-column container, two-column ("step") sections that
   stack on mobile. Theme via CSS custom properties, with a
   prefers-color-scheme: dark fallback that flips the surface palette.
   ───────────────────────────────────────────────────────────────── */

:root {
  --bg: #fcfcfd;
  --surface: #ffffff;
  --surface-2: #f7f7f9;
  --surface-3: #f0f1f4;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #0b0d12;
  --text-muted: #5b6472;
  --text-faint: #8a93a3;
  --accent: #2f6f4f;          /* deep emerald, less "stripe-blue" */
  --accent-fg: #ffffff;
  --accent-soft: #e6f1eb;
  --warn: #b45309;
  --warn-soft: #fff5e0;
  --error: #b91c1c;
  --error-soft: #fee2e2;
  --ok: #166534;
  --code-bg: #0f172a;
  --code-fg: #e6e7eb;
  --shadow: 0 1px 2px rgba(11, 13, 18, 0.04), 0 8px 24px rgba(11, 13, 18, 0.04);
  --radius: 10px;
  --radius-sm: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1015;
    --surface: #14181f;
    --surface-2: #1a1f28;
    --surface-3: #232a35;
    --border: #2a313c;
    --border-strong: #394250;
    --text: #ecedf0;
    --text-muted: #a4abb8;
    --text-faint: #6c7484;
    --accent: #5fb98b;
    --accent-fg: #07140d;
    --accent-soft: #16291f;
    --warn: #f0b35e;
    --warn-soft: #2a200c;
    --error: #f87171;
    --error-soft: #2a1414;
    --ok: #4ade80;
    --code-bg: #0a0d12;
    --code-fg: #e6e7eb;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

* { box-sizing: border-box; }

[x-cloak] { display: none !important; }

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

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    system-ui, "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

code, pre, .mono {
  font-family: ui-monospace, "JetBrains Mono", "Menlo", "SF Mono",
    "Source Code Pro", monospace;
  font-size: 0.92em;
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Hero ─────────────────────────────────────────────────────── */
.hero {
  padding: 4.5rem 0 3rem;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(ellipse at 70% 0%, var(--accent-soft) 0%, transparent 55%),
    var(--bg);
}
.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
  font-weight: 600;
}
.hero h1 {
  font-size: clamp(2rem, 4.5vw, 3.25rem);
  line-height: 1.1;
  margin: 0 0 1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  max-width: 22ch;
}
.hero h1 .accent { color: var(--accent); }
.lede {
  font-size: 1.1rem;
  color: var(--text-muted);
  max-width: 60ch;
  margin: 0 0 1.75rem;
}
.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.hero-meta {
  margin-top: 2rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.dot {
  display: inline-block;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  flex: none;
}
.dot-amber { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }

/* ── Buttons ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border-color: var(--accent);
}
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); text-decoration: none; }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-2);
  text-decoration: none;
}
.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

/* ── Step sections (narration + stage) ───────────────────────── */
.step {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 3rem;
  padding: 4rem 0;
  border-bottom: 1px solid var(--border);
}
.step:last-of-type { border-bottom: none; }
.step-narration { padding-top: 0.25rem; }
.step-num {
  font-family: ui-monospace, monospace;
  color: var(--text-faint);
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  margin: 0 0 0.5rem;
}
.step-narration h2 {
  font-size: 1.6rem;
  margin: 0 0 1rem;
  letter-spacing: -0.01em;
  font-weight: 650;
}
.step-narration p {
  color: var(--text-muted);
  margin: 0 0 1rem;
  max-width: 38ch;
}
.step-narration code {
  background: var(--surface-3);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
  color: var(--text);
}

/* ── Panel (live API stage) ──────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  gap: 0.75rem;
}
.panel-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
  color: var(--text);
  min-width: 0;
}
.panel-title code {
  background: transparent;
  padding: 0;
  color: var(--text);
}
.method {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-muted);
}
.method-post {
  background: var(--accent-soft);
  color: var(--accent);
}
@media (prefers-color-scheme: dark) {
  .method-post { background: var(--accent-soft); color: var(--accent); }
}
.panel-body {
  padding: 1.25rem;
}
.empty {
  color: var(--text-faint);
  margin: 0;
  font-size: 0.95rem;
}
.error-banner {
  margin: 0;
  padding: 0.65rem 0.85rem;
  background: var(--error-soft);
  color: var(--error);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}

/* ── Inbox cards ─────────────────────────────────────────────── */
.inbox-list {
  display: flex;
  flex-direction: column;
}
.inbox-card {
  appearance: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  text-align: left;
  padding: 1rem 1.25rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font: inherit;
  color: inherit;
  transition: background 120ms ease;
}
.inbox-card:last-child { border-bottom: none; }
.inbox-card:hover { background: var(--surface-2); }
.inbox-card.is-active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}
.inbox-card-main { min-width: 0; flex: 1; }
.inbox-card-title {
  margin: 0 0 0.25rem;
  font-weight: 550;
  font-size: 0.98rem;
}
.inbox-card-id {
  margin: 0;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inbox-card-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex: none;
}
.meta-count {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── Status pills ────────────────────────────────────────────── */
.status-pill {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: lowercase;
  background: var(--surface-3);
  color: var(--text-muted);
  white-space: nowrap;
}
.status-sent     { background: var(--surface-3);  color: var(--text-muted); }
.status-pending  { background: var(--surface-3);  color: var(--text-muted); }
.status-signed   { background: var(--accent-soft); color: var(--accent); }
.status-completed{ background: var(--accent-soft); color: var(--accent); }
.status-declined { background: var(--error-soft); color: var(--error); }
.status-canceled { background: var(--error-soft); color: var(--error); }

/* ── Snapshot pretty view ────────────────────────────────────── */
.snapshot-header {
  padding: 1.25rem 1.25rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.snapshot-header h3 {
  margin: 0 0 0.25rem;
  font-size: 1.15rem;
  font-weight: 600;
}
.snapshot-id {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  color: var(--text-faint);
  margin: 0 0 0.6rem;
  word-break: break-all;
}
.snapshot-tags {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
}
.muted { color: var(--text-muted); }

.snapshot-body {
  padding: 1rem 1.25rem 1.25rem;
}
.snapshot-body h4 {
  margin: 0 0 0.5rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 600;
}
.signer-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.signer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  gap: 1rem;
}
.signer-email {
  margin: 0;
  font-weight: 500;
  font-size: 0.92rem;
  word-break: break-all;
}
.signer-name {
  margin: 0;
  font-size: 0.82rem;
}
.raw-toggle {
  margin-top: 0.5rem;
  border-top: 1px dashed var(--border);
  padding-top: 0.85rem;
}
.raw-toggle summary {
  cursor: pointer;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
  user-select: none;
}
.raw-toggle summary:hover { color: var(--text); }
.kv {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.4rem 1rem;
  margin: 0.85rem 0 0;
  font-size: 0.85rem;
}
.kv dt {
  color: var(--text-muted);
  font-weight: 500;
}
.kv dd { margin: 0; }
.kv code { font-size: 0.85em; background: var(--surface-3); padding: 0.05rem 0.3rem; border-radius: 3px; }

/* ── Panel footer + downloadable artifact ────────────────────── */
.panel-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.artifact {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1rem 1.25rem;
}
.artifact-text { min-width: 0; flex: 1; }
.artifact-title {
  margin: 0 0 0.2rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
}
.artifact-sub {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
  max-width: 60ch;
}
@media (max-width: 540px) {
  .artifact { flex-direction: column; align-items: flex-start; gap: 0.6rem; }
}

/* ── Raw JSON output ─────────────────────────────────────────── */
.json {
  background: var(--code-bg);
  color: var(--code-fg);
  margin: 0;
  padding: 1rem 1.25rem;
  overflow: auto;
  max-height: 32rem;
  font-size: 0.82rem;
  line-height: 1.5;
}
.json code { background: transparent; padding: 0; color: inherit; }

/* ── Audit results ───────────────────────────────────────────── */
.audit-summary {
  padding: 1.25rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.audit-summary.is-ok .audit-headline { color: var(--ok); }
.audit-summary.is-bad .audit-headline { color: var(--error); }
.audit-headline {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 600;
}
.audit-stats {
  margin: 0;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.audit-results {
  list-style: none;
  margin: 0;
  padding: 0;
}
.audit-row {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.audit-row:last-child { border-bottom: none; }
.audit-mark {
  font-weight: 700;
  font-size: 0.95rem;
}
.audit-row.ok .audit-mark { color: var(--ok); }
.audit-row.bad .audit-mark { color: var(--error); }
.audit-id {
  font-family: ui-monospace, monospace;
  font-size: 0.78rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}
.audit-meta {
  font-size: 0.78rem;
}

/* ── CTA ─────────────────────────────────────────────────────── */
.cta {
  padding: 4.5rem 0 3rem;
  text-align: center;
  border-top: 1px solid var(--border);
}
.cta h2 {
  font-size: 1.85rem;
  margin: 0 0 0.75rem;
  letter-spacing: -0.01em;
  font-weight: 650;
}
.cta p {
  color: var(--text-muted);
  max-width: 50ch;
  margin: 0 auto 2rem;
}
.install {
  max-width: 36rem;
  margin: 0 auto 2rem;
}
.install-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
  text-align: left;
}
.install-cmd {
  margin: 0;
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  text-align: left;
  overflow-x: auto;
}
.install-cmd code { background: transparent; padding: 0; color: inherit; }
.install-cmd code::before { content: "$ "; color: var(--text-faint); }
.cta-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Footer ──────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.footer p { margin: 0 0 0.5rem; max-width: 70ch; }
.footer code {
  background: var(--surface-3);
  padding: 0.05rem 0.35rem;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 820px) {
  .step {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding: 3rem 0;
  }
  .step-narration p { max-width: none; }
  .hero { padding: 3rem 0 2rem; }
  .hero h1 { max-width: none; }
  .container { padding: 0 1.25rem; }
}
