/* Universal Paper shared design language, v2 (2026-11-22). v2: light-weight sans headlines (both references use them), orbit motif.
 * Used by the Playground page and the developer explainer. Light theme first; dark mirrors it.
 * Fonts (Google Fonts):
 * https://fonts.googleapis.com/css2?family=Inter+Tight:wght@300;400;500&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500&family=Source+Serif+4:opsz,wght@8..60,400;8..60,600&display=swap
 * Source Serif 4 is only for rendered contract text ("paper"), never for headings.
 */
:root {
  color-scheme: light;
  --bg: #f7f5f0;          /* warm paper */
  --bg-2: #efece4;        /* inset band, alternating section */
  --surface: #fffdf9;     /* raised surface (editor, paper) */
  --ink: #15171b;         /* text */
  --ink-2: #4d525a;       /* secondary text */
  --ink-3: #868a91;       /* tertiary, captions, eyebrow */
  --rule: #e2ddd2;        /* hairlines */
  --rule-2: #cfc8b9;      /* stronger rule, input borders */
  --accent: #2f45c6;      /* ink blue, links, primary button, focus */
  --accent-ink: #ffffff;
  --accent-soft: #e6e9fb;
  --ok: #2c7a53;  --ok-soft: #e2f1e8;   /* verified */
  --bad: #cf3f2c; --bad-soft: #fbe6e2;  /* broken / tampered */
  --warn: #a86a12; --warn-soft: #f8eedb;
  --flip: #f6e3a8;        /* highlight behind changed hex digits */
  --shadow: 0 1px 2px rgba(21,23,27,.04), 0 8px 24px -12px rgba(21,23,27,.12);

  --f-display: "Inter Tight", "Inter", system-ui, sans-serif;   /* weight 300, tracking -0.035em */
  --f-paper: "Source Serif 4", Georgia, serif;
  --f-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;

  /* type scale (fluid) */
  --t-hero: clamp(2.6rem, 1.6rem + 4.2vw, 5rem);    /* Inter Tight 300, line-height 1.02, letter-spacing -0.035em */
  --t-h2: clamp(2rem, 1.4rem + 2.4vw, 3.2rem);       /* Inter Tight 300, line-height 1.08, letter-spacing -0.03em */
  --t-h3: 1.15rem;                                    /* Inter 600, line-height 1.3 */
  --t-lead: clamp(1.05rem, 1rem + 0.35vw, 1.25rem);   /* Inter 400, line-height 1.55, color --ink-2 */
  --t-body: 1rem;                                     /* line-height 1.6 */
  --t-small: 0.875rem;
  --t-eyebrow: 0.75rem;                               /* mono, uppercase, letter-spacing 0.12em, color --ink-3 */

  /* spacing (4px base) */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 24px; --s-6: 32px; --s-7: 48px; --s-8: 64px; --s-9: 96px; --s-10: 144px;
  --section-y: clamp(72px, 10vw, 144px);
  --gutter: max(16px, env(safe-area-inset-left), env(safe-area-inset-right));
  --maxw: 1180px;
  --measure: 62ch;

  --r-1: 6px; --r-2: 10px; --r-3: 16px; --r-pill: 999px;

  --ease: cubic-bezier(.2, .7, .2, 1);
  --d-fast: 160ms; --d-med: 420ms; --d-slow: 900ms;

  --header-h: 64px;
}
:root[data-theme="dark"] { color-scheme: dark;
  --bg: #0f1114; --bg-2: #15181c; --surface: #1a1d22; --ink: #f1efe9; --ink-2: #b3b6bc; --ink-3: #80848b;
  --rule: #262a30; --rule-2: #353a42; --accent: #8fa0ff; --accent-ink: #0f1114; --accent-soft: #1e2440;
  --ok: #7fd6a8; --ok-soft: #15291f; --bad: #ff8a78; --bad-soft: #2e1714; --warn: #f0b960; --warn-soft: #2b2112;
  --flip: #5a4a17; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -16px rgba(0,0,0,.6);
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { color-scheme: dark;
  --bg: #0f1114; --bg-2: #15181c; --surface: #1a1d22; --ink: #f1efe9; --ink-2: #b3b6bc; --ink-3: #80848b;
  --rule: #262a30; --rule-2: #353a42; --accent: #8fa0ff; --accent-ink: #0f1114; --accent-soft: #1e2440;
  --ok: #7fd6a8; --ok-soft: #15291f; --bad: #ff8a78; --bad-soft: #2e1714; --warn: #f0b960; --warn-soft: #2b2112;
  --flip: #5a4a17; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 32px -16px rgba(0,0,0,.6);
} }

