/* =========================================================
   ChainScope live-data additions (load after styles.css)
   ========================================================= */

/* Variables referenced in styles.css but never defined */
/* Declared on body too so they follow body.dark's --surface / --line */
:root, body { --panel: var(--surface); --card-bg: var(--surface); --border: var(--line); --amber: #c9861a; }

/* ---------- Network status pill ---------- */
.network-pill { display: inline-flex; align-items: center; gap: 4px; }
.network-pill .status-dot { animation: dotPulse 2s ease-in-out infinite; }
.network-pill.is-warn .status-dot { background: #e0a31c; }
.network-pill.is-error .status-dot { background: var(--red); animation: none; }
@keyframes dotPulse { 50% { opacity: .35; } }

/* ---------- Loading skeletons ---------- */
.is-loading {
  color: transparent !important;
  width: 92px;
  max-width: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--line), var(--surface2), var(--line));
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.panel-msg { color: var(--muted); font-size: 12px; padding: 22px 6px; text-align: center; line-height: 1.6; }
td.panel-msg { white-space: normal; }

/* ---------- Refresh / updated label ---------- */
.refresh-wrap { display: flex; align-items: center; gap: 12px; }
.updated { color: var(--muted); font-size: 11px; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px rgba(19,165,111,.18); }

/* ---------- Headline stats (TRONSCAN-style) ---------- */
.secondary-grid { margin-top: 14px; }
.headline-card { display: block; color: inherit; transition: border-color .15s, transform .15s, box-shadow .15s; }
.headline-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 14px 34px rgba(40,100,232,.12); }
.headline-card strong { font-size: clamp(17px, 1.65vw, 23px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.3px; }
.delta-line { display: flex; align-items: center; gap: 7px; font-size: 11px; margin-top: 2px; }
.delta-line span { color: #9aa4b4; font-size: 10px; padding: 2px 6px; border-radius: 5px; background: var(--surface2); border: 1px solid var(--line); }
.delta-line b { font-weight: 700; color: var(--muted); }
.headline-card .sparkline i { background: #c9d9fb; }
body.dark .headline-card .sparkline i, body.dark .sparkline i { background: #2c4270; }

@media (max-width: 700px) {
  .headline-card strong { font-size: 15px; }
  .delta-line { flex-wrap: wrap; gap: 5px; }
  .delta-line b { font-size: 10px; }
  .delta-line span { font-size: 9px; padding: 1px 5px; }

  /* line the y-axis labels up with the 190px-tall mobile chart */
  .chart-wrap { padding-left: 36px; height: auto; }
  .y-labels { top: 12px; bottom: auto; height: 178px; left: 4px; }
}
@media (max-width: 430px) {
  .headline-card strong { font-size: 14px; }
}

/* ---------- Live value changes ---------- */
.flash-up { animation: flashUp 1.1s ease-out; }
.flash-down { animation: flashDown 1.1s ease-out; }
@keyframes flashUp { 0%, 35% { color: var(--green); } 100% { color: inherit; } }
@keyframes flashDown { 0%, 35% { color: var(--red); } 100% { color: inherit; } }
.estimate::before { content: "≈ "; color: var(--muted); font-weight: 600; }
.headline-card strong.estimate::before { font-size: .8em; }

/* ---------- Chart series palette (validated: adjacent CVD ΔE ≥ 8.4 in both modes) ---------- */
body {
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --s6: #008300;
  --cv-grid: #edf0f4; --cv-base: #d6dce6; --cv-ink: #9aa5b5;
}
body.dark {
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --s6: #008300;
  --cv-grid: #1e2a3d; --cv-base: #2c3a52; --cv-ink: #7f8ba0;
}

/* ---------- Network analytics ---------- */
.analytics { margin-top: 34px; }
.analytics-tools { display: flex; align-items: center; gap: 12px; }
.ana-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; } /* 3 per row on desktop */
.ana-wide { grid-column: 1 / -1; }
.ana-panel { min-width: 0; }
.ana-panel .panel-head { align-items: flex-start; }
.ana-sub { margin: 4px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.ana-sub em { font-style: normal; color: #9aa4b4; }
.ana-split { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.ana-split > div { min-width: 0; }
.ana-split h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.table-btn { border: 1px solid var(--line); background: var(--surface); color: var(--muted); border-radius: 7px;
  padding: 5px 10px; font-size: 11px; font-weight: 600; flex-shrink: 0; }
.table-btn:hover { color: var(--text); border-color: var(--accent); }

/* chart primitives (charts.js) */
.cv { position: relative; min-width: 0; }
.cv-plot { position: relative; width: 100%; }
.cv-plot svg { display: block; overflow: visible; }
.cv-grid line { stroke: var(--cv-grid); stroke-width: 1; shape-rendering: crispEdges; }
.cv-grid line.cv-base { stroke: var(--cv-base); }
.cv-tick { fill: var(--cv-ink); font-size: 10px; font-family: Inter, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.cv-cursor { stroke: var(--cv-base); stroke-width: 1; opacity: 0; }
.cv-hoverband { fill: var(--text); fill-opacity: .05; opacity: 0; }
.cv-dot { stroke: var(--surface); stroke-width: 2; }
.cv-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; margin: -4px 0 10px; font-size: 11px; color: var(--muted); }
.cv-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cv-legend i, .cv-tip i { width: 9px; height: 9px; border-radius: 3px; display: inline-block; flex-shrink: 0; }
.cv-tip { position: absolute; top: 0; left: 0; z-index: 4; pointer-events: none; opacity: 0; transition: opacity .1s;
  min-width: 170px; background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 9px;
  box-shadow: 0 12px 30px rgba(15,25,45,.14); padding: 9px 11px; font-size: 11px; }
.cv-tip-date { color: var(--muted); font-size: 10px; margin-bottom: 6px; }
.cv-tip div:not(.cv-tip-date) { display: flex; align-items: center; gap: 7px; padding: 2px 0; }
.cv-tip span { color: var(--muted); flex: 1; }
.cv-tip b { font-variant-numeric: tabular-nums; }
.cv-tip .cv-tip-total { border-top: 1px solid var(--line); margin-top: 4px; padding-top: 5px !important; }
.cv-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 60px 10px; }

/* horizontal ranked bars */
.hb { display: flex; flex-direction: column; gap: 4px; }
.hb-row { display: grid; grid-template-columns: minmax(90px, 38%) 1fr auto; align-items: center; gap: 10px; padding: 7px 0; }
.hb-label { font-size: 12px; font-weight: 600; min-width: 0; line-height: 1.3; overflow-wrap: anywhere; }
.hb-label a:hover { color: var(--accent); }
.hb-label small { display: block; font-weight: 400; font-size: 10px; color: var(--muted); margin-top: 2px; }
.hb-track { height: 8px; background: var(--surface2); border-radius: 4px; overflow: hidden; }
.hb-track span { display: block; height: 100%; border-radius: 4px; }
.hb-value { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 58px; text-align: right; }

/* table twin */
.cv-table { display: none; max-height: 290px; overflow: auto; }
.cv-table table { min-width: 0; width: 100%; }
.cv-table th { position: sticky; top: 0; background: var(--surface); padding: 6px 8px; }
.cv-table td { padding: 7px 8px; white-space: nowrap; }
.cv-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.cv-table th:not(:first-child) { text-align: right; }
.show-table .cv-plot, .show-table .cv-legend { display: none; }
.show-table .cv-table { display: block; }

/* 3 per row on every desktop/laptop width; 2 on tablets; 1 on phones */
@media (max-width: 768px) {
  .ana-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .ana-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
  .ana-split { grid-template-columns: minmax(0, 1fr); gap: 16px; }
  .analytics-tools .updated { display: none; }
}
@media (max-width: 700px) {
  .analytics-head { flex-wrap: wrap; }
  .ana-panel .panel-head { padding: 0 0 12px; }
  .hb-row { grid-template-columns: minmax(70px, 32%) 1fr auto; gap: 8px; }
}

/* ---------- Chart ---------- */
.chart-wrap { position: relative; }
.chart-msg { position: absolute; inset: 0 0 0 42px; display: grid; place-items: center; }
.chart-cursor { stroke: var(--accent); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0; vector-effect: non-scaling-stroke; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 3;
  background: #162235; color: #fff; padding: 7px 10px; border-radius: 8px;
  font-size: 11px; line-height: 1.4; white-space: nowrap;
  transform: translate(-50%, calc(-100% - 10px)); opacity: 0; transition: opacity .12s;
}
.chart-tip span { color: #a9b8d3; }
.chart-summary { color: var(--muted); font-size: 11px; margin: 8px 0 0 42px; }
.line-chart { cursor: crosshair; }

/* ---------- Tokens ---------- */
.token-logo { position: relative; overflow: hidden; background: var(--accent); }
.token-logo img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: var(--surface); }

/* ---------- Tables / links ---------- */
.clickable { cursor: pointer; }
tr.clickable:hover td, .rank-row.clickable:hover, .token-row.clickable:hover { background: var(--surface2); }
.link { color: var(--accent); cursor: pointer; }
.link:hover { text-decoration: underline; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.muted { color: var(--muted); }

.tx-type {
  display: inline-block; font-size: 10px; font-weight: 600; padding: 3px 7px; border-radius: 6px;
  background: var(--surface2); border: 1px solid var(--line); color: var(--text);
  max-width: 150px; overflow: hidden; text-overflow: ellipsis; vertical-align: middle;
}
.status.failed { background: #fdecee; color: var(--red); }
.status.pending { background: #fff4de; color: var(--amber); }

/* Live transaction feed replaces the looping scroller */
.tx-scroll { height: auto; overflow-x: auto; overflow-y: visible; }
.tx-scroll::before, .tx-scroll::after { display: none; }
.tx-scroll .tx-table thead { position: static; }
.tx-scroll .tx-table tbody { transform: none !important; }
tr.row-new td { animation: rowIn 2.2s ease-out; }
@keyframes rowIn {
  0% { background: rgba(40,100,232,.16); }
  100% { background: transparent; }
}

select.filter-btn { appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 13px) 50%, calc(100% - 9px) 50%; background-size: 4px 4px; background-repeat: no-repeat; }

/* ---------- Developer banner links ---------- */
.dev-actions .btn { display: inline-block; border: 0; background: var(--accent); color: #fff; padding: 13px 22px; border-radius: 8px; font-weight: 700; text-align: center; white-space: nowrap; }
.dev-actions .btn.ghost { background: transparent; border: 1px solid rgba(255,255,255,.2); }

/* ---------- Search result links ---------- */
.search-result .link { font-weight: 600; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 16px;
  background: rgba(10,16,28,.55); backdrop-filter: blur(3px); }
.modal.hidden { display: none; }
.modal-card { width: min(660px, 100%); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--surface); color: var(--text); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0,0,0,.25); animation: modalIn .16s ease-out; }
@keyframes modalIn { from { opacity: 0; transform: translateY(8px); } }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 4px 18px 20px; overflow: auto; }
.kv { display: grid; grid-template-columns: 140px 1fr; margin: 0; }
.kv dt, .kv dd { margin: 0; padding: 11px 0; border-bottom: 1px solid var(--line); font-size: 12px; }
.kv dt { color: var(--muted); padding-right: 12px; }
.kv dd { word-break: break-all; line-height: 1.55; }
.kv dd small { font-size: 11px; }
.modal-link { display: inline-block; margin-top: 16px; color: var(--accent); font-weight: 600; font-size: 13px; }

@media (max-width: 560px) {
  .kv { grid-template-columns: 1fr; }
  .kv dt { border-bottom: 0; padding-bottom: 2px; }
  .kv dd { padding-top: 0; }
  .refresh-wrap .updated { display: none; }
}

@media (max-width: 700px) {
  .chart-summary { margin-left: 10px; }
  .chart-msg { inset: 0; }
  .dev-actions .btn { width: 100%; padding: 10px 8px; font-size: 11px; }
}

/* ---------- Dark mode tweaks ---------- */
body.dark .status.failed { background: rgba(226,90,103,.15); }
body.dark .status.pending { background: rgba(224,163,28,.15); }
body.dark .status { background: rgba(19,165,111,.15); }
body.dark .tx-type { background: #1b283c; border-color: #2a3850; }
body.dark .main-nav a:hover, body.dark .main-nav a.active { background: rgba(255,255,255,.05); }
body.dark th { color: #7f8ba0; }

@media (prefers-reduced-motion: reduce) {
  .is-loading, .network-pill .status-dot, tr.row-new td { animation: none; }
}

/* =========================================================
   HERO ILLUSTRATION — live block stack (original artwork)
   ========================================================= */
.hero-copy { min-width: 0; }
.hero-art { display: none; }

/* Hero spans the full width: the text stays aligned with the page content
   (same left edge as the 1280px container), the illustration hugs the right edge. */
@media (min-width: 1080px) {
  .hero-inner {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; align-items: center;
    max-width: none;
    padding-left: max(32px, calc((100% - 1280px) / 2 + 32px));
    padding-right: 3%;
  }
  .hero-art { display: block; position: relative; width: 320px; height: 320px; justify-self: end; margin-right: 8px; }
}
@media (min-width: 1280px) {
  .hero-art { width: 360px; height: 360px; }
}

.hero-art-svg { width: 100%; height: 100%; overflow: visible; }
.ha-ring { stroke: rgba(40, 100, 232, .22); stroke-width: 1.2; }
.ha-ring-dash { stroke-dasharray: 3 7; animation: haSpin 60s linear infinite; transform-origin: 180px 180px; }
.ha-links line { stroke: rgba(40, 100, 232, .16); stroke-width: 1; }
.ha-nodes circle { fill: #fff; stroke: var(--accent); stroke-width: 1.6; }
.ha-packets circle { fill: var(--accent); }

.ha-stack { animation: haFloat 6s ease-in-out infinite; }
.ha-top { fill: #8fb1ff; }
.ha-left { fill: #2864e8; }
.ha-right { fill: #1a4bbd; }
.ha-cube-2 { opacity: .55; }
.ha-cube-3 { opacity: .28; }
.ha-mark { fill: rgba(255, 255, 255, .9); }
.ha-cube-1 polygon { stroke: rgba(255, 255, 255, .35); stroke-width: .8; stroke-linejoin: round; }

/* new block drops onto the stack */
#haTopBlock.ha-drop { animation: haDrop .7s cubic-bezier(.2, .9, .3, 1.25); }

.ha-chip {
  position: absolute; display: flex; gap: 14px; align-items: center;
  padding: 10px 13px; border-radius: 12px;
  background: rgba(255, 255, 255, .86); border: 1px solid #dfe7f5;
  box-shadow: 0 12px 30px rgba(38, 78, 145, .12); backdrop-filter: blur(8px);
}
.ha-chip small { display: block; font-size: 9px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.ha-chip b { display: block; font-size: 13px; margin-top: 2px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.ha-chip-top { top: 26px; right: -6px; }
.ha-chip-bottom { bottom: 22px; left: -10px; }
.ha-chip-bottom > div + div { padding-left: 14px; border-left: 1px solid var(--line); }
.ha-chip-bottom b#haProducer { max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.ha-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(19, 165, 111, .16); animation: dotPulse 2s ease-in-out infinite; }
.ha-chip b.ha-bump { animation: flashUp 1.1s ease-out; }

@keyframes haFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }
@keyframes haSpin { to { transform: rotate(360deg); } }
@keyframes haDrop { 0% { transform: translateY(-46px); opacity: 0; } 60% { opacity: 1; } 100% { transform: translateY(0); } }

body.dark .ha-nodes circle { fill: #121c2b; }
body.dark .ha-ring { stroke: rgba(93, 141, 255, .28); }
body.dark .ha-links line { stroke: rgba(93, 141, 255, .18); }
body.dark .ha-chip { background: rgba(18, 28, 43, .88); border-color: #2b3b55; box-shadow: 0 12px 30px rgba(0, 0, 0, .3); }

@media (prefers-reduced-motion: reduce) {
  .ha-stack, .ha-ring-dash, #haTopBlock.ha-drop, .ha-dot { animation: none; }
  .ha-packets { display: none; }
}