/* ════════════════════════════════════════════════════════════════
   pages/asset.html - per-asset detail (/asset/:symbol)
   Reuses the wallet.css visual tokens (w-card / w-pad / flow colour
   variables) but keeps a separate .ast-* namespace so the layout
   can evolve independently. Flow colours use --flow-in / --flow-out
   (admin-customizable, set by flow-colors.js); NEVER raw --green / --red
   so the page follows the admin invert toggle. The .ssr-* block at the
   bottom is the crawler/no-JS fallback that services/seo/seo.js injects.
   ════════════════════════════════════════════════════════════════ */

body { min-height: 100vh; display: flex; flex-direction: column; }

.ast-shell { max-width: 1320px; margin: 16px auto 80px; padding: 0 16px; width: 100%; }
@media (max-width: 860px) { .ast-shell { padding: 0 6px; } }

/* Two-column layout: main column + right-side searchable rail of all
   tracked assets. The rail is a sticky 300px column on desktop; on tablets
   and below it collapses to a full-width row below the main content. */
.ast-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
@media (max-width: 1024px) { .ast-layout { grid-template-columns: 1fr; } }
.ast-main { min-width: 0; }   /* let grid item shrink under content overflow */

.ast-sidebar { position: sticky; top: 16px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; min-height: 0; }
@media (max-width: 1024px) { .ast-sidebar { position: static; max-height: 60vh; } }
.ast-rail-card { display: flex; flex-direction: column; min-height: 0; height: 100%; padding: 12px 0 0; }
.ast-rail-head { padding: 0 14px 8px; }
.ast-rail-head h3 { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--text-lo); display: flex; align-items: center; gap: 7px; }
.ast-rail-search { width: 100%; padding: 7px 10px; background: var(--bg-input); border: 1px solid var(--border2); border-radius: var(--r-md); color: var(--text-hi); font-family: var(--font); font-size: 12.5px; outline: none; transition: border-color .12s; }
.ast-rail-search:focus { border-color: var(--accent-2); }
.ast-rail-search::placeholder { color: var(--text-lo); }

.ast-rail-list { overflow-y: auto; overflow-x: hidden; min-height: 0; padding: 4px 4px 8px; }
.ast-rail-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; padding: 7px 10px; border-radius: var(--r-md); cursor: pointer; text-decoration: none; color: inherit; transition: background-color .1s; }
.ast-rail-row:hover { background: var(--bg-hover); }
.ast-rail-row.active { background: var(--accent-dim); }
.ast-rail-row.active .ast-rail-sym { color: var(--accent-2); }
.ast-rail-ico { width: 22px; height: 22px; border-radius: 50%; overflow: hidden; display: inline-grid; place-items: center; background: var(--bg-active); flex: none; }
.ast-rail-ico img, .ast-rail-ico span { width: 100% !important; height: 100% !important; border-radius: 50% !important; margin: 0 !important; object-fit: cover; }
.ast-rail-mid { min-width: 0; }
.ast-rail-sym { font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--text-hi); }
.ast-rail-sub { font-size: 10.5px; color: var(--text-lo); font-family: var(--mono); margin-top: 1px; }
.ast-rail-right { text-align: right; }
.ast-rail-price { font-family: var(--mono); font-size: 12px; color: var(--text-md); font-weight: 600; }
.ast-rail-chg   { font-family: var(--mono); font-size: 10.5px; font-weight: 600; margin-top: 1px; }
.ast-rail-chg.pos { color: var(--flow-in, var(--green)); }
.ast-rail-chg.neg { color: var(--flow-out, var(--red)); }

.ast-rail-empty { color: var(--text-lo); font-size: 12px; padding: 16px 14px; text-align: center; }

/* ════ MOBILE INLINE RAIL (≤860px) ════
   On phones the right rail collapses into an expandable "Other assets"
   panel that lives above the hero. Default closed. Tap to reveal the
   search + list (same data, same renderer - see js/pages/asset.js
   mountSidebar / renderRailList). Frees the bottom of the page from
   carrying a giant rail. */
