/* Crypto Fundamentals — the tool's own layout.
   Tokens and shared components (buttons, badges, labels, header, footer, tool
   shell) come from the main site's /site.css. Dark only. */

/* Older token names, kept as aliases of the site tokens: this file and the
   personal version's AI Insights panel (insights.css) still use them. */
:root {
  --text: var(--fg);
  --surface: var(--panel);
  --elevated: var(--panel);
  --tertiary: var(--muted);
  --success: var(--up);
  --error: var(--down);
  --warning: var(--warn);
  --info: oklch(0.74 0.11 235);
  --accent-tint: color-mix(in oklch, var(--accent) 12%, transparent);
  --display: var(--font-head);
  --body: var(--font-body);
  --r-card: var(--r-panel);
  --r-badge: var(--r-ctl);
  --r-btn: var(--r-ctl);
}

/* brand.css variants the tool still uses, on top of site.css .btn / .badge */
.btn-ghost, .btn-secondary { background: transparent; }
.badge-info { color: var(--info); }
.badge-success { color: var(--up); }
.badge-warning { color: var(--warn); }
.badge-error { color: var(--down); }
.badge-accent { color: var(--accent); }

.sub { color: var(--muted); max-width: 70ch; margin: 0; font-size: 15px; line-height: 1.65; }

