/* ============================================================
   QuantumBlock — Cypherpunk / cryptographic system
   Mono-forward, hash-chain centric, dense data
   ============================================================ */

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

:root {
  /* dark (default) */
  --bg:           #07090a;
  --bg-1:         #0c1012;
  --bg-2:         #11171a;
  --bg-3:         #161e22;
  --line:         #1d262b;
  --line-2:       #2a3940;
  --ink:          #d8e0dc;
  --ink-dim:      #8a9690;
  --ink-faint:    #515c58;

  --green:        oklch(0.82 0.17 148);
  --green-dim:    oklch(0.62 0.13 148);
  --green-bg:     oklch(0.30 0.10 148 / 0.12);

  --red:          oklch(0.68 0.20 25);
  --red-dim:      oklch(0.55 0.16 25);
  --red-bg:       oklch(0.30 0.12 25 / 0.12);

  --amber:        oklch(0.82 0.15 80);
  --amber-bg:     oklch(0.40 0.11 80 / 0.14);

  --accent:       var(--green);
  --hash-tone:    oklch(0.65 0.04 160);

  --grid:         rgba(255,255,255,0.025);
  --shadow:       0 0 0 1px var(--line);
}

[data-theme="light"] {
  --bg:           #f4f3ee;
  --bg-1:         #eceae3;
  --bg-2:         #e3e0d8;
  --bg-3:         #d9d6cd;
  --line:         #cbc7bc;
  --line-2:       #a8a392;
  --ink:          #16191a;
  --ink-dim:      #4f5550;
  --ink-faint:    #8a8d85;

  --green:        oklch(0.50 0.15 148);
  --green-dim:    oklch(0.40 0.12 148);
  --green-bg:     oklch(0.85 0.08 148 / 0.45);

  --red:          oklch(0.50 0.18 25);
  --red-dim:      oklch(0.40 0.14 25);
  --red-bg:       oklch(0.85 0.08 25 / 0.4);

  --amber:        oklch(0.55 0.13 70);
  --amber-bg:     oklch(0.85 0.08 70 / 0.5);

  --accent:       var(--green);
  --hash-tone:    oklch(0.40 0.04 160);

  --grid:         rgba(0,0,0,0.04);
}

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

body {
  font-family: "JetBrains Mono", ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.55;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  font-variant-ligatures: none;
  min-height: 100vh;
  position: relative;
}
/* grid moved to its own pseudo so canvas BG can sit beneath, content sits above both */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image:
    linear-gradient(to right, var(--grid) 1px, transparent 1px),
    linear-gradient(to bottom, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  background-position: -1px -1px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.7;
}

::selection { background: var(--green); color: var(--bg); }

/* --- Custom scrollbars (dark) --- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track {
  background: var(--bg);
  border-left: 1px solid var(--line);
  border-top: 1px solid var(--line);
}
::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--green); }
::-webkit-scrollbar-corner { background: var(--bg); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) var(--bg); }
[data-theme="light"] ::-webkit-scrollbar-track { background: var(--bg-1); }
[data-theme="light"] ::-webkit-scrollbar-thumb { background: var(--line-2); border-color: var(--bg-1); }

/* --- Stacking: canvas BG behind, fixed UI above --- */
body > #qb-bg { z-index: 0; }
.qb-bar { z-index: 50; }
.hash-marquee { position: relative; z-index: 2; }
.qb-main, .qb-footer, section, main { position: relative; z-index: 1; }
.qb-tweaks { position: fixed !important; z-index: 1000 !important; bottom: 24px !important; right: 24px !important; left: auto !important; top: auto !important; width: 280px; }
.reg { position: fixed !important; z-index: 51 !important; }

a { color: var(--ink); text-decoration: none; border-bottom: 1px dotted var(--ink-faint); }
a:hover { color: var(--green); border-bottom-color: var(--green); }

/* --- Top bar --- */
.qb-bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}
.qb-bar .brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; letter-spacing: 0.04em;
  font-size: 13px;
  border-bottom: none;
}
.qb-bar .brand .mark {
  width: 22px; height: 22px;
  border: 1px solid var(--ink);
  position: relative;
  display: inline-block;
}
.qb-bar .brand .mark::before,
.qb-bar .brand .mark::after {
  content: "";
  position: absolute;
  background: var(--ink);
}
.qb-bar .brand .mark::before { left: 4px; right: 4px; top: 50%; height: 1px; transform: translateY(-50%); }
.qb-bar .brand .mark::after  { top: 4px; bottom: 4px; left: 50%; width: 1px; transform: translateX(-50%); }
.qb-bar .brand b { font-weight: 700; }
.qb-bar .brand .slash { color: var(--ink-faint); font-weight: 400; }
.qb-bar nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.qb-bar nav a, .qb-bar nav .nav-btn {
  padding: 6px 10px;
  font-size: 12px;
  color: var(--ink-dim);
  border: 1px solid transparent;
  border-bottom: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  background: transparent;
  font-family: inherit;
}
.qb-bar nav a:hover, .qb-bar nav .nav-btn:hover { color: var(--ink); border-color: var(--line-2); background: var(--bg-1); }
.qb-bar nav a.active { color: var(--green); border-color: var(--line-2); background: var(--bg-1); }
.qb-bar .status {
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.08em;
}
.qb-bar .status .dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 3px var(--green-bg);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* --- Layout --- */
.qb-main {
  max-width: 1480px;
  margin: 0 auto;
  padding: 28px;
}