/* ---- base */
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 var(--t-body)/1.6 var(--f-body); -webkit-font-smoothing: antialiased; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.section { padding: var(--section-y) 0; border-top: 1px solid var(--rule); }
.section.alt { background: var(--bg-2); }
.eyebrow { font: 500 var(--t-eyebrow)/1 var(--f-mono); text-transform: uppercase; letter-spacing: .12em; color: var(--ink-3); }
.display { font: 300 var(--t-hero)/1.02 var(--f-display); letter-spacing: -0.035em; margin: 0; text-wrap: balance; }
.h2 { font: 300 var(--t-h2)/1.08 var(--f-display); letter-spacing: -0.03em; margin: 0; text-wrap: balance; }
.display em, .h2 em { font-style: normal; color: var(--accent); }
/* stats: big light numbers in outlined pills (Commure) */
.stat { display: grid; gap: 4px; padding: 14px 22px; border: 1px solid var(--rule-2); border-radius: var(--r-pill); }
.stat b { font: 300 1.9rem/1 var(--f-display); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.stat span { font-size: var(--t-small); color: var(--ink-3); }
/* orbit motif: thin rings echoing the circular mark. Decorative, aria-hidden. */
.orbit { position: absolute; border: 1px solid var(--rule-2); border-radius: 50%; pointer-events: none; }
.orbit.dash { border-style: dashed; }
@media (prefers-reduced-motion: no-preference) { .orbit.spin { animation: orbit-spin 60s linear infinite; } }
@keyframes orbit-spin { to { transform: rotate(360deg); } }
.lead { font-size: var(--t-lead); line-height: 1.55; color: var(--ink-2); max-width: var(--measure); }
a { color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ---- header (same on both pages) */
.site-header { position: sticky; top: 0; z-index: 20; height: var(--header-h); background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-bottom: 1px solid var(--rule); }
.site-header .wrap { height: 100%; display: flex; align-items: center; gap: var(--s-5); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font: 600 1rem/1 var(--f-body); letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; background: currentColor; -webkit-mask: var(--logo) center/contain no-repeat; mask: var(--logo) center/contain no-repeat; }
/* set --logo: url(data:image/png;base64,...) of assets/universal-paper-mark-black-512.png (any opaque colour works as a mask) */
.site-nav { display: flex; gap: var(--s-5); margin-left: auto; font-size: var(--t-small); }
.site-nav a { color: var(--ink-2); text-decoration: none; }
.site-nav a:hover, .site-nav a[aria-current="true"] { color: var(--ink); }
.theme-toggle { width: 36px; height: 36px; border-radius: var(--r-pill); border: 1px solid var(--rule); background: transparent; color: var(--ink-2); display: grid; place-items: center; cursor: pointer; }
@media (max-width: 720px) { .site-nav { display: none; } .site-header .wrap { gap: var(--s-3); } .site-header .btn { margin-left: auto; } }

/* ---- buttons */
.btn { display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 0 16px; border-radius: var(--r-pill); border: 1px solid var(--rule-2); background: transparent; color: var(--ink); font: 500 var(--t-small)/1 var(--f-body); text-decoration: none; cursor: pointer; transition: background var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease); }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

/* ---- hashes */
.hash { font: 400 0.82rem/1.5 var(--f-mono); color: var(--ink-2); word-break: break-all; }
.hash .flip { background: var(--flip); color: var(--ink); border-radius: 2px; }
.badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: var(--r-pill); font: 500 0.75rem/1.4 var(--f-mono); background: var(--bg-2); color: var(--ink-2); }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }

/* ---- scrollytelling: sticky visual + scrolling steps
 * <section class="scrolly">
 *   <div class="scrolly-visual"><div class="scrolly-stage">…</div></div>
 *   <ol class="scrolly-steps"><li class="scrolly-step" data-step="0">…</li>…</ol>
 * </section>
 * JS: IntersectionObserver with rootMargin "-50% 0px -50% 0px" sets .is-active on the step and
 * data-step on .scrolly; the visual reads data-step. Reduced motion: every step shows its final state.
 */
.scrolly { display: grid; grid-template-columns: 56fr 44fr; gap: var(--s-8); align-items: start; }
.scrolly-visual { position: sticky; top: calc(var(--header-h) + var(--s-6)); height: calc(100vh - var(--header-h) - var(--s-8)); display: grid; place-items: center; }
.scrolly-stage { width: 100%; }
.scrolly-steps { list-style: none; margin: 0; padding: 30vh 0; display: grid; gap: 40vh; }
.scrolly-step { opacity: .32; transition: opacity var(--d-med) var(--ease); max-width: 42ch; }
.scrolly-step.is-active { opacity: 1; }
.scrolly-step h3 { font: 600 var(--t-h3)/1.3 var(--f-body); margin: var(--s-2) 0; }
.scrolly-step p { color: var(--ink-2); margin: 0; }
@media (max-width: 820px) {
  .scrolly { grid-template-columns: 1fr; gap: 0; }
  .scrolly-visual { top: var(--header-h); height: 42vh; z-index: 2; background: var(--bg); border-bottom: 1px solid var(--rule); padding: var(--s-3) 0; }
  .scrolly-steps { padding: 8vh 0 30vh; gap: 52vh; }
  .scrolly-step { background: color-mix(in srgb, var(--surface) 92%, transparent); border: 1px solid var(--rule); border-radius: var(--r-3); padding: var(--s-5); box-shadow: var(--shadow); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 1ms !important; animation-duration: 1ms !important; }
  .scrolly-step { opacity: 1; }
}

/* ---- reveal on scroll (one-shot) */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity var(--d-slow) var(--ease), transform var(--d-slow) var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; } }