/* search */
.searchbar { position: relative; margin: 20px 0 28px; }
.searchbar input {
  width: 100%; height: 48px; border-radius: var(--r-panel); border: 1px solid var(--border);
  background: var(--panel); color: var(--fg); font: 15px var(--font-mono); padding: 0 120px 0 44px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.searchbar input:focus { border-color: var(--accent); }
.searchbar .ico { position: absolute; left: 16px; top: 13px; color: var(--muted); font-size: 16px; }
.searchbar .hint { position: absolute; right: 16px; top: 15px; font: 12px var(--font-mono); color: var(--tertiary); pointer-events: none; }
@media (max-width: 600px) { .searchbar .hint { display: none; } .searchbar input { padding-right: 14px; } }
.dd {
  position: absolute; z-index: 20; left: 0; right: 0; top: 54px; background: var(--elevated);
  border: 1px solid var(--border); border-radius: var(--r-card); overflow: hidden;
}
.dd .it { display: flex; align-items: center; gap: 10px; padding: 10px 14px; cursor: pointer; font-size: 14px; }
.dd .it b { font-family: var(--display); font-weight: 600; min-width: 52px; }
.dd .it span { color: var(--muted); }
.dd .it.sel, .dd .it:hover { background: var(--accent-tint); }
.dd .it img { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.dd .it .r { margin-left: auto; color: var(--tertiary); font-size: 12px; }
.dd .it .clash { font-style: normal; font-size: 11px; color: var(--warning); margin-left: 6px; }
.examples { margin-top: 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip-btn {
  font: 500 12px var(--font-mono); min-height: 34px; padding: 6px 12px; border-radius: var(--r-ctl); cursor: pointer;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
}
.chip-btn:hover { border-color: var(--accent); color: var(--accent); }
.outside {
  margin-bottom: 18px; padding: 10px 14px; border-radius: var(--r-card); font-size: 13px;
  background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent);
}
.outside code { font-size: 12px; word-break: break-all; }
.dd .msg { padding: 12px 14px; font-size: 13px; color: var(--muted); }

/* identity */
.idrow { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.idrow .logo { width: 44px; height: 44px; border-radius: 50%; background: var(--surface); }
.idrow h2 { font-size: clamp(24px, 3vw, 30px); }
.idrow .sym { color: var(--muted); font-weight: 600; margin-left: 8px; font-size: 16px; }
.idrow .px { margin-left: auto; text-align: right; }
.idrow .px .p { font-family: var(--font-mono); font-size: 22px; font-weight: 500; }
.idrow .px .c { font-size: 12px; color: var(--muted); }
.badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
/* hover/focus tooltip for badges that carry a rule */
.tip { position: relative; cursor: help; outline: none; }
.tip:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.tip:hover::after, .tip:focus::after {
  content: attr(data-tip); position: absolute; z-index: 6; left: 0; top: calc(100% + 6px); width: max-content; max-width: min(320px, 80vw);
  white-space: normal; text-transform: none; letter-spacing: 0; font: 400 12px/1.5 var(--body); color: var(--text);
  background: var(--bg); border: 1px solid var(--border); border-radius: var(--r-card); padding: 8px 10px;
}
.contracts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 12px; font-size: 12px; }
.contracts .label { margin-right: 2px; }
.contracts .muted { color: var(--muted); }
.addr {
  display: inline-flex; align-items: center; gap: 6px; font: 500 12px var(--body); color: var(--text); cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-badge); padding: 3px 8px;
}
.addr code { color: var(--muted); font-size: 11px; }
.addr:hover { border-color: var(--accent); }
.addr.copied { border-color: var(--success); }
.addr.copied code::after { content: " ✓ copied"; color: var(--success); }
.memenote {
  margin-top: 14px; padding: 10px 14px; border-radius: var(--r-card); font-size: 13px;
  background: color-mix(in srgb, var(--info) 10%, transparent); border: 1px solid color-mix(in srgb, var(--info) 35%, transparent);
}
.kpis { display: flex; gap: 28px; flex-wrap: wrap; margin-top: 16px; }
.kpi .label { display: block; }
.kpi b { font-family: var(--font-mono); font-size: 16px; font-weight: 500; }

/* rating tones: colour = favourability, the word = magnitude */
.t-g2 { --tone: var(--up); }
.t-g1 { --tone: color-mix(in oklch, var(--up) 60%, var(--muted)); }
.t-n  { --tone: var(--muted); }
.t-b1 { --tone: var(--warn); }
.t-b2 { --tone: var(--down); }

/* Rating strip in the site's 10-segment style: each of the five steps fills two
   segments (very low = 2, very high = 10); the colour keeps the favourability. */
.strip { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.strip i { width: 7px; height: 8px; border-radius: 2px; background: var(--track); }
.strip i.on { background: var(--tone); }
.strip b { margin-left: 8px; font: 500 12px var(--font-mono); color: var(--tone); }
.strip.none { font: 12px var(--font-mono); color: var(--muted); }

/* factsheet */
section.sec { padding: 26px 0; border-top: 1px solid var(--border); margin-top: 24px; }
.sec-head { display: flex; align-items: baseline; gap: 10px; }
.sec-head .verdict { font: 500 12px var(--font-mono); text-transform: uppercase; letter-spacing: 0.12em; color: var(--tone); }
.lead { font-size: 16px; margin: 8px 0 16px; max-width: 70ch; }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.fact {
  position: relative; padding: 14px; border-radius: var(--r-card); background: var(--surface);
  border: 1px solid var(--border); border-left: 3px solid var(--tone); outline: none;
}
.fact:focus-visible { box-shadow: 0 0 0 2px var(--accent); }
.fact .label { display: block; margin-bottom: 6px; width: fit-content; }
.fact .vv { font-family: var(--font-mono); font-size: 20px; font-weight: 500; display: block; margin-bottom: 6px; }
.fact .ex { font-size: 12px; color: var(--muted); margin-top: 6px; }
.fact .src { font-size: 11px; color: var(--tertiary); margin-top: 4px; }
/* the house rule, shown on hover or keyboard focus */
.fact .rule {
  display: none; position: absolute; z-index: 5; left: 12px; right: 12px; top: calc(100% + 6px);
  background: var(--elevated); border: 1px solid var(--border); border-radius: var(--r-card);
  padding: 10px 12px; font-size: 12px; color: var(--text);
}
.fact:hover .rule, .fact:focus .rule { display: block; }

/* states */
.state { padding: 36px 0; color: var(--muted); }
.state .btn { margin-top: 12px; }
.skel { height: 14px; border-radius: 6px; background: var(--border); opacity: 0.5; margin: 10px 0; }

.tool-legend { margin-top: 36px; padding-top: 18px; border-top: 1px solid var(--border); color: var(--muted); font: 12px/1.7 var(--font-mono); }
.tool-legend a { color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }
.tool-legend a:hover { color: var(--accent); }
.health { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 6px; vertical-align: 1px; }
.health.ok { background: var(--success); }
.health.warn { background: var(--warning); }

/* charts */
.chartbox { margin-top: 18px; padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--r-panel); background: var(--surface); }
.chart { margin: 8px 0 0; }
.svg { width: 100%; height: auto; display: block; }
.svg .st { fill: var(--accent); }
.svg .ax { fill: var(--muted); font: 10px var(--font-mono); }
.svg .now { stroke: var(--warning); stroke-dasharray: 3 3; }
.svg .maxline { stroke: var(--muted); stroke-dasharray: 2 4; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 11px; color: var(--muted); margin-top: 6px; }
.legend .lg i { display: inline-block; width: 9px; height: 9px; background: var(--accent); margin-right: 5px; border-radius: 2px; vertical-align: -1px; }
.nochart { font-size: 12px; color: var(--tertiary); padding: 20px 0; text-align: center; border: 1px dashed var(--border); border-radius: var(--r-card); }
.svg .b1 { fill: var(--accent); }
.svg .b2 { fill: var(--accent); opacity: 0.4; }
.fact .ex.peer { color: var(--text); font-weight: 500; }
.hbars { display: grid; gap: 6px; margin-top: 8px; }
.hb { display: grid; grid-template-columns: minmax(110px, 180px) 1fr 52px; gap: 10px; align-items: center; font-size: 12px; }
.hb .hn { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: ui-monospace, monospace; font-size: 11px; }
.hb em { font-style: normal; font-family: var(--body); color: var(--tertiary); font-size: 10px; }
.hbar { height: 8px; background: var(--border); border-radius: 4px; overflow: hidden; }
.hbar i { display: block; height: 100%; background: var(--accent); }
.hv { text-align: right; font-variant-numeric: tabular-nums; }

/* view bar: area verdicts (same place in both views) + layout toggle */
.viewbar { display: flex; align-items: flex-start; gap: 12px; margin-top: 22px; flex-wrap: wrap; }
.areachips { display: flex; flex-wrap: wrap; gap: 6px; flex: 1 1 320px; }
.chip { display: inline-flex; align-items: center; gap: 6px; font: 12px var(--font-mono); padding: 6px 10px; border-radius: var(--r-ctl);
  border: 1px solid var(--border); color: var(--text); background: var(--surface); text-decoration: none; }
.chip:hover { border-color: var(--accent); text-decoration: none; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--tone); }
.viewtoggle { display: inline-flex; border: 1px solid var(--border); border-radius: var(--r-btn); overflow: hidden; flex: none; }
.viewtoggle button { font: 500 12px var(--font-mono); min-height: 34px; padding: 7px 14px; background: var(--panel); color: var(--muted); border: 0; cursor: pointer; }
.viewtoggle button.on { background: var(--accent); color: var(--accent-fg); }
section.sec { scroll-margin-top: 16px; }

