/* ============================================================
   x402ledger.ai — design system v4.1: "Ledger Green"
   Coinbase-language: white surfaces, confident grotesque,
   ledger-green accent, pill buttons, soft grey panels,
   rounded product cards — with accounting DNA intact:
   evidence chips, double-rule totals, balanced registers.
   ============================================================ */

:root {
  --bg: #ffffff;
  --panel: #f5f6f8;        /* raised sections / soft cards */
  --panel-2: #eef0f3;      /* deeper grey */
  --ink: #0a0b0d;          /* Coinbase near-black */
  --dim: #5b616e;          /* secondary text */
  --faint: #8a919e;        /* captions */
  --line: #e4e7eb;
  --line-strong: #d0d5dd;
  --brand: #0a8754;         /* ledger green */
  --brand-deep: #076b42;
  --brand-soft: #e7f4ee;
  --green: #098551;        /* balanced / protocol-confirmed */
  --green-soft: #e6f4ec;
  --cyan: #0e7e8f;
  --cyan-soft: #e3f3f5;
  --slate: #47548c;
  --slate-soft: #eaedf7;
  --grey: #5b616e;
  --grey-soft: #eef0f3;
  --amber: #9a6003;        /* unresolved */
  --amber-soft: #fbf0dc;
  --sans: 'Hanken Grotesk', 'Helvetica Neue', sans-serif;
  --mono: 'Geist Mono', 'Consolas', monospace;
  --wrap: 1180px;
  --gutter: clamp(1.25rem, 4vw, 2.5rem);
  --nav-h: 4.5rem;
  --r-card: 20px;
  --r-pill: 100px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html {
  scroll-behavior: smooth;
  color-scheme: light;
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
/* horizontal scroll containers (mobile register cards) get a slim bar; the page keeps the native scrollbar */
.artifact { scrollbar-width: thin; }

body {
  font-family: var(--sans);
  font-weight: 400;
  font-size: 1.0625rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* clean canvas; whisper of green at the hero horizon */
.atmosphere { position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background: radial-gradient(1200px 420px at 60% -14%, rgba(10, 135, 84, 0.05), transparent 62%);
}

::selection { background: var(--brand); color: #fff; }

a { color: inherit; text-decoration: none; }
p a, li a { color: var(--brand); transition: color .15s; }
p a:hover, li a:hover { color: var(--brand-deep); text-decoration: underline; }

img, svg { max-width: 100%; display: block; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------- typography ---------- */
h1, h2, h3, .display { font-family: var(--sans); font-weight: 600; letter-spacing: -0.028em; text-wrap: balance; }
h1 em, h2 em, h3 em, .display em, .q em { font-style: normal; color: var(--brand); }

.display { font-size: clamp(2.7rem, 5.6vw, 4.9rem); line-height: 1.03; }
h2 { font-size: clamp(1.95rem, 3.6vw, 3rem); line-height: 1.07; }
h3 { font-size: clamp(1.22rem, 1.9vw, 1.45rem); line-height: 1.25; letter-spacing: -0.015em; }

.lede { font-size: clamp(1.1rem, 1.6vw, 1.3rem); color: var(--dim); line-height: 1.55; font-weight: 400; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }

.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }

.kicker {
  display: inline-flex; align-items: center; gap: 0.6rem;
  font-family: var(--sans); font-size: 0.85rem; font-weight: 600;
  letter-spacing: 0.01em; color: var(--brand);
}
.kicker .idx { font-family: var(--mono); font-size: 0.7rem; color: var(--faint); font-weight: 500; }

/* ---------- evidence chips: tinted pills ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-family: var(--mono); font-size: 0.62rem; font-weight: 500;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.32rem 0.7rem; border-radius: var(--r-pill); white-space: nowrap;
}
.chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip--protocol   { color: var(--green); background: var(--green-soft); }
.chip--pattern    { color: var(--cyan);  background: var(--cyan-soft); }
.chip--inferred   { color: var(--slate); background: var(--slate-soft); }
.chip--other      { color: var(--grey);  background: var(--grey-soft); }
.chip--unresolved { color: var(--amber); background: var(--amber-soft); }

/* ---------- buttons: pills ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
  font-family: var(--sans); font-size: 0.98rem; font-weight: 600;
  letter-spacing: -0.01em; padding: 0.85rem 1.7rem; border-radius: var(--r-pill);
  border: 1px solid transparent; cursor: pointer; transition: all .18s ease;
}
.btn--primary { background: var(--brand); color: #fff; }
.btn--primary:hover { background: var(--brand-deep); transform: translateY(-1px); box-shadow: 0 8px 24px rgba(10,135,84,.25); }
.btn--ghost { border-color: var(--line-strong); color: var(--ink); background: var(--bg); }
.btn--ghost:hover { border-color: var(--ink); }
.btn .arr { transition: transform .2s; }
.btn:hover .arr { transform: translateX(3px); }

/* ---------- nav ---------- */
.nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: color-mix(in srgb, #ffffff 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.nav-in { max-width: var(--wrap); margin: 0 auto; padding: 0 var(--gutter);
  height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 2rem; }

/* logo: green ledger tile + lowercase wordmark */
.logo { display: inline-flex; align-items: center; font-size: 1.28rem; line-height: 1; font-weight: 700; letter-spacing: -0.03em; }
.logo::before {
  content: ''; width: 30px; height: 30px; border-radius: 9px; flex: none; margin-right: 0.6rem;
  background: var(--brand) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3E%3Cg stroke='%23ffffff' stroke-linecap='round'%3E%3Cline x1='8' y1='10' x2='22' y2='10' stroke-width='2' opacity='.85'/%3E%3Cline x1='8' y1='15' x2='18' y2='15' stroke-width='2' opacity='.85'/%3E%3Cline x1='8' y1='20.2' x2='22' y2='20.2' stroke-width='2.2'/%3E%3Cline x1='8' y1='23.6' x2='22' y2='23.6' stroke-width='2.2'/%3E%3C/g%3E%3C/svg%3E") center/cover no-repeat;
}
.logo .x4 { color: var(--ink); }
.logo .lg { color: var(--brand); }

.nav-links { display: flex; align-items: center; gap: 1.9rem; }
.nav-links a:not(.btn) {
  font-family: var(--sans); font-size: 0.95rem; font-weight: 500;
  color: var(--ink); transition: color .15s;
}
.nav-links a:not(.btn):hover { color: var(--brand); }
.nav-links a[aria-current="page"] { color: var(--brand); font-weight: 600; }
.nav .btn { padding: 0.6rem 1.25rem; font-size: 0.9rem; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line-strong); border-radius: var(--r-pill);
  color: var(--ink); font-family: var(--sans); font-size: 0.88rem; font-weight: 600;
  padding: 0.5rem 1.1rem; cursor: pointer; }

@media (max-width: 880px) {
  .nav-toggle { display: block; }
  .nav-links {
    position: fixed; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: #fff; border-bottom: 1px solid var(--line);
    display: none; padding: 0.5rem 0 1rem; box-shadow: 0 24px 40px rgba(10,11,13,.08);
  }
  .nav-links.open { display: flex; }
  .nav-links a:not(.btn) { padding: 0.95rem var(--gutter); border-bottom: 1px solid var(--line); }
  .nav-links .btn { margin: 1rem var(--gutter) 0; }
}

/* ---------- sections ---------- */
main { padding-top: var(--nav-h); }
.section { padding: clamp(4.5rem, 9vw, 7.5rem) 0; position: relative; }
.section--raised { background: var(--panel); }

.rule { height: 1px; background: var(--line); max-width: var(--wrap); margin: 0 auto; }
.rule::after { content: none; }

.sec-head { max-width: 780px; margin-bottom: clamp(2.5rem, 5vw, 3.8rem); }
.sec-head .kicker { margin-bottom: 1rem; }
.sec-head h2 { margin-bottom: 1rem; }

.dbl { border-bottom: 3px double var(--line-strong); }

/* ---------- hero ---------- */
.hero { padding: clamp(3.8rem, 7vw, 6.5rem) 0 clamp(3.5rem, 6vw, 5.5rem); position: relative; }
.hero-grid { display: grid; grid-template-columns: 1.02fr 0.98fr; gap: clamp(2.5rem, 5vw, 4.5rem); align-items: center; }
.hero-grid > * { min-width: 0; }
@media (max-width: 980px) { .hero-grid { grid-template-columns: 1fr; } }
.hero .display { margin: 1.1rem 0 1.4rem; }
.hero .lede { max-width: 32rem; margin-bottom: 2.2rem; }
.hero-ctas { display: flex; gap: 0.9rem; flex-wrap: wrap; margin-bottom: 2.6rem; }
.hero-facts { display: flex; gap: clamp(1.5rem, 3vw, 2.75rem); flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 1.5rem; }
.fact .n { font-family: var(--mono); font-size: 1.18rem; font-weight: 500; color: var(--ink); display: block; }
.fact .l { font-size: 0.82rem; color: var(--faint); }

/* ---------- artifact: product card ---------- */
.artifact {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-card);
  box-shadow: 0 4px 12px rgba(10,11,13,.04), 0 24px 60px rgba(10,11,13,.10);
  overflow-x: auto; overflow-y: hidden; font-size: 0.8rem; position: relative;
}
@media (max-width: 980px) { .artifact .register { min-width: 480px; } }
.artifact-bar {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.85rem 1.15rem; border-bottom: 1px solid var(--line); background: var(--panel);
}
.artifact-bar .dots { display: flex; gap: 5px; }
.artifact-bar .dots i { width: 8px; height: 8px; border-radius: 50%; background: var(--line-strong); }
.artifact-bar .t { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--dim); }
.artifact-bar .st { margin-left: auto; }

.register { width: 100%; border-collapse: collapse; }
.register th {
  font-family: var(--mono); font-size: 0.6rem; font-weight: 500; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--faint); text-align: left;
  padding: 0.62rem 0.95rem; border-bottom: 1px solid var(--line);
}
.register td { padding: 0.66rem 0.95rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.register td.num, .register th.num { text-align: right; font-family: var(--mono); }
.register tr:hover td { background: #fafbfc; }
.register .cp { font-family: var(--mono); color: var(--dim); font-size: 0.72rem; }
.register .amt { color: var(--ink); font-size: 0.78rem; font-family: var(--mono); font-weight: 500; }
.register tfoot td { font-family: var(--mono); font-size: 0.75rem; color: var(--ink); border-bottom: none; border-top: 1px solid var(--line-strong); background: var(--panel); }
.register tfoot .total { border-bottom: 3px double var(--line-strong); font-weight: 600; }
.ok { color: var(--green); }
.tick { color: var(--brand); font-weight: 600; }

.rollfwd {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 1.1rem;
  padding: 0.85rem 1.15rem; font-family: var(--mono); font-size: 0.69rem; color: var(--dim);
  border-top: 1px solid var(--line); background: var(--panel);
}
.rollfwd b { color: var(--ink); font-weight: 600; }

/* ---------- cards ---------- */
.cards { display: grid; gap: clamp(0.9rem, 1.8vw, 1.25rem); }
.cards--3 { grid-template-columns: repeat(3, 1fr); }
.cards--2 { grid-template-columns: repeat(2, 1fr); }
.cards--4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 980px) { .cards--3, .cards--4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .cards--3, .cards--2, .cards--4 { grid-template-columns: 1fr; } }
.card {
  background: var(--panel); border-radius: var(--r-card);
  padding: clamp(1.6rem, 2.7vw, 2.2rem);
  transition: transform .18s ease, box-shadow .18s ease;
}
.section--raised .card { background: #fff; }
.card:hover { transform: translateY(-3px); box-shadow: 0 16px 40px rgba(10,11,13,.08); }
.card .ci {
  font-family: var(--mono); font-size: 0.62rem; color: var(--brand); letter-spacing: 0.12em;
  display: block; margin-bottom: 1.3rem; font-weight: 500;
}
.card h3 { margin-bottom: 0.6rem; }
.card p { font-size: 0.95rem; color: var(--dim); line-height: 1.58; }
.card .chip { margin-bottom: 1rem; }

/* ---------- statement ---------- */
.statement { max-width: 900px; }
.statement .q {
  font-family: var(--sans); font-weight: 600;
  font-size: clamp(1.6rem, 3.1vw, 2.5rem); line-height: 1.16; letter-spacing: -0.025em;
  margin: 1.1rem 0 1.5rem; text-wrap: balance;
}

/* ---------- charter ---------- */
.charter {
  border-radius: var(--r-card); padding: clamp(2rem, 4vw, 3.2rem);
  background: var(--ink); color: #fff; position: relative;
}
.charter::before {
  content: 'PERMANENT'; position: absolute; top: 1.4rem; right: 1.4rem;
  font-family: var(--mono); font-size: 0.6rem; font-weight: 500; letter-spacing: 0.18em;
  color: #9fd8bf; border: 1px solid rgba(159,216,191,.5); border-radius: var(--r-pill);
  padding: 0.35rem 0.75rem;
}
.charter h3 { font-size: clamp(1.5rem, 2.6vw, 2rem); margin-bottom: 1.2rem; color: #fff; }
.charter h3 em { color: #9fd8bf; }
.charter .never-list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem 2rem; margin: 1.4rem 0; }
@media (max-width: 720px) { .charter .never-list { grid-template-columns: 1fr; } }
.charter .never-list li {
  font-family: var(--mono); font-size: 0.82rem; color: #c6cbd4;
  display: flex; gap: 0.7rem; align-items: baseline;
}
.charter .never-list li::before { content: '\2A09'; color: #ff7a6b; font-size: 0.78rem; }
.charter .src { font-family: var(--mono); font-size: 0.65rem; color: #7d8590; letter-spacing: 0.08em; }
.charter p { color: #c6cbd4; }
.charter p.dim { color: #c6cbd4; }

/* ---------- steps ---------- */
.steps { counter-reset: step; display: grid; gap: 0; }
.step { counter-increment: step; position: relative; padding: 0 0 2.2rem 3.3rem; }
.step:last-child { padding-bottom: 0; }
.step::before {
  content: counter(step);
  position: absolute; left: 0; top: 0;
  width: 2.1rem; height: 2.1rem; display: flex; align-items: center; justify-content: center;
  font-family: var(--sans); font-size: 0.95rem; font-weight: 700; color: var(--brand);
  background: var(--brand-soft); border-radius: 50%;
}
.step:not(:last-child)::after {
  content: ''; position: absolute; left: 1.02rem; top: 2.4rem; bottom: 0.3rem; width: 2px;
  background: var(--line);
}
.step h3 { margin-bottom: 0.5rem; }
.step p { color: var(--dim); font-size: 0.97rem; max-width: 44rem; }

/* ---------- taxonomy table ---------- */
.tax-table { width: 100%; border-collapse: separate; border-spacing: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.tax-table th {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint); text-align: left; padding: 0.95rem 1.25rem; background: var(--panel);
  border-bottom: 1px solid var(--line);
}
.tax-table td { padding: 1.05rem 1.25rem; border-bottom: 1px solid var(--line); font-size: 0.95rem; color: var(--dim); vertical-align: top; }
.tax-table tr:last-child td { border-bottom: none; }
.tax-table td:first-child { white-space: nowrap; }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--line); background: var(--panel); margin-top: clamp(3rem, 6vw, 5rem); }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2.5rem; padding: clamp(3rem, 5vw, 4.2rem) 0 2.5rem; }
@media (max-width: 860px) { .foot-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .foot-grid { grid-template-columns: 1fr; } }
.foot-brand p { font-size: 0.92rem; color: var(--dim); max-width: 22rem; margin-top: 1.1rem; line-height: 1.6; }
.foot-col .h {
  font-family: var(--sans); font-size: 0.85rem; font-weight: 700; color: var(--ink); margin-bottom: 1.1rem;
}
.foot-col ul { list-style: none; display: grid; gap: 0.65rem; }
.foot-col a { font-size: 0.95rem; color: var(--dim); transition: color .15s; }
.foot-col a:hover { color: var(--brand); }
.foot-legal {
  display: flex; flex-wrap: wrap; gap: 1rem 2rem; justify-content: space-between; align-items: center;
  padding: 1.4rem 0 2rem; border-top: 1px solid var(--line);
  font-size: 0.8rem; color: var(--faint);
}
.foot-legal a { color: var(--faint); } .foot-legal a:hover { color: var(--brand); }

/* ---------- reveal motion (JS-gated: content always visible without JS) ---------- */
html.js .reveal { opacity: 0; transform: translateY(14px); transition: opacity .55s ease, transform .55s cubic-bezier(.2,.7,.2,1); }
html.js .reveal.is-in { opacity: 1; transform: none; }
html.js .reveal[data-d="1"] { transition-delay: .07s; }
html.js .reveal[data-d="2"] { transition-delay: .14s; }
html.js .reveal[data-d="3"] { transition-delay: .21s; }
html.js .reveal[data-d="4"] { transition-delay: .28s; }
@media (prefers-reduced-motion: reduce) {
  html.js .reveal { opacity: 1; transform: none; transition: none; }
}

html.js .is-in .chip { animation: pop .35s cubic-bezier(.2,.9,.3,1.3) backwards; }
html.js .is-in .register tr:nth-child(1) .chip { animation-delay: .25s; }
html.js .is-in .register tr:nth-child(2) .chip { animation-delay: .37s; }
html.js .is-in .register tr:nth-child(3) .chip { animation-delay: .49s; }
html.js .is-in .register tr:nth-child(4) .chip { animation-delay: .61s; }
html.js .is-in .register tr:nth-child(5) .chip { animation-delay: .73s; }
@keyframes pop { from { opacity: 0; transform: scale(1.25); } to { opacity: 1; transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { html.js .is-in .chip { animation: none; } }

/* ---------- page hero ---------- */
.page-hero { padding: clamp(3.2rem, 6vw, 5.2rem) 0 clamp(2.5rem, 5vw, 3.8rem); }
.page-hero h1 { font-size: clamp(2.4rem, 5vw, 4.1rem); line-height: 1.04; margin: 1.1rem 0 1.3rem; max-width: 900px; }
.page-hero .lede { max-width: 44rem; }

/* ---------- misc ---------- */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(2rem, 5vw, 4.5rem); align-items: start; }
.two-col > * { min-width: 0; }
@media (max-width: 860px) { .two-col { grid-template-columns: 1fr; } }

.skip-link { position: absolute; left: -9999px; top: 0; z-index: 300; background: var(--brand); color: #fff;
  padding: 0.8rem 1.2rem; font-size: 0.9rem; font-weight: 600; border-radius: 0 0 8px 0; }
.skip-link:focus { left: 0; }

:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; border-radius: 4px; }
