/* BTC Black Hole Dashboard.
   Design Read: live BTC macro dashboard for one reader checking price vs
   realized price and MVRV, in a black-hole visual language.
   Dials: ENERGY 1 / RHYTHM 1 / MOTION 1.
   Reasons: true black background because the black-hole identity is the
   brand; starlight white price because it is the focal point; amber at
   the live marker, halving lines, cycle-top trend, projection band, the
   single control border, and the focus outline because one accent marks
   the key moments and the keyboard focus; violet realized and teal MVRV
   because each series needs one distinct color; Orbitron for headings and
   Space Mono for data because the spec pairs display type with data type;
   uniform panels with 12-16px gaps because RHYTHM 1 is deliberate;
   nothing animates on a loop because MOTION 1 is hover states only.
   System fonts only: Orbitron and Space Mono are used when installed locally,
   with a clean sans and mono fallback otherwise. No webfont fetch. */

:root {
  --bg: #000000;
  --panel: #070707;
  --border: #2a2a2a;
  --text: #f2f2f2;
  --muted: #a6aeb8;
  --amber: #f5a623;
  --amber-dim: #b97f1a;
  --teal: #2dd4bf;
  --violet: #a78bfa;
  --m2: #8aa8c8;
  --focus: #f5a623;
  --error: #f87171;
  --display: "Orbitron", "DejaVu Sans", system-ui, sans-serif;
  --data: "Space Mono", "JetBrains Mono", "DejaVu Sans Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--data);
  font-size: 16px;
  line-height: 1.5;
  padding: 16px;
}

.page-head {
  max-width: 1120px;
  margin: 0 auto 16px;
}

h1 {
  font-family: var(--display);
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  line-height: 1.15;
  margin: 8px 0 4px;
  letter-spacing: 0.02em;
}

.h1-dim { color: var(--muted); }

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 0.95rem;
}

main, footer {
  max-width: 1120px;
  margin: 0 auto;
}

h2 {
  font-family: var(--display);
  font-size: 1.05rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  margin: 0 0 8px;
}

/* Live readings: one row on desktop, stacked on phones. */
.live {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}

.stat {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 14px 16px;
  min-width: 0;
}

.stat-label {
  margin: 0 0 6px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-source {
  display: block;
  letter-spacing: 0;
  text-transform: none;
  font-size: 0.8rem;
  color: var(--muted);
}

.stat-value {
  margin: 0;
  font-size: clamp(1.7rem, 4.5vw, 2.4rem);
  line-height: 1.1;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.stat-value-sm { font-size: clamp(1.5rem, 4vw, 2rem); }

.stat-sub {
  margin: 8px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

/* LIVE marker: one amber dot, no glow, no pulse. Shown only when live. */
.live-mark {
  display: inline-block;
  vertical-align: middle;
  font-size: 0.75rem;
  letter-spacing: 0.18em;
  color: var(--amber);
  border: 1px solid var(--amber-dim);
  border-radius: 4px;
  padding: 3px 8px 3px 7px;
  margin-left: 8px;
}

.live-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  margin-right: 6px;
  vertical-align: 1px;
}

.live-mark.stale {
  color: var(--muted);
  border-color: var(--border);
}
.live-mark.stale .live-dot { background: var(--muted); }

/* Buttons: one real control (pause/resume) plus retry. 44px minimum. */
.btn {
  font-family: var(--data);
  font-size: 1rem;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 16px;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--amber-dim);
  border-radius: 6px;
  cursor: pointer;
}

.btn:hover { border-color: var(--amber); color: var(--amber); }
.btn:active { background: #1a1206; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* States: loading, empty, error. */
.state {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 16px;
}

.state-title {
  font-family: var(--display);
  font-size: 1.1rem;
  margin: 0 0 8px;
}

.state p { margin: 0 0 12px; color: var(--muted); }
.state .state-title { color: var(--text); }
.state code { color: var(--text); }

.state-error { border-color: #7f1d1d; }
.state-error .state-title { color: var(--error); }

/* Panels and charts. */
.panel {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0 0 12px;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.legend li { display: flex; align-items: center; gap: 8px; }

.swatch {
  display: inline-block;
  width: 22px;
  height: 0;
  border-top: 3px solid var(--text);
  flex: none;
}
.swatch-price { border-color: #f5f5f5; }
.swatch-realized { border-color: var(--violet); }
.swatch-m2 { border-color: var(--m2); }
.swatch-band {
  height: 10px;
  border: 1px solid var(--amber-dim);
  background: rgba(245, 166, 35, 0.18);
}
.swatch-proj-realized { border-top: 3px dotted var(--violet); }
.swatch-mvrv { border-color: var(--teal); }
.swatch-trend { border-color: var(--amber); }
.swatch-breakeven { border-top: 2px dashed var(--teal); }

.chart-wrap { width: 100%; overflow: hidden; }
.chart-wrap svg {
  display: block;
  width: 100%;
  height: auto;
}

.chart-note {
  margin: 12px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

footer {
  border-top: 1px solid var(--border);
  padding: 16px 0 8px;
  color: var(--muted);
  font-size: 0.85rem;
}
footer p { margin: 0 0 4px; }

/* Phones: stack the stats, keep everything inside 360px. */
@media (max-width: 720px) {
  body { padding: 12px; }
  .live { grid-template-columns: 1fr 1fr; }
  .stat-control { grid-column: 1 / -1; }
}

@media (max-width: 400px) {
  .live { grid-template-columns: 1fr; }
  .panel { padding: 12px; }
  .stat { padding: 12px; }
}

/* [hidden] must win over display rules elsewhere in this file
   (e.g. .legend li is display:flex, .live-mark is inline-block). */
[hidden] { display: none !important; }

/* Motion: nothing on this page animates on a loop. The only change is the
   live price text, updated in place. Honor reduced motion anyway. */
@media (prefers-reduced-motion: reduce) {
  * { transition: none; animation: none; }
}
