/* Reddit Trader — one stylesheet for every page.
   Tokens first, then layout, then components. Nothing here is page-specific:
   index, docs and launch all read from the same scale. */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  /* Surfaces. Never pure #000 — it smears on OLED and kills the orange bloom. */
  --bg: #0b0c0e;
  --bg-deep: #08090a;
  --surface: #121418;
  --surface-2: #171a1f;
  --border: #23272e;
  --border-soft: #191d23;

  /* Text */
  --fg: #f4f6f8;
  --fg-dim: #a2abb6;
  --fg-faint: #6b737d;

  /* Brand — pulled off the render, not off Reddit's palette. */
  --orange: #ff4a17;
  --orange-soft: #ff7a45;
  --orange-deep: #d63a0f;
  --amber: #ffb648;

  /* Semantics */
  --up: #35c76a;
  --down: #ef4444;

  /* Rhythm — 4/8 scale, density 5/10. */
  --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;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 18px;
  --r-full: 999px;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --shell: 1180px;

  --z-nav: 40;
  --z-modal: 100;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--fg);
  font-family: Inter, system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  letter-spacing: -0.011em;
  -webkit-font-smoothing: antialiased;
}

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

a {
  color: inherit;
}

h1,
h2,
h3 {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0;
}

/* Every number on the site is tabular so a live value never reflows its row. */
.num,
.mono {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

.shell {
  width: 100%;
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--s-5);
}

/* ── Navigation ─────────────────────────────────────────────────────────── */

.nav {
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border-bottom: 1px solid var(--border-soft);
}

.nav__inner {
  display: flex;
  align-items: center;
  gap: var(--s-5);
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  text-decoration: none;
  margin-right: auto;
}

/* The mark is a full-bleed orange square, so it gets its corners here rather than in the file —
   one less thing to regenerate if the radius ever changes. */
.brand img {
  width: 32px;
  height: 32px;
  border-radius: 9px;
}

.brand b {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.02em;
}

.nav a.link {
  color: var(--fg-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: var(--s-2) 0;
  transition: color 0.18s var(--ease);
}

.nav a.link:hover,
.nav a.link[aria-current='page'] {
  color: var(--fg);
}

.nav a.link[aria-current='page'] {
  box-shadow: inset 0 -2px 0 var(--orange);
}

/* The X mark. Sized as a proper 44px target even though the glyph inside it is 16px. */
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: 0 -10px;
  color: var(--fg-dim);
  text-decoration: none;
  border-radius: var(--r-full);
  transition: color 0.18s var(--ease), background 0.18s var(--ease);
}

.icon-link:hover {
  color: var(--fg);
  background: var(--surface-2);
}

.icon-link:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 2px;
}

/* `display` on the class outranks the UA rule the hidden attribute relies on, so an X mark with
   no handle behind it would sit there as a dead link. Both marks stay out until config names one. */
.icon-link[hidden],
footer a[hidden] {
  display: none;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5);
  border-radius: var(--r-full);
  border: 1px solid transparent;
  background: var(--orange);
  color: #16090400;
  color: #180800;
  font: 600 14px/1 Inter, sans-serif;
  letter-spacing: -0.01em;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.18s var(--ease), background 0.18s var(--ease), border-color 0.18s var(--ease);
}

.btn:hover {
  background: var(--orange-soft);
}

.btn:active {
  transform: scale(0.97);
}

.btn:focus-visible {
  outline: 2px solid var(--orange);
  outline-offset: 3px;
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--fg);
}

.btn--ghost:hover {
  background: var(--surface-2);
  border-color: #33383f;
}

.btn[disabled],
.btn[aria-disabled='true'] {
  opacity: 0.42;
  pointer-events: none;
}

/* ── Hero ───────────────────────────────────────────────────────────────── */

.hero {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border-soft);
}

/* No bloom behind the agent — he is a cut-out sitting on the page, and a glow behind him reads
   as a halo. The only warmth in the hero is a low band along the very bottom of the section, well
   clear of the character. */
.hero::before {
  content: '';
  position: absolute;
  inset: auto 0 -40% 0;
  height: 420px;
  background: radial-gradient(60% 100% at 50% 100%, rgba(255, 74, 23, 0.07), transparent 70%);
  pointer-events: none;
}

.hero__grid {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
  gap: var(--s-7);
  align-items: center;
  padding: var(--s-9) 0;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 6px var(--s-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface);
  color: var(--fg-dim);
  font: 500 12px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: var(--r-full);
  background: var(--orange);
  box-shadow: 0 0 0 0 rgba(255, 74, 23, 0.6);
  animation: pulse 2.4s var(--ease) infinite;
}

