/* ==========================================================================
   datarail.org/foundry

   The Library's palette and page shapes, so it reads as another room in the
   same building. The fintech part is the readout: a price ticker under the
   header, mono tabular numbers, stat tiles, and gains and losses that carry a
   sign as well as a colour, so the colour is never the only signal.

   Loaded after /assets/circuit.css, which owns the edge rails.
   ========================================================================== */

:root {
  --bg: #05070b;
  --bg-soft: #0b0f16;
  --bg-raised: #10151e;
  --fg: #f5f5f7;
  --muted: #9ca3af;
  --dim: #7d8694;

  --accent: #42f5ff;
  --accent-strong: #42ffb3;
  --warm: #e0b25c;
  --bad: #ff8098;
  --line: #1c232f;

  --up: #42ffb3;
  --down: #ff8098;

  /* Chart marks: dimmer than the neon so they sit inside the dark band and
     stay apart for colour-blind readers (checked with the palette validator). */
  --mark-mine: #1aa3ae;
  --mark-rent: #b8862f;

  --font-main: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  --radius: 10px;
  --fast: 150ms ease-out;
  --shell: 980px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-main);
  background: radial-gradient(circle at 50% -6%, #0d1622 0, var(--bg) 58%, #03050a 100%);
  background-attachment: fixed;
  color: var(--fg);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
h1, h2 { margin: 0; line-height: 1.14; font-weight: 600; letter-spacing: -0.02em; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 5px; }

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 20px; }
@media (max-width: 420px) { .shell { padding: 0 16px; } }
.label {
  font-family: var(--font-mono); font-size: 0.67rem;
  text-transform: uppercase; letter-spacing: 0.18em; color: var(--dim);
}
.num, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 60;
  background: var(--accent); color: #05070b; padding: 10px 16px;
  font-weight: 600; text-decoration: none;
}
.skip-link:focus { left: 8px; top: 8px; }
.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;
}

.up { color: var(--up); }
.down { color: var(--down); }

/* ---------- Header + ticker ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(5, 7, 11, 0.9);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}
.header-inner {
  max-width: var(--shell); margin: 0 auto; padding: 11px 20px;
  display: flex; align-items: center; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 9px; margin-right: auto; text-decoration: none; }
.brand-dot {
  width: 9px; height: 9px; border-radius: 50%; flex: none;
  background: var(--accent); box-shadow: 0 0 9px var(--accent);
}
.brand-text { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.16em; text-transform: uppercase; }
.brand-text b { color: var(--accent); font-weight: 600; }
.header-nav { display: flex; gap: 16px; font-size: 0.84rem; }
.header-nav a { color: var(--muted); text-decoration: none; transition: color var(--fast); }
.header-nav a:hover { color: var(--fg); }
@media (max-width: 560px) { .header-nav a:not(:first-child):not(:nth-child(2)) { display: none; } }

.ticker {
  border-top: 1px solid var(--line); overflow: hidden; white-space: nowrap;
  font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted);
  mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.ticker-track { display: inline-flex; gap: 34px; padding: 6px 0; animation: tick 48s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-item b { color: var(--fg); font-weight: 600; margin-right: 7px; }
.ticker-item .chg { margin-left: 7px; }
@keyframes tick { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- Hero ---------- */
.hero { padding: 42px 0 10px; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 2.6rem); margin: 11px 0 13px; max-width: 20ch; }
.hero p { margin: 0; color: var(--muted); max-width: 62ch; }
.hero .asof { margin-top: 14px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--dim); }
.asof .stale { color: var(--warm); }

/* ---------- Sections ---------- */
.panel-section { padding: 30px 0 8px; scroll-margin-top: 84px; }
.sec-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 8px; flex-wrap: wrap; }
.sec-head h2 { font-size: 1.3rem; }
.sec-head .n { font-family: var(--font-mono); font-size: 0.68rem; color: var(--dim); margin-left: auto; }
.sec-note { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; max-width: 64ch; }
.fine { color: var(--dim); font-size: 0.8rem; margin: 10px 0 0; max-width: 70ch; }

