:root {
  --bg: #f3e9d8;
  --paper: #f9f3e8;
  --card: rgba(250, 245, 236, .94);
  --text: #1f1915;
  --text-2: rgba(31, 25, 21, .72);
  --text-3: rgba(31, 25, 21, .5);
  --line: rgba(31, 25, 21, .12);
  --line-2: rgba(31, 25, 21, .24);
  --accent: #7a2318;
  --accent-soft: rgba(122, 35, 24, .1);
  --indigo: #24305e;
  --ochre: #94620f;
  --fringe: #c4ad86;
  --radius: 6px;
  --gutter: clamp(16px, 4.5vw, 64px);
  --display: "DM Serif Display", Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: clip; }
html { scroll-behavior: smooth; background: var(--bg); }
body {
  margin: 0;
  background: transparent;
  color: var(--text);
  font: 400 16px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
h1, h2 { margin: 0; font-family: var(--display); font-weight: 400; }
.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; }
.nowrap { white-space: nowrap; }

/* the 3D layer; a still of the rug and a CSS floor underneath when WebGL is off */
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; opacity: 0; transition: opacity 1s ease-out; pointer-events: none; }
#bg.ready { opacity: 1; }
html.no-webgl body, html:not(.js) body {
  background: radial-gradient(1100px 700px at 72% 38%, rgba(122, 35, 24, .06), transparent 70%), var(--bg);
}
html.no-webgl .rug-stage, html:not(.js) .rug-stage {
  background: url("../assets/rug-still.jpg") 50% 50% / contain no-repeat;
  transition: transform .9s cubic-bezier(.55, 0, .25, 1), opacity .9s ease-in;
}
html.no-webgl .rug-stage.yanked { transform: translateX(55%) rotate(-5deg); opacity: 0; }

/* header */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 28px;
  height: 64px; padding: 0 var(--gutter);
  background: rgba(243, 233, 216, .96); border-bottom: 1px solid var(--line);
}
.mark { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font: 400 23px/1 var(--display); letter-spacing: -.01em; }
.nav { display: flex; gap: 26px; margin-left: auto; }
.nav a { text-decoration: none; color: var(--text-2); font-size: 14px; transition: color .18s ease-out; }
.nav a:hover { color: var(--text); }
.top-actions { display: flex; gap: 8px; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: var(--radius);
  font: 500 15px/1 var(--sans); text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: opacity .18s ease-out, border-color .18s ease-out, color .18s ease-out, background-color .18s ease-out;
}
.btn-primary { background: var(--text); color: var(--paper); border: 1px solid var(--text); }
.btn-primary:hover { opacity: .88; }
.btn-accent { background: var(--text); color: var(--paper); border: 1px solid var(--text); min-width: 96px; }
.btn-accent:hover { opacity: .88; }
.btn-secondary { border: 1px solid var(--line-2); color: var(--text); background: transparent; }
.btn-secondary:hover { border-color: var(--text); }
.btn-icon { min-width: 48px; padding: 0; }
.btn-small { min-height: 40px; padding: 0 15px; font-size: 14px; }
.top-actions .btn-icon { min-height: 40px; min-width: 40px; }
.btn[aria-disabled="true"] { background: transparent; border: 1px solid var(--line-2); color: var(--text-2); cursor: default; opacity: 1; }
.link { color: var(--text-2); font-size: 13px; align-self: center; padding: 0 4px; }

/* hero */
.hero {
  display: grid; grid-template-columns: minmax(0, 540px) minmax(0, 1fr);
  align-items: center; gap: 24px 32px;
  min-height: calc(100vh - 64px); min-height: calc(100svh - 64px);
  padding: clamp(18px, 3vh, 36px) var(--gutter) clamp(18px, 3vh, 32px);
  scroll-margin-top: 64px;
  overflow-x: clip;
}
.hero-copy { min-width: 0; }
.kicker { margin: 0 0 12px; font: italic 400 16px/1.2 var(--display); color: var(--text-2); }
h1 { font-size: clamp(52px, 6.1vw, 98px); line-height: .9; letter-spacing: -.018em; margin-bottom: 18px; }
h1 em { font-style: italic; color: var(--accent); }
.lede { margin: 0 0 18px; font-size: 16px; color: var(--text-2); max-width: 35em; }
.rug-stage { position: relative; align-self: stretch; min-height: 420px; }
.rug-inline { display: none; }