@keyframes pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(255, 74, 23, 0.55);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(255, 74, 23, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255, 74, 23, 0);
  }
}

h1 {
  font-size: clamp(38px, 6vw, 66px);
  margin: var(--s-5) 0 var(--s-4);
}

h1 em {
  font-style: normal;
  color: var(--orange);
}

.lede {
  color: var(--fg-dim);
  font-size: 17px;
  max-width: 46ch;
  margin: 0 0 var(--s-6);
}

.hero__cta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
}

/* The contract address. Written out in full, and `user-select: all` makes one click select the
   whole thing — a copy button would be a nicer gesture but this cannot copy a truncated address
   by accident, which is the failure that actually costs people money. */
.ca[hidden] {
  display: none;
}

.ca {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-3);
  margin: 0 0 var(--s-5);
}

.ca__label {
  font: 500 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-faint);
}

.ca__addr {
  font-size: 13px;
  color: var(--fg);
  word-break: break-all;
  user-select: all;
  -webkit-user-select: all;
  cursor: text;
}

/* ── The agent at its desk ──────────────────────────────────────────────── */

/* No card, no border, no halo: the art is a cut-out on transparency and sits straight on the
   page. The only thing under it is the status strip, which is a chain read, not decoration. */
.stage {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
}

.stage__art {
  width: 100%;
  max-width: 480px;
  height: auto;
  margin: 0 auto;
  display: block;
  /* One soft drop shadow so the cut-out has weight on the dark page instead of floating flat. */
  filter: drop-shadow(0 24px 44px rgba(0, 0, 0, 0.55));
}

/* A rule and a line of type, not a panel. Anything boxed here would read as a frame. */
.stage__hud {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding-top: var(--s-3);
  border-top: 1px solid var(--border-soft);
  font: 500 12px/1.4 'JetBrains Mono', monospace;
  letter-spacing: 0.02em;
}

.stage__hud .state {
  color: var(--orange);
  text-transform: uppercase;
}

.stage__hud .sep {
  color: var(--fg-faint);
}

.stage__hud .meta {
  color: var(--fg-dim);
  margin-left: auto;
  text-align: right;
}

/* ── Sections ───────────────────────────────────────────────────────────── */

section {
  padding: var(--s-9) 0;
  border-bottom: 1px solid var(--border-soft);
}

.sec-head {
  max-width: 62ch;
  margin-bottom: var(--s-7);
}

.sec-head h2 {
  font-size: clamp(26px, 3.4vw, 38px);
  margin-bottom: var(--s-3);
}

.sec-head p {
  color: var(--fg-dim);
  margin: 0;
}

.kicker {
  display: block;
  font: 500 12px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: var(--s-4);
}

/* ── Cards / stats ──────────────────────────────────────────────────────── */

.grid {
  display: grid;
  gap: var(--s-4);
}

.grid--3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid--4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.grid--2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  padding: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.card h3 {
  font-size: 17px;
  margin-bottom: var(--s-2);
}

.card p {
  color: var(--fg-dim);
  font-size: 15px;
  margin: 0;
}

.card__step {
  font: 700 12px/1 'JetBrains Mono', monospace;
  color: var(--orange);
  display: block;
  margin-bottom: var(--s-3);
}

.stat {
  padding: var(--s-5);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.stat dt {
  font: 500 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: var(--s-3);
}

.stat dd {
  margin: 0;
  font-family: 'JetBrains Mono', monospace;
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.stat dd .unit {
  font-size: 13px;
  color: var(--fg-faint);
  margin-left: 6px;
}

.stat .sub {
  display: block;
  margin-top: var(--s-2);
  font: 400 12px/1.4 Inter, sans-serif;
  color: var(--fg-faint);
  letter-spacing: 0;
}

/* An unknown number is four dots. It is never a zero and never a guess. */
.pending {
  color: var(--fg-faint);
}

/* ── The move log ───────────────────────────────────────────────────────── */

.log {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  overflow: hidden;
}

.log__row {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: var(--s-4);
  align-items: center;
  padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--border-soft);
  font-size: 14px;
}

.log__row:last-child {
  border-bottom: 0;
}

.log__when {
  font: 400 12px/1 'JetBrains Mono', monospace;
  color: var(--fg-faint);
}

.log__what b {
  font-weight: 600;
}

.log__what span {
  color: var(--fg-dim);
}

.log__tx {
  font: 500 12px/1 'JetBrains Mono', monospace;
  color: var(--orange);
  text-decoration: none;
  white-space: nowrap;
}

.log__tx:hover {
  text-decoration: underline;
}

.log__empty {
  padding: var(--s-7) var(--s-5);
  text-align: center;
  color: var(--fg-faint);
  font-size: 14px;
}

/* ── Prose (docs) ───────────────────────────────────────────────────────── */

.prose {
  max-width: 72ch;
}

.prose h2 {
  font-size: 28px;
  margin: var(--s-8) 0 var(--s-4);
  scroll-margin-top: 88px;
}

.prose h3 {
  font-size: 19px;
  margin: var(--s-6) 0 var(--s-3);
}

.prose p,
.prose li {
  color: var(--fg-dim);
  font-size: 16px;
}

.prose li {
  margin-bottom: var(--s-2);
}

.prose strong {
  color: var(--fg);
  font-weight: 600;
}

.prose code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  padding: 2px 6px;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--amber);
  word-break: break-all;
}

