/* ===========================================================================
   Stake.Cake — /solana/ onchain-metrics dashboards.
   Loaded AFTER guides/guide.css, so it inherits every design token and the
   shared chrome (header, footer, buttons, prose). This file only adds the
   dashboard + chart pieces.
   =========================================================================== */

/* ---------- Dashboard card ---------- */
.dash { max-width: var(--maxw); margin: 0 auto; }
.dash + .dash { margin-top: 40px; }
.dash-card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px 22px 20px;
  box-shadow: var(--shadow);
}
.dash-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.dash-title { font-family: 'Space Grotesk', sans-serif; font-size: clamp(20px, 3vw, 25px); font-weight: 700; letter-spacing: -0.02em; margin: 0; scroll-margin-top: 90px; }
.dash-sub { margin: 6px 0 0; font-size: 14.5px; color: var(--muted); max-width: 640px; }
.dash-cap {
  display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 13px; color: var(--muted-2); white-space: nowrap;
}
.dash-cap a { color: var(--muted); }
.dash-live-dot {
  width: 7px; height: 7px; flex: none; border-radius: 50%;
  background: var(--sol-green); box-shadow: 0 0 0 0 rgba(20,241,149,0.55);
  animation: dashPulse 2.4s ease-out infinite;
}
@keyframes dashPulse {
  0%   { box-shadow: 0 0 0 0 rgba(20,241,149,0.55); }
  70%  { box-shadow: 0 0 0 6px rgba(20,241,149,0); }
  100% { box-shadow: 0 0 0 0 rgba(20,241,149,0); }
}
@media (prefers-reduced-motion: reduce) { .dash-live-dot { animation: none; } }

/* ---------- Stat row: the latest epoch's headline numbers ---------- */
.dash-stats {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px;
  margin: 20px 0 4px;
}
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 14px 16px; }
.stat-k { display: flex; align-items: center; gap: 7px; font-size: 12px; letter-spacing: 0.03em; color: var(--muted-2); text-transform: uppercase; }
.stat-v { margin-top: 6px; font-family: 'Space Grotesk', sans-serif; font-size: clamp(19px, 2.6vw, 24px); font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-v small { font-size: 13px; font-weight: 500; color: var(--muted-2); letter-spacing: 0; }
.stat.is-total { background: rgba(255,168,5,0.07); border-color: rgba(255,168,5,0.25); }
.stat.is-total .stat-v { color: var(--gold-soft); }
.swatch { width: 9px; height: 9px; border-radius: 2px; flex: none; }
.sw-issuance { background: #ffa805; }
.sw-jito     { background: #9945ff; }
.sw-fees     { background: #14f195; }

/* ---------- Chart ---------- */
.chart-wrap { position: relative; margin: 18px 0 6px; }

/* Brush navigator — mini overview of the whole series with a draggable window. */
.chart-brush { position: relative; width: 100%; height: 52px; margin-top: 8px; }
.chart-brush canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Interactive canvas (fills the frame; the noscript SVG is the fallback). */
.chart-frame canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block;
  cursor: crosshair; touch-action: pan-y; }

/* Hover tooltip */
.chart-tooltip { position: absolute; z-index: 5; pointer-events: none; min-width: 156px;
  background: rgba(12,16,20,0.96); border: 1px solid var(--line-strong); border-radius: 10px;
  padding: 9px 11px; box-shadow: var(--shadow); font-size: 12.5px; }
.chart-tooltip .tt-date { font-family: 'Space Grotesk', sans-serif; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.chart-tooltip .tt-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 1px 0; color: var(--muted); }
.chart-tooltip .tt-row span { display: inline-flex; align-items: center; gap: 6px; }
.chart-tooltip .tt-row i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; flex: none; }
.chart-tooltip .tt-row b { color: var(--text); font-variant-numeric: tabular-nums; }
.chart-tooltip .tt-total { margin-top: 5px; padding-top: 5px; border-top: 1px solid var(--line); }
.chart-tooltip .tt-total b { color: var(--gold-soft); }
.chart-frame {
  /* Aspect ratio matches the SVG viewBox (1040x440) so the chart scales
     uniformly at every width — no stretched axis labels, no letterboxing. */
  position: relative; width: 100%; aspect-ratio: 1040 / 440;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.015), transparent 40%),
    var(--bg);
  overflow: hidden;
}
/* Older engines without aspect-ratio support fall back to a sensible height. */
@supports not (aspect-ratio: 1 / 1) { .chart-frame { height: clamp(240px, 40vw, 420px); } }
.chart-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.chart-svg .c-yl, .chart-svg .c-xl {
  font-family: 'Inter', sans-serif; fill: var(--muted-2);
}
.chart-svg .c-yl { font-size: 13px; }
.chart-svg .c-xl { font-size: 12px; }