.tag {
  display: inline-block; font-family: var(--font-mono); font-size: 0.56rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.12em; vertical-align: 2px;
  border: 1px solid var(--line); border-radius: 3px; padding: 2px 7px; color: var(--dim);
}
.tag.live { border-color: var(--accent-strong); color: var(--accent-strong); }
.tag.warn { border-color: var(--warm); color: var(--warm); margin-left: auto; }

/* ---------- Controls ---------- */
.controls {
  display: grid; gap: 14px 22px; margin: 6px 0 16px;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.field { display: grid; gap: 6px; }
.field output { color: var(--fg); margin-left: 6px; letter-spacing: 0.04em; }
select, .rig input {
  font: inherit; font-size: 0.9rem; color: var(--fg);
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px;
}
select:focus, .rig input:focus { border-color: var(--accent); outline: none; }
input[type="range"] { width: 100%; accent-color: var(--accent); height: 22px; margin: 0; }

.rig {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft);
  padding: 0 14px; margin-bottom: 18px;
}
.rig summary {
  cursor: pointer; padding: 10px 0; display: flex; gap: 12px; align-items: center;
  font-size: 0.86rem; color: var(--muted); list-style: none;
}
.rig summary::-webkit-details-marker { display: none; }
.rig summary::before { content: "+"; font-family: var(--font-mono); color: var(--accent); width: 10px; }
.rig[open] summary::before { content: "−"; }
.rig-flag { font-family: var(--font-mono); font-size: 0.66rem; color: var(--warm); margin-left: auto; }
.rig-note { margin: 0 0 10px; font-size: 0.82rem; color: var(--dim); }
.rig-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); margin-bottom: 12px; }
.rig-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rig-row .algo { grid-column: 1 / -1; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); }
.rig-row label { display: grid; gap: 3px; font-size: 0.7rem; color: var(--dim); }
.rig input { width: 100%; font-family: var(--font-mono); font-size: 0.82rem; padding: 6px 8px; }
.rig .btn { margin-bottom: 14px; }

/* ---------- Stat tiles ---------- */
.tiles { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 16px; }
.tile {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: linear-gradient(180deg, var(--bg-raised), var(--bg-soft));
  padding: 14px 16px; position: relative; overflow: hidden;
}
.tile::after {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--circuit-echo, var(--accent)); opacity: 0.7;
}
.tile .v { display: block; margin-top: 6px; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 1.45rem; font-weight: 600; letter-spacing: -0.02em; }
.tile .s { display: block; margin-top: 2px; font-size: 0.76rem; color: var(--dim); }