/* table view */
.tablewrap { margin-top: 18px; max-width: 100%; }
table.score { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: auto; }
table.score th, table.score td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.score thead th { font: 500 11px var(--font-mono); letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); }
table.score tr.grp th { background: var(--panel); font: 600 14px var(--font-head); scroll-margin-top: 16px; }
table.score tr.grp .verdict { color: var(--tone); margin-left: 6px; }
table.score td.v { font-family: var(--font-mono); font-weight: 500; }
table.score td.src { color: var(--tertiary); font-size: 11px; }
table.score .ex { color: var(--muted); font-size: 11px; margin-top: 3px; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  table.score th.src, table.score td.src { display: none; }
  table.score th, table.score td { padding: 8px 6px; }
  table.score .strip b { display: none; }
}

/* source failures */
.srcfail { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 10px 0; padding: 8px 12px; font: 400 13px var(--body);
  border-radius: var(--r-card); background: color-mix(in srgb, var(--warning) 12%, transparent); border: 1px solid color-mix(in srgb, var(--warning) 40%, transparent); }

/* methodology page */
.navlink { color: var(--muted); font-size: 13px; }
.doc { padding-bottom: 20px; }
.doc section { padding: 26px 0 6px; border-top: 1px solid var(--border); margin-top: 26px; scroll-margin-top: 16px; }
.doc h2 { margin-bottom: 12px; font-size: clamp(22px, 3vw, 26px); }
.doc p { max-width: 75ch; }
.toc { margin: 22px 0 0; font-size: 13px; color: var(--muted); line-height: 2; }
.callout { padding: 12px 14px; border-radius: var(--r-card); background: var(--accent-tint); border: 1px solid var(--border); }
.marea { border-top: 0 !important; padding-top: 10px !important; }
.marea h3 { margin: 18px 0 6px; font-size: 17px; }
.metric { padding: 12px 0 10px; border-bottom: 1px solid var(--border); scroll-margin-top: 16px; }
.metric:target { background: var(--accent-tint); border-radius: var(--r-card); padding-left: 10px; }
.metric h4 { font: 600 15px var(--display); margin: 0 0 6px; }
.metric p { margin: 4px 0; }
.metric .meta { font-size: 13px; color: var(--muted); }
.metric .meta .label { margin-right: 6px; }
.glossary dt { font: 600 14px var(--display); margin-top: 14px; scroll-margin-top: 16px; }
.glossary dt:target { color: var(--accent); }
.glossary dd { margin: 4px 0 0; color: var(--muted); max-width: 75ch; }
table.types td.ar, table.types th.ar { text-align: center; font-size: 11px; }
.small { font-size: 12px; }
@media (max-width: 640px) { table.types th.ar, table.types td.ar { display: none; } }

