/* =====================================================================
   Jeremy Crypto — Design System
   Restrained, institutional, data-dense. Dark by default, light toggle.
   Colour-blind-safe accents. Print CSS at the bottom.
   ===================================================================== */

:root {
  /* Neutral scale (dark theme default) */
  --bg:          #0e1116;
  --bg-elev:     #161b22;
  --bg-elev-2:   #1c232d;
  --border:      #2a323d;
  --border-soft: #232a33;
  --text:        #e6edf3;
  --text-soft:   #adbac7;
  --text-dim:    #768390;

  /* Accents — deliberately muted, not casino-neon */
  --accent:      #4a9eff;   /* primary/interactive (blue, CB-safe) */
  --accent-soft: #1d3a5f;
  --pos:         #3fb950;   /* gains — never auto "buy" */
  --neg:         #f85149;   /* losses — never auto "sell" */
  --warn:        #d29922;
  --muted-chip:  #30363d;

  /* Score bands (sequential, CB-safe blues→amber, NOT red/green) */
  --band-exceptional: #2f81f7;
  --band-excellent:   #3d8bfd;
  --band-strong:      #58a6ff;
  --band-moderate:    #d29922;
  --band-speculative: #db8a1a;
  --band-weak:        #8b6b1f;

  /* Risk scale (single-hue amber ramp — higher = more saturated) */
  --risk-lo: #2ea043;
  --risk-md: #d29922;
  --risk-hi: #db6d28;
  --risk-xh: #f85149;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.25);
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  --maxw: 1180px;
}

[data-theme="light"] {
  --bg:          #f6f8fa;
  --bg-elev:     #ffffff;
  --bg-elev-2:   #f0f3f6;
  --border:      #d0d7de;
  --border-soft: #e2e7ec;
  --text:        #1f2328;
  --text-soft:   #424a53;
  --text-dim:    #6e7781;
  --accent:      #0969da;
  --accent-soft: #ddf0ff;
  --muted-chip:  #eaeef2;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 18px rgba(0,0,0,.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1,h2,h3,h4 { line-height: 1.25; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.6rem; margin: 0 0 .2em; }
h2 { font-size: 1.2rem; margin: 1.8em 0 .6em; }
h3 { font-size: 1.02rem; margin: 1.4em 0 .4em; color: var(--text); }
p { margin: .5em 0; color: var(--text-soft); }
small { color: var(--text-dim); }
code { font-family: var(--mono); font-size: .86em; background: var(--bg-elev-2); padding: .1em .35em; border-radius: 4px; }

/* ---------- Layout ---------- */
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 20px; }
.site { min-height: 100vh; display: flex; flex-direction: column; }
.main { flex: 1; padding: 28px 0 80px; }

/* ---------- Top nav ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { display: flex; align-items: center; gap: 20px; height: 58px; }
.brand { font-weight: 750; font-size: 1.05rem; letter-spacing: -0.02em; white-space: nowrap; }
.brand span { color: var(--accent); }
.nav { display: flex; gap: 2px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: var(--text-soft); padding: 7px 11px; border-radius: var(--radius-sm);
  font-size: .88rem; font-weight: 550;
}
.nav a:hover { background: var(--bg-elev-2); text-decoration: none; color: var(--text); }
.nav a.active { color: var(--text); background: var(--bg-elev-2); }

/* Phones: the nav has nowhere to go inside a 58px bar, so it used to wrap onto
   three rows and overflow onto the page content. Give the bar an auto height,
   keep brand + theme toggle on row 1, and let the nav be a single horizontally
   scrollable strip on row 2 — every section stays reachable, nothing collides. */
@media (max-width: 760px) {
  .topbar .wrap {
    height: auto;
    min-height: 52px;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 9px;
    padding-bottom: 9px;
  }
  .brand { order: 1; }
  .theme-btn { order: 2; margin-left: auto; }
  .nav {
    order: 3;
    width: 100%;
    margin-left: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 1px;
  }
  .nav::-webkit-scrollbar { display: none; }
  .nav a { flex: 0 0 auto; white-space: nowrap; padding: 7px 12px; }
}
.theme-btn {
  background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-soft);
  width: 34px; height: 34px; border-radius: var(--radius-sm); cursor: pointer; font-size: 1rem;
}
.theme-btn:hover { color: var(--text); }