.kicker {
  font-size: 10px;
  color: var(--ink-faint);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  display: flex;
  align-items: center;
  gap: 10px;
}
.kicker::before {
  content: "";
  width: 18px; height: 1px;
  background: var(--ink-faint);
}
.kicker.no-rule::before { display: none; }

h1, h2, h3 { font-weight: 500; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 42px; line-height: 1.05; }
h2 { font-size: 22px; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--ink-dim); }

.serif { font-family: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif; letter-spacing: -0.01em; }

/* --- Cards --- */
.card {
  background: color-mix(in srgb, var(--bg-1) 88%, transparent);
  border: 1px solid var(--line);
  position: relative;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.card .corner {
  position: absolute;
  width: 8px; height: 8px;
  border: 1px solid var(--ink-faint);
}
.card .corner.tl { top: -1px; left: -1px; border-right: none; border-bottom: none; }
.card .corner.tr { top: -1px; right: -1px; border-left: none; border-bottom: none; }
.card .corner.bl { bottom: -1px; left: -1px; border-right: none; border-top: none; }
.card .corner.br { bottom: -1px; right: -1px; border-left: none; border-top: none; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center; gap: 8px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border: 1px solid var(--line-2);
  background: var(--bg-1);
  color: var(--ink);
  cursor: pointer;
  transition: all 120ms ease;
  border-bottom: 1px solid var(--line-2);
}
.btn:hover { border-color: var(--green); color: var(--green); background: var(--bg-2); }
.btn.primary {
  background: var(--green);
  color: var(--bg);
  border-color: var(--green);
  font-weight: 700;
}
.btn.primary:hover { background: var(--ink); border-color: var(--ink); color: var(--bg); }

/* --- Mono number --- */
.num { font-variant-numeric: tabular-nums; }

/* --- Pos / Neg --- */
.pos { color: var(--green); }
.neg { color: var(--red); }
.warn { color: var(--amber); }
.muted { color: var(--ink-dim); }
.faint { color: var(--ink-faint); }

/* --- Tags / chips --- */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid var(--line-2);
  color: var(--ink-dim);
  font-weight: 500;
}
.tag.long  { color: var(--green); border-color: var(--green-dim); background: var(--green-bg); }
.tag.short { color: var(--red); border-color: var(--red-dim); background: var(--red-bg); }
.tag.open  { color: var(--amber); border-color: var(--amber); background: var(--amber-bg); }
.tag.win   { color: var(--green); border-color: var(--green-dim); background: var(--green-bg); }
.tag.loss  { color: var(--red); border-color: var(--red-dim); background: var(--red-bg); }
.tag.neutral { color: var(--ink-dim); }

/* --- Hash glyph --- */
.hash {
  font-family: "JetBrains Mono", monospace;
  font-size: 11px;
  color: var(--hash-tone);
  letter-spacing: 0.02em;
  cursor: pointer;
}
.hash:hover { color: var(--green); }
.hash .h-prefix { color: var(--ink-faint); }

/* --- ASCII separators --- */
.ascii-rule {
  font-family: "JetBrains Mono", monospace;
  color: var(--ink-faint);
  font-size: 11px;
  letter-spacing: 0.05em;
  white-space: nowrap;
  overflow: hidden;
  user-select: none;
}

/* --- Hash-chain prominence variants --- */
[data-hash-prom="hero"] .chain-strip { display: block; }
[data-hash-prom="standard"] .chain-strip { display: block; opacity: 0.85; }
[data-hash-prom="subtle"] .chain-strip { display: none; }

/* --- Header strip (chain visualisation) --- */
.hash-marquee {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-1) 80%, transparent);
  overflow: hidden;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  position: relative;
  z-index: 2;
  backdrop-filter: blur(4px);
}
.hash-marquee .track { display: none; }
.hash-marquee svg { display: block; width: 100%; height: 56px; }
.hash-marquee .helix-label {
  position: absolute; top: 50%; left: 16px; transform: translateY(-50%);
  font-size: 9px; color: var(--ink-faint);
  text-transform: uppercase; letter-spacing: 0.18em;
  pointer-events: none; z-index: 2;
  background: var(--bg-1);
  padding: 4px 10px;
  border: 1px solid var(--line);
}
.hash-marquee .helix-label b { color: var(--green); font-weight: 500; letter-spacing: 0.1em; }

