/* ============================================================================
   Market Terminal design system — shared by /, /quickstart, /world,
   /leaderboard. Dark charcoal canvas, amber signal accent, monospace-forward.
   Green/red are reserved for market semantics only.
   ========================================================================== */

:root {
  --bg: #0a0c10;
  --bg-panel: #0f1218;
  --bg-raised: #141924;
  --bg-inset: #0c0f14;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --text: #e8ecf1;
  --muted: #9aa4b2;
  --dim: #626e80;
  --amber: #ffb454;
  --amber-hot: #ffc97e;
  --amber-dim: rgba(255, 180, 84, 0.12);
  --green: #34d399;
  --red: #f87171;
  --cyan: #7dd3fc;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --maxw: 72rem;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    repeating-linear-gradient(0deg, transparent 0 47px, rgba(255,255,255,0.015) 47px 48px),
    repeating-linear-gradient(90deg, transparent 0 47px, rgba(255,255,255,0.015) 47px 48px),
    radial-gradient(1200px 500px at 70% -10%, rgba(255,180,84,0.05), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--amber); color: #100b02; }

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

code, pre, kbd { font-family: var(--mono); font-size: 0.86em; }

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

.skip {
  position: absolute; left: -9999px; top: 0; background: var(--amber); color: #100b02;
  padding: 0.5rem 1rem; font-family: var(--mono); z-index: 200;
}
.skip:focus { left: 0.5rem; top: 0.5rem; }

/* --- focus ---------------------------------------------------------------- */
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 2px; }

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(10, 12, 16, 0.82);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar-inner {
  display: flex; align-items: center; gap: 1.25rem;
  min-height: 3.25rem; flex-wrap: wrap; padding-top: 0.4rem; padding-bottom: 0.4rem;
}
.brand {
  display: flex; align-items: center; gap: 0.55rem;
  font-family: var(--mono); font-weight: 700; letter-spacing: 0.08em;
  font-size: 0.95rem; color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand .glyph { color: var(--amber); font-size: 1.05rem; }
.brand .sub { color: var(--dim); font-weight: 400; letter-spacing: 0.02em; }

.nav { display: flex; gap: 0.25rem; flex-wrap: wrap; margin-left: auto; align-items: center; }
.nav a {
  font-family: var(--mono); font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: var(--muted); padding: 0.42rem 0.7rem;
  border: 1px solid transparent;
}
.nav a:hover { color: var(--text); text-decoration: none; border-color: var(--line-strong); }
.nav a.on { color: var(--amber); border-color: rgba(255,180,84,0.35); background: var(--amber-dim); }

.tickchip {
  font-family: var(--mono); font-size: 0.75rem; color: var(--amber);
  border: 1px solid rgba(255,180,84,0.35); padding: 0.28rem 0.6rem;
  display: inline-flex; gap: 0.5rem; align-items: center; white-space: nowrap;
}
.tickchip .dot {
  width: 6px; height: 6px; background: var(--amber); display: inline-block;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.8rem; text-transform: uppercase;
  letter-spacing: 0.1em; cursor: pointer; padding: 0.62rem 1.1rem;
  border: 1px solid var(--line-strong); background: transparent; color: var(--text);
  transition: all 120ms ease;
}
.btn:hover { border-color: var(--amber); color: var(--amber); text-decoration: none; }
.btn.primary { border-color: var(--amber); background: var(--amber); color: #140d02; font-weight: 700; }
.btn.primary:hover { background: var(--amber-hot); border-color: var(--amber-hot); color: #140d02; }
.btn.big { padding: 0.85rem 1.5rem; font-size: 0.88rem; }
.btn[disabled] { opacity: 0.45; pointer-events: none; }

/* --------------------------------------------------------------------------
   Sections & type
   -------------------------------------------------------------------------- */
.section { padding: 3.5rem 0; border-top: 1px solid var(--line); }
.section.tight { padding: 2.25rem 0; }

.kicker {
  font-family: var(--mono); font-size: 0.72rem; text-transform: uppercase;
  letter-spacing: 0.22em; color: var(--amber); margin: 0 0 0.75rem;
}
h1, h2, h3 { font-family: var(--sans); letter-spacing: -0.01em; margin: 0 0 0.75rem; }
h1 { font-size: clamp(2.1rem, 5.2vw, 3.4rem); line-height: 1.08; font-weight: 800; }
h2 { font-size: clamp(1.45rem, 3vw, 2rem); line-height: 1.15; font-weight: 750; }
h3 { font-size: 1.02rem; font-weight: 650; }
.lede { color: var(--muted); font-size: 1.06rem; max-width: 44rem; }

.mono-label {
  font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--dim);
}

/* --------------------------------------------------------------------------
   Panels (terminal cards)
   -------------------------------------------------------------------------- */
.panel { border: 1px solid var(--line); background: linear-gradient(180deg, var(--bg-panel), var(--bg-inset)); }
.panel-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border-bottom: 1px solid var(--line); padding: 0.5rem 0.9rem;
  font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--dim);
}
.panel-bar .live { color: var(--amber); }
.panel-body { padding: 1rem 0.9rem; }
.panel-body.flush { padding: 0; }