/* ---------- Cards & grid ---------- */
.card {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
}
.card h2:first-child, .card h3:first-child { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
@media (max-width: 860px) { .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .grid-2,.grid-3,.grid-4 { grid-template-columns: 1fr; } }

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .7rem; font-weight: 700; color: var(--text-dim); }

/* ---------- Metric tiles ---------- */
.metric { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 14px; }
.metric .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); display: flex; align-items: center; gap: 5px; }
.metric .value { font-size: 1.28rem; font-weight: 680; font-family: var(--mono); margin-top: 3px; letter-spacing: -0.02em; }
.metric .sub { font-size: .78rem; color: var(--text-dim); }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.dim { color: var(--text-dim); }
.mono { font-family: var(--mono); }

/* ---------- Badges / chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 5px; font-size: .74rem; font-weight: 600;
  padding: 3px 9px; border-radius: 999px; background: var(--muted-chip); color: var(--text-soft);
  border: 1px solid var(--border-soft);
}
.chip.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

.status { font-weight: 650; padding: 4px 11px; border-radius: 999px; font-size: .78rem; border: 1px solid transparent; }
.status[data-s="High Conviction"] { background: #123a1f; color: #56d364; border-color:#1f5c33; }
.status[data-s="Positive"]        { background: #0f2f4a; color: #58a6ff; border-color:#1c4e7a; }
.status[data-s="Neutral"]         { background: #2a2f37; color: #adbac7; }
.status[data-s="Watch"]           { background: #3a2f12; color: #e3b341; border-color:#5c471f; }
.status[data-s="Reducing"]        { background: #45260f; color: #f0883e; border-color:#6b3a1c; }
.status[data-s="Exited"]          { background: #3d1a1a; color: #f85149; border-color:#5c2626; }
.status[data-s="Under Review"]    { background: #2a2f37; color: #d2a8ff; }

/* ---------- Data provenance markers ---------- */
.tag-live, .tag-manual, .tag-calc {
  font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 5px; border-radius: 4px; vertical-align: middle;
}
.tag-live   { background: #0f2f24; color: #3fb950; }
.tag-manual { background: #33240f; color: #d29922; }
.tag-calc   { background: #1c2440; color: #6ea8ff; }

/* ---------- Tables ---------- */
table.data { width: 100%; border-collapse: collapse; font-size: .88rem; }
table.data th, table.data td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border-soft); }
table.data th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); font-weight: 700; }
table.data td.num, table.data th.num { text-align: right; font-family: var(--mono); }
table.data tr:hover td { background: var(--bg-elev-2); }
.table-scroll { overflow-x: auto; }

/* ---------- Score display ---------- */
.score-hero { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.score-ring {
  --v: 0; width: 108px; height: 108px; border-radius: 50%; flex-shrink: 0;
  background: conic-gradient(var(--ring-col) calc(var(--v) * 1%), var(--bg-elev-2) 0);
  display: grid; place-items: center; position: relative;
}
.score-ring::before { content:""; position: absolute; inset: 10px; border-radius: 50%; background: var(--bg-elev); }
.score-ring .num { position: relative; font-family: var(--mono); font-size: 1.7rem; font-weight: 700; }
.score-ring .num small { font-size: .8rem; color: var(--text-dim); }
.band-label { font-weight: 650; font-size: .95rem; }

.score-bar { height: 8px; border-radius: 999px; background: var(--bg-elev-2); overflow: hidden; }
.score-bar > i { display: block; height: 100%; border-radius: 999px; }

/* expandable calc rows */
details.calc { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 12px; }
details.calc > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; font-size: .9rem; list-style: none; }
details.calc > summary::-webkit-details-marker { display: none; }
details.calc > summary::before { content: "▸ "; color: var(--text-dim); }
details.calc[open] > summary::before { content: "▾ "; }
details.calc .calc-body { padding: 0 14px 12px; }