/* Block stream */
.block-stream {
  display: flex; align-items: center; height: 56px;
  padding: 0 0 0 200px;
  font-family: "JetBrains Mono", monospace;
  font-size: 9px;
  white-space: nowrap;
  overflow: hidden;
  position: relative;
}
.block-stream-track {
  display: flex; align-items: center; gap: 0;
  animation: bs-slide 90s linear infinite;
  will-change: transform;
}
@keyframes bs-slide {
  from { transform: translateX(0); }
  to { transform: translateX(-50%); }
}
.bs-block {
  display: inline-flex; flex-direction: column;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg-1) 70%, transparent);
  padding: 5px 9px;
  min-width: 130px;
  position: relative;
}
.bs-block.win    { border-left: 2px solid var(--green); }
.bs-block.loss   { border-left: 2px solid var(--red); }
.bs-block.open   { border-left: 2px solid var(--orange); }
.bs-block.genesis{ border-left: 2px solid var(--ink-faint); }
.bs-block .bs-id { color: var(--ink-faint); letter-spacing: 0.08em; }
.bs-block .bs-id b { color: var(--ink); font-weight: 500; }
.bs-block .bs-hash { color: var(--green); letter-spacing: 0; margin-top: 2px; }
.bs-block .bs-pnl  { position: absolute; top: 5px; right: 9px; font-size: 9px; }
.bs-block .bs-pnl.pos { color: var(--green); }
.bs-block .bs-pnl.neg { color: var(--red); }
.bs-block .bs-pnl.opn { color: var(--orange); }
.bs-link {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; color: var(--ink-faint);
  font-size: 11px;
}
.bs-link::before { content: "─◆─"; letter-spacing: -2px; }

/* --- Tweaks-related --- */
[data-hash-prom="subtle"] .hash-marquee { display: none; }
[data-hash-prom="subtle"] .hash { opacity: 0.5; }

/* --- Glitch text accent --- */
.glitch {
  position: relative;
  display: inline-block;
}
.glitch::before, .glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0; left: 0; right: 0;
  pointer-events: none;
}
.glitch::before {
  color: var(--green);
  transform: translate(-1px, 0);
  mix-blend-mode: screen;
  clip-path: polygon(0 0, 100% 0, 100% 33%, 0 33%);
  animation: glitch-a 4s infinite steps(1);
  opacity: 0.7;
}
.glitch::after {
  color: var(--red);
  transform: translate(1px, 0);
  mix-blend-mode: screen;
  clip-path: polygon(0 66%, 100% 66%, 100% 100%, 0 100%);
  animation: glitch-b 4.7s infinite steps(1);
  opacity: 0.5;
}
@keyframes glitch-a {
  0%, 92%, 100% { transform: translate(0,0); opacity: 0; }
  93% { transform: translate(-2px,1px); opacity: 0.8; }
  94% { transform: translate(2px,-1px); opacity: 0.8; }
  95% { transform: translate(-1px,0); opacity: 0.6; }
  96% { transform: translate(0,1px); opacity: 0; }
}
@keyframes glitch-b {
  0%, 88%, 100% { transform: translate(0,0); opacity: 0; }
  89% { transform: translate(2px,-1px); opacity: 0.7; }
  90% { transform: translate(-2px,1px); opacity: 0.7; }
  91% { transform: translate(1px,0); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .glitch::before, .glitch::after { animation: none; opacity: 0; }
}

/* --- Hero scan-line accent --- */
.scanlines {
  position: relative;
}
.scanlines::after {
  content: "";
  position: absolute; inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.04) 3px,
    rgba(0,0,0,0.04) 4px
  );
  mix-blend-mode: multiply;
  opacity: 0.5;
}
[data-theme="light"] .scanlines::after {
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 3px,
    rgba(0,0,0,0.025) 3px,
    rgba(0,0,0,0.025) 4px
  );
}

/* --- Footer --- */
.qb-footer {
  border-top: 1px solid var(--line);
  margin-top: 80px;
  padding: 32px 28px 60px;
  color: var(--ink-faint);
  font-size: 11px;
  display: flex; flex-wrap: wrap; gap: 24px;
  justify-content: space-between;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.qb-footer a { border-bottom: none; }
.qb-footer a:hover { color: var(--green); }

/* --- utilities --- */
.row { display: flex; align-items: center; gap: 12px; }
.col { display: flex; flex-direction: column; gap: 12px; }
.between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; } .gap-32 { gap: 32px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; } .mb-32 { margin-bottom: 32px; } .mb-48 { margin-bottom: 48px; }