.prose pre {
  margin: var(--s-4) 0;
  padding: var(--s-4);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  overflow-x: auto;
}

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  color: var(--fg-dim);
  font-size: 12.5px;
  line-height: 1.65;
  word-break: normal;
}

.prose a {
  color: var(--orange);
  text-underline-offset: 3px;
}

.note {
  margin: var(--s-5) 0;
  padding: var(--s-4) var(--s-5);
  border-left: 2px solid var(--orange);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
  background: var(--surface);
}

.note p {
  margin: 0;
  font-size: 15px;
}

/* Tables of addresses and parameters. Scrolls inside itself, never the page. */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin: var(--s-5) 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th,
td {
  text-align: left;
  padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

th {
  font: 500 11px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--fg-faint);
  background: var(--surface-2);
}

td {
  color: var(--fg-dim);
}

tr:last-child td {
  border-bottom: 0;
}

td.mono {
  color: var(--fg);
}

/* ── Table of contents (docs) ───────────────────────────────────────────── */

.docs-grid {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: var(--s-8);
  align-items: start;
  padding: var(--s-8) 0;
}

.toc {
  position: sticky;
  top: 88px;
}

.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc a {
  display: block;
  padding: 7px var(--s-4);
  color: var(--fg-faint);
  text-decoration: none;
  font-size: 13px;
  border-left: 2px solid transparent;
  margin-left: -1px;
  transition: color 0.18s var(--ease), border-color 0.18s var(--ease);
}

.toc a:hover {
  color: var(--fg);
}

.toc a.is-active {
  color: var(--fg);
  border-left-color: var(--orange);
}

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

footer {
  padding: var(--s-7) 0 var(--s-8);
  color: var(--fg-faint);
  font-size: 13px;
}

footer .row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-5);
  align-items: center;
}

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

footer a:hover {
  color: var(--fg);
}

footer .fine {
  margin-top: var(--s-5);
  max-width: 76ch;
  line-height: 1.6;
  color: var(--fg-faint);
}

/* ── Ops console (launch.html) ──────────────────────────────────────────── */

.field {
  margin-bottom: var(--s-4);
}

.field label {
  display: block;
  font: 500 12px/1 'JetBrains Mono', monospace;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-faint);
  margin-bottom: var(--s-2);
}

.field input,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  color: var(--fg);
  font: 400 15px/1.5 Inter, sans-serif;
}

.field input:focus,
.field textarea:focus {
  outline: 2px solid var(--orange);
  outline-offset: 1px;
  border-color: transparent;
}

.field .help {
  display: block;
  margin-top: 6px;
  font-size: 12px;
  color: var(--fg-faint);
}

.console {
  margin-top: var(--s-5);
  padding: var(--s-4);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  font: 400 12.5px/1.7 'JetBrains Mono', monospace;
  color: var(--fg-dim);
  white-space: pre-wrap;
  word-break: break-word;
  min-height: 90px;
}

.console .ok {
  color: var(--up);
}

.console .err {
  color: var(--down);
}

/* ── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 940px) {
  .hero__grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-6);
    padding: var(--s-7) 0 var(--s-8);
  }
  .hero__copy {
    order: 2;
  }
  .stage {
    order: 1;
  }
  .stage__art {
    max-width: 440px;
  }
  .grid--4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .docs-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--s-5);
  }
  .toc {
    position: static;
  }
}

@media (max-width: 640px) {
  .shell {
    padding: 0 var(--s-4);
  }
  section {
    padding: var(--s-8) 0;
  }
  .grid--3,
  .grid--4,
  .grid--2 {
    grid-template-columns: minmax(0, 1fr);
  }
  .log__row {
    grid-template-columns: 1fr auto;
    row-gap: var(--s-1);
  }
  .log__when {
    grid-column: 1 / -1;
  }
  .nav__inner {
    gap: var(--s-4);
  }
  .brand b {
    font-size: 14px;
  }
}
