/* Cairn - CRT terminal aesthetic. Black-and-white phosphor screen with one faint
   green for the cursor/live signal. Sharp edges, scanlines, monospace, motion that
   feels like a terminal painting itself. Class names match app.js; restyled, not renamed. */
:root {
  /* canonical cairn explorer tokens (references/csd-indexer/public/explorer.html) */
  --bg: #050505;
  --panel: #0a0c0b;
  --panel2: #0d0f0e;
  --line: #1b1f1d;
  --line2: #242a27;      /* hover line */
  --text: #f2f2f2;
  --muted: #6f6f6f;      /* --dim */
  --dim: #6f6f6f;
  --dim2: #a6a6a6;
  --accent: #f2f2f2;     /* "white" ink */
  --accent2: #a6a6a6;
  --green: #57d977;      /* phosphor - cursor, live, ok (used sparingly) */
  --amber: #ffd24a;      /* headings, pending, gold accents */
  --red: #ff6b6b;
  --chain: #57d977;
  --demo: #8a8a8a;
  --glow: 0 0 1px rgba(242,242,242,.25);
}
* { box-sizing: border-box; }
html, body { background: var(--bg); }
body {
  margin: 0; color: var(--text);
  font: 13.5px/1.6 ui-monospace, "SF Mono", "SFMono-Regular", "JetBrains Mono", Menlo, Consolas, "Liberation Mono", monospace;
  letter-spacing: .2px;
  -webkit-font-smoothing: antialiased;
}
/* CRT: scanlines + a faint vignette, drawn over everything, never intercepting clicks */
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,0) 0, rgba(0,0,0,0) 2px, rgba(0,0,0,.16) 3px, rgba(0,0,0,0) 4px),
    radial-gradient(120% 120% at 50% 0%, transparent 60%, rgba(0,0,0,.45) 100%);
  mix-blend-mode: multiply; animation: flicker 6s infinite steps(60);
}
@keyframes flicker { 0%,97%{opacity:1} 98%{opacity:.94} 99%{opacity:.99} 100%{opacity:1} }
/* ambient atmosphere: green top-right + amber bottom-left - exact explorer wash */
body::before {
  content: ""; position: fixed; top: 0; left: 0; right: 0; height: 100vh; height: 100lvh;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(60% 40% at 70% -10%, rgba(87,217,119,.05), transparent 60%),
    radial-gradient(40% 30% at 10% 110%, rgba(255,210,74,.04), transparent 60%);
}
a { color: var(--text); text-decoration: underline; text-underline-offset: 2px; text-decoration-color: var(--line2); }
a:hover { text-decoration-color: var(--green); }
code { background: #0d0d0d; padding: 1px 5px; font-size: 12.5px; color: var(--dim2); border: 1px solid var(--line); border-radius: 4px; }
.muted { color: var(--muted); }
::selection { background: var(--green); color: #000; }
::-webkit-scrollbar { width: 9px; height: 9px; } ::-webkit-scrollbar-thumb { background: #222; } ::-webkit-scrollbar-track { background: #0a0a0a; }

/* blinking block cursor, reusable */
.cursor::after, .blink { content: "▋"; color: var(--green); animation: blink 1.1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* page reveal after boot (staggered). #app is visible by default so a JS failure
   can never leave a black screen; the html.booted class (added by boot.js the moment
   the boot screen clears) just adds the entrance animation. */
html.booted #app > *, #app.up > * { animation: rise .5s both; }
html.booted #app > *:nth-child(2), #app.up > *:nth-child(2){animation-delay:.05s}
html.booted #app > *:nth-child(3), #app.up > *:nth-child(3){animation-delay:.1s}
html.booted #app > *:nth-child(4), #app.up > *:nth-child(4){animation-delay:.15s}
html.booted #app > *:nth-child(n+5), #app.up > *:nth-child(n+5){animation-delay:.2s}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 26px; border-bottom: 1px solid var(--line);
  background: linear-gradient(#050505f5, #050505e6); backdrop-filter: blur(6px);
}
/* gradient hairline under the header - the family signature (green -> amber) */
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(87,217,119,.5), rgba(255,210,74,.4), transparent);
}
.brand { display: flex; gap: 14px; align-items: center; }
.logo { width: 52px; height: 52px; object-fit: contain; flex: none; filter: drop-shadow(0 0 6px rgba(87,217,119,.12)); }
h1 { margin: 0; font-size: 20px; letter-spacing: 2px; font-weight: 700; text-shadow: var(--glow); }
h1::before { content: "pool@substrate:~$ "; color: var(--green); font-weight: 400; font-size: 13px; letter-spacing: .5px; }
.tag { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.tag::before { content: "// "; color: var(--line2); }
.chain { font-size: 12px; color: var(--muted); text-align: right; border: 1px solid var(--line); padding: 7px 11px; background: var(--panel); border-radius: 8px; }
.chain b { color: var(--green); }
.head-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

/* buttons: sharp, with a left-to-right fill sweep on hover */
.ghost-btn {
  background: transparent; color: var(--muted); border: 1px solid var(--line2);
  padding: 7px 13px; cursor: pointer; font: inherit; font-size: 12.5px; position: relative;
  border-radius: 6px; transition: color .18s, border-color .18s;
}
.ghost-btn::before { content: "["; opacity: 0; margin-right: 3px; transition: opacity .15s; color: var(--green); }
.ghost-btn::after  { content: "]"; opacity: 0; margin-left: 3px; transition: opacity .15s; color: var(--green); }
.ghost-btn:hover { color: var(--text); border-color: var(--green); }
.ghost-btn:hover::before, .ghost-btn:hover::after { opacity: 1; }
.ghost-btn.active { color: var(--green); border-color: var(--green); }
.ghost-btn.gold { color: #ffd24a; border-color: rgba(255,210,74,.45); }
.ghost-btn.gold::before, .ghost-btn.gold::after { color: #ffd24a; }
.ghost-btn.gold:hover { color: #000; background: #ffd24a; border-color: #ffd24a; }
/* anchors styled as buttons: kill the global underline, keep the chrome */
a.ghost-btn { text-decoration: none; display: inline-block; }
a.ghost-btn:hover { text-decoration: none; }
.modal ul { padding-left: 18px; margin: 6px 0; }

/* ── hero: the 5-second pitch (propose → back → earn) ───────────────────────── */
.hero { padding: 20px 26px 4px; }
.hero-lede { margin: 0 0 12px; font-size: 15.5px; color: var(--accent); letter-spacing: .2px; }
.hero-lede::before { content: "$ "; color: var(--green); }
.flow { display: flex; gap: 10px; align-items: stretch; }
.flow-step {
  flex: 1 1 0; min-width: 0; text-align: left; cursor: pointer; font: inherit;
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  padding: 12px 14px; display: flex; flex-direction: column; gap: 5px; position: relative;
  transition: border-color .18s, background .18s; text-decoration: none;
}
.flow-step::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--line2); transition: background .18s; }
.flow-step:hover { border-color: var(--line2); background: #0e0e0e; }
.flow-step:hover::before { background: var(--green); }
.fs-head { display: flex; align-items: baseline; gap: 8px; font-size: 14.5px; }
.fs-head b { color: var(--accent); letter-spacing: 1px; text-transform: uppercase; font-size: 13.5px; }
.fs-n { color: var(--green); font-size: 11.5px; }
.fs-sub { color: var(--muted); font-size: 12px; line-height: 1.55; }
.flow-arrow { align-self: center; color: var(--line2); font-size: 16px; flex: none; }
/* step 3 (earn) is the newcomer hook - gold, the CairnX family accent */
.fs-earn .fs-n, .fs-earn .fs-head b { color: #ffd24a; }
.fs-earn:hover { border-color: rgba(255,210,74,.5); }
.fs-earn:hover::before { background: #ffd24a; }

/* CairnX nav link + per-item trade chip: gold = the trade surface */
.trade-link { color: #ffd24a; border-color: rgba(255,210,74,.4); }
.trade-link:hover { color: #ffd24a; border-color: #ffd24a; }
.trade-link::before, .trade-link::after { color: #ffd24a; }
a.chip.trade-chip { color: #ffd24a; border-color: rgba(255,210,74,.4); text-decoration: none; }
a.chip.trade-chip:hover { border-color: #ffd24a; }

.stats { display: flex; gap: 12px; padding: 18px 26px 4px; flex-wrap: wrap; }
.stat { background: var(--panel); border: 1px solid var(--line); padding: 11px 15px; min-width: 118px; position: relative; transition: border-color .18s; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--line2); transition: background .18s; }
.stat:hover { border-color: var(--line2); }
.stat:hover::before { background: var(--green); }
.stat .n { font-size: 21px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }

.banner { margin: 14px 26px; padding: 11px 15px; background: var(--panel); border: 1px solid var(--line2); border-left: 2px solid var(--green); color: var(--accent2); font-size: 13px; }

.domains { display: flex; gap: 6px; flex-wrap: wrap; }
.domains button { background: var(--panel); color: var(--muted); border: 1px solid var(--line); padding: 6px 13px; cursor: pointer; font: inherit; font-size: 12.5px; transition: .15s; }
.domains button::before { content: ""; }
.domains button.active { background: var(--accent); color: #000; border-color: var(--accent); font-weight: 700; }
.domains button:hover:not(.active) { border-color: var(--line2); color: var(--text); }
.tab-count { opacity: .55; font-size: 11px; margin-left: 4px; }
.domains button.active .tab-count { opacity: .8; }

.controls { display: flex; justify-content: space-between; align-items: center; padding: 16px 26px 8px; flex-wrap: wrap; gap: 12px; border-top: 1px solid var(--line); margin-top: 12px; }
.ctl { color: var(--muted); font-size: 12.5px; display: inline-flex; align-items: center; gap: 6px; }
.ctl select, .search { background: var(--panel); color: var(--text); border: 1px solid var(--line2); padding: 6px 10px; font: inherit; }
.search { margin: 6px 26px 0; padding: 9px 14px; width: calc(100% - 52px); }
.search:focus, .ctl select:focus { outline: none; border-color: var(--green); }
.search::placeholder { color: #555; }

.board { padding: 12px 26px 40px; display: flex; flex-direction: column; gap: 8px; }
.card {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 16px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); padding: 13px 16px; cursor: pointer;
  position: relative; transition: border-color .15s, background .15s, transform .05s;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--green); transition: width .12s; }
.card:hover { border-color: var(--line2); background: #0e0e0e; }
.card:hover::before { width: 2px; }
.card:active { transform: translateX(1px); }
.rank { font-size: 18px; font-weight: 800; color: var(--muted); text-align: center; }
.rank::before { content: "#"; color: var(--line2); font-size: 13px; }
.rank.top { color: var(--green); }
/* grid items must be allowed to shrink - a long unbreakable token (txid, URL) would
   otherwise force the 1fr column wider than the viewport on phones */
.c-main, .c-num { min-width: 0; }
.c-main h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.c-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 12px; color: var(--muted); }
.chip { background: var(--panel2); border: 1px solid var(--line); padding: 2px 8px; font-size: 11px; }
.badge { padding: 2px 8px; font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .8px; border: 1px solid var(--line2); }
.badge.demo { color: var(--demo); }
.badge.chain { color: var(--green); border-color: rgba(87,217,119,.4); }
.badge.chain::before { content: "⛓ "; }
.badge.sealed { color: var(--accent); border-color: var(--line2); letter-spacing: .4px; }
.body-ex { color: #9a9a9a; font-size: 13px; margin: 4px 0 0; max-width: 72ch; overflow-wrap: anywhere; }
.c-num { text-align: right; min-width: 150px; }
.c-num .csd { font-size: 17px; font-weight: 700; color: var(--accent); }
.c-num .sub { font-size: 11.5px; color: var(--muted); }
.bar { height: 5px; background: #161616; margin-top: 8px; overflow: hidden; border: 1px solid var(--line); }
.bar > i { display: block; height: 100%; background: repeating-linear-gradient(90deg, var(--green) 0 3px, #2f7a45 3px 6px); }
.pledge { color: var(--accent2); font-size: 12px; margin-top: 3px; }

.foot { padding: 24px 26px 80px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; max-width: 92ch; }
.foot p { margin: 6px 0; }
.foot::before { content: "$ cat README"; display: block; color: var(--green); margin-bottom: 10px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.78); display: grid; place-items: center; padding: 20px; z-index: 50; backdrop-filter: blur(1px); }
.modal-bg[hidden] { display: none; }
.modal { background: linear-gradient(180deg, var(--panel), #080a09); border: 1px solid var(--line2); border-radius: 12px; max-width: 720px; width: 100%; max-height: 86vh; overflow: auto; padding: 0 26px 26px; position: relative; animation: rise .25s both; }
.modal::before { content: ""; display: block; position: sticky; top: 0; height: 34px; margin: 0 -26px 14px; background: #0e0e0e; border-bottom: 1px solid var(--line2); }
.modal h2 { margin: 0 0 6px; font-size: 17px; } .modal h2::before { content: "$ "; color: var(--green); }
.modal .sec { margin-top: 18px; }
.modal .kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 12px; font-size: 13px; }
.modal .kv div:nth-child(odd) { color: var(--muted); }
.mono { font-family: inherit; font-size: 12px; word-break: break-all; }
.ok { color: var(--green); } .bad { color: var(--red); }
.close { position: absolute; right: 18px; top: 6px; cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; z-index: 2; background: none; border: none; padding: 0; font-family: inherit; }
.close:hover { color: var(--green); }
.sec-h { font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.modal details summary { cursor: pointer; }
.supporter-row { display: flex; justify-content: space-between; border-bottom: 1px solid var(--line); padding: 6px 0; font-size: 13px; }
.mini-bar { display: inline-block; width: 80px; height: 5px; background: #161616; overflow: hidden; border: 1px solid var(--line); }
.mini-bar > i { display: block; height: 100%; background: var(--green); }
.cli { background: #000; border: 1px solid var(--line2); border-left: 2px solid var(--green); padding: 12px; font-family: inherit; font-size: 12.5px; color: var(--text); white-space: pre-wrap; }
.cli::selection { background: var(--green); color: #000; }
.empty { color: var(--muted); text-align: center; padding: 50px; }

.right-controls { display: flex; gap: 14px; align-items: center; }
.propose-btn { background: var(--accent); color: #000; border: 1px solid var(--accent); padding: 8px 16px; font-weight: 700; cursor: pointer; font: inherit; font-size: 13px; transition: .15s; }
.propose-btn:hover { background: #000; color: var(--green); border-color: var(--green); }
.form { display: grid; grid-template-columns: 140px 1fr; gap: 10px 12px; align-items: center; margin-top: 14px; }
.form label { color: var(--muted); font-size: 13px; }
.form label::before { content: "› "; color: var(--line2); }
.form input, .form textarea, .form select { background: #000; color: var(--text); border: 1px solid var(--line2); padding: 8px 10px; font: inherit; width: 100%; }
.form input:focus, .form textarea:focus, .form select:focus { outline: none; border-color: var(--green); }
.form textarea { resize: vertical; }

/* ── boot sequence overlay (shared boot.js typewriter - centered phosphor pre) ── */
#boot {
  position: fixed; top: 0; left: 0; right: 0; bottom: auto; min-height: 100vh; min-height: 100lvh;
  background: var(--bg); z-index: 300; display: grid; place-items: center; padding: 24px;
  overflow: hidden; transition: opacity .5s ease; animation: bootclear .5s 5.5s forwards;
}
#boot.done { opacity: 0; pointer-events: none; }
@keyframes bootclear { to { opacity: 0; visibility: hidden; pointer-events: none; } } /* failsafe: clears even with zero JS */
#boot pre { margin: 0; color: var(--green); font-family: inherit; font-size: 13px; line-height: 1.7; text-shadow: 0 0 6px rgba(87,217,119,.4); }

/* ── hidden command line (easter egg): toggle with ` or / ── */
#cmd { position: fixed; left: 0; right: 0; bottom: 0; z-index: 80; background: #000; border-top: 1px solid var(--green); transform: translateY(100%); transition: transform .18s; }
#cmd.open { transform: none; }
#cmd .out { max-height: 38vh; overflow: auto; padding: 10px 16px; font-size: 12.5px; white-space: pre-wrap; color: var(--accent2); }
#cmd .in { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--line); }
#cmd .in span { color: var(--green); }
#cmd input { flex: 1; background: transparent; border: none; outline: none; color: var(--text); font: inherit; }
#matrix { position: fixed; inset: 0; z-index: 90; pointer-events: none; }

@media (prefers-reduced-motion: reduce) {
  body::after { animation: none; }
  #app, #app.up > *, html.booted #app > * { animation: none; opacity: 1; }
  .blink, .cursor::after { animation: none; }
  #boot { animation: bootclear .3s 0s forwards; }
  .stat, .card, .ghost-btn, .flow-step { transition: none; }
}
@media (max-width: 640px) {
  /* header: compact brand + wrapping ghost-button nav (mirrors landing/wall mobile);
     the stacked header is tall, so it does not stick on phones */
  .top { position: static; flex-direction: column; gap: 10px; align-items: stretch; padding: 12px 16px; }
  .brand { gap: 10px; }
  .logo { width: 38px; height: 38px; }
  h1 { font-size: 17px; }
  h1::before { content: "~$ "; }
  .tag { font-size: 11.5px; }
  .head-right { justify-content: flex-start; gap: 8px; }
  .ghost-btn { padding: 6px 10px; font-size: 12px; }
  .chain { flex: 1 1 100%; text-align: left; order: 10; }
  /* gutters: 26px → 16px on phones; the flow stacks vertically */
  .hero { padding: 16px 16px 4px; }
  .hero-lede { font-size: 14px; }
  .flow { flex-direction: column; gap: 8px; }
  .flow-arrow { display: none; }
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 14px 16px 4px; }
  .stat { min-width: 0; }
  .banner { margin: 12px 16px; }
  .controls { flex-direction: column; align-items: stretch; padding: 14px 16px 8px; }
  .right-controls { flex-wrap: wrap; gap: 8px; }
  .ctl { flex: 1 1 45%; }
  .ctl select { flex: 1; min-width: 0; }
  .right-controls .propose-btn, .right-controls .ghost-btn { flex: 1 1 auto; text-align: center; }
  .lens-note { margin: 8px 16px 0; }
  .search { margin: 6px 16px 0; width: calc(100% - 32px); }
  .board { padding: 12px 16px 32px; }
  .card { grid-template-columns: 30px 1fr; gap: 10px; }
  .rank { font-size: 15px; }
  .c-num { grid-column: 2; text-align: left; min-width: 0; margin-top: 6px; }
  .foot { padding: 20px 16px 70px; }
  .modal { padding: 0 16px 18px; }
  .modal::before { margin: 0 -16px 12px; }
  .modal .kv, .form { grid-template-columns: 1fr; }
}

/* ─── lens note + open domains ───────────────────────────────────────────── */
/* lens helper line: aligned to the same 26px gutter as the controls/search/board,
   reads as one terminal-style note (wraps cleanly under itself on narrow screens). */
.lens-note { margin: 9px 26px 0; font-size: 12px; color: var(--muted); line-height: 1.5; }
.lens-note strong { color: var(--accent); font-weight: 700; }
.lens-note strong::before { content: "lens · "; color: var(--green); font-weight: 400; letter-spacing: .3px; }
.lens-note strong::after { content: ":"; color: var(--muted); }
.lens-desc { color: var(--muted); }
.lens-hint { color: var(--line2); }
.lens-hint::before { content: "  // "; }
.more-domains { color: var(--green); border-color: rgba(87,217,119,.35) !important; }

.domain-list { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; max-height: 50vh; overflow-y: auto; }
.domain-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; text-align: left; width: 100%; padding: 9px 11px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; font: inherit; color: var(--text); }
.domain-row:hover { border-color: var(--green); }
.domain-row code { color: var(--accent); }
.dim { color: var(--muted); font-size: 12px; }

/* download-verify block (get-wallet modal) */
pre.verify{background:#0c0c0c;border:1px solid var(--line,#242424);border-radius:6px;padding:10px;font-size:12px;line-height:1.5;overflow-x:auto;white-space:pre-wrap;word-break:break-all;color:var(--ink,#e6e6e6)}
details summary{outline:none}

/* in-page toast (replaces native alert popups) */
#toast {
  position: fixed; right: 18px; bottom: 18px; z-index: 1000;
  max-width: 340px; padding: 14px 16px 14px 16px;
  background: var(--panel2); border: 1px solid var(--line2); border-left: 3px solid var(--green);
  border-radius: 10px; color: var(--text); font-size: 13px; line-height: 1.5;
  box-shadow: 0 18px 50px rgba(0,0,0,.6);
  opacity: 0; transform: translateY(10px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
#toast.show { opacity: 1; transform: none; pointer-events: auto; }
#toast.err { border-left-color: #ff6b6b; }
#toast .toast-body b { color: var(--accent); }
#toast .toast-sub { color: var(--muted); font-size: 12px; margin-top: 3px; }
#toast .toast-link { display: inline-block; margin-top: 8px; color: var(--green); text-decoration: none; font-size: 12px; }
#toast .toast-link:hover { text-decoration: underline; }
#toast .toast-x { position: absolute; top: 6px; right: 8px; background: none; border: none; color: var(--muted); font-size: 16px; cursor: pointer; line-height: 1; padding: 2px; }
#toast .toast-x:hover { color: var(--text); }
@media (prefers-reduced-motion: reduce) { #toast { transition: none; } }