/* metric labels link to their methodology entry */
a.mlink { color: inherit; text-decoration: none; border-bottom: 1px dotted var(--tertiary); }
a.mlink:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* personal version */
.tool-title .badge-info { align-self: center; }
.outside.personal { background: var(--accent-tint); border-color: var(--border); }
.dd .it .noimg { width: 22px; height: 22px; border-radius: 50%; background: var(--border); flex: none; }

/* "check elsewhere" links where a source has nothing on file */
.ex.check a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }

/* crisp factsheet: value and rating on one row, one context line, collapsed gaps */
.fact .vrow { display: flex; align-items: center; justify-content: space-between; gap: 6px 12px; flex-wrap: wrap; }
.fact .vrow .vv { margin-bottom: 0; }
.fact .ex { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.fact .rule .more, .fact .rule .src { display: block; margin-top: 6px; color: var(--muted); }
.fact .rule .src { font-size: 11px; color: var(--tertiary); }
.sec-head { margin-bottom: 12px; }
.gaps { margin: 12px 0 0; font-size: 13px; color: var(--muted); line-height: 1.7; }
.gaps .gw { color: var(--tertiary); }
.gaps a { color: var(--muted); text-decoration: underline dotted; text-underline-offset: 3px; }
.fact .rule .hint { display: block; margin-bottom: 6px; font-weight: 500; }

/* how old the live data is, with a Refresh button */
.fresh { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 14px 0 0; font-size: 12px; color: var(--muted); }
.fresh .btn { padding: 2px 10px; }

/* house rule as a five-step scale (tooltips and the methodology page) */
.scale { margin: 0 0 4px; }
.scale-dir { font-size: 11px; font-weight: 600; color: var(--text); margin-bottom: 6px; }
.scale-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 3px; }
.scale .seg { text-align: center; padding: 0 1px; opacity: .55; }
.scale .seg i { display: block; height: 6px; border-radius: 3px; background: var(--tone); margin-bottom: 4px; }
.scale .seg b { display: block; font-size: 10px; font-weight: 600; color: var(--tone); white-space: nowrap; }
.scale .seg span { display: block; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.scale .seg.on { opacity: 1; }
.scale .seg.on i { height: 8px; box-shadow: 0 0 0 2px color-mix(in srgb, var(--tone) 35%, transparent); }
.scale .seg.on span { color: var(--text); font-weight: 600; }
.scale-note { margin-top: 6px; font-size: 11px; color: var(--text); }
.fact .rule { min-width: min(330px, calc(100vw - 64px)); }
.fact .rule .hint { display: block; margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--border); font-weight: 400; color: var(--muted); }

/* the peer group behind the valuation ratings */
.peers summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
.peers summary .label { color: var(--accent); }
.peers-hint { font-size: 12px; color: var(--muted); }
.peerwrap { max-height: 380px; overflow: auto; margin-top: 10px; border: 1px solid var(--border); border-radius: var(--r-card); }
.peertable { width: 100%; font-size: 13px; }
.peertable th { position: sticky; top: 0; background: var(--surface); }
.peertable .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.peertable td span { color: var(--muted); }
.peertable a { color: var(--text); text-decoration: none; }
.peertable a:hover b { color: var(--accent); }
.peertable tr.me td { background: var(--accent-tint); }
.peertable tr.me td:first-child { box-shadow: inset 3px 0 0 var(--accent); }

/* methodology: the rule leads each metric, the definition follows */
.metric .mrule { max-width: 520px; margin: 8px 0 10px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-card); background: var(--surface); }
.metric .mrule .scale .seg { opacity: 1; }
.metric .mrule .scale .seg b, .metric .mrule .scale .seg span { font-size: 11px; }
.metric .mrule-plain { margin: 0; font-size: 13px; color: var(--muted); }
.metric .mwhat { font-size: 14px; color: var(--muted); max-width: 70ch; }
