/* Bitcoin Power-Law Dashboard — refined-dark "precision instrument" design system.
   Flat by intent: no box-shadow / text-shadow / glow anywhere. Depth comes from layered
   slate values + hairlines. Self-hosted type: Hanken Grotesk (UI) + Geist Mono (figures). */

/* ---------- self-hosted fonts (offline, latin subset) ---------- */
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/vendor/fonts/hanken-grotesk-400.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/vendor/fonts/hanken-grotesk-500.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/vendor/fonts/hanken-grotesk-600.woff2") format("woff2"); }
@font-face { font-family: "Hanken Grotesk"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/vendor/fonts/hanken-grotesk-700.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/vendor/fonts/geist-mono-400.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 500; font-display: swap;
  src: url("/static/vendor/fonts/geist-mono-500.woff2") format("woff2"); }
@font-face { font-family: "Geist Mono"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/vendor/fonts/geist-mono-600.woff2") format("woff2"); }

:root {
  --bg:        #0a0d12;
  --bg-1:      #0c1017;   /* top bar / footer            */
  --bg-2:      #10151e;   /* elevated cards              */
  --line:      #1a222e;   /* structural hairlines        */
  --hair:      rgba(255,255,255,.08);
  --line-soft: rgba(255,255,255,.05);
  --text:      #e9eef6;
  --muted:     #8a97a8;
  --faint:     #76828f;   /* WCAG-AA on the slate canvas (>=4.5:1) for small labels */
  --orange:    #f7931a;   /* price / Bitcoin             */
  --orange-soft: rgba(247,147,26,.13);
  --buy:       #3aa3ff;   /* low / support / cheap       */
  --fair:      #dfe7f1;   /* mid / fair value            */
  --sell:      #ff6b6b;   /* high / resistance / dear     */
  --gold:      #f4c025;   /* halving                     */
  --proj:      #9b8cff;   /* cycle projection            */
  --sans: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --topbar-h: 60px;
  --channel-h: 34px;
  --pad: clamp(13px, 2.4vw, 28px);
}

* { box-sizing: border-box; }

/* `hidden` must always beat component display rules (e.g. `.error { display:flex }`) so an
   empty overlay can never sit opaque on top of the chart and blank it out. */
[hidden] { display: none !important; }

html, body { height: 100%; overflow: hidden; }      /* never scroll, never a scrollbar */
body {
  margin: 0;
  display: flex; flex-direction: column;
  height: 100dvh; min-height: 0;
  background:
    radial-gradient(120% 80% at 50% -10%, #0d121b 0%, rgba(13,18,27,0) 60%),
    linear-gradient(180deg, #0b0f16 0%, #090c11 100%);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

/* numbers stay column-aligned and don't jitter as values update */
.v, .cap b, .tt .val, .tt .tt-date { font-variant-numeric: tabular-nums; font-feature-settings: "tnum" 1; }

/* ---------- top bar ---------- */
#topbar {
  flex: 0 0 auto;
  height: var(--topbar-h);
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 var(--pad);
  padding-top: env(safe-area-inset-top);
  background: linear-gradient(180deg, rgba(255,255,255,.018), rgba(255,255,255,0)) , var(--bg-1);
  border-bottom: 1px solid var(--line);
  z-index: 6;
}

.brand { display: flex; align-items: center; gap: 11px; min-width: 0; }
.brand .logo {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--orange-soft, rgba(247,147,26,.13));
  border: 1px solid rgba(247,147,26,.35);
  color: var(--orange); font-size: 18px; line-height: 1;
}
.brand .title {
  display: flex; flex-direction: column; line-height: 1.05;
  font-weight: 700; font-size: 14px; letter-spacing: .2px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand .title-sub { font-weight: 500; font-size: 11px; color: var(--faint); letter-spacing: .14em; text-transform: uppercase; }

.readout { display: flex; align-items: center; gap: clamp(13px, 1.8vw, 22px); }
.readout .sep { width: 1px; height: 28px; background: var(--hair); flex: 0 0 auto; }
.metric { display: flex; flex-direction: column; gap: 4px; line-height: 1; }
.metric .k {
  font-size: 10px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--faint); font-weight: 600;
}
.metric .v { font-family: var(--mono); font-size: 15px; font-weight: 500; letter-spacing: -.01em; }
.metric.price .v { font-size: 22px; font-weight: 600; color: var(--orange); }
.metric .v.buy  { color: var(--buy); }
.metric .v.sell { color: var(--sell); }
.metric .v.gold { color: var(--gold); }

/* verdict pill — the app's headline call, with a flat status dot */
.v.zone {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 4px 11px 4px 9px; border-radius: 999px;
  font-family: var(--sans); font-size: 12.5px; font-weight: 600; letter-spacing: .01em;
  background: rgba(223,231,241,.07); color: var(--fair);
  border: 1px solid rgba(223,231,241,.18);
}
.v.zone .zdot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: 0 0 auto; }
.v.zone[data-z="buy"]      { background: rgba(58,163,255,.13); color: #8fc8ff; border-color: rgba(58,163,255,.42); }
.v.zone[data-z="deep"]     { background: rgba(58,163,255,.2);  color: #b6dbff; border-color: rgba(58,163,255,.58); }
.v.zone[data-z="fair"]     { background: rgba(223,231,241,.08); color: var(--fair); border-color: rgba(223,231,241,.26); }
.v.zone[data-z="sell"]     { background: rgba(255,107,107,.13); color: #ffa1a1; border-color: rgba(255,107,107,.42); }
.v.zone[data-z="euphoria"] { background: rgba(255,107,107,.22); color: #ffc2c2; border-color: rgba(255,107,107,.58); }

/* ---------- channel position meter ---------- */
.channel {
  flex: 0 0 auto; height: var(--channel-h);
  display: flex; align-items: center; gap: 14px;
  padding: 0 var(--pad);
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--muted);
  z-index: 5;
}
.channel .cap { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; font-family: var(--sans); font-size: 10px; letter-spacing: .09em; text-transform: uppercase; color: var(--faint); font-weight: 600; }
.channel .cap.right { justify-content: flex-end; }
.channel .cap b { color: var(--text); font-weight: 600; font-family: var(--mono); font-size: 12px; letter-spacing: 0; text-transform: none; }
.channel .cap .dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.channel .dot.buy { background: var(--buy); }
.channel .dot.sell { background: var(--sell); }
.channel .track {
  position: relative; flex: 1 1 auto; height: 5px; border-radius: 999px;
  background: linear-gradient(90deg, rgba(58,163,255,.55), rgba(223,231,241,.22) 50%, rgba(255,107,107,.55));
}
.channel .tick {
  position: absolute; top: -3px; width: 1px; height: 11px;
  background: rgba(255,255,255,.28);
}
.channel .tick.fair { left: 50%; transform: translateX(-50%); }
.channel .marker {
  position: absolute; top: 50%; left: 50%;
  width: 12px; height: 12px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: var(--orange); border: 2px solid var(--bg-1);
  transition: left .5s cubic-bezier(.22,.61,.36,1);
}

/* ---------- chart ---------- */
main { position: relative; flex: 1 1 auto; min-height: 0; }
#chart { position: absolute; inset: 0; }

/* scenario panel — its own card beneath the legend (top-left), never grabs focus */
.proj-note {
  position: absolute; top: 40px; left: 50px; z-index: 3;   /* clear of the y-axis labels */
  width: 212px; max-width: 44%;
  padding: 9px 11px 8px; border-radius: 10px;
  background: rgba(12,16,23,.78); border: 1px solid var(--line);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  font-family: var(--sans); color: var(--muted); line-height: 1.25;
  pointer-events: none;
}
.proj-note .pn-head { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 700; color: var(--text); }
.proj-note .proj-swatch { width: 16px; height: 0; flex: 0 0 auto; border-top: 2px dashed var(--proj); }
.proj-note .pn-sub { font-size: 10px; color: var(--faint); margin: 3px 0 8px; }
.proj-note .pn-foot { font-size: 10px; color: var(--muted); margin-top: 7px; }
.proj-note .pn-foot b { color: var(--text); font-weight: 600; }
.proj-note .pn-cav { font-size: 9px; color: var(--faint); margin-top: 4px; font-style: italic; }

/* mini crash-depth bars: each cycle's drawdown hangs from a 0% (ATH) baseline; softening = shorter */
.pn-bars { display: flex; align-items: flex-start; gap: 7px; }
.pn-col { display: flex; flex-direction: column; align-items: center; gap: 3px; flex: 1 1 0; }
.pn-track { position: relative; width: 11px; height: 42px; overflow: hidden; border-radius: 0 0 2px 2px;
  background: rgba(255,255,255,.05); border-top: 1px solid rgba(255,255,255,.18); }
.pn-fill { position: absolute; top: 0; left: 0; right: 0; border-radius: 0 0 2px 2px;
  background: rgba(255,107,107,.45); }                      /* historical crash drop */
.pn-col.proj .pn-fill { background: var(--proj); }          /* the projected (trend) drop */
.pn-band { position: absolute; left: 50%; width: 1px; transform: translateX(-50%);
  background: var(--proj); opacity: .55; }                  /* +/-sigma whisker on the projection */
.pn-cap { font-family: var(--mono); font-size: 9px; color: var(--faint); }
.pn-col.proj .pn-cap { color: var(--proj); font-weight: 600; }
.pn-yr { font-family: var(--mono); font-size: 9px; color: var(--faint); }

/* shared overlay base */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
}
.loader {
  z-index: 4; flex-direction: column; gap: 15px;
  color: var(--muted); font-size: 13px; transition: opacity .35s ease;
}
.loader.gone { opacity: 0; pointer-events: none; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 2px solid rgba(247,147,26,.16); border-top-color: var(--orange);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.error { z-index: 5; padding: 24px; }
.error-card {
  display: flex; flex-direction: column; align-items: center; gap: 11px;
  max-width: 380px; text-align: center;
  padding: 28px 32px; border-radius: 16px;
  background: var(--bg-2); border: 1px solid var(--line);
}
.error-glyph { font-size: 30px; color: var(--sell); line-height: 1; }
.error-title { font-size: 15px; font-weight: 700; color: var(--text); }
.error-detail { font-size: 12px; color: var(--faint); font-family: var(--mono); word-break: break-word; }
.btn {
  margin-top: 6px; padding: 10px 20px; border-radius: 10px;
  border: 1px solid rgba(247,147,26,.5); background: rgba(247,147,26,.1);
  color: var(--orange); font-family: var(--sans); font-size: 13px; font-weight: 600; cursor: pointer;
  transition: background .15s ease, border-color .15s ease;
}
.btn:hover { background: rgba(247,147,26,.18); border-color: var(--orange); }
.btn:active { transform: translateY(1px); }

/* ---------- footer ---------- */
#footer {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 12px;
  padding: 8px var(--pad);
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  font-family: var(--sans); font-size: 11px; color: var(--faint);
  border-top: 1px solid var(--line); background: var(--bg-1);
}
#footer .grow { flex: 1 1 auto; }
#footer .muted { color: var(--faint); }
#footer .proj-low {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--mono); color: var(--proj); font-size: 11px;
}
#footer .proj-low::before {
  content: ""; width: 14px; height: 0; border-top: 2px dashed var(--proj);
}

/* ---------- ECharts tooltip ---------- */
.tt { font-family: var(--mono); min-width: 224px; }
.tt .tt-date { font-family: var(--sans); font-weight: 700; font-size: 12px; color: var(--text); margin-bottom: 8px; }
.tt .tt-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 2.5px 0; }
.tt .tt-row .lbl { display: flex; align-items: center; gap: 8px; color: var(--muted); font-family: var(--sans); font-size: 12px; }
.tt .tt-row .val { font-weight: 600; font-size: 12px; color: var(--text); }
.tt .swatch { width: 8px; height: 8px; border-radius: 2px; flex: 0 0 auto; }
.tt .dash { width: 13px; height: 0; border-top: 2px dashed var(--proj); flex: 0 0 auto; }
.tt .tt-sep { height: 1px; background: var(--line); margin: 8px 0; }
.tt .tt-head { display: flex; align-items: center; gap: 8px; font-family: var(--sans); font-weight: 700; font-size: 12px; margin-bottom: 7px; }
.tt .tt-zone { margin-top: 8px; font-family: var(--sans); font-size: 11px; color: var(--muted); }
.tt .tt-foot { margin-top: 6px; font-family: var(--sans); font-size: 10.5px; color: var(--faint); }
.tt .neg { color: #ff8b8b; } .tt .pos { color: #7ee0a3; }
.tt .accent-ath  { color: var(--sell); }
.tt .accent-low  { color: var(--buy); }
.tt .accent-halv { color: var(--gold); }
.tt .accent-proj { color: var(--proj); }

/* ---------- entrance (subtle, staggered) ---------- */
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#topbar  { animation: rise .5s ease both; }
.channel { animation: rise .5s ease .06s both; }
main     { animation: rise .55s ease .12s both; }
#footer  { animation: rise .5s ease .18s both; }

/* ---------- responsive ---------- */
@media (max-width: 900px) { .hide-md { display: none !important; } }
@media (max-width: 720px) {
  :root { --topbar-h: 56px; --channel-h: 30px; }
  .brand .title { display: none; }
  .hide-sm { display: none !important; }
  .metric.price .v { font-size: 19px; }
  .readout { gap: 14px; }
  .readout .sep { height: 24px; }
  .channel { font-size: 10.5px; gap: 11px; }
  /* the verbose caption crowds a small chart — the footer callout + on-chart label carry it */
  .proj-note { display: none !important; }
}
@media (max-width: 380px) {
  :root { --pad: 11px; }
  .readout { gap: 11px; }
  .metric .v { font-size: 14px; }
  .metric.price .v { font-size: 18px; }
  .channel .cap b { font-size: 11px; }
  .proj-note { font-size: 10px; max-width: 78%; }
}

@media (prefers-reduced-motion: reduce) {
  .channel .marker, .btn { transition: none; }
  .spinner { animation-duration: 1.4s; }
  #topbar, .channel, main, #footer { animation: none; }
}
