/* ccnodes v2 explorer — self-contained dark theme, no external deps */

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c232c;
  --line: #30363d;
  --fg: #e6edf3;
  --muted: #8b949e;
  --accent: #1f6feb;          /* overridden per-chain at runtime */
  --green: #3fb950;
  --amber: #d29922;
  --red: #f85149;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font: 15px/1.5 var(--sans);
  background: var(--bg);
  color: var(--fg);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

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

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: baseline; gap: 8px; color: var(--fg); }
.brand:hover { text-decoration: none; }
.brand-name { font-size: 18px; font-weight: 700; letter-spacing: .2px; }
.brand-tag {
  font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 10px; padding: 1px 8px;
}

.chain-select { display: flex; align-items: center; gap: 8px; }
.chain-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); flex: 0 0 auto; }

select, input, button {
  font: inherit; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px;
}
select { cursor: pointer; }
select option:disabled { color: var(--muted); }

.search { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.search input { flex: 1; }
.search button { background: var(--accent); border-color: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.search button:hover { filter: brightness(1.08); }

/* ---------- Layout ---------- */
.view { flex: 1; max-width: 1080px; width: 100%; margin: 0 auto; padding: 22px 20px 40px; }
.footer { border-top: 1px solid var(--line); padding: 14px 20px; text-align: center; font-size: 12px; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }

h2.section-title { font-size: 15px; margin: 26px 0 10px; font-weight: 600; letter-spacing: .3px; }
h2.section-title:first-child { margin-top: 4px; }

.page-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.page-head h1 { font-size: 20px; margin: 0; font-weight: 600; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 8px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.card .v { font-size: 22px; font-weight: 600; margin-top: 6px; word-break: break-word; }
.card .v.small { font-size: 16px; }

/* ---------- Panels ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.panel + .panel { margin-top: 14px; }
.panel-head { padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 600; font-size: 14px; display: flex; justify-content: space-between; align-items: center; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; }
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-family: var(--mono); white-space: nowrap; }

/* key/value definition list for detail pages */
.kv { display: grid; grid-template-columns: max-content 1fr; }
.kv > div { padding: 9px 16px; border-bottom: 1px solid var(--line); min-width: 0; }
.kv > div:nth-child(odd) { color: var(--muted); font-size: 13px; white-space: nowrap; }
.kv > div:nth-child(even) { font-family: var(--mono); word-break: break-all; }
.kv > div:nth-last-child(1), .kv > div:nth-last-child(2) { border-bottom: none; }
.kv .plain { font-family: var(--sans); }

/* ---------- Hash / copy ---------- */
.hash { font-family: var(--mono); }
.copy {
  cursor: pointer; border: none; background: transparent; color: var(--muted);
  padding: 0 4px; font-size: 13px; line-height: 1; vertical-align: middle;
}
.copy:hover { color: var(--fg); }

/* ---------- Badges ---------- */
.badge { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 20px; border: 1px solid var(--line); font-weight: 600; }
.badge.ok { color: var(--green); border-color: rgba(63,185,80,.4); background: rgba(63,185,80,.1); }
.badge.warn { color: var(--amber); border-color: rgba(210,153,34,.4); background: rgba(210,153,34,.1); }
.badge.bad { color: var(--red); border-color: rgba(248,81,73,.4); background: rgba(248,81,73,.1); }
.badge.accent { color: var(--accent); border-color: var(--accent); }

/* ---------- IO (tx inputs/outputs) ---------- */
.io { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.io-col { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.io-row { padding: 10px 14px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.io-row:last-child { border-bottom: none; }
.io-addr { font-family: var(--mono); font-size: 13px; word-break: break-all; min-width: 0; }
.io-val { font-family: var(--mono); white-space: nowrap; color: var(--fg); }
.io-foot { padding: 10px 14px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin: 18px 0 0; }
.tab { padding: 9px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; font-size: 14px; }
.tab.active { color: var(--fg); border-bottom-color: var(--accent); }

/* ---------- Buttons / misc ---------- */
.btn {
  background: var(--panel-2); border: 1px solid var(--line); color: var(--fg);
  border-radius: 8px; padding: 8px 14px; cursor: pointer; font-size: 14px;
}
.btn:hover { background: var(--line); }
.center { text-align: center; }
.mt { margin-top: 14px; }

/* ---------- Loading / empty / error ---------- */
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 40px 0; justify-content: center; }
.spinner {
  width: 16px; height: 16px; border: 2px solid var(--line);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty { color: var(--muted); padding: 24px; text-align: center; }

.banner {
  border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px;
  border: 1px solid rgba(248,81,73,.4); background: rgba(248,81,73,.08); color: var(--fg);
}
.banner .t { font-weight: 600; color: var(--red); margin-bottom: 2px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--panel); border: 1px solid var(--line); color: var(--fg);
  padding: 9px 16px; border-radius: 20px; font-size: 13px; opacity: 0;
  pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
 * Chain strip — live block visualizer (the "cooler mempool.space")
 * A horizontal lane of extruded 3D blocks. Newest on the LEFT,
 * preceded by a pulsing mempool/pending tile. Persists on every page.
 * ============================================================ */
.chainstrip {
  --cube: 96px;        /* front-face edge */
  --depth: 12px;       /* extrusion depth (top + side faces) */
  --gap: 30px;         /* horizontal gap between blocks (room for connector) */
  --lane-pt: 30px;     /* lane top padding — rail alignment tracks this */
  /* body is a fixed-height flex column and this section has overflow:hidden,
     so its flex min-size is 0 — without this it gets squeezed to nothing the
     moment the main view renders tall content. */
  flex-shrink: 0;
  position: relative;
  background:
    radial-gradient(1200px 80px at 18% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%),
    linear-gradient(180deg, var(--panel) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.chainstrip[hidden] { display: none; }

/* horizontal scroller; scrollbar hidden, scrolls on overflow.
   Full viewport width: confirmed blocks stretch across the whole left side,
   anchored right against the pending tile (margin-left:auto on the first
   tile right-aligns when the chain has fewer blocks than fit — the auto
   margin collapses to 0 once the lane overflows). */
.cs-lane {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: var(--lane-pt) 22px 26px;
  overflow-x: auto;
  scrollbar-width: none;
}
.cs-lane > :first-child { margin-left: auto; }
.cs-lane::-webkit-scrollbar { display: none; }

/* the animated "data rail" running through the centre of the blocks */
.cs-lane::before {
  content: '';
  position: absolute;
  left: 0; right: 0;
  top: calc(var(--lane-pt) + var(--depth) + var(--cube) / 2);   /* face vertical centre */
  height: 2px;
  background: repeating-linear-gradient(90deg,
    color-mix(in srgb, var(--accent) 55%, transparent) 0 10px,
    transparent 10px 26px);
  opacity: .5;
  animation: cs-flow 1.1s linear infinite;
  z-index: 0;
  pointer-events: none;
}
@keyframes cs-flow { to { background-position: 26px 0; } }

/* ---- a single block: the front face is the anchor ---- */
.cs-block {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: var(--cube);
  height: var(--cube);
  margin-top: var(--depth);    /* leave room for the top face */
  color: var(--fg);
  border-radius: 4px;
  background:
    linear-gradient(155deg,
      color-mix(in srgb, var(--accent) 38%, var(--panel-2)) 0%,
      color-mix(in srgb, var(--accent) 14%, var(--panel)) 100%);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent),
    0 10px 22px -10px color-mix(in srgb, var(--accent) calc(var(--heat, 0) * 60%), #000);
  transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
  will-change: transform;
}
.cs-block:hover { text-decoration: none; }

/* top face — skewed lighter slab */
.cs-block::before {
  content: '';
  position: absolute;
  top: calc(-1 * var(--depth)); left: 0;
  width: 100%; height: var(--depth);
  background: color-mix(in srgb, var(--accent) 60%, #fff 10%);
  transform: skewX(45deg);
  transform-origin: bottom left;
  border-radius: 3px 3px 0 0;
}
/* right face — skewed darker slab */
.cs-block::after {
  content: '';
  position: absolute;
  top: 0; right: calc(-1 * var(--depth));
  width: var(--depth); height: 100%;
  background: color-mix(in srgb, var(--accent) 32%, #000 28%);
  transform: skewY(45deg);
  transform-origin: top left;
  border-radius: 0 3px 3px 0;
}

.cs-block:hover {
  transform: translateY(-7px);
  filter: brightness(1.12);
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--accent) 40%, transparent),
    0 18px 30px -10px color-mix(in srgb, var(--accent) 70%, #000);
}

/* face content */
.cs-face-in {
  position: relative;
  z-index: 1;
  height: 100%;
  min-width: 0;
  padding: 8px 9px 9px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  text-align: left;
}
.cs-h { font-family: var(--mono); font-size: 12.5px; font-weight: 700; letter-spacing: 0; line-height: 1.1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-mid { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.cs-txs { font-size: 15px; font-weight: 600; white-space: nowrap; }
.cs-sub { font-size: 10.5px; color: color-mix(in srgb, var(--fg) 75%, var(--accent));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cs-age { font-size: 10px; color: var(--muted); white-space: nowrap; }

/* relative-fill meter pinned to the bottom edge of the face */
.cs-fill { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: color-mix(in srgb, #000 35%, transparent); border-radius: 0 0 4px 4px; overflow: hidden; }
.cs-fill > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #fff)); box-shadow: 0 0 8px var(--accent); }

/* freshest block keeps a gentle breathing glow */
.cs-block.cs-tip { animation: cs-breathe 2.4s ease-in-out infinite; }
@keyframes cs-breathe {
  0%, 100% { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent), 0 10px 22px -10px #000; }
  50%      { box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 55%, transparent), 0 0 26px -2px var(--accent); }
}

/* new block sliding in + shifting the chain (arrives at the right edge, by the mempool tile) */
.cs-block.cs-new { animation: cs-arrive .55s cubic-bezier(.22,1,.36,1) both; }
@keyframes cs-arrive {
  0%   { transform: translateX(34px) translateY(8px) scale(.7); opacity: 0; }
  60%  { transform: translateY(-4px) scale(1.04); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}
/* one-time staggered reveal on first paint */
.cs-block.cs-boot { animation: cs-fade .5s ease both; animation-delay: calc(var(--i, 0) * 55ms); }
@keyframes cs-fade { from { opacity: 0; transform: translateY(10px) scale(.92); } to { opacity: 1; transform: none; } }

/* ---- pending / mempool tile on the leading edge ---- */
.cs-pending {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  width: var(--cube);
  height: var(--cube);
  margin-top: var(--depth);
  border-radius: 4px;
  border: 1px dashed color-mix(in srgb, var(--accent) 70%, var(--line));
  background:
    repeating-linear-gradient(-45deg,
      color-mix(in srgb, var(--accent) 12%, transparent) 0 8px,
      transparent 8px 16px),
    color-mix(in srgb, var(--accent) 6%, var(--panel));
  color: var(--fg);
  overflow: hidden;
  animation: cs-pulse 1.8s ease-in-out infinite;
}
.cs-pending::after {                 /* sweeping shimmer */
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(110deg, transparent 30%, color-mix(in srgb, var(--accent) 30%, transparent) 50%, transparent 70%);
  transform: translateX(-100%);
  animation: cs-shimmer 2.2s ease-in-out infinite;
}
@keyframes cs-shimmer { 0% { transform: translateX(-120%); } 60%, 100% { transform: translateX(120%); } }
@keyframes cs-pulse {
  0%, 100% { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
  50%      { border-color: color-mix(in srgb, var(--accent) 95%, transparent); box-shadow: 0 0 20px -4px var(--accent); }
}
.cs-pending .cs-face-in { z-index: 2; }
.cs-pending .cs-h { color: var(--accent); }

/* live dot in the pending tile header */
.cs-live { display: inline-flex; align-items: center; gap: 5px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.cs-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 6px var(--green); animation: cs-blink 1.4s ease-in-out infinite; }
@keyframes cs-blink { 50% { opacity: .25; } }

.cs-empty { color: var(--muted); font-size: 13px; padding: 34px 22px; max-width: 1080px; margin: 0 auto; }

@media (prefers-reduced-motion: reduce) {
  .cs-lane::before, .cs-block.cs-tip, .cs-block.cs-new, .cs-block.cs-boot,
  .cs-pending, .cs-pending::after, .cs-live::before { animation: none; }
}

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
  .topbar { gap: 10px; }
  .search { order: 3; flex-basis: 100%; }
  .io { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; }
  .kv > div:nth-child(odd) { padding-bottom: 0; border-bottom: none; }
  .kv > div:nth-child(even) { padding-top: 2px; }
  .card .v { font-size: 19px; }
  .chainstrip { --cube: 82px; --depth: 10px; --gap: 24px; --lane-pt: 24px; }
  .cs-lane { padding: var(--lane-pt) 16px 20px; }
}

/* ---------- Topnav (Leaderboard / API keys) ---------- */
.topnav { display: flex; align-items: center; gap: 14px; margin-left: auto; }
.topnav a { color: var(--muted); font-size: 13px; white-space: nowrap; }
.topnav a:hover { color: var(--fg); text-decoration: none; }
.topnav .topnav-cta {
  color: var(--fg); border: 1px solid var(--accent); border-radius: 8px;
  padding: 6px 12px; font-weight: 600;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
}
.topnav .topnav-cta:hover { background: color-mix(in srgb, var(--accent) 28%, transparent); }

/* ---------- Account dashboard ---------- */
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-accent:hover { filter: brightness(1.1); background: var(--accent); }

.acct-connect { padding: 26px 24px; }
.acct-connect h2 { margin: 0 0 8px; font-size: 17px; }
.acct-connect .btn-accent { margin: 14px 0; padding: 10px 18px; font-size: 15px; }
.small { font-size: 12.5px; }

.acct-warn {
  border: 1px solid rgba(210,153,34,.5); background: rgba(210,153,34,.08);
  color: var(--fg); border-radius: 8px; padding: 10px 12px; font-size: 13px;
}

.meter { height: 6px; background: color-mix(in srgb, #000 35%, transparent);
  border-radius: 4px; overflow: hidden; margin-top: 8px; }
.meter > i { display: block; height: 100%;
  background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #fff)); }

.key-reveal { padding: 16px 18px; margin: 14px 0;
  border-color: var(--accent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 30%, transparent); }
.key-line { display: flex; align-items: center; gap: 6px; margin: 10px 0;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  overflow-x: auto; }
.key-line code { font-size: 14px; word-break: break-all; }
.key-reveal .acct-warn { margin: 10px 0; }
tr.key-off td { opacity: .55; }

.acct-points { padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.acct-optout { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); cursor: pointer; }

.buy-body { padding: 14px 16px; }
.buy-body p { margin: 8px 0; }
.buy-chain { display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 0; border-top: 1px solid var(--line); }
.buy-assets { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { display: inline-block; font-size: 12px; padding: 2px 9px; border-radius: 14px;
  border: 1px solid var(--line); background: var(--panel-2); font-family: var(--mono); }
.buy-body .acct-warn { margin-top: 12px; }

@media (max-width: 720px) {
  .topnav { order: 2; margin-left: 0; }
}