/* ---------- Yield table ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; }
.yield { min-width: 720px; font-size: 0.86rem; }
.yield th {
  font-family: var(--font-mono); font-size: 0.62rem; font-weight: 500; text-transform: uppercase;
  letter-spacing: 0.14em; color: var(--dim); text-align: left; padding: 10px 12px;
  border-bottom: 1px solid var(--line); background: var(--bg-soft); white-space: nowrap;
}
.yield td { padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.yield tbody tr:last-child td { border-bottom: 0; }
.yield .num, .mini .num { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.yield .coin b { font-weight: 600; margin-right: 8px; }
.yield .coin .algo { font-family: var(--font-mono); font-size: 0.7rem; color: var(--dim); }
.yield tr.best td { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.yield tr.best .coin b { color: var(--accent); }
.yield tr.na td { color: var(--dim); }
.yield tr.na .coin b { color: var(--muted); }
.yield .tag { margin-left: 8px; }
.yield .stale { color: var(--warm); font-size: 0.66rem; margin-left: 6px; font-family: var(--font-mono); }

/* ---------- Versus chart ---------- */
.versus {
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft);
  padding: 18px 18px 12px;
}
.vs-row { display: grid; grid-template-columns: 132px minmax(0, 1fr) 96px; gap: 12px; align-items: center; margin-bottom: 12px; }
.vs-name { font-size: 0.86rem; display: flex; align-items: center; gap: 8px; }
.vs-name i { width: 10px; height: 10px; border-radius: 2px; flex: none; }
.vs-name small { display: block; color: var(--dim); font-size: 0.7rem; font-family: var(--font-mono); }
.vs-track { position: relative; height: 26px; cursor: default; }
.vs-zero { position: absolute; top: -4px; bottom: -4px; width: 1px; background: var(--dim); }
.vs-bar { position: absolute; top: 5px; height: 16px; border-radius: 0 4px 4px 0; }
.vs-bar.neg { border-radius: 4px 0 0 4px; }
.vs-val { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-size: 0.86rem; }
.vs-axis { display: grid; grid-template-columns: 132px minmax(0, 1fr) 96px; gap: 12px; }
.vs-axis div { position: relative; height: 16px; font-family: var(--font-mono); font-size: 0.62rem; color: var(--dim); }
.vs-axis span { position: absolute; transform: translateX(-50%); }
.vs-val { white-space: nowrap; }
@media (max-width: 560px) {
  .vs-row, .vs-axis { grid-template-columns: 64px minmax(0, 1fr) 72px; gap: 8px; }
  .vs-name small, .vs-val .label { display: none; }
  .vs-axis span:not(:first-child):not(:last-child) { display: none; }
}
.verdict { margin: 14px 0 0; font-size: 0.95rem; color: var(--muted); max-width: 70ch; }
.verdict b { color: var(--fg); }

/* ---------- Pool ---------- */
.pool-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg-soft); padding: 14px 16px; overflow-x: auto; }
.card .label { margin: 0 0 8px; }
.mini { font-size: 0.82rem; }
.mini th { font-family: var(--font-mono); font-size: 0.6rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.12em; color: var(--dim); text-align: left; padding: 6px 6px 6px 0; border-bottom: 1px solid var(--line); }
.mini td { padding: 7px 6px 7px 0; border-bottom: 1px solid var(--line); white-space: nowrap; }
.mini tr:last-child td { border-bottom: 0; }
.mini .you td:first-child { color: var(--accent); }

/* ---------- Buttons, notes ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 20px; border-radius: 999px; background: transparent;
  border: 1px solid var(--accent); color: var(--accent); font: inherit;
  font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; text-decoration: none;
  transition: background var(--fast), color var(--fast);
}
.btn:hover { background: var(--accent); color: #05070b; }
.btn-small { padding: 6px 14px; font-size: 0.7rem; }

.note {
  border: 1px solid var(--line); border-left: 3px solid var(--warm);
  border-radius: var(--radius); background: var(--bg-soft);
  padding: 15px 17px; font-size: 0.86rem; color: var(--muted); margin: 34px 0 0;
}
.note strong { color: var(--fg); display: block; margin-bottom: 4px; }

.tip {
  position: fixed; z-index: 80; pointer-events: none;
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 8px;
  padding: 9px 11px; font-size: 0.76rem; color: var(--muted); min-width: 180px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
}
.tip b { color: var(--fg); display: block; margin-bottom: 4px; font-size: 0.8rem; }
.tip .r { display: flex; justify-content: space-between; gap: 14px; font-family: var(--font-mono); }
.tip .r span:last-child { color: var(--fg); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: var(--bg-soft); padding: 26px 0 34px; margin-top: 42px; }
.footer-inner { display: flex; gap: 14px 24px; flex-wrap: wrap; align-items: baseline; }
.footer-inner a { color: var(--muted); text-decoration: none; }
.footer-inner a:hover { color: var(--accent); }
.footer-note { width: 100%; margin: 10px 0 0; font-size: 0.79rem; color: var(--dim); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