.token { display: flex; gap: 8px; align-items: stretch; }
.ca {
  display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0;
  min-height: 48px; padding: 0 14px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: var(--paper); color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.ca:not(.is-set) { cursor: default; }
.ca-label { font-size: 12px; color: var(--text-3); }
.ca-value { flex: 1; min-width: 0; font: 13px/1 var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ca-copy { font-size: 13px; color: var(--text-2); }
.ca:not(.is-set) .ca-copy { display: none; }
.ca.is-copied .ca-copy { color: var(--accent); }

/* the inspection card: the live check */
.inspect {
  margin-top: 16px; padding: 12px 14px 12px;
  background: var(--card); border: 1px solid var(--line-2); border-radius: 10px;
  box-shadow: 0 22px 44px -34px rgba(70, 35, 10, .45);
}
.inspect-head { display: flex; gap: 8px; }
.inspect input {
  flex: 1; min-width: 0; height: 46px; padding: 0 12px;
  border: 1px solid var(--line-2); border-radius: var(--radius); background: #fffbf4; color: var(--text);
  font: 13px var(--mono); transition: border-color .18s ease-out;
}
.inspect input::placeholder { color: var(--text-3); font-family: var(--sans); font-size: 14px; }
.inspect input:focus { outline: none; border-color: var(--text); }
.inspect input:focus-visible { outline: 2px solid rgba(36, 48, 94, .35); outline-offset: 1px; }
.inspect .btn { min-height: 46px; }
.presets { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 10px 0 2px; min-height: 30px; }
.presets-label { font: italic 400 15px/1 var(--display); color: var(--text-3); margin-right: 2px; }
.fresh { display: contents; }
.fresh .sep { font-size: 12px; color: var(--text-3); margin: 0 2px 0 6px; }
.chip {
  height: 30px; padding: 0 10px; border: 1px solid var(--line-2); border-radius: var(--radius);
  background: transparent; color: var(--text); font: 500 12.5px/1 var(--sans); cursor: pointer;
  transition: border-color .18s ease-out; max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { border-color: var(--text); }
.chip[aria-pressed="true"] { border-color: var(--text); background: rgba(31, 25, 21, .05); }
.status {
  margin: 8px 0 6px; font: 11.5px/1.5 var(--mono); color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.status .who { color: var(--text-2); }
.status .who::after { content: " >"; color: var(--text-3); }

.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.rows li {
  display: grid; grid-template-columns: 16px minmax(0, auto) minmax(0, 1fr) minmax(0, auto);
  align-items: center; gap: 10px; min-height: 30px; padding: 0 2px;
  border-bottom: 1px solid var(--line); font-size: 14px;
}
.rows .label { white-space: nowrap; }
.rows .tool { font: 10.5px var(--mono); color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows .val { font: 12px var(--mono); color: var(--text-2); text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rows li[data-state="idle"] .val, .rows li[data-state="checking"] .val { color: var(--text-3); }
.rows li[data-state="fail"] .val { color: var(--accent); }
.rows li[data-state="warn"] .val { color: var(--ochre); }
.rows li.flash { animation: flash .7s ease-out; }
@keyframes flash { from { background: rgba(36, 48, 94, .09); } to { background: transparent; } }

.flag { position: relative; width: 16px; height: 16px; border-radius: 3px; border: 1px dashed var(--line-2); flex: none; }
.rows .flag { display: block; }
li[data-state="checking"] .flag { border-style: solid; }
li[data-state="checking"] .flag::after { content: ""; position: absolute; left: 5px; top: 5px; width: 4px; height: 4px; border-radius: 1px; background: var(--text-3); }
.js li[data-state="checking"] .flag::after { animation: blink .9s steps(1) infinite; }
@keyframes blink { 50% { opacity: .2; } }
li[data-state="pass"] .flag { background: var(--indigo); border: 1px solid var(--indigo); }
li[data-state="pass"] .flag::after { content: ""; position: absolute; left: 4.5px; top: 1.5px; width: 4px; height: 8px; border: solid #f6eedf; border-width: 0 2px 2px 0; transform: rotate(45deg); }
li[data-state="warn"] .flag { background: var(--ochre); border: 1px solid var(--ochre); }
li[data-state="warn"] .flag::after { content: ""; position: absolute; left: 6px; top: 2.5px; width: 2px; height: 6px; background: #f6eedf; box-shadow: 0 8px 0 0 #f6eedf; }
li[data-state="fail"] .flag { background: var(--accent); border: 1px solid var(--accent); }
li[data-state="fail"] .flag::before, li[data-state="fail"] .flag::after { content: ""; position: absolute; left: 6.5px; top: 2.5px; width: 1.8px; height: 9px; background: #f6eedf; transform: rotate(45deg); }
li[data-state="fail"] .flag::after { transform: rotate(-45deg); }
li[data-state="error"] .flag { border-style: solid; }
li[data-state="error"] .flag::after { content: "?"; position: absolute; inset: 0; display: grid; place-items: center; font: 600 10px/1 var(--sans); color: var(--text-3); }

.verdict { margin: 10px 0 0; min-height: 28px; font: 400 23px/1.2 var(--display); color: var(--text); }
.verdict[data-v="fail"] { color: var(--accent); }
.verdict[data-v="idle"] { color: var(--text-3); font-style: italic; }
.fine { margin: 4px 0 0; font-size: 11.5px; line-height: 1.45; color: var(--text-3); }

/* scroll beats over the dots */
.layers { padding: 6vh var(--gutter) 0; }
.beat { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; justify-content: center; max-width: min(44%, 620px); }
.layers .kicker { color: var(--accent); }
.beat-line { margin: 0; font: 400 clamp(34px, 4.7vw, 70px)/1.03 var(--display); letter-spacing: -.012em; text-wrap: balance; }

/* sections */
.tools, .connect { position: relative; padding: clamp(72px, 10vw, 128px) var(--gutter) 0; scroll-margin-top: 64px; }
.section-head { max-width: 560px; }
h2 { font-size: clamp(34px, 4vw, 56px); line-height: 1; letter-spacing: -.012em; margin-bottom: 16px; }
.section-head > p:not(.kicker) { margin: 0; color: var(--text-2); font-size: 16px; }

table { width: 100%; border-collapse: collapse; margin-top: 36px; background: rgba(243, 233, 216, .86); }
th { text-align: left; font: 400 12px/1 var(--sans); color: var(--text-3); padding: 0 16px 12px 0; }
td { padding: 16px 16px 16px 0; border-top: 1px solid var(--line); vertical-align: top; font-size: 15px; }
td.n { font: 400 11px/1.9 var(--mono); color: var(--text-3); width: 48px; }
td.t { font: 500 13px/1.7 var(--mono); white-space: nowrap; }
td.s { font-size: 13px; line-height: 1.7; white-space: nowrap; color: var(--text); }
td.s::before {
  content: ""; display: inline-block; width: 8px; height: 8px; margin: 0 10px 0 2px; vertical-align: 0; transform: rotate(45deg);
  background: radial-gradient(circle, #efe3c9 0 1.4px, var(--indigo) 1.9px);
}
td.s.wait { color: var(--text-2); }
td.s.wait::before { background: none; box-shadow: inset 0 0 0 1px var(--text-3); }

.connect { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px 56px; align-items: start; }
.rules { margin: 28px 0 0; padding: 0; list-style: none; }
.rules li { display: flex; gap: 14px; padding: 13px 0; border-top: 1px solid var(--line); font-size: 15px; }
.rules .ix { font: 11px var(--mono); color: var(--text-3); padding-top: 4px; }
.code-wrap { position: relative; background: var(--paper); border: 1px solid var(--line-2); border-radius: 10px; }
.code-wrap::before, .code-wrap::after {
  content: ""; position: absolute; top: 12px; bottom: 12px; width: 9px; pointer-events: none;
  background: repeating-linear-gradient(180deg, var(--fringe) 0 1.5px, transparent 1.5px 5px);
}
.code-wrap::before { left: -10px; }
.code-wrap::after { right: -10px; }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); font: 11px var(--mono); color: var(--text-3); }
.copy-code { min-height: 34px; padding: 0 12px; border: 1px solid var(--line-2); border-radius: var(--radius); background: none; color: var(--text); font: 500 12.5px var(--sans); cursor: pointer; }
.copy-code:hover { border-color: var(--text); }
.code { margin: 0; padding: 18px 20px; font: 400 12px/1.75 var(--mono); color: var(--text-3); overflow-x: auto; }
.code .k { color: var(--text); }
.code .v { color: var(--indigo); }

.foot { padding: clamp(80px, 12vw, 140px) var(--gutter) 40px; }
.foot-row { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 20px; border-top: 1px solid var(--line-2); }
.foot-row::before {
  content: ""; position: absolute; left: 0; right: 0; top: -9px; height: 8px;
  background: repeating-linear-gradient(90deg, var(--fringe) 0 1.5px, transparent 1.5px 6px);
}
.mark-small { font: 400 20px var(--display); }
.foot-links { display: flex; gap: 20px; }
.foot-links a { font-size: 14px; color: var(--text-2); text-decoration: none; }
.foot-links a:hover { color: var(--text); }
.foot p { margin: 16px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--text-3); }

/* reveals */
.js .hero-copy > * { animation: rise .7s cubic-bezier(.2, .7, .2, 1) backwards; }
.js .hero-copy > :nth-child(2) { animation-delay: .06s; }
.js .hero-copy > :nth-child(3) { animation-delay: .12s; }
.js .hero-copy > :nth-child(4) { animation-delay: .18s; }
.js .hero-copy > :nth-child(5) { animation-delay: .26s; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
.js .reveal { opacity: 0; transform: translateY(18px); transition: opacity .7s ease-out, transform .7s cubic-bezier(.2, .7, .2, 1); }
.js .reveal.in { opacity: 1; transform: none; }

@media (max-width: 1240px) {
  .rows .tool { display: none; }
  .rows li { grid-template-columns: 16px minmax(0, auto) minmax(0, 1fr); }
}

/* tablet */
@media (max-width: 1060px) {
  .hero { grid-template-columns: minmax(0, 1fr); max-width: 680px; margin: 0 auto; }
  .hero-copy { display: contents; }
  .hero > * { grid-column: 1; }
  .hero .kicker { order: 1; margin-bottom: -12px; }
  .hero h1 { order: 2; margin-bottom: -8px; }
  .hero .lede { order: 3; margin-bottom: 0; }
  .hero .token { order: 4; }
  .hero > .rug-stage { display: none; }
  .inspect { order: 6; margin-top: 0; display: flex; flex-direction: column; background: transparent; border: 0; box-shadow: none; padding: 0; }
  .inspect-head { order: 1; }
  .presets { order: 2; }
  .rug-inline { display: block; order: 3; min-height: 0; height: clamp(210px, 56vw, 400px); margin: 0 calc(var(--gutter) * -1); }
  .status { order: 4; margin-top: 2px; }
  .verdict { order: 5; margin: 0 0 10px; }
  .rows { order: 6; }
  .fine { order: 7; margin-top: 8px; }
  .connect { grid-template-columns: minmax(0, 1fr); }
}

/* phone */
@media (max-width: 760px) {
  .top { gap: 12px; height: 56px; padding-right: 10px; }
  .nav { display: none; }
  .top-actions { margin-left: auto; }
  .top-actions .btn-icon { min-height: 44px; min-width: 44px; }
  .top .mark { min-height: 44px; }
  .hide-phone { display: none; }
  .hero { padding-top: 20px; gap: 16px; min-height: 0; scroll-margin-top: 56px; }
  .hero .kicker { font-size: 15px; margin-bottom: -6px; }
  h1 { font-size: clamp(44px, 13.4vw, 60px); }
  .hero h1 { margin-bottom: -6px; }
  .lede { font-size: 15px; }
  .token {
    position: fixed; z-index: 20; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
    padding: 6px; gap: 6px; background: rgba(243, 233, 216, .97); border: 1px solid var(--line-2); border-radius: 10px;
    box-shadow: 0 10px 30px -18px rgba(70, 35, 10, .5);
  }
  .token .ca, .token .btn { min-height: 46px; }
  .token .chart { display: none; }
  body { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
  .fresh .sep { display: none; }
  .chip { min-height: 44px; padding: 0 12px; }
  .presets { gap: 6px; }
  .copy-code { min-height: 44px; }
  .inspect .btn { min-width: 84px; }
  .rows li { font-size: 13.5px; gap: 8px; }
  .rows .val { font-size: 11.5px; }
  .verdict { font-size: 21px; }
  .beat { max-width: none; justify-content: flex-start; padding-top: 14svh; }
  table, thead, tbody, tr, td, th { display: block; }
  thead { display: none; }
  tr { border-top: 1px solid var(--line); padding: 14px 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 12px; }
  td { border: 0; padding: 0; }
  td.n { width: auto; grid-column: 1; grid-row: 1; }
  td.t { grid-column: 2; grid-row: 1; overflow: hidden; text-overflow: ellipsis; font-size: 12px; }
  td.s { grid-column: 3; grid-row: 1; font-size: 12px; }
  td:nth-child(3) { grid-column: 1 / -1; color: var(--text-2); font-size: 14px; }
  .code { font-size: 11px; padding: 16px; }
  .foot-row { flex-wrap: wrap; }
  .foot-links { gap: 4px; margin-right: -10px; }
  .foot-links a { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 44px; padding: 0 10px; }
  .code-wrap::before { left: -11px; width: 8px; }
  .code-wrap::after { right: -11px; width: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .js .reveal { opacity: 1; transform: none; }
}