.ast-rail-mobile { display: none; }
@media (max-width: 1024px) {
  .ast-rail-mobile { display: block; margin-bottom: 10px; }
  .ast-rail-mobile-trigger { display: flex; align-items: center; gap: 8px; width: 100%; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border); border-radius: 10px; color: var(--text-hi); font-family: var(--font); font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; -webkit-tap-highlight-color: transparent; }
  .ast-rail-mobile-trigger:hover { border-color: var(--border3); }
  .ast-rail-mobile-trigger .mat-ic { font-size: 18px; color: var(--accent-2); }
  .ast-rail-mobile-trigger .chev { margin-left: auto; transition: transform .15s; }
  .ast-rail-mobile.open .ast-rail-mobile-trigger .chev { transform: rotate(180deg); }
  .ast-rail-mobile-body { display: none; margin-top: 8px; }
  .ast-rail-mobile.open .ast-rail-mobile-body { display: block; }
  .ast-rail-mobile .ast-rail-card { max-height: 50vh; }
  .ast-rail-mobile .ast-rail-list { max-height: calc(50vh - 70px); }
  /* Hide the desktop sidebar on phones - data is now in the inline rail */
  .ast-sidebar { display: none; }
}

/* ════ MOBILE TUNING (≤860px) ════ */
@media (max-width: 860px) {
  .ast-shell { margin-top: 10px; margin-bottom: 24px; }

  /* Hero: tighter padding, single-column stacking */
  .ast-identity { padding: 14px 14px; gap: 10px; }
  .ast-headrow { gap: 8px; }
  .ast-icon { width: 32px; height: 32px; }
  .ast-sym { font-size: 18px; }
  .ast-price { font-size: 14px; margin-left: 0; flex-basis: 100%; order: 5; }
  .ast-chg { font-size: 11px; padding: 1px 6px; }

  /* Wrapper chips horizontal-scroll if many */
  .ast-fam { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 2px; }
  .ast-fam::-webkit-scrollbar { height: 0; }
  .ast-fam-chip { flex-shrink: 0; }

  /* KPI cards: tighter */
  .ast-kpis { gap: 8px; margin-top: 10px; }
  .ast-kpi { padding: 10px 12px; }
  .ast-kpi-label { font-size: 10px; margin-bottom: 4px; }
  .ast-kpi-value { font-size: 16px; }
  .ast-kpi-sub { font-size: 10.5px; }

  /* Chart card: smaller, hide the verbose legend hint */
  .ast-chart-card { padding: 12px 12px 14px; margin-top: 10px; }
  .ast-chart-head { gap: 8px; margin-bottom: 6px; }
  .ast-chart-title { font-size: 12px; }
  .ast-chart-legend { font-size: 10.5px; gap: 8px; }
  .ast-chart-legend > span:last-child { display: none; }   /* drop hint on phones */
  .ast-chart { height: 240px; }

  /* Actor filter chips: full-width row */
  .ast-actor-filter { flex-wrap: wrap; gap: 5px; }
  .ast-actor-chip { font-size: 11px; padding: 4px 8px; }

  /* Actor cards: tighter */
  .ast-actors { margin-top: 10px; gap: 10px; }
  .ast-actor-card { padding: 12px 12px 10px; }
  .ast-actor-card h3 { margin-bottom: 8px; font-size: 11px; }

  /* Recent events: tighter */
  .ast-events { padding: 12px 12px; margin-top: 10px; }
  .ast-events h3 { font-size: 11px; margin-bottom: 8px; }
  .ast-event-row { padding: 6px 0; font-size: 12px; }

  /* Bucket popup as a MOBILE BOTTOM SHEET - fixed at bottom, full-width,
     swipe-friendly. The desktop variant is an absolute box inside the chart
     which goes off-screen on a phone. */
  .ast-bucket-pop { position: fixed; left: 8px !important; right: 8px; bottom: 8px; top: auto !important; max-width: none; width: auto; max-height: 65vh; overflow-y: auto; padding: 14px 14px; border-radius: 14px; box-shadow: 0 -8px 32px rgba(0,0,0,.45), 0 0 0 1px rgba(255,255,255,.04); animation: ast-sheet-up .18s ease-out; }
  .ast-bucket-pop h4 { font-size: 12px; }
  .ast-bucket-pop li { padding: 8px 8px; font-size: 13px; }
  .ast-bucket-close { font-size: 22px; top: 8px; right: 12px; line-height: 1; padding: 4px 6px; }
  @keyframes ast-sheet-up { from { transform: translateY(60%); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

  /* Hover tooltip useless on touch - hide. Click still pins the full popup. */
  .ast-hover-tip { display: none !important; }

  /* "Show all" button on the events list */
  .ast-events-more { display: block; width: 100%; margin-top: 10px; padding: 9px; background: var(--bg-card2); border: 1px solid var(--border); border-radius: 8px; color: var(--accent-2); font-family: var(--font); font-size: 12.5px; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent; }
}

/* Actor filter chips above the chart - matches the project's other ark-seg
   chip style by hand-rolling locally so we don't pull a global rebuild for a
   single new control. */
.ast-actor-filter { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.ast-actor-chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border2); color: var(--text-md); background: var(--bg-card2); cursor: pointer; transition: .12s; }
.ast-actor-chip:hover { color: var(--text-hi); border-color: var(--border3); }
.ast-actor-chip.active { color: var(--accent-2); border-color: var(--accent-border); background: var(--accent-dim); }
.ast-actor-chip .ct { font-family: var(--mono); font-size: 10.5px; opacity: .75; }

/* Live event highlight - briefly flashes a newly-arrived tx row so the user's
   eye catches it. Subtle but unmistakable: accent-tinted background, glowing
   left edge, fades out over ~3s. Triggered by the WS subscriber when a new
   anomaly matches this asset. */
.ast-event-row.live-new { animation: ast-row-pop 3.2s ease-out; position: relative; }
@keyframes ast-row-pop {
  0%   { background: var(--accent-dim); box-shadow: inset 3px 0 0 var(--accent-2); }
  25%  { background: var(--accent-dim); box-shadow: inset 3px 0 0 var(--accent-2); }
  100% { background: transparent;        box-shadow: inset 3px 0 0 transparent; }
}
.ast-event-row .live-tag { display: inline-block; font-family: var(--mono); font-size: 9.5px; font-weight: 700; color: var(--accent-2); background: var(--accent-dim); border-radius: 4px; padding: 1px 5px; margin-right: 4px; letter-spacing: .4px; vertical-align: middle; }

/* Pulsing ring drawn over the chart at a new tx's coordinates. Fades + grows
   then dies. Pure CSS; positioned absolutely inside the chart container. */
.ast-pulse { position: absolute; pointer-events: none; width: 14px; height: 14px; border-radius: 50%; transform: translate(-50%, -50%); z-index: 8; animation: ast-pulse 2.4s ease-out forwards; }
@keyframes ast-pulse {
  0%   { box-shadow: 0 0 0 0   rgba(155,114,255,.70); transform: translate(-50%,-50%) scale(0.6); opacity: 1; }
  70%  { box-shadow: 0 0 0 22px rgba(155,114,255,0);   transform: translate(-50%,-50%) scale(1.4); opacity: .6; }
  100% { box-shadow: 0 0 0 28px rgba(155,114,255,0);   transform: translate(-50%,-50%) scale(1.6); opacity: 0; }
}
.ast-pulse.in  { background: var(--flow-in,  #00d17a); animation-name: ast-pulse-in; }
.ast-pulse.out { background: var(--flow-out, #ff4d4d); animation-name: ast-pulse-out; }
@keyframes ast-pulse-in {
  0%   { box-shadow: 0 0 0 0   rgba(0,209,122,.65); transform: translate(-50%,-50%) scale(0.6); opacity: 1; }
  70%  { box-shadow: 0 0 0 22px rgba(0,209,122,0);   transform: translate(-50%,-50%) scale(1.4); opacity: .6; }
  100% { box-shadow: 0 0 0 28px rgba(0,209,122,0);   transform: translate(-50%,-50%) scale(1.6); opacity: 0; }
}
@keyframes ast-pulse-out {
  0%   { box-shadow: 0 0 0 0   rgba(255,77,77,.65); transform: translate(-50%,-50%) scale(0.6); opacity: 1; }
  70%  { box-shadow: 0 0 0 22px rgba(255,77,77,0);   transform: translate(-50%,-50%) scale(1.4); opacity: .6; }
  100% { box-shadow: 0 0 0 28px rgba(255,77,77,0);   transform: translate(-50%,-50%) scale(1.6); opacity: 0; }
}

.ast-back { display: inline-flex; align-items: center; gap: 6px; font-family: var(--mono); font-size: 12px; font-weight: 700; color: var(--text-md); margin-bottom: 12px; text-decoration: none; }
.ast-back:hover { color: var(--accent-2); }
.ast-back .mat-ic { font-size: 16px; }

/* generic card (mirrors .w-card) */
.ast-card { background: var(--bg-card); background-image: var(--grad-card); border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-1); position: relative; }
.ast-pad  { padding: 16px 18px; }
.ast-card h3 { margin: 0 0 2px; font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: var(--text-lo); display: flex; align-items: center; gap: 7px; }
.ast-card h3 .mat-ic { font-size: 16px; }
.ast-sub { font-size: 11.5px; color: var(--text-lo); }
.ast-mono { font-family: var(--mono); }
.ast-up   { color: var(--flow-in, var(--green)); }
.ast-down { color: var(--flow-out, var(--red)); }
.ast-pos  { color: var(--green); } .ast-neg { color: var(--red); }

/* ════ HERO ════ */
.ast-hero { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.ast-identity { padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; }
.ast-headrow { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ast-icon { width: 38px; height: 38px; border-radius: 50%; overflow: hidden; display: inline-grid; place-items: center; flex: none; background: var(--bg-active); }
.ast-icon img, .ast-icon span { width: 100% !important; height: 100% !important; border-radius: 50% !important; margin: 0 !important; object-fit: cover; }
.ast-sym { font-family: var(--mono); font-size: 22px; color: var(--text-hi); font-weight: 700; letter-spacing: -.2px; }
.ast-price { font-family: var(--mono); font-size: 16px; color: var(--text-hi); font-weight: 600; margin-left: auto; }
.ast-chg { font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 2px 7px; border-radius: 6px; }
.ast-chg.pos { color: var(--flow-in, var(--green)); background: rgba(0,209,122,.10); }
.ast-chg.neg { color: var(--flow-out, var(--red));  background: rgba(255,77,77,.10); }

/* family / wrapper chips row */
.ast-fam { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.ast-fam-label { font-size: 11px; color: var(--text-lo); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; }
.ast-fam-chip { display: inline-flex; align-items: center; gap: 5px; font-family: var(--mono); font-size: 12px; font-weight: 600; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--border2); color: var(--text-md); background: var(--bg-card2); text-decoration: none; }
.ast-fam-chip:hover { color: var(--text-hi); border-color: var(--border3); background: var(--bg-hover); }
.ast-fam-chip.base { color: var(--accent-2); border-color: var(--accent-border); background: var(--accent-dim); }

/* wrappers include/exclude toggle */
.ast-wrap-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--text-md); cursor: pointer; user-select: none; }
.ast-wrap-toggle input { accent-color: var(--accent-2); }

/* ════ KPI STRIP ════ */
.ast-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 14px; }
@media (max-width: 860px) { .ast-kpis { grid-template-columns: repeat(2, 1fr); } }
.ast-kpi { padding: 14px 16px; }
.ast-kpi-label { font-size: 11px; color: var(--text-lo); text-transform: uppercase; letter-spacing: .6px; font-weight: 600; margin-bottom: 6px; }
.ast-kpi-value { font-family: var(--mono); font-size: 20px; font-weight: 700; color: var(--text-hi); }
.ast-kpi-sub   { font-size: 11.5px; color: var(--text-lo); margin-top: 4px; }

/* ════ CHART ════ */
.ast-chart-card { margin-top: 14px; padding: 14px 16px 16px; }
.ast-chart-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.ast-chart-title { font-size: 13px; font-weight: 600; color: var(--text-hi); }
.ast-chart-legend { display: flex; gap: 12px; font-size: 11.5px; color: var(--text-md); margin-left: auto; flex-wrap: wrap; }
.ast-leg-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.ast-chart { height: 360px; width: 100%; position: relative; }
@media (max-width: 860px) { .ast-chart { height: 280px; } }
.ast-chart-empty { color: var(--text-lo); font-size: 12px; text-align: center; padding: 60px 0; }

/* Hover tooltip - follows the crosshair on the chart, shows bucket summary at
   a glance. Lightweight (no list, no close button) - click pins the full list. */
.ast-hover-tip { position: absolute; z-index: 25; max-width: 260px; padding: 7px 10px; background: var(--bg-card2); border: 1px solid var(--border3); border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: 11.5px; color: var(--text-md); pointer-events: none; line-height: 1.4; transform: translate(8px, -50%); }
.ast-hover-tip .hh { font-family: var(--mono); font-size: 10.5px; color: var(--text-lo); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 3px; }
.ast-hover-tip .hb b { color: var(--text-hi); font-family: var(--mono); }
.ast-hover-tip .hb .in  { color: var(--flow-in,  var(--green)); }
.ast-hover-tip .hb .out { color: var(--flow-out, var(--red)); }
.ast-hover-tip .hh2 { font-size: 10.5px; color: var(--text-lo); margin-top: 3px; }

/* tooltip for marker bucket clicks (cluster expand) */
.ast-bucket-pop { position: absolute; z-index: 30; max-width: 320px; padding: 10px 12px; background: var(--bg-card2); border: 1px solid var(--border3); border-radius: var(--r-md); box-shadow: var(--shadow-2); font-size: 12px; color: var(--text-md); }
.ast-bucket-pop h4 { margin: 0 0 6px; font-size: 11px; text-transform: uppercase; color: var(--text-lo); font-weight: 700; letter-spacing: .6px; }
.ast-bucket-pop ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.ast-bucket-pop li { cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.ast-bucket-pop li:hover { background: var(--bg-hover); color: var(--text-hi); }
.ast-bucket-pop .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.ast-bucket-close { position: absolute; top: 4px; right: 6px; cursor: pointer; color: var(--text-lo); font-size: 14px; }

/* ════ ACTOR TABLE ════ */
.ast-actors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-top: 14px; }
/* Tablet: 2-up (don't waste a third row on a narrow tablet). */
@media (max-width: 1024px) and (min-width: 861px) { .ast-actors { grid-template-columns: 1fr 1fr; } }
/* Phone: horizontal swipe through MM / CEX / Whale cards. One at a time,
   snap-aligned. Way more space-efficient than three stacked cards and matches
   the native "swipe cards" UX users expect on iOS/Android. */
@media (max-width: 860px) {
  .ast-actors {
    grid-template-columns: 86% 86% 86%;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: 10px;
    padding-bottom: 4px;
  }
  .ast-actors::-webkit-scrollbar { height: 0; }
  .ast-actor-card { scroll-snap-align: start; min-width: 0; }
}
.ast-actor-card { padding: 14px 16px 12px; }
.ast-actor-card h3 { margin-bottom: 10px; }
.ast-actor-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid var(--border); }
.ast-actor-row:first-of-type { border-top: 0; }
.ast-actor-name { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; color: var(--text-hi); font-weight: 600; flex: 1; min-width: 0; text-decoration: none; }
.ast-actor-name .ast-actor-name-txt { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ast-actor-name img,
.ast-actor-name span:first-child:not(.ast-actor-name-txt) { flex: 0 0 auto; }
.ast-actor-name a { color: inherit; }
a.ast-actor-name:hover .ast-actor-name-txt { color: var(--accent-2); }
.ast-actor-net  { font-family: var(--mono); font-size: 12.5px; font-weight: 700; }
.ast-actor-cnt  { font-family: var(--mono); font-size: 11px; color: var(--text-lo); min-width: 30px; text-align: right; }
.ast-empty { color: var(--text-lo); font-size: 12px; padding: 6px 0; }

/* ════ RECENT EVENTS ════ */
.ast-events { margin-top: 14px; padding: 14px 16px; }
.ast-events h3 { margin-bottom: 10px; }
.ast-event-row { display: grid; grid-template-columns: auto 90px 1fr auto auto; gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--border); font-size: 12.5px; cursor: pointer; }
.ast-event-row:first-of-type { border-top: 0; }
.ast-event-row:hover { background: var(--bg-hover); border-radius: 6px; }
.ast-event-row .ago  { font-family: var(--mono); font-size: 11px; color: var(--text-lo); white-space: nowrap; }
.ast-event-row .cp   { color: var(--text-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ast-event-row .cex  { font-family: var(--mono); font-size: 11px; color: var(--text-lo); }
.ast-event-row .usd  { font-family: var(--mono); font-weight: 700; }
.ast-event-row .usd.in  { color: var(--flow-in, var(--green)); }
.ast-event-row .usd.out { color: var(--flow-out, var(--red)); }
@media (max-width: 860px) {
  .ast-event-row { grid-template-columns: auto 1fr auto; }
  .ast-event-row .cex, .ast-event-row .cp { display: none; }
}