pre.codeblock {
  margin: 0; padding: 1rem 0.9rem; overflow-x: auto;
  font-family: var(--mono); font-size: 0.8rem; line-height: 1.65;
  color: var(--text); background: var(--bg-inset);
  border-top: 1px solid var(--line); white-space: pre;
}
pre.codeblock .cmt { color: var(--dim); }
pre.codeblock .str { color: var(--amber); }
pre.codeblock .kw { color: var(--cyan); }

.cursor::after { content: "▊"; color: var(--amber); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* --------------------------------------------------------------------------
   Hero
   -------------------------------------------------------------------------- */
.hero { padding: 4.25rem 0 3rem; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 2.5rem; align-items: center; }
.hero h1 em { font-style: normal; color: var(--amber); }
.hero-ctas { display: flex; gap: 0.8rem; flex-wrap: wrap; margin-top: 1.6rem; }
.hero-note { font-family: var(--mono); font-size: 0.74rem; color: var(--dim); margin-top: 0.9rem; }

.statstrip {
  display: flex; flex-wrap: wrap; gap: 0; border: 1px solid var(--line);
  border-left: none; border-right: none; background: rgba(15, 18, 24, 0.6);
  margin: 2.75rem 0 0;
}
.statstrip .stat {
  flex: 1 1 auto; padding: 0.85rem 1.1rem; border-right: 1px solid var(--line); min-width: 9rem;
}
.statstrip .stat:last-child { border-right: none; }
.statstrip .k { font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.18em; text-transform: uppercase; color: var(--dim); }
.statstrip .v { font-family: var(--mono); font-size: 1.15rem; color: var(--text); font-variant-numeric: tabular-nums; }
.statstrip .v.amber { color: var(--amber); }

/* --------------------------------------------------------------------------
   Tape (marquee of recent fills)
   -------------------------------------------------------------------------- */
.tape-wrap { border-bottom: 1px solid var(--line); background: var(--bg-inset); overflow: hidden; }
.tape {
  display: flex; width: max-content; animation: tape 40s linear infinite;
  font-family: var(--mono); font-size: 0.76rem; color: var(--muted);
  padding: 0.42rem 0; white-space: nowrap;
}
.tape:hover { animation-play-state: paused; }
.tape span { padding: 0 1.4rem; }
.tape .up { color: var(--green); }
.tape .dn { color: var(--red); }
.tape .g { color: var(--amber); text-transform: uppercase; }
@keyframes tape { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* --------------------------------------------------------------------------
   Grids & cards
   -------------------------------------------------------------------------- */
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.grid4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }

.card {
  border: 1px solid var(--line); background: linear-gradient(180deg, var(--bg-panel), var(--bg-inset));
  padding: 1.35rem 1.2rem; position: relative;
}
.card .idx { font-family: var(--mono); color: var(--amber); font-size: 0.72rem; letter-spacing: 0.14em; }
.card h3 { margin-top: 0.5rem; }
.card p { color: var(--muted); font-size: 0.92rem; margin: 0.4rem 0 0; }
.card ul { margin: 0.6rem 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.92rem; }
.card li { margin: 0.3rem 0; }
.card li b, .card p b { color: var(--text); font-weight: 600; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.tbl { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.tbl th {
  font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase;
  letter-spacing: 0.16em; color: var(--dim); text-align: left; font-weight: 500;
  padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--line-strong);
}
.tbl td { padding: 0.55rem 0.9rem; border-bottom: 1px solid var(--line); font-size: 0.88rem; }
.tbl tr:last-child td { border-bottom: none; }
.tbl td.num, .tbl th.num { text-align: right; font-family: var(--mono); font-size: 0.82rem; }
.tbl tr.clickable { cursor: pointer; }
.tbl tr.clickable:hover td { background: rgba(255, 180, 84, 0.05); }
.up { color: var(--green); }
.dn { color: var(--red); }
.amber { color: var(--amber); }
.dimtxt { color: var(--dim); }

/* --------------------------------------------------------------------------
   Phase stepper
   -------------------------------------------------------------------------- */
.phases { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: stretch; }
.phase {
  border: 1px solid var(--line); background: var(--bg-panel); padding: 0.7rem 0.85rem;
  flex: 1 1 8.5rem; min-width: 8.5rem; position: relative;
}
.phase .n { font-family: var(--mono); font-size: 0.64rem; color: var(--amber); letter-spacing: 0.14em; }
.phase .t { font-family: var(--mono); font-size: 0.8rem; font-weight: 700; margin: 0.2rem 0 0.15rem; }
.phase .d { font-size: 0.76rem; color: var(--dim); line-height: 1.4; }

/* --------------------------------------------------------------------------
   Goods chain
   -------------------------------------------------------------------------- */
.chain { display: flex; flex-direction: column; gap: 1.1rem; }
.chain-tier { display: flex; align-items: center; gap: 0.9rem; flex-wrap: wrap; }
.chain-tier .tierlbl { font-family: var(--mono); font-size: 0.7rem; color: var(--dim); width: 8.5rem; letter-spacing: 0.12em; flex-shrink: 0; }
.chip {
  display: inline-block; font-family: var(--mono); font-size: 0.76rem;
  border: 1px solid var(--line-strong); padding: 0.32rem 0.7rem; color: var(--text);
  background: var(--bg-panel);
}
.chip small { color: var(--dim); }
.recipe-note { font-family: var(--mono); font-size: 0.74rem; color: var(--dim); }

/* --------------------------------------------------------------------------
   Sector tiles
   -------------------------------------------------------------------------- */
.sector {
  border: 1px solid var(--line); background: var(--bg-panel); padding: 0.9rem 1rem;
}
.sector .nm { font-weight: 650; font-size: 0.94rem; }
.sector .dep { margin-top: 0.45rem; display: flex; flex-wrap: wrap; gap: 0.35rem; }
.sector .dep .chip { font-size: 0.68rem; padding: 0.18rem 0.5rem; }
.sector .mod { font-family: var(--mono); font-size: 0.72rem; margin-top: 0.5rem; }
.mod.pos { color: var(--green); }
.mod.neg { color: var(--red); }
.mod.zero { color: var(--dim); }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
footer.site { border-top: 1px solid var(--line); margin-top: 3rem; padding: 2.5rem 0 3rem; background: var(--bg-inset); }
.foot-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 2rem; }
.foot-grid h4 {
  font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase;
  letter-spacing: 0.18em; color: var(--dim); margin: 0 0 0.7rem; font-weight: 500;
}
.foot-grid ul { list-style: none; margin: 0; padding: 0; }
.foot-grid li { margin: 0.4rem 0; font-size: 0.86rem; }
.foot-grid a { color: var(--muted); }
.foot-grid a:hover { color: var(--amber); text-decoration: none; }
.agent-cta {
  border: 1px dashed rgba(255, 180, 84, 0.4); background: var(--amber-dim);
  padding: 0.9rem 1.1rem; font-family: var(--mono); font-size: 0.8rem;
  color: var(--text); line-height: 1.6;
}
.agent-cta code { color: var(--amber); }
.fineprint { margin-top: 2rem; padding-top: 1.25rem; border-top: 1px solid var(--line); color: var(--dim); font-size: 0.76rem; display: flex; flex-wrap: wrap; gap: 1rem; justify-content: space-between; }

/* --------------------------------------------------------------------------
   Modal (faction mint)
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(4, 5, 8, 0.78); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center; z-index: 100; padding: 4.5rem 1rem 2rem;
}
.modal-backdrop.open { display: flex; }
.modal {
  width: min(46rem, 100%); max-height: calc(100vh - 7rem); overflow-y: auto;
  border: 1px solid rgba(255, 180, 84, 0.4); background: var(--bg-panel);
  box-shadow: 0 0 60px rgba(255, 180, 84, 0.07), 0 30px 60px rgba(0,0,0,0.6);
}
.modal-head {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--line); padding: 0.7rem 1rem;
  font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase; color: var(--amber);
}
.modal-head button { background: none; border: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; font-family: var(--mono); }
.modal-body { padding: 1rem; }
.modal-body .row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 0.9rem; }
.modal-body input[type="text"] {
  background: var(--bg-inset); border: 1px solid var(--line-strong); color: var(--text);
  font-family: var(--mono); font-size: 0.85rem; padding: 0.55rem 0.7rem; flex: 1 1 12rem;
}
.mint-out { border: 1px solid var(--line); background: var(--bg-inset); padding: 1rem; font-family: var(--mono); font-size: 0.78rem; white-space: pre-wrap; word-break: break-all; color: var(--muted); }
.mint-out .keyhl { color: var(--amber); }
.copy-btn { font-family: var(--mono); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.1em; border: 1px solid var(--line-strong); background: none; color: var(--muted); padding: 0.3rem 0.6rem; cursor: pointer; }
.copy-btn:hover { color: var(--amber); border-color: var(--amber); }

/* --------------------------------------------------------------------------
   Quickstart specifics
   -------------------------------------------------------------------------- */
.rung { display: grid; grid-template-columns: 11rem minmax(0, 1fr); gap: 1.5rem; padding: 2rem 0; border-top: 1px solid var(--line); }
.rung:first-of-type { border-top: none; }
.rung-rail .rn { font-family: var(--mono); color: var(--amber); font-size: 0.72rem; letter-spacing: 0.16em; }
.rung-rail h3 { margin: 0.35rem 0 0.4rem; font-size: 1.15rem; }
.rung-rail p { color: var(--dim); font-size: 0.84rem; margin: 0; }
.ref-tables h3 { margin-top: 1.75rem; }
.ref-tables h3:first-child { margin-top: 0; }

.notice {
  border: 1px solid var(--line); border-left: 3px solid var(--amber);
  background: var(--amber-dim); padding: 0.75rem 1rem; font-size: 0.86rem; color: var(--text);
  margin: 0.9rem 0;
}
.notice.warn { border-left-color: var(--red); background: rgba(248, 113, 113, 0.07); }

.loop-diagram {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem;
  font-family: var(--mono); font-size: 0.82rem;
}
.loop-diagram .step { border: 1px solid var(--line-strong); padding: 0.45rem 0.8rem; background: var(--bg-panel); }
.loop-diagram .step.hot { border-color: rgba(255,180,84,0.5); color: var(--amber); }
.loop-diagram .arr { color: var(--dim); }

/* --------------------------------------------------------------------------
   Firehose / log lines
   -------------------------------------------------------------------------- */
.loglines { font-family: var(--mono); font-size: 0.78rem; line-height: 1.8; padding: 0.75rem 0.9rem; }
.loglines div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.loglines .tk { color: var(--dim); }
.loglines .et { color: var(--cyan); }
.loglines .fillp { color: var(--green); }
.loglines .fillm { color: var(--red); }
.loglines .shock { color: var(--amber); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  .hero-grid, .grid3, .grid4 { grid-template-columns: 1fr; }
  .grid2 { grid-template-columns: 1fr; }
  .rung { grid-template-columns: 1fr; gap: 0.75rem; }
  .foot-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .statstrip .stat { min-width: 50%; border-bottom: 1px solid var(--line); }
  .foot-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .tape { animation: none; }
  .tickchip .dot { animation: none; }
  html { scroll-behavior: auto; }
}