/* tooltip */
.tt { border-bottom: 1px dotted var(--text-dim); cursor: help; position: relative; }
.tt:hover::after {
  content: attr(data-tip); position: absolute; left: 0; top: 130%; z-index: 60;
  background: var(--bg-elev-2); color: var(--text); border: 1px solid var(--border);
  padding: 8px 10px; border-radius: 6px; width: max-content; max-width: 280px;
  font-size: .78rem; font-weight: 400; line-height: 1.4; box-shadow: var(--shadow); white-space: normal;
}

/* ---------- Callouts ---------- */
.callout { border-left: 3px solid var(--accent); background: var(--bg-elev); padding: 12px 16px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 14px 0; }
.callout.warn { border-color: var(--warn); }
.callout.neg { border-color: var(--neg); }
.callout.pos { border-color: var(--pos); }
.callout .t { font-weight: 650; margin-bottom: 3px; }

.disclaimer { font-size: .78rem; color: var(--text-dim); border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 14px; margin: 18px 0; }

/* ---------- Coin page bits ---------- */
.coin-head { display: flex; gap: 16px; align-items: flex-start; flex-wrap: wrap; }
.coin-logo { width: 52px; height: 52px; border-radius: 12px; background: var(--bg-elev-2); display:grid; place-items:center; font-weight:800; font-family:var(--mono); font-size:1.1rem; }
.coin-title h1 { margin: 0; }
.coin-title .tick { color: var(--text-dim); font-family: var(--mono); font-weight: 600; }
.sectors { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }

.two-col { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
@media (max-width: 960px) { .two-col { grid-template-columns: 1fr; } }
.side-sticky { position: sticky; top: 74px; display: grid; gap: 14px; }

.kv { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: .86rem; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; font-family: var(--mono); text-align: right; }

.pills { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-btn { background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text-soft); padding: 5px 11px; border-radius: 999px; font-size: .8rem; cursor: pointer; }
.pill-btn.active { background: var(--accent-soft); color: var(--accent); border-color: transparent; }

/* checklist */
ul.check { list-style: none; padding: 0; margin: .4em 0; }
ul.check li { padding: 5px 0 5px 26px; position: relative; color: var(--text-soft); border-bottom: 1px solid var(--border-soft); }
ul.check li::before { content: "☐"; position: absolute; left: 4px; color: var(--text-dim); }
ul.check li.done::before { content: "☑"; color: var(--accent); }

/* footer */
.foot { border-top: 1px solid var(--border); padding: 20px 0; color: var(--text-dim); font-size: .8rem; }

/* chart */
.chart-box { position: relative; }
canvas.chart { width: 100%; display: block; }

/* prose lists kept tight */
.prose ul { padding-left: 20px; }
.prose li { margin: 3px 0; color: var(--text-soft); }

.hidden { display: none !important; }

/* =====================================================================
   PRINT — one-page A4 summary. Add class .print-mode on <body> or use
   the dedicated print view. Hides nav/chrome, tightens everything.
   ===================================================================== */
@media print {
  @page { size: A4 portrait; margin: 12mm; }
  body { background: #fff; color: #000; font-size: 10px; }
  .topbar, .foot, .no-print, .theme-btn, .nav, details.calc summary::before { display: none !important; }
  .main { padding: 0; }
  .card { box-shadow: none; border: 1px solid #bbb; padding: 8px; break-inside: avoid; }
  .print-only { display: block !important; }
  a { color: #000; text-decoration: none; }
  .metric .value { font-size: 1rem; }
  h1 { font-size: 1.2rem; } h2 { font-size: .95rem; margin: .6em 0 .3em; }
  .two-col { grid-template-columns: 1fr; }
  .grid { gap: 8px; }
}
.print-only { display: none; }