.chart-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 14px 2px 0; }
.leg { display: inline-flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); }
.leg b { color: var(--text); font-weight: 600; }
.leg .swatch { width: 11px; height: 11px; border-radius: 3px; }

.chart-xcap { margin: 8px 2px 0; font-size: 12.5px; color: var(--muted-2); }

/* ---------- Data table (server-rendered; carries the numbers for search/a11y) ---------- */
.dash-data { margin: 18px 0 0; }
.dash-data > summary {
  cursor: pointer; list-style: none; display: inline-flex; align-items: center; gap: 8px;
  font-size: 13.5px; color: var(--muted); padding: 7px 12px;
  border: 1px solid var(--line-strong); border-radius: 999px; background: rgba(255,255,255,0.03);
  transition: color .2s, border-color .2s, background .2s;
}
.dash-data > summary:hover { color: var(--text); border-color: var(--gold); }
.dash-data > summary::-webkit-details-marker { display: none; }
.dash-data[open] > summary { margin-bottom: 14px; }
.dash-tbl-wrap { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.dash-tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 520px; }
.dash-tbl th, .dash-tbl td { padding: 9px 13px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dash-tbl thead th { position: sticky; top: 0; background: var(--surface-2); font-family: 'Space Grotesk', sans-serif; font-weight: 600; color: var(--text); z-index: 1; }
.dash-tbl tbody td { color: var(--muted); font-variant-numeric: tabular-nums; }
.dash-tbl th:first-child, .dash-tbl td:first-child { text-align: left; color: var(--text); }
.dash-tbl td:last-child { color: var(--gold-soft); font-weight: 600; }
.dash-tbl tr:last-child td { border-bottom: none; }

.dash-note { margin: 16px 2px 0; font-size: 13px; line-height: 1.6; color: var(--muted-2); }
.dash-note strong { color: var(--muted); }
.dash-note a { color: var(--muted); text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Hub: metric preview cards (sparkline + stat + link) ---------- */
.metric-grid { max-width: var(--maxw); margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.metric-card { display: flex; flex-direction: column; background: linear-gradient(180deg, var(--surface), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; text-decoration: none; color: inherit; position: relative; overflow: hidden; transition: transform .2s, border-color .2s, box-shadow .2s; }
a.metric-card:hover { transform: translateY(-4px); border-color: var(--line-strong); box-shadow: var(--shadow); }
a.metric-card::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--gold), var(--sol-green)); opacity: 0; transition: opacity .25s; }
a.metric-card:hover::after { opacity: 1; }
.mc-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 14px; }
.mc-title { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 16px; }
.mc-tag { font-size: 10.5px; letter-spacing: 0.05em; text-transform: uppercase; color: var(--muted-2); border: 1px solid var(--line-strong); border-radius: 999px; padding: 2px 9px; white-space: nowrap; }
.mc-stat { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.mc-stat b { font-family: 'Space Grotesk', sans-serif; font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.mc-stat small { color: var(--muted-2); font-size: 12.5px; }
.mc-trend { margin-left: auto; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mc-trend.up { color: var(--sol-green); }
.mc-trend.down { color: #ff6b6b; }
.spark { width: 100%; height: 54px; display: block; margin-bottom: 14px; }
.mc-desc { color: var(--muted); font-size: 14px; margin: 0 0 16px; line-height: 1.5; }
.mc-more { margin-top: auto; color: var(--sol-green); font-family: 'Space Grotesk', sans-serif; font-weight: 600; font-size: 14px; }
.metric-card.is-soon { opacity: 0.6; }
.metric-card.is-soon .mc-desc { margin-bottom: 0; }

@media (max-width: 820px) {
  .metric-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .dash-head { flex-direction: column; }
}
@media (max-width: 560px) {
  .metric-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .dash-card { padding: 16px 14px 16px; }
}
